Represent enumerations as constant definitions

- Instead of representating enumeration values with a special node type,
  use the same ZCC_ConstantDef nodes that const_def produces. These are
  created at the same scope as the ZCC_Enum, rather than being contained
  entirely within it. To mark the end of enums for a single instance of
  ZCC_Enum, a ZCC_EnumTerminator node is now appended to the chain of
  ZCC_ConstantDefs.
This commit is contained in:
Randy Heit 2013-09-12 21:39:10 -05:00
commit af8e0f2ba6
3 changed files with 93 additions and 44 deletions

View file

@ -301,16 +301,13 @@ static void PrintEnum(FLispString &out, ZCC_TreeNode *node)
out.Open("enum");
out.AddName(enode->EnumName);
PrintBuiltInType(out, enode->EnumType);
PrintNodes(out, enode->Elements, false, true);
out.Add(enode->Elements == NULL ? "nil" : "...", 3);
out.Close();
}
static void PrintEnumNode(FLispString &out, ZCC_TreeNode *node)
static void PrintEnumTerminator(FLispString &out, ZCC_TreeNode *node)
{
ZCC_EnumNode *enode = (ZCC_EnumNode *)node;
out.Open("enum-node");
out.AddName(enode->ElemName);
PrintNodes(out, enode->ElemValue, false);
out.Open("enum-term");
out.Close();
}
@ -802,7 +799,7 @@ void (* const TreeNodePrinter[NUM_AST_NODE_TYPES])(FLispString &, ZCC_TreeNode *
PrintClass,
PrintStruct,
PrintEnum,
PrintEnumNode,
PrintEnumTerminator,
PrintStates,
PrintStatePart,
PrintStateLabel,