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
)
24 add_symbol(&scope
->symbols
, sym
);
27 static void start_scope(struct scope
**s
)
29 struct scope
*scope
= __alloc_bytes(sizeof(*scope
));
30 memset(scope
, 0, sizeof(*scope
));
35 void start_symbol_scope(void)
37 start_scope(&block_scope
);
40 void start_function_scope(void)
42 start_scope(&function_scope
);
43 start_scope(&block_scope
);
46 static void remove_symbol_scope(struct symbol
*sym
, void *data
, int flags
)
48 struct symbol
**ptr
= sym
->id_list
;
51 ptr
= &(*ptr
)->next_id
;
55 static void end_scope(struct scope
**s
)
57 struct scope
*scope
= *s
;
58 struct symbol_list
*symbols
= scope
->symbols
;
61 scope
->symbols
= NULL
;
62 symbol_iterate(symbols
, remove_symbol_scope
, NULL
);
65 void end_symbol_scope(void)
67 end_scope(&block_scope
);
70 void end_function_scope(void)
72 end_scope(&block_scope
);
73 end_scope(&function_scope
);