summaryrefslogtreecommitdiff
path: root/src/ast/expr.cpp
diff options
context:
space:
mode:
authorJohn Hodge (sonata) <tpg@mutabah.net>2015-01-17 14:44:26 +0800
committerJohn Hodge (sonata) <tpg@mutabah.net>2015-01-17 14:44:26 +0800
commit0eaa7a5a300de625dfa813f49b04407c9f0a4feb (patch)
tree96a81ddeca3006469005591e4433ed9a6d0e9737 /src/ast/expr.cpp
parentf99a99e79ff7946dcf7a283c87caf8f0a92c2c03 (diff)
downloadmrust-0eaa7a5a300de625dfa813f49b04407c9f0a4feb.tar.gz
Trait serialise
Diffstat (limited to 'src/ast/expr.cpp')
-rw-r--r--src/ast/expr.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ast/expr.cpp b/src/ast/expr.cpp
index 92a189e1..7cde198f 100644
--- a/src/ast/expr.cpp
+++ b/src/ast/expr.cpp
@@ -29,10 +29,27 @@ SERIALISE_TYPE(Expr::, "Expr", {
DEBUG("tag = " << tag);
ExprNode* ptr = nullptr;
- if(tag == "ExprNode_Block") ptr = new ExprNode_Block;
- else if(tag == "ExprNode_Macro") ptr = new ExprNode_Macro;
+ #define _(x) if(tag == #x) ptr = new x;
+ _(ExprNode_Block)
+ else _(ExprNode_Macro)
+ else _(ExprNode_Return)
+ else _(ExprNode_LetBinding)
+ else _(ExprNode_Assign)
+ else _(ExprNode_CallPath)
+ else _(ExprNode_CallMethod)
+ else _(ExprNode_CallObject)
+ else _(ExprNode_Match)
+ else _(ExprNode_If)
+ else _(ExprNode_Integer)
+ else _(ExprNode_StructLiteral)
+ else _(ExprNode_Tuple)
+ else _(ExprNode_NamedValue)
+ else _(ExprNode_Field)
+ else _(ExprNode_CallPath)
+ else _(ExprNode_BinOp)
else
throw ::std::runtime_error("Unknown node type " + tag);
+ #undef _
ptr->deserialise(d);
d.end_object(tag.c_str());