diff options
author | John Hodge <tpg@mutabah.net> | 2016-05-01 20:44:57 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-05-01 20:44:57 +0800 |
commit | 8863535ad350137189fcafce1343765500bc445a (patch) | |
tree | f13c723f1377599ac867d56c721ab89832607f97 /src/expand/derive.cpp | |
parent | 58036edfc5e36e9463147b6984c99a5094882881 (diff) | |
download | mrust-8863535ad350137189fcafce1343765500bc445a.tar.gz |
Fix handling of tuple/unit structs
Diffstat (limited to 'src/expand/derive.cpp')
-rw-r--r-- | src/expand/derive.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/expand/derive.cpp b/src/expand/derive.cpp index 6b52982d..c14753e9 100644 --- a/src/expand/derive.cpp +++ b/src/expand/derive.cpp @@ -83,7 +83,26 @@ public: node = NEWNODE(AST::ExprNode_CallMethod, mv$(node), AST::PathNode("finish",{}), {}); ), (Tuple, - assert(!"TODO: derive() debug on tuple struct"); + node = NEWNODE(AST::ExprNode_NamedValue, AST::Path("f")); + node = NEWNODE(AST::ExprNode_CallMethod, + mv$(node), AST::PathNode("debug_tuple",{}), + vec$( NEWNODE(AST::ExprNode_String, name) ) + ); + for( unsigned int idx = 0; idx < e.ents.size(); idx ++ ) + { + node = NEWNODE(AST::ExprNode_CallMethod, + mv$(node), AST::PathNode("field",{}), + vec$( + NEWNODE(AST::ExprNode_UniOp, AST::ExprNode_UniOp::REF, + NEWNODE(AST::ExprNode_Field, + NEWNODE(AST::ExprNode_NamedValue, AST::Path("self")), + FMT(idx) + ) + ) + ) + ); + } + node = NEWNODE(AST::ExprNode_CallMethod, mv$(node), AST::PathNode("finish",{}), {}); ) ) |