4 * Basic symbol and namespace definitions.
6 * Copyright (C) 2003 Linus Torvalds, all rights reserved.
12 * An identifier with semantic meaning is a "symbol".
14 * There's a 1:n relationship: each symbol is always
15 * associated with one identifier, while each identifier
16 * can have one or more semantic meanings due to C scope
19 * The progression is symbol -> token -> identifier. The
20 * token contains the information on where the symbol was
49 unsigned long modifiers
;
50 struct symbol
*base_type
;
54 enum namespace namespace:8;
56 struct token
*token
; /* Where this symbol was declared */
57 struct token
*ident
; /* What identifier this symbol is associated with */
58 struct symbol
*next_id
; /* Next semantic symbol that shares this identifier */
59 struct symbol
**id_list
; /* Backpointer to symbol list head */
61 struct preprocessor_sym
{
63 struct token
*expansion
;
64 struct token
*arglist
;
67 struct symbol
*next
; /* Next symbol at this level */
70 struct symbol_list
*arguments
;
71 struct statement
*stmt
;
72 struct symbol_list
*symbol_list
;
73 long long value
; /* Initial value */
79 #define MOD_AUTO 0x0001
80 #define MOD_REGISTER 0x0002
81 #define MOD_STATIC 0x0004
82 #define MOD_EXTERN 0x0008
84 #define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN)
86 #define MOD_CONST 0x0010
87 #define MOD_VOLATILE 0x0020
88 #define MOD_SIGNED 0x0040
89 #define MOD_UNSIGNED 0x0080
91 #define MOD_CHAR 0x0100
92 #define MOD_SHORT 0x0200
93 #define MOD_LONG 0x0400
94 #define MOD_LONGLONG 0x0800
96 #define MOD_TYPEDEF 0x1000
97 #define MOD_STRUCTOF 0x2000
98 #define MOD_UNIONOF 0x4000
99 #define MOD_ENUMOF 0x8000
101 #define MOD_TYPEOF 0x10000
102 #define MOD_ATTRIBUTE 0x20000
105 extern struct symbol void_type
,
111 /* Basic identifiers */
112 extern struct ident sizeof_ident
,
129 extern struct ident __asm___ident
,
138 #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE)
140 extern struct symbol
*lookup_symbol(struct ident
*, enum namespace);
141 extern void init_symbols(void);
142 extern struct symbol
*alloc_symbol(struct token
*, int type
);
143 extern void show_type(struct symbol
*);
144 extern const char *modifier_string(unsigned long mod
);
145 extern void show_symbol(struct symbol
*);
146 extern void show_type_list(struct symbol
*);
147 extern void show_symbol_list(struct symbol_list
*, const char *);
148 extern void add_symbol(struct symbol_list
**, struct symbol
*);
149 extern void bind_symbol(struct symbol
*, struct ident
*, enum namespace);
151 #endif /* SEMANTIC_H */