diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-14 22:06:10 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-14 22:06:10 +0100 |
commit | 9e7f4c9d43b310c280cd6432cd4150411f4b914e (patch) | |
tree | c7be57a91602c228f05ff1cab2f186dcc6635733 /flowgraph | |
parent | 009e450626194299ee4b5ccb8463ac64e127fde6 (diff) |
Added system tests
Diffstat (limited to 'flowgraph')
-rw-r--r-- | flowgraph/node.cpp | 13 | ||||
-rw-r--r-- | flowgraph/node.h | 24 | ||||
-rw-r--r-- | flowgraph/storage.h | 18 |
3 files changed, 39 insertions, 16 deletions
diff --git a/flowgraph/node.cpp b/flowgraph/node.cpp index 795a252..9b68d74 100644 --- a/flowgraph/node.cpp +++ b/flowgraph/node.cpp @@ -14,17 +14,22 @@ Data FlowGraph::MakeConstantInt(int i) return Data(DataType::Int, std::make_shared<Constant>(value)); } -Data FlowGraph::MakeLocalPointer(const std::string& name) +Data FlowGraph::MakeLocalPointer(FlowGraph::LocalScope& scope, const std::string& name) { - return Data(DataType::Pointer, std::make_shared<LocalStorage>(name)); + return Data(DataType::Pointer, std::make_shared<LocalStorage>(scope, name)); } -Data FlowGraph::MakeLocalSize(const std::string& name) +Data FlowGraph::MakeLocalSize(FlowGraph::LocalScope& scope, const std::string& name) { - return Data(DataType::Size, std::make_shared<LocalStorage>(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; +} diff --git a/flowgraph/node.h b/flowgraph/node.h index 9ae5479..98c684d 100644 --- a/flowgraph/node.h +++ b/flowgraph/node.h @@ -43,8 +43,8 @@ namespace FlowGraph { }; Data MakeConstantInt(int i); - Data MakeLocalPointer(const std::string& name); - Data MakeLocalSize(const std::string& name); + Data MakeLocalPointer(FlowGraph::LocalScope& scope, const std::string& name); + Data MakeLocalSize(FlowGraph::LocalScope& scope, const std::string& name); Data MakeTemporaryInt(LocalScope& scope); class MemCopy: public Node @@ -114,7 +114,8 @@ namespace FlowGraph { { Increment, Decrement, - Negate + Negate, + Store // just take Data as-is to store it at destination }; class UnaryOperation: public Node @@ -159,4 +160,21 @@ namespace FlowGraph { BinaryOperationType m_type; }; + // Open a new scope, with stack frame + class CreateScopeOp: public Node + { + public: + CreateScopeOp() {} + LocalScope& scope(); + private: + LocalScope m_scope; + }; + + // Close current scope, closing stack frame + class DestroyScopeOp: public Node + { + public: + DestroyScopeOp() {} + }; + } // namespace FlowGraph diff --git a/flowgraph/storage.h b/flowgraph/storage.h index 28aae1e..fd3c085 100644 --- a/flowgraph/storage.h +++ b/flowgraph/storage.h @@ -37,15 +37,6 @@ namespace FlowGraph { std::string m_name; }; - class LocalStorage : public Storage - { - public: - LocalStorage(const std::string& name): m_name(name) {} - const std::string& name() const { return m_name; } - private: - std::string m_name; - }; - // Provide a context for local temporaries name generation class LocalScope { @@ -56,6 +47,15 @@ namespace FlowGraph { size_t m_index{ 0 }; }; + class LocalStorage : public Storage + { + public: + LocalStorage(LocalScope& scope, const std::string& name): m_name(name) {} + const std::string& name() const { return m_name; } + private: + std::string m_name; + }; + // intermediate results, anonymous values // use generated name class TemporaryStorage : public Storage |