summaryrefslogtreecommitdiffhomepage
path: root/flowgraph/node.cpp
diff options
context:
space:
mode:
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>())
+{
+}
+