summaryrefslogtreecommitdiffhomepage
path: root/flowgraph/node.cpp
blob: 9b68d7455ebabebf5b178d326b30fc804fe215e5 (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
#include "node.h"

#include "data.h"

#include <boost/endian/conversion.hpp>

using namespace FlowGraph;

// 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));
}

Data FlowGraph::MakeLocalPointer(FlowGraph::LocalScope& scope, const std::string& name)
{
 return Data(DataType::Pointer, std::make_shared<LocalStorage>(scope, name));
}

Data FlowGraph::MakeLocalSize(FlowGraph::LocalScope& scope, const std::string& name)
{
 return Data(DataType::Size, std::make_shared<LocalStorage>(scope, name));
}

Data FlowGraph::MakeTemporaryInt(FlowGraph::LocalScope& scope)
{
 return Data(DataType::Int, std::make_shared<TemporaryStorage>(scope));
}

LocalScope& CreateScopeOp::scope()
{
 return m_scope;
}