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 | MOD_INLINE)
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
113 #define MOD_INLINE 0x40000
115 #define MOD_NOCAST 0x100000
116 #define MOD_NODEREF 0x200000
119 extern struct symbol void_type
,
126 extern struct symbol bool_ctype
, void_ctype
,
127 char_ctype
, uchar_ctype
,
128 short_ctype
, ushort_ctype
,
129 int_ctype
, uint_ctype
,
130 long_ctype
, ulong_ctype
,
131 llong_ctype
, ullong_ctype
,
132 float_ctype
, double_ctype
, ldouble_ctype
,
133 string_ctype
, ptr_ctype
;
136 /* Basic identifiers */
137 extern struct ident sizeof_ident
,
154 extern struct ident __asm___ident
,
163 #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE)
165 extern struct symbol
*lookup_symbol(struct ident
*, enum namespace);
166 extern void init_symbols(void);
167 extern struct symbol
*alloc_symbol(struct position
, int type
);
168 extern void show_type(struct symbol
*);
169 extern const char *modifier_string(unsigned long mod
);
170 extern void show_symbol(struct symbol
*);
171 extern void show_type_list(struct symbol
*);
172 extern void show_symbol_list(struct symbol_list
*, const char *);
173 extern void add_symbol(struct symbol_list
**, struct symbol
*);
174 extern void bind_symbol(struct symbol
*, struct ident
*, enum namespace);
176 extern struct symbol
*examine_symbol_type(struct symbol
*);
177 extern void examine_simple_symbol_type(struct symbol
*);
179 #endif /* SEMANTIC_H */