static SYM_HANDLE GetLocalVarDecls( void ) { SYM_HANDLE symlist; SYM_HANDLE symhandle; SYM_ENTRY sym; DeclList( &symlist ); if( symlist != 0 ) { symhandle = CurFunc->u.func.locals; // symhandle will be non-zero if MakeNewSym was called while // parsing the declaration list. if( symhandle != 0 ) { // if some temporaries were created for( ;; ) { // - find end of list SymGet( &sym, symhandle ); if( sym.handle == 0 ) break; symhandle = sym.handle; } sym.handle = symlist; SymReplace( &sym, symhandle ); } else { CurFunc->u.func.locals = symlist; } } return( symlist ); }
static void LeftBrace( void ) { TREEPTR tree; /* <storage> <type> function( <parms> ) { <- this is SymLevel == 1 (weird code is for SymLevel > 1 ) */ // DeclList might generate some quads to do some initializers // if that happens, we want them output after the OPR_NEWBLOCK node StartNewBlock(); NextToken(); ++SymLevel; tree = LeafNode( OPR_NEWBLOCK ); AddStmt( tree ); BlockStack->sym_list = 0; BlockStack->gen_endblock = TRUE; DeclList( &BlockStack->sym_list ); tree->op.sym_handle = BlockStack->sym_list; }
void ParsePgm( void ) { SYM_HANDLE dummysym; CompFlags.external_defn_found = 0; CompFlags.initializing_data = 0; dummysym = SYM_NULL; GlobalSym = SYM_NULL; do { if( DeclList( &dummysym ) ) { /* if this is a function defn */ FuncDefn( CurFunc ); SrcLoc = CurFunc->src_loc; GenFunctionNode( CurFuncHandle ); SymLevel = 1; ParmDeclList(); SymLevel = 0; if( CurToken == T_LEFT_BRACE ) { BeginFunc(); Statement(); CMemFree( CurFunc->name ); CurFunc->name = NULL; SymReplace( CurFunc, CurFuncHandle ); CurFunc = NULL; CurFuncNode = NULL; CurFuncHandle = SYM_NULL; } else { MustRecog( T_LEFT_BRACE ); } } } while( CurToken != T_EOF ); if( CompFlags.external_defn_found == 0 ) { if( !CompFlags.extensions_enabled ) { CErr1( ERR_NO_EXTERNAL_DEFNS_FOUND ); } } }