4 * This is pretty trivial.
6 * Copyright (C) 2003 Transmeta Corp.
8 * Licensed under the Open Software License version 1.1
17 static struct scope toplevel_scope
= { .next
= &toplevel_scope
};
19 struct scope
*block_scope
= &toplevel_scope
,
20 *function_scope
= &toplevel_scope
,
21 *file_scope
= &toplevel_scope
;
23 void bind_scope(struct symbol
*sym
, struct scope
*scope
)
26 add_symbol(&scope
->symbols
, sym
);
29 static void start_scope(struct scope
**s
)
31 struct scope
*scope
= __alloc_scope(0);
32 memset(scope
, 0, sizeof(*scope
));
37 void start_symbol_scope(void)
39 start_scope(&block_scope
);
42 void start_function_scope(void)
44 start_scope(&function_scope
);
45 start_scope(&block_scope
);
48 static void remove_symbol_scope(struct symbol
*sym
, void *data
, int flags
)
50 struct symbol
**ptr
= sym
->id_list
;
53 ptr
= &(*ptr
)->next_id
;
57 static void end_scope(struct scope
**s
)
59 struct scope
*scope
= *s
;
60 struct symbol_list
*symbols
= scope
->symbols
;
63 scope
->symbols
= NULL
;
64 symbol_iterate(symbols
, remove_symbol_scope
, NULL
);
67 void end_symbol_scope(void)
69 end_scope(&block_scope
);
72 void end_function_scope(void)
74 end_scope(&block_scope
);
75 end_scope(&function_scope
);