summaryrefslogtreecommitdiff
path: root/node/StatementNode.hh
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-06-05 01:25:59 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-06-05 01:25:59 +0800
commit176c8e70f56bbbbe5ab2063f22000b9af0180e85 (patch)
tree0f291a33e69bd9c840131e170e63c0d245268d7b /node/StatementNode.hh
parentbaa601da82cce51d2b4bd39a32fdc5b8de5c6452 (diff)
add case statement support
Diffstat (limited to 'node/StatementNode.hh')
-rw-r--r--node/StatementNode.hh18
1 files changed, 18 insertions, 0 deletions
diff --git a/node/StatementNode.hh b/node/StatementNode.hh
index b729001..81cbb93 100644
--- a/node/StatementNode.hh
+++ b/node/StatementNode.hh
@@ -105,6 +105,24 @@ class ContinueStatementNode : public BaseNode {
virtual Value CodeGen() override;
virtual int Travel(Traveler& traveler) override;
};
+
+using CasePair =
+ std::pair<std::shared_ptr<ExprNode>, std::shared_ptr<BaseNode>>;
+
+class SwitchStatementNode : public BaseNode {
+ public:
+ SwitchStatementNode(Context* context,
+ std::shared_ptr<ExprNode> CaseVariable,
+ std::list<CasePair>&& CasePairs,
+ std::shared_ptr<BaseNode> DefaultAction);
+ virtual Value CodeGen() override;
+ virtual int Travel(Traveler& traveler) override;
+
+ protected:
+ std::shared_ptr<ExprNode> CaseVariable_;
+ std::list<CasePair> CasePairs_;
+ std::shared_ptr<BaseNode> DefaultAction_;
+};
} // namespace pcc
#endif