diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-14 22:09:22 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-14 22:09:22 +0800 |
commit | 4dfe5c315498ef816baa3c62e36bc0d72cff50a9 (patch) | |
tree | aae657d43c099d1709f24931f6185c9a59b73be2 /src/hir/expr.hpp | |
parent | 6f390a1f245d467ef8f2aa7c9e0ad7b300a4e681 (diff) | |
download | mrust-4dfe5c315498ef816baa3c62e36bc0d72cff50a9.tar.gz |
HIR - Move borrow ops to their own node type
Diffstat (limited to 'src/hir/expr.hpp')
-rw-r--r-- | src/hir/expr.hpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/hir/expr.hpp b/src/hir/expr.hpp index f69429f6..8da873c1 100644 --- a/src/hir/expr.hpp +++ b/src/hir/expr.hpp @@ -301,15 +301,11 @@ struct ExprNode_UniOp: public ExprNode { enum class Op { - Ref, // '& <expr>' - RefMut, // '&mut <expr>' 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 "-"; } @@ -327,6 +323,20 @@ struct ExprNode_UniOp: NODE_METHODS(); }; +struct ExprNode_Borrow: + public ExprNode +{ + ::HIR::BorrowType m_type; + ::HIR::ExprNodeP m_value; + + ExprNode_Borrow(Span sp, ::HIR::BorrowType bt, ::HIR::ExprNodeP value): + ExprNode( mv$(sp) ), + m_type(bt), + m_value( mv$(value) ) + {} + + NODE_METHODS(); +}; struct ExprNode_Cast: public ExprNode { @@ -731,6 +741,7 @@ public: NV(ExprNode_Assign) NV(ExprNode_BinOp) NV(ExprNode_UniOp) + NV(ExprNode_Borrow) NV(ExprNode_Cast) // Conversion NV(ExprNode_Unsize) // Coercion NV(ExprNode_Index) @@ -773,6 +784,7 @@ public: NV(ExprNode_Assign) NV(ExprNode_BinOp) NV(ExprNode_UniOp) + NV(ExprNode_Borrow) NV(ExprNode_Cast) NV(ExprNode_Unsize) NV(ExprNode_Index) |