//- declarations -------------------------------------------------------- public void makeDeclarationNode(DeclSpecNode declarspecs, DeclaratorNode declarator, InitializerNode initializer) { VarDeclNode vardecl = new VarDeclNode(); vardecl.varType = declarspecs.baseType; DeclaratorNode dnode = declarator; while (dnode != null) { if (dnode is IdentDeclaratorNode) { vardecl.name = ((IdentDeclaratorNode)dnode).ident; } dnode = dnode.next; } vardecl.initializer = initializer; symbolTable.addSymbol(vardecl.name, vardecl); //add decl to either global or local decl list if (curFunc != null) { curFunc.locals.Add(vardecl); } else { curModule.globals.Add(vardecl); } if (initializer != null && curBlock != null) { DeclarInitStatementNode dstmt = new DeclarInitStatementNode(vardecl, initializer.initExpr); addStmtToBlock(dstmt); vardecl.initializer = null; } }
public void makeParamDeclarNode(DeclSpecNode declarspecs, DeclaratorNode declar) { ParamDeclNode pdecl = new ParamDeclNode(); pdecl.pType = declarspecs.baseType; DeclaratorNode dnode = declar; while (dnode != null) { if (dnode is IdentDeclaratorNode) { pdecl.name = ((IdentDeclaratorNode)dnode).ident; } dnode = dnode.next; } symbolTable.addSymbol(pdecl.name, pdecl); curParamList.paramList.Add(pdecl); }
public void startFuncDef(DeclSpecNode declarspecs, DeclaratorNode declarator) { FuncDefNode func = new FuncDefNode(); func.returnType = declarspecs.baseType; DeclaratorNode dnode = declarator; while (dnode != null) { if (dnode is IdentDeclaratorNode) { func.name = ((IdentDeclaratorNode)dnode).ident; } if (dnode is ParamListNode) { func.paramList = ((ParamListNode)dnode).paramList; } dnode = dnode.next; } symbolTable.addSymbol(func.name, func); //add func def to global symbol tbl curModule.funcs.Add(func); //add func to module's func list curFunc = func; enterBlock(); //enter function "super" block }
public TypeNameNode makeTypeNameNode(DeclSpecNode list, DeclaratorNode declar) { return(null); }
//- declarators ------------------------------------------------------- public DeclaratorNode makePointerNode(TypeQualNode qualList, DeclaratorNode declar) { return(null); }
public StructDeclaratorNode makeStructDeclaractorNode(DeclaratorNode declarnode, ConstExprNode constexpr) { return(null); }