4 * Basic symbol and namespace definitions.
6 * Copyright (C) 2003 Transmeta Corp.
8 * Licensed under the Open Software License version 1.1
14 * An identifier with semantic meaning is a "symbol".
16 * There's a 1:n relationship: each symbol is always
17 * associated with one identifier, while each identifier
18 * can have one or more semantic meanings due to C scope
21 * The progression is symbol -> token -> identifier. The
22 * token contains the information on where the symbol was
53 unsigned long modifiers
;
54 unsigned long alignment
;
55 unsigned int contextmask
, context
, as
;
56 struct symbol
*base_type
;
60 int (*evaluate
)(struct expression
*);
61 void (*expand
)(struct expression
*);
65 enum namespace namespace:8;
67 struct position pos
; /* Where this symbol was declared */
68 struct ident
*ident
; /* What identifier this symbol is associated with */
69 struct symbol
*next_id
; /* Next semantic symbol that shares this identifier */
70 struct symbol
**id_list
; /* Backpointer to symbol list head */
71 struct symbol
*replace
; /* What is this symbol shadowed by in copy-expression */
73 struct symbol
*same_symbol
;
76 struct /* preprocessor_sym */ {
77 struct token
*expansion
;
78 struct token
*arglist
;
81 struct /* ctype_sym */ {
83 unsigned int bit_size
;
84 unsigned int bit_offset
:8,
92 struct symbol_list
*arguments
;
93 struct statement
*stmt
;
94 struct symbol_list
*symbol_list
;
95 struct expression
*initializer
;
96 long long value
; /* Initial value */
98 void *aux
; /* Auxiliary info, eg. backend information */
102 #define MOD_AUTO 0x0001
103 #define MOD_REGISTER 0x0002
104 #define MOD_STATIC 0x0004
105 #define MOD_EXTERN 0x0008
107 #define MOD_STORAGE (MOD_AUTO | MOD_REGISTER | MOD_STATIC | MOD_EXTERN | MOD_INLINE | MOD_TOPLEVEL)
109 #define MOD_CONST 0x0010
110 #define MOD_VOLATILE 0x0020
111 #define MOD_SIGNED 0x0040
112 #define MOD_UNSIGNED 0x0080
114 #define MOD_CHAR 0x0100
115 #define MOD_SHORT 0x0200
116 #define MOD_LONG 0x0400
117 #define MOD_LONGLONG 0x0800
119 #define MOD_TYPEDEF 0x1000
120 #define MOD_STRUCTOF 0x2000
121 #define MOD_UNIONOF 0x4000
122 #define MOD_ENUMOF 0x8000
124 #define MOD_TYPEOF 0x10000
125 #define MOD_ATTRIBUTE 0x20000
126 #define MOD_INLINE 0x40000
127 #define MOD_ADDRESSABLE 0x80000
129 #define MOD_NOCAST 0x100000
130 #define MOD_NODEREF 0x200000
131 #define MOD_ACCESSED 0x400000
132 #define MOD_TOPLEVEL 0x800000 // scoping..
134 #define MOD_LABEL 0x1000000
135 #define MOD_ASSIGNED 0x2000000
138 extern struct symbol void_type
,
146 extern struct symbol bool_ctype
, void_ctype
,
147 char_ctype
, uchar_ctype
,
148 short_ctype
, ushort_ctype
,
149 int_ctype
, uint_ctype
,
150 long_ctype
, ulong_ctype
,
151 llong_ctype
, ullong_ctype
,
152 float_ctype
, double_ctype
, ldouble_ctype
,
153 string_ctype
, ptr_ctype
, label_type
;
156 /* Basic identifiers */
157 extern struct ident sizeof_ident
,
174 extern struct ident __asm___ident
,
184 #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE)
186 extern struct symbol_list
*used_list
;
188 extern void access_symbol(struct symbol
*);
191 extern struct symbol
*lookup_symbol(struct ident
*, enum namespace);
192 extern void init_symbols(void);
193 extern struct symbol
*alloc_symbol(struct position
, int type
);
194 extern void show_type(struct symbol
*);
195 extern const char *modifier_string(unsigned long mod
);
196 extern void show_symbol(struct symbol
*);
197 extern void show_type_list(struct symbol
*);
198 extern void show_symbol_list(struct symbol_list
*, const char *);
199 extern void add_symbol(struct symbol_list
**, struct symbol
*);
200 extern void bind_symbol(struct symbol
*, struct ident
*, enum namespace);
202 extern struct symbol
*examine_symbol_type(struct symbol
*);
203 extern void examine_simple_symbol_type(struct symbol
*);
204 extern const char *show_typename(struct symbol
*sym
);
206 extern void debug_symbol(struct symbol
*);
207 extern void merge_type(struct symbol
*sym
, struct symbol
*base_type
);
208 extern void check_declaration(struct symbol
*sym
);
210 #endif /* SEMANTIC_H */