diff options
author | Roland Reichwein <mail@reichwein.it> | 2020-11-15 18:39:01 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2020-11-15 18:39:01 +0100 |
commit | a3b4cd4fdd4340c952eaa00bca9bebf817b901ae (patch) | |
tree | 055d3ae4b9d1e37682c2e49b31a6531f189eebf5 /flowgraph/node.h | |
parent | d07c5bc14edbe071ee7b4f47f174780e95e451aa (diff) |
Fixed unit tests, prepared hierarchical evaluation via stack (WIP)
Diffstat (limited to 'flowgraph/node.h')
-rw-r--r-- | flowgraph/node.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/flowgraph/node.h b/flowgraph/node.h index 77395f0..5ea194d 100644 --- a/flowgraph/node.h +++ b/flowgraph/node.h @@ -19,8 +19,11 @@ namespace FlowGraph { public: Node(){} Node(std::vector<Data> operands): mOperands(operands) {} - std::vector<Data>& operands() { return mOperands; } virtual ~Node() {}; // force class to be polymorphic (e.g. in a container) + + std::vector<Data>& operands() { return mOperands; } + Data& destination(); // best-effort return of result/destination; else throw + private: std::vector<Data> mOperands; }; @@ -115,7 +118,6 @@ namespace FlowGraph { Increment, Decrement, Negate, - Store // just take Data as-is to store it at destination }; class UnaryOperation: public Node @@ -130,6 +132,16 @@ namespace FlowGraph { UnaryOperationType m_type; }; + // Just take a value e.g. Immediate and store it for later use. + // Should be optimized out later. + class DataNode: public Node + { + public: + DataNode(Data& value): + Node(std::vector<Data>({value})) + {} + }; + enum class BinaryOperationType: int { Add, |