diff options
| author | Nagi5Yeq <wu@x-nagi.com> | 2020-05-21 13:32:12 +0800 |
|---|---|---|
| committer | Nagi5Yeq <wu@x-nagi.com> | 2020-05-21 13:32:12 +0800 |
| commit | 3832be8be4b23fb9e93a3f181e4205eadbdbf4de (patch) | |
| tree | 0b958eb72400458401be619b04a8a6cf77194255 /node/ExprNode.hh | |
| parent | 41f6e75e3f26bdcccfcb3910f202452e14653826 (diff) | |
binary and unary operations
Diffstat (limited to 'node/ExprNode.hh')
| -rw-r--r-- | node/ExprNode.hh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/node/ExprNode.hh b/node/ExprNode.hh new file mode 100644 index 0000000..ac62975 --- /dev/null +++ b/node/ExprNode.hh @@ -0,0 +1,43 @@ +#ifndef PCC_EXPRNODE_H +#define PCC_EXPRNODE_H + +#include "BaseNode.hh" +#include "Type.hh" + +namespace pcc { +class ExprNode : public BaseNode { + public: + ExprNode(Context* context); + virtual Value CodeGen() = 0; + std::shared_ptr<Type> GetType(); + + protected: + std::shared_ptr<Type> type_; +}; + +class BinaryExprNode : public ExprNode { + public: + BinaryExprNode(Context* context, BinaryOperator op, + std::shared_ptr<ExprNode> left, + std::shared_ptr<ExprNode> right); + virtual Value CodeGen(); + + protected: + BinaryOperator op_; + std::shared_ptr<ExprNode> left_, right_; +}; + +class UnaryExprNode : public ExprNode { + public: + UnaryExprNode(Context* context, UnaryOperator op, + std::shared_ptr<ExprNode> value); + virtual Value CodeGen(); + + protected: + UnaryOperator op_; + std::shared_ptr<ExprNode> value_; +}; + +} // namespace pcc + +#endif // !PCC_EXPRNODE_H |
