summaryrefslogtreecommitdiff
path: root/src/hir/expr.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-06-26 17:42:42 +0800
committerJohn Hodge <tpg@mutabah.net>2016-06-26 17:42:42 +0800
commit7be1b3aeb885bb020faddb3b390a49d6d6f206d5 (patch)
tree006b8aa15ab5ea909ec7e4c6030c4f1a734e039f /src/hir/expr.hpp
parente9714fa625e02047d50d56fdd8c665742a443c73 (diff)
downloadmrust-7be1b3aeb885bb020faddb3b390a49d6d6f206d5.tar.gz
HIR Typecheck - Hacking to pieces
Diffstat (limited to 'src/hir/expr.hpp')
-rw-r--r--src/hir/expr.hpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/hir/expr.hpp b/src/hir/expr.hpp
index 7e43e206..65e5bb0d 100644
--- a/src/hir/expr.hpp
+++ b/src/hir/expr.hpp
@@ -166,6 +166,25 @@ struct ExprNode_Assign:
And, Or , Xor,
Shr, Shl,
};
+ static const char* opname(Op v) {
+ switch(v)
+ {
+ case Op::None: return "";
+ case Op::Add: return "+";
+ case Op::Sub: return "-";
+ case Op::Mul: return "*";
+ case Op::Div: return "/";
+ case Op::Mod: return "%";
+
+ case Op::And: return "&";
+ case Op::Or: return "|";
+ case Op::Xor: return "^";
+
+ case Op::Shr: return ">>";
+ case Op::Shl: return "<<";
+ }
+ throw "";
+ }
Op m_op;
ExprNodeP m_slot;
@@ -199,6 +218,34 @@ struct ExprNode_BinOp:
And, Or , Xor,
Shr, Shl,
};
+ static const char* opname(Op v) {
+ switch(v)
+ {
+ case Op::CmpEqu: return "==";
+ case Op::CmpNEqu: return "!=";
+ case Op::CmpLt: return "<";
+ case Op::CmpLtE: return "<=";
+ case Op::CmpGt: return ">";
+ case Op::CmpGtE: return ">=";
+
+ case Op::BoolAnd: return "&&";
+ case Op::BoolOr: return "||";
+
+ case Op::Add: return "+";
+ case Op::Sub: return "-";
+ case Op::Mul: return "*";
+ case Op::Div: return "/";
+ case Op::Mod: return "%";
+
+ case Op::And: return "&";
+ case Op::Or: return "|";
+ case Op::Xor: return "^";
+
+ case Op::Shr: return ">>";
+ case Op::Shl: return "<<";
+ }
+ return "??";
+ }
Op m_op;
::HIR::ExprNodeP m_left;
@@ -234,6 +281,15 @@ struct ExprNode_UniOp:
Invert, // '!<expr>'
Negate, // '-<expr>'
};
+ static const char* opname(Op v) {
+ switch(v) {
+ case Op::Ref: return "&";
+ case Op::RefMut:return "&mut";
+ case Op::Invert:return "!";
+ case Op::Negate:return "-";
+ }
+ throw "";
+ }
Op m_op;
::HIR::ExprNodeP m_value;