- added ProcessStruct, analogous to ProcessClass.

Now everything should be in place to resolve all constants - inside and outside classes or structs.
This commit is contained in:
Christoph Oelckers 2016-10-08 15:39:54 +02:00
parent d139ee9f68
commit 5bb6bb31ca
2 changed files with 48 additions and 2 deletions

View file

@ -82,6 +82,51 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *tnode)
case AST_States:
case AST_VarDeclarator:
case AST_FuncDeclarator:
case AST_Default:
break;
default:
assert(0 && "Unhandled AST node type");
break;
}
node = node->SiblingNext;
}
while (node != cnode->Body);
}
//==========================================================================
//
// ZCCCompiler :: ProcessClass
//
//==========================================================================
void ZCCCompiler::ProcessStruct(ZCC_Struct *cnode, PSymbolTreeNode *tnode)
{
Structs.Push(ZCC_StructWork(static_cast<ZCC_Struct *>(cnode), tnode));
ZCC_StructWork &cls = Structs.Last();
auto node = cnode->Body;
do
{
switch (node->NodeType)
{
case AST_ConstantDef:
if ((tnode = AddNamedNode(static_cast<ZCC_NamedNode *>(node))))
{
cls.Constants.Push(static_cast<ZCC_ConstantDef *>(node)); break;
}
break;
case AST_Enum: break;
case AST_EnumTerminator:break;
// todo
case AST_VarDeclarator:
break;
default:
assert(0 && "Unhandled AST node type");
break;
}
node = node->SiblingNext;
@ -115,7 +160,7 @@ ZCCCompiler::ZCCCompiler(ZCC_AST &ast, DObject *_outer, PSymbolTable &_symbols,
switch (node->NodeType)
{
case AST_Class: ProcessClass(static_cast<ZCC_Class *>(node), tnode); break;
case AST_Struct: Structs.Push(ZCC_StructWork(static_cast<ZCC_Struct *>(node), tnode)); break;
case AST_Struct: ProcessStruct(static_cast<ZCC_Struct *>(node), tnode); break;
case AST_ConstantDef: Constants.Push(static_cast<ZCC_ConstantDef *>(node)); break;
default: assert(0 && "Default case is just here to make GCC happy. It should never be reached");
}

View file

@ -59,6 +59,7 @@ public:
private:
void ProcessClass(ZCC_Class *node, PSymbolTreeNode *tnode);
void ProcessStruct(ZCC_Struct *node, PSymbolTreeNode *tnode);
void CreateStructTypes();
void CreateClassTypes();
void CompileConstants(const TArray<ZCC_ConstantDef *> &defs);