4 * This is pretty trivial.
6 * Copyright (C) 2003 Transmeta Corp, all rights reserved.
15 static struct scope toplevel_scope
= { .next
= &toplevel_scope
};
17 struct scope
*block_scope
= &toplevel_scope
,
18 *function_scope
= &toplevel_scope
,
19 *file_scope
= &toplevel_scope
;
21 void bind_scope(struct symbol
*sym
, struct scope
*scope
)
23 add_symbol(&scope
->symbols
, sym
);
26 static void start_scope(struct scope
**s
)
28 struct scope
*scope
= __alloc_bytes(sizeof(*scope
));
29 memset(scope
, 0, sizeof(*scope
));
34 void start_symbol_scope(void)
36 start_scope(&block_scope
);
39 void start_function_scope(void)
41 start_scope(&function_scope
);
42 start_scope(&block_scope
);
45 static void remove_symbol_scope(struct symbol
*sym
, void *data
, int flags
)
47 struct symbol
**ptr
= sym
->id_list
;
50 ptr
= &(*ptr
)->next_id
;
54 static void end_scope(struct scope
**s
)
56 struct scope
*scope
= *s
;
57 struct symbol_list
*symbols
= scope
->symbols
;
60 scope
->symbols
= NULL
;
61 symbol_iterate(symbols
, remove_symbol_scope
, NULL
);
64 void end_symbol_scope(void)
66 end_scope(&block_scope
);
69 void end_function_scope(void)
71 end_scope(&block_scope
);
72 end_scope(&function_scope
);