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
48 unsigned long modifiers
;
49 struct symbol
*base_type
;
53 enum namespace namespace:8;
55 struct token
*token
; /* Where this symbol was declared */
56 struct token
*ident
; /* What identifier this symbol is associated with */
57 struct symbol
*next_id
; /* Next semantic symbol that shares this identifier */
58 struct symbol
**id_list
; /* Backpointer to symbol list head */
60 struct preprocessor_sym
{
62 struct token
*expansion
;
63 struct token
*arglist
;
66 struct symbol
*next
; /* Next symbol at this level */
68 unsigned int bit_size
;
69 unsigned int alignment
:24,
73 struct symbol_list
*arguments
;
74 struct statement
*stmt
;
75 struct symbol_list
*symbol_list
;
76 long long value
; /* Initial value */
78 int arg_count
:10, variadic
:1;
84 #define MOD_AUTO 0x0001
85 #define MOD_REGISTER 0x0002
86 #define MOD_STATIC 0x0004
87 #define MOD_EXTERN 0x0008
89 #define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN)
91 #define MOD_CONST 0x0010
92 #define MOD_VOLATILE 0x0020
93 #define MOD_SIGNED 0x0040
94 #define MOD_UNSIGNED 0x0080
96 #define MOD_CHAR 0x0100
97 #define MOD_SHORT 0x0200
98 #define MOD_LONG 0x0400
99 #define MOD_LONGLONG 0x0800
101 #define MOD_TYPEDEF 0x1000
102 #define MOD_STRUCTOF 0x2000
103 #define MOD_UNIONOF 0x4000
104 #define MOD_ENUMOF 0x8000
106 #define MOD_TYPEOF 0x10000
107 #define MOD_ATTRIBUTE 0x20000
110 extern struct symbol void_type
,
117 extern struct symbol bool_ctype
, void_ctype
,
118 char_ctype
, uchar_ctype
,
119 short_ctype
, ushort_ctype
,
120 int_ctype
, uint_ctype
,
121 long_ctype
, ulong_ctype
,
122 llong_ctype
, ullong_ctype
,
123 float_ctype
, double_ctype
, ldouble_ctype
,
124 string_ctype
, ptr_ctype
;
127 /* Basic identifiers */
128 extern struct ident sizeof_ident
,
145 extern struct ident __asm___ident
,
154 #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE)
156 extern struct symbol
*lookup_symbol(struct ident
*, enum namespace);
157 extern void init_symbols(void);
158 extern struct symbol
*alloc_symbol(struct token
*, int type
);
159 extern void show_type(struct symbol
*);
160 extern const char *modifier_string(unsigned long mod
);
161 extern void show_symbol(struct symbol
*);
162 extern void show_type_list(struct symbol
*);
163 extern void show_symbol_list(struct symbol_list
*, const char *);
164 extern void add_symbol(struct symbol_list
**, struct symbol
*);
165 extern void bind_symbol(struct symbol
*, struct ident
*, enum namespace);
167 extern void examine_symbol_type(struct symbol
*);
168 extern void examine_simple_symbol_type(struct symbol
*);
170 #endif /* SEMANTIC_H */