4 * This is pretty trivial.
6 * Copyright (C) 2003 Transmeta Corp.
7 * 2003-2004 Linus Torvalds
9 * Licensed under the Open Software License version 1.1
19 static struct scope toplevel_scope
= { .next
= &toplevel_scope
};
21 struct scope
*block_scope
= &toplevel_scope
,
22 *function_scope
= &toplevel_scope
,
23 *file_scope
= &toplevel_scope
;
25 void bind_scope(struct symbol
*sym
, struct scope
*scope
)
28 add_symbol(&scope
->symbols
, sym
);
31 static void start_scope(struct scope
**s
)
33 struct scope
*scope
= __alloc_scope(0);
34 memset(scope
, 0, sizeof(*scope
));
39 void start_symbol_scope(void)
41 start_scope(&block_scope
);
44 void start_function_scope(void)
46 start_scope(&function_scope
);
47 start_scope(&block_scope
);
50 static void remove_symbol_scope(struct symbol
*sym
)
52 struct symbol
**ptr
= sym
->id_list
;
55 ptr
= &(*ptr
)->next_id
;
59 static void end_scope(struct scope
**s
)
61 struct scope
*scope
= *s
;
62 struct symbol_list
*symbols
= scope
->symbols
;
66 scope
->symbols
= NULL
;
67 FOR_EACH_PTR(symbols
, sym
) {
68 remove_symbol_scope(sym
);
69 } END_FOR_EACH_PTR(sym
);
72 void end_symbol_scope(void)
74 end_scope(&block_scope
);
77 void end_function_scope(void)
79 end_scope(&block_scope
);
80 end_scope(&function_scope
);