summaryrefslogtreecommitdiffhomepage
path: root/flowgraph/scope.cpp
blob: 54a3ccaa0f7a2009a801551bd77d6b0a5d50b419 (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
#include "scope.h"

#include "storage.h"

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

void FlowGraph::LocalScope::append(const FlowGraph::LocalScope& other)
{
 m_variables.insert(m_variables.end(), other.m_variables.begin(), other.m_variables.end());
}

index_t FlowGraph::LocalScope::indexOfStorage(const Storage& storage) const
{
 std::cout << "DEBUG: " << m_variables.size() << std::endl;
 for (index_t i = 0; i < m_variables.size(); i++) {
  FlowGraph::Storage& i_storage {*(m_variables[i]->storage())};

  if (&i_storage == &storage) // compare addresses
   return i;
 }

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