3 static struct scope
*scope
;
5 void enter_scope(void) {
6 struct scope
*new_scope
;
9 new_scope
->parent
= scope
;
13 void exit_scope(void) {
14 scope
= scope
->parent
;
17 /* might be called before the declaration_specifiers have been filled in */
18 void add_declaration(struct declarator
*d
) {
19 /* skip nameless declarators to simplify some callers */
21 if(!scope
->declarations
)
22 scope
->declarations
= dict_new();
23 dict_add(scope
->declarations
, d
->name
, d
);
25 /* XXX redeclaration */
28 struct declarator
*lookup(const char *name
) {
29 const struct scope
*s
;
32 for(s
= scope
; s
; s
= s
->parent
)
33 if(s
->declarations
&& (d
= dict_get(s
->declarations
, name
)))
38 void scope_init(void) {