4 * This is pretty trivial.
14 base_scope
= { .next
= &base_scope
},
15 *current_scope
= &base_scope
;
17 void bind_scope(struct symbol
*sym
)
19 add_symbol(¤t_scope
->symbols
, sym
);
22 void start_symbol_scope(void)
24 struct scope
*scope
= __alloc_bytes(sizeof(*scope
));
25 memset(scope
, 0, sizeof(*scope
));
26 scope
->next
= current_scope
;
27 current_scope
= scope
;
30 static void remove_symbol_scope(struct symbol
*sym
)
32 struct symbol
**ptr
= sym
->id_list
;
35 ptr
= &(*ptr
)->next_id
;
39 void end_symbol_scope(void)
41 struct scope
*scope
= current_scope
;
42 struct symbol_list
*symbols
= scope
->symbols
;
44 current_scope
= scope
->next
;
45 scope
->symbols
= NULL
;
46 symbol_iterate(symbols
, remove_symbol_scope
);