summaryrefslogtreecommitdiffhomepage
path: root/flowgraph/node.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-11-15 18:39:01 +0100
committerRoland Reichwein <mail@reichwein.it>2020-11-15 18:39:01 +0100
commita3b4cd4fdd4340c952eaa00bca9bebf817b901ae (patch)
tree055d3ae4b9d1e37682c2e49b31a6531f189eebf5 /flowgraph/node.h
parentd07c5bc14edbe071ee7b4f47f174780e95e451aa (diff)
Fixed unit tests, prepared hierarchical evaluation via stack (WIP)
Diffstat (limited to 'flowgraph/node.h')
-rw-r--r--flowgraph/node.h16
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,