annotate dmd/backend/Symbol.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children fd4acc376c45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.backend.LIST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.backend.block;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.backend.func_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.backend.enum_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.backend.struct_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.backend.template_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.backend.targ_types;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.backend.vec_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.backend.SYMIDX;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.backend.regm_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 struct Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 ushort id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 Symbol* Sl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 Symbol* Sr; // left, right child
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 Symbol *Snext; // next in threaded list
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 dt_t* Sdt; // variables: initializer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 type* Stype; // type of Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 tym_t ty()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 return Stype.Tty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 union // variants for different Symbol types
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 enum_t* Senum; // SCenum
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 func_t* Sfunc; // tyfunc
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 list_t Spath1; // SCfuncalias member functions: same as Spath
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 // and in same position
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 // SCadl: list of associated functions for ADL lookup
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 struct // SClabel
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 int Slabel; // TRUE if label was defined
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 block* Slabelblk; // label block
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 /// #define Senumlist Senum->SEenumlist
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 struct // SClinkage
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 int Slinkage; // tym linkage bits
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 uint Smangle;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 char Sbit; // SCfield: bit position of start of bit field
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 char Swidth; // SCfield: width in bits of bit field
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 targ_size_t Smemoff; // SCmember,SCfield: offset from start of struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 elem* Svalue; /* SFLvalue: value of const
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 SFLdtorexp: for objects with destructor,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 conditional expression to precede dtor call
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 struct_t* Sstruct; // SCstruct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 template_t* Stemplate; // SCtemplate
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 Symbol* Simport; // SCextern: if dllimport Symbol, this is the
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 // Symbol it was imported from
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 ubyte Spreg; // SCfastpar: register parameter is passed in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 Symbol* Sscope; // enclosing scope (could be struct tag,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 // enclosing inline function for statics,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 // or namespace)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 ///#define isclassmember(s) ((s)->Sscope && (s)->Sscope->Sclass == SCstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 const(char)* prettyIdent; // the symbol identifer as the user sees it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 enum_SC Sclass; // storage class (SCxxxx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 char Sfl; // flavor (FLxxxx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 SYMFLGS Sflags; // flag bits (SFLxxxx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 vec_t Srange; // live range, if any
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 vec_t Slvreg; // when symbol is in register
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 targ_size_t Ssize; // tyfunc: size of function
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 targ_size_t Soffset; // variables: offset of Symbol in its storage class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 SYMIDX Ssymnum; // Symbol number (index into globsym.tab[])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 // SCauto,SCparameter,SCtmp,SCregpar,SCregister
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 short Sseg; // segment index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 int Sweight; // usage count, the higher the number,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 // the more worthwhile it is to put in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 // a register
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 union
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 uint Sxtrnnum; // SCcomdef,SCextern,SCcomdat: external symbol # (starting from 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 uint Stypidx; // SCstruct,SCunion,SCclass,SCenum,SCtypedef: debug info type index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 ubyte Sreglsw;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 ubyte Sregmsw;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 regm_t Sregm; // mask of registers
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 regm_t Sregsaved; // mask of registers not affected by this func
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 char Sident[35]; // identifier string (dynamic array)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 // (the size is for static Symbols)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 bool needThis() // true if symbol needs a 'this' pointer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 void dumpSymbol(Symbol* foo)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 foreach (a, b; foo.tupleof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 static if (typeof(foo.tupleof[a]).stringof != "char[35u]") {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 std.stdio.writeln(foo.tupleof[a].stringof, " ", cast(char*)&foo.tupleof[a] - cast(char*)foo, " = ", cast(int)foo.tupleof[a]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 //std.stdio.writeln("printf(\"", foo.tupleof[a].stringof, " %d = %d\\n\",(char*)(&", foo.tupleof[a].stringof, ")-(char*)foo, ", foo.tupleof[a].stringof, ");");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 std.stdio.writefln("(*foo).Sclass %d = %d", (cast(char*)&foo.Sclass - cast(char*)foo), cast(int)foo.Sclass);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 //std.stdio.writeln("printf(\"(*foo).Sclass %d %d\\n\", ((char*)&foo->Sclass - (char*)foo), (int)foo->Sclass);");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 struct Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 ushort id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 ///#define IDsymbol 0x5678
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 ///#define symbol_debug(s) assert((s)->id == IDsymbol)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 ///#define class_debug(s) assert((s)->id == IDsymbol)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 ///#define symbol_debug(s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 ///#define class_debug(s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 Symbol* Sl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 Symbol* Sr; // left, right child
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 Symbol *Snext; // next in threaded list
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 dt_t* Sdt; // variables: initializer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 type* Stype; // type of Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 auto ty() {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 //return Stype.Tty;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 auto Senumlist()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 return Senum.SEenumlist;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 union // variants for different Symbol types
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 enum_t* Senum; // SCenum
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 func_t* Sfunc; // tyfunc
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 list_t Spath1; // SCfuncalias member functions: same as Spath
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 // and in same position
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 // SCadl: list of associated functions for ADL lookup
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 struct // SClabel
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 int Slabel; // TRUE if label was defined
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 block* Slabelblk_; // label block
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 struct // SClinkage
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 long Slinkage; // tym linkage bits
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 uint Smangle;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 long Slinkage; // SClinkage, tym linkage bits
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 char Sbit; // SCfield: bit position of start of bit field
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 char Swidth; // SCfield: width in bits of bit field
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 targ_size_t Smemoff; // SCmember,SCfield: offset from start of struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 elem* Svalue; /* SFLvalue: value of const
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 SFLdtorexp: for objects with destructor,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 conditional expression to precede dtor call
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 struct_t* Sstruct; // SCstruct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 template_t* Stemplate; // SCtemplate
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 version (SCPP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 struct // SCnamespace
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 Symbol* Snameroot; // the Symbol table for the namespace
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 list_t Susing; // other namespaces from using-directives
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 Symbol* Smemalias; // SCalias: pointer to Symbol to use instead
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 // (generated by using-declarations and
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 // namespace-alias-definitions)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 // SCmemalias: pointer to member of base class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 // to use instead (using-declarations)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 symlist_t Spath; // SCmemalias: path of classes to get to base
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 // class of which Salias is a member
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 Symbol* Simport; // SCextern: if dllimport Symbol, this is the
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 // Symbol it was imported from
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 ubyte Spreg; // SCfastpar: register parameter is passed in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 version (SCPP_OR_MARS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 Symbol* Sscope; // enclosing scope (could be struct tag,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 // enclosing inline function for statics,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 // or namespace)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 //#define isclassmember(s) ((s)->Sscope && (s)->Sscope->Sclass == SCstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 version (SCPP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 Symbol* Scover; // if there is a tag name and a regular name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 // of the same identifier, Scover is the tag
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 // Scover can be SCstruct, SCenum, SCtemplate
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 // or an SCalias to them.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 //#define isscover(s) ((s)->Sclass == SCstruct || (s)->Sclass == SCenum || (s)->Sclass == SCtemplate)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 uint Ssequence; // sequence number (used for 2 level lookup)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 // also used as 'parameter number' for SCTtemparg
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 } else version (MARS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 const(char)* prettyIdent; // the symbol identifer as the user sees it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 } else version (AUTONEST) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 ubyte Spush; // # of pushes followed by # of
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 ubyte Spop; // pops of scope level
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 version (ELFOBJ_OR_MACHOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 int obj_si; // Symbol index of coff or elf symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 uint dwarf_off; // offset into .debug section
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 targ_size_t code_off; // rel. offset from start of block where var is initialized
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 targ_size_t last_off; // last offset using var
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 targ_size_t Slocalgotoffset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 SC Sclass; // storage class (SCxxxx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 char Sfl; // flavor (FLxxxx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 SYMFLGS Sflags; // flag bits (SFLxxxx)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 /// #define SFLmark 0x08 // temporary marker
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 /// #define SFLvalue 0x01 // Svalue contains const expression
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 /// #define SFLimplem 0x02 // if seen implementation of Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 // (function body for functions,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 // initializer for variables)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 /// #define SFLdouble 0x02 // SCregpar or SCparameter, where float
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 // is really passed as a double
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 /// #define SFLfree 0x04 // if we can symbol_free() a Symbol in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 // a Symbol table[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 /// #define SFLexit 0x10 // tyfunc: function does not return
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 // (ex: exit,abort,_assert,longjmp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 /// #define SFLtrue 0x200 // value of Symbol != 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 /// #define SFLreplace SFLmark // variable gets replaced in inline expansion
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 /// #define SFLskipinit 0x10000 // SCfield, SCmember: initializer is skipped
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 /// #define SFLnodebug 0x20000 // don't generate debug info
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 /// #define SFLwasstatic 0x800000 // was an uninitialized static
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 /// #define SFLweak 0x1000000 // resolve to NULL if not found
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 // CPP
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 /// #define SFLnodtor 0x10 // set if destructor for Symbol is already called
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 /// #define SFLdtorexp 0x80 // Svalue has expression to tack onto dtor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 /// #define SFLmutable 0x100000 // SCmember or SCfield is mutable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 /// #define SFLdyninit 0x200000 // symbol has dynamic initializer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 /// #define SFLtmp 0x400000 // symbol is a generated temporary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 ///#define SFLthunk 0x40000 // symbol is temporary for thunk
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 // Possible values for protection bits
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 /// #define SFLprivate 0x60
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 /// #define SFLprotected 0x40
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 /// #define SFLpublic 0x20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 /// #define SFLnone 0x00
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 /// #define SFLpmask 0x60 // mask for the protection bits
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 version (VEC_VTBL_LIST) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 /// #define SFLvtbl 0x2000 // Symbol is a vtable or vbtable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 // OPTIMIZER and CODGEN
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 /// #define GTregcand 0x100 // if Symbol is a register candidate
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 /// #define SFLdead 0x800 // this variable is dead
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 // OPTIMIZER only
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 /// #define SFLunambig 0x400 // only accessible by unambiguous reference,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 // i.e. cannot be addressed via pointer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 // (GTregcand is a subset of this)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 // P.S. code generator turns off this
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 // flag if any reads are done from it.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 // This is to eliminate stores to it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 // that are never read.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 /// #define SFLlivexit 0x1000 // live on exit from function
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 /// #define SFLnotbasiciv 0x4000 // not a basic induction variable
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 /// #define SFLnord SFLdouble // SCauto,SCregister,SCtmp: disallow redundant warnings
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 // CODGEN only
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 /// #define GTtried SFLmark // tried to place in register
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 /// #define GTbyte 0x8000 // variable is sometimes accessed as
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 /// #define SFLread 0x40000 // variable is actually read from
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 // (to eliminate dead stores)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 /// #define SFLspill 0x80000 // only in register part of the time
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 vec_t Srange; // live range, if any
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 vec_t Slvreg; // when symbol is in register
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 targ_size_t Ssize; // tyfunc: size of function
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 targ_size_t Soffset; // variables: offset of Symbol in its storage class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 version (TARGET_MAC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 ///#define Smemoff Soffset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 // CPP || OPTIMIZER
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 SYMIDX Ssymnum; // Symbol number (index into globsym.tab[])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 // SCauto,SCparameter,SCtmp,SCregpar,SCregister
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 // CODGEN
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 short Sseg; // segment index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 int Sweight; // usage count, the higher the number,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 // the more worthwhile it is to put in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 // a register
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 union
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 uint Sxtrnnum; // SCcomdef,SCextern,SCcomdat: external symbol # (starting from 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 uint Stypidx; // SCstruct,SCunion,SCclass,SCenum,SCtypedef: debug info type index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 struct
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 ubyte Sreglsw;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 ubyte Sregmsw;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 regm_t Sregm; // mask of registers
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 } // SCregister,SCregpar,SCpseudo: register number
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 regm_t Sregsaved; // mask of registers not affected by this func
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 version (SOURCE_4SYMS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 Srcpos Ssrcpos; // file position for definition
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 // Target Additions
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 /// TARGET_structSYMBOL
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 char Sident[SYM_PREDEF_SZ]; // identifier string (dynamic array)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 // (the size is for static Symbols)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 long[0] Sident; // identifier string (dynamic array) as a str4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 bool needThis() // true if symbol needs a 'this' pointer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 +/