scopes.c
// Add a symbol to the current scope
Add a symbol to the current scope
Add a symbol to the current scope
Symbol *new_symbol(char *identifier) {
    if (cur_scope->symbol_count == cur_scope->max_count)
        panic("Exceeded max symbol table size of %d symbols", cur_scope->max_count);
    Symbol *symbol = malloc(sizeof(Symbol));
    memset(symbol, 0, sizeof(Symbol));
    symbol->identifier = identifier;
    cur_scope->symbol_list[cur_scope->symbol_count++] = symbol;
    strmap_put(cur_scope->symbols, identifier, symbol);
    symbol->scope = cur_scope;
    return symbol;
}
Symbol * new_symbol ( char * identifier ) { if ( cur_scope -> symbol_count == cur_scope -> max_count ) panic ( " " , cur_scope -> max_count ) ; Symbol * symbol = malloc ( sizeof ( Symbol ) ) ; memset ( symbol , 0 , sizeof ( Symbol ) ) ; symbol -> identifier = identifier ; cur_scope -> symbol_list [ cur_scope -> symbol_count ++ ] = symbol ; strmap_put ( cur_scope -> symbols , identifier , symbol ) ; symbol -> scope = cur_scope ; return symbol ; }
Add a symbol to the current scope
Add a symbol to the current scope