summaryrefslogtreecommitdiffhomepage
path: root/flowgraph/scope.cpp
blob: dd6c62c2e0171448abcd205707504026e6c00c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "scope.h"

#include "storage.h"

FlowGraph::LocalScope::LocalScope()
{
}

FlowGraph::LocalScope::~LocalScope()
{
}

void FlowGraph::LocalScope::push_back(std::shared_ptr<Data> data)
{
 m_variables.push_back(data);
}

void FlowGraph::LocalScope::append(const FlowGraph::LocalScope& other)
{
 // actually move variables to new scope
 m_variables.insert(m_variables.end(), other.m_variables.begin(), other.m_variables.end());
}

index_t FlowGraph::LocalScope::indexOfData(const FlowGraph::Data& data) const
{
 for (index_t i = 0; i < m_variables.size(); i++) {
  if (*m_variables[i] == data)
   return i;
 }

 throw std::runtime_error("ICE: Data not found");
}

size_t FlowGraph::LocalScope::size() const
{
 return m_variables.size();
}