summaryrefslogtreecommitdiffhomepage
path: root/flowgraph/node.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-11-17 12:38:40 +0100
committerRoland Reichwein <mail@reichwein.it>2020-11-17 12:38:40 +0100
commit927eb99e75325164a541c2638e1e607294019381 (patch)
tree5b5476456f0f957fc7492465ff08ace54e1a9e48 /flowgraph/node.cpp
parentc9cb051fae190acfc36813e4a23759fb9b9c3df3 (diff)
Complete hierarchical evaluation (unittest and systemtest fixed)
Diffstat (limited to 'flowgraph/node.cpp')
-rw-r--r--flowgraph/node.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/flowgraph/node.cpp b/flowgraph/node.cpp
index 2d757f9..8e8b5eb 100644
--- a/flowgraph/node.cpp
+++ b/flowgraph/node.cpp
@@ -1,6 +1,7 @@
#include "node.h"
#include "data.h"
+#include "minicc.h"
#include <boost/endian/conversion.hpp>
@@ -19,33 +20,40 @@ FlowGraph::Data& Node::destination()
// 4 byte for now
Data FlowGraph::MakeConstantInt(int i)
{
- std::vector<uint8_t> value(size_t(4), uint8_t(0));
- *(reinterpret_cast<int32_t*>(value.data())) = boost::endian::native_to_little(static_cast<int32_t>(i));
- return Data{DataType::Int, std::make_shared<Constant>(value)};
+ return Data{DataType::Int, std::make_shared<Constant>(to_little_endian(int32_t(i)))};
}
-Data FlowGraph::MakeLocalPointer(FlowGraph::LocalScope& scope, const std::string& name)
+Data FlowGraph::MakeLocalPointer(std::shared_ptr<FlowGraph::LocalScope> scope, const std::string& name)
{
- Data data{DataType::Pointer, std::make_shared<LocalStorage>(scope, name)};
- scope.push_back(std::make_shared<Data>(data));
+ Data data{DataType::Pointer, std::make_shared<LocalStorage>(name)};
+ scope->push_back(std::make_shared<Data>(data));
return data;
}
-Data FlowGraph::MakeLocalSize(FlowGraph::LocalScope& scope, const std::string& name)
+Data FlowGraph::MakeLocalSize(std::shared_ptr<FlowGraph::LocalScope> scope, const std::string& name)
{
- Data data{DataType::Size, std::make_shared<LocalStorage>(scope, name)};
- scope.push_back(std::make_shared<Data>(data));
+ Data data{DataType::Size, std::make_shared<LocalStorage>(name)};
+ scope->push_back(std::make_shared<Data>(data));
return data;
}
-Data FlowGraph::MakeTemporaryInt(FlowGraph::LocalScope& scope)
+Data FlowGraph::MakeTemporaryInt(std::shared_ptr<FlowGraph::LocalScope> scope)
{
- Data data{DataType::Int, std::make_shared<TemporaryStorage>(scope)};
- scope.push_back(std::make_shared<Data>(data));
+ Data data{DataType::Int, std::make_shared<TemporaryStorage>()};
+ scope->push_back(std::make_shared<Data>(data));
return data;
}
-LocalScope& CreateScopeOp::scope()
+FlowGraph::CreateScopeOp::CreateScopeOp(): m_scope(std::make_shared<LocalScope>())
+{
+}
+
+std::shared_ptr<LocalScope> FlowGraph::CreateScopeOp::scope()
{
return m_scope;
}
+
+FlowGraph::DestroyScopeOp::DestroyScopeOp(std::shared_ptr<LocalScope> scope): m_scope(std::make_shared<LocalScope>())
+{
+}
+