From 2a1414ad6638a21c64737c77a310c52200e5172f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 12 Sep 2013 22:06:57 -0500 Subject: [PATCH] Use labels in autogenerated enum value expressions - For an enum like this: enum { value1 = SOME_NUM*2, value2 }; Generate an increment expression for value2 of the form (add (id value1) 1) and not (add (* SOME_NUM 2) 1) --- src/zscript/zcc-parse.lemon | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/zscript/zcc-parse.lemon b/src/zscript/zcc-parse.lemon index 6c86a03a20..e4f0d1fbd1 100644 --- a/src/zscript/zcc-parse.lemon +++ b/src/zscript/zcc-parse.lemon @@ -310,7 +310,12 @@ enum_def(X) ::= ENUM(T) IDENTIFIER(A) enum_type(B) LBRACE opt_enum_list(C) RBRAC NEW_INTCONST_NODE(cval, TypeSInt32, 1, T); one = cval; } - BINARY_EXPR(prev->Value, one, PEX_Add); + NEW_AST_NODE(ExprID, label, node); + label->Operation = PEX_ID; + label->Identifier = prev->Name; + label->Type = NULL; + + BINARY_EXPR(label, one, PEX_Add); node->Value = expr; } }