4 * Basic symbol and namespace definitions.
6 * Copyright (C) 2003 Transmeta Corp, 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
50 unsigned long modifiers
;
51 unsigned long alignment
;
52 unsigned int contextmask
, context
, as
;
53 struct symbol
*base_type
;
57 enum namespace namespace:8;
59 struct position pos
; /* Where this symbol was declared */
60 struct ident
*ident
; /* What identifier this symbol is associated with */
61 struct symbol
*next_id
; /* Next semantic symbol that shares this identifier */
62 struct symbol
**id_list
; /* Backpointer to symbol list head */
64 struct preprocessor_sym
{
66 struct token
*expansion
;
67 struct token
*arglist
;
70 struct symbol
*next
; /* Next symbol at this level */
72 unsigned int bit_size
;
73 unsigned int bit_offset
:8,
79 struct symbol_list
*arguments
;
80 struct statement
*stmt
;
81 struct symbol_list
*symbol_list
;
82 struct expression
*initializer
;
83 long long value
; /* Initial value */
89 #define MOD_AUTO 0x0001
90 #define MOD_REGISTER 0x0002
91 #define MOD_STATIC 0x0004
92 #define MOD_EXTERN 0x0008
94 #define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN)
96 #define MOD_CONST 0x0010
97 #define MOD_VOLATILE 0x0020
98 #define MOD_SIGNED 0x0040
99 #define MOD_UNSIGNED 0x0080
101 #define MOD_CHAR 0x0100
102 #define MOD_SHORT 0x0200
103 #define MOD_LONG 0x0400
104 #define MOD_LONGLONG 0x0800
106 #define MOD_TYPEDEF 0x1000
107 #define MOD_STRUCTOF 0x2000
108 #define MOD_UNIONOF 0x4000
109 #define MOD_ENUMOF 0x8000
111 #define MOD_TYPEOF 0x10000
112 #define MOD_ATTRIBUTE 0x20000
114 #define MOD_NOCAST 0x100000
115 #define MOD_NODEREF 0x200000
118 extern struct symbol void_type
,
125 extern struct symbol bool_ctype
, void_ctype
,
126 char_ctype
, uchar_ctype
,
127 short_ctype
, ushort_ctype
,
128 int_ctype
, uint_ctype
,
129 long_ctype
, ulong_ctype
,
130 llong_ctype
, ullong_ctype
,
131 float_ctype
, double_ctype
, ldouble_ctype
,
132 string_ctype
, ptr_ctype
;
135 /* Basic identifiers */
136 extern struct ident sizeof_ident
,
153 extern struct ident __asm___ident
,
162 #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE)
164 extern struct symbol
*lookup_symbol(struct ident
*, enum namespace);
165 extern void init_symbols(void);
166 extern struct symbol
*alloc_symbol(struct position
, int type
);
167 extern void show_type(struct symbol
*);
168 extern const char *modifier_string(unsigned long mod
);
169 extern void show_symbol(struct symbol
*);
170 extern void show_type_list(struct symbol
*);
171 extern void show_symbol_list(struct symbol_list
*, const char *);
172 extern void add_symbol(struct symbol_list
**, struct symbol
*);
173 extern void bind_symbol(struct symbol
*, struct ident
*, enum namespace);
175 extern struct symbol
*examine_symbol_type(struct symbol
*);
176 extern void examine_simple_symbol_type(struct symbol
*);
178 #endif /* SEMANTIC_H */