From 71c7fd62f8b5257b82cf32b0f747fcf313fcc617 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 6 Nov 2020 18:20:34 +0100 Subject: Prepare Token/Node handling --- flowgraph/data.h | 2 ++ flowgraph/node.cpp | 21 +++++++++++++++++++-- flowgraph/node.h | 5 ++++- flowgraph/storage.h | 5 +++-- 4 files changed, 28 insertions(+), 5 deletions(-) (limited to 'flowgraph') diff --git a/flowgraph/data.h b/flowgraph/data.h index 353567c..1ed4964 100644 --- a/flowgraph/data.h +++ b/flowgraph/data.h @@ -1,3 +1,5 @@ +// Basic Data types, abstract (not yet machine specific) + #pragma once #include diff --git a/flowgraph/node.cpp b/flowgraph/node.cpp index fc55ef6..f81a7e1 100644 --- a/flowgraph/node.cpp +++ b/flowgraph/node.cpp @@ -2,8 +2,25 @@ #include "data.h" +#include + using namespace FlowGraph; -Data FlowGraph::MakeLocalPointer(const std::string& name) { return Data(DataType::Pointer, std::make_shared(name)); } -Data FlowGraph::MakeLocalSize(const std::string& name) { return Data(DataType::Size, std::make_shared(name)); } +// 4 byte for now +Data FlowGraph::MakeConstantInt(int i) +{ + std::vector value(size_t(4)); + *(reinterpret_cast(value.data())) = boost::endian::native_to_little(static_cast(i)); + return Data(DataType::Int, std::make_shared(value)); +} + +Data FlowGraph::MakeLocalPointer(const std::string& name) +{ + return Data(DataType::Pointer, std::make_shared(name)); +} + +Data FlowGraph::MakeLocalSize(const std::string& name) +{ + return Data(DataType::Size, std::make_shared(name)); +} diff --git a/flowgraph/node.h b/flowgraph/node.h index 37af95a..40846e2 100644 --- a/flowgraph/node.h +++ b/flowgraph/node.h @@ -1,3 +1,5 @@ +// Nodes in flow graph: Abstract Operations + #pragma once #include "data.h" @@ -36,6 +38,7 @@ namespace FlowGraph { Data m_location; // in: Pointer }; + Data MakeConstantInt(int i); Data MakeLocalPointer(const std::string& name); Data MakeLocalSize(const std::string& name); @@ -147,4 +150,4 @@ namespace FlowGraph { Data m_source1; }; -} +} // namespace FlowGraph diff --git a/flowgraph/storage.h b/flowgraph/storage.h index c2fa7c5..efd7d52 100644 --- a/flowgraph/storage.h +++ b/flowgraph/storage.h @@ -1,3 +1,4 @@ +// Different kinds of abstract storage locations: Constants, Global and Local Storage, Temporaries, ... #pragma once #include "data.h" @@ -15,13 +16,13 @@ namespace FlowGraph { class Storage { public: - virtual ~Storage() {} // force class to be polymorphic + virtual ~Storage() {} // force class to be polymorphic, for smart pointers }; class Constant: public Storage { public: - Constant(std::vector value) {} // little endian data + Constant(std::vector& value): m_value(value) {} // little endian data const std::vector& value() const { return m_value; } private: std::vector m_value; -- cgit v1.2.3