Mercurial > projects > ddmd
annotate dmd/EnumDeclaration.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | acd69f84627e |
children | 90821c10b6a7 |
rev | line source |
---|---|
0 | 1 module dmd.EnumDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.ScopeDsymbol; |
5 import dmd.AddExp; | |
6 import dmd.Type; | |
7 import dmd.CmpExp; | |
8 import dmd.IntegerExp; | |
9 import dmd.EqualExp; | |
10 import dmd.TOK; | |
11 import dmd.Id; | |
12 import dmd.TY; | |
13 import dmd.DsymbolTable; | |
14 import dmd.STC; | |
15 import dmd.Expression; | |
16 import dmd.Identifier; | |
17 import dmd.Dsymbol; | |
18 import dmd.Scope; | |
19 import dmd.OutBuffer; | |
20 import dmd.HdrGenState; | |
21 import dmd.Global; | |
22 import dmd.Loc; | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
20
diff
changeset
|
23 import dmd.Module; |
0 | 24 import dmd.TypeEnum; |
25 import dmd.EnumMember; | |
26 import dmd.DYNCAST; | |
27 import dmd.WANT; | |
28 import dmd.Id; | |
79 | 29 import dmd.Json; |
0 | 30 import dmd.Lexer; |
31 | |
32 import dmd.backend.SC; | |
33 import dmd.backend.FL; | |
34 import dmd.backend.Util; | |
35 import dmd.backend.Symbol; | |
36 import dmd.backend.Classsym; | |
37 import dmd.backend.SFL; | |
38 import dmd.backend.LIST; | |
39 import dmd.codegen.Util; | |
40 | |
41 import std.stdio : writef; | |
42 | |
43 class EnumDeclaration : ScopeDsymbol | |
44 { /* enum ident : memtype { ... } | |
45 */ | |
46 Type type; // the TypeEnum | |
47 Type memtype; // type of the members | |
48 | |
79 | 49 version (DMDV1) |
50 { | |
0 | 51 ulong maxval; |
52 ulong minval; | |
53 ulong defaultval; // default initializer | |
79 | 54 } |
55 else | |
56 { | |
0 | 57 Expression maxval; |
58 Expression minval; | |
59 Expression defaultval; // default initializer | |
60 } | |
61 bool isdeprecated; | |
62 | |
63 this(Loc loc, Identifier id, Type memtype) | |
64 { | |
65 super(id); | |
66 this.loc = loc; | |
67 type = new TypeEnum(this); | |
68 this.memtype = memtype; | |
69 } | |
70 | |
72 | 71 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 72 { |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
73 Type t = null; |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
74 if (memtype) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
75 t = memtype.syntaxCopy(); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
76 |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
77 EnumDeclaration ed; |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
78 if (s) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
79 { ed = cast(EnumDeclaration)s; |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
80 ed.memtype = t; |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
81 } |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
82 else |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
83 ed = new EnumDeclaration(loc, ident, t); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
84 ScopeDsymbol.syntaxCopy(ed); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
85 return ed; |
0 | 86 } |
87 | |
72 | 88 override void semantic(Scope sc) |
0 | 89 { |
90 Type t; | |
91 Scope sce; | |
92 | |
93 //writef("EnumDeclaration.semantic(sd = %p, '%s') %s\n", sc.scopesym, sc.scopesym.toChars(), toChars()); | |
94 //writef("EnumDeclaration.semantic() %s\n", toChars()); | |
95 if (!members) // enum ident; | |
96 return; | |
97 | |
98 if (!memtype && !isAnonymous()) | |
99 { | |
100 // Set memtype if we can to reduce fwd reference errors | |
101 memtype = Type.tint32; // case 1) enum ident { ... } | |
102 } | |
103 | |
104 if (symtab) // if already done | |
105 { | |
106 if (!scope_) | |
107 return; // semantic() already completed | |
108 } | |
109 else | |
110 symtab = new DsymbolTable(); | |
111 | |
112 Scope scx = null; | |
113 if (scope_) | |
114 { sc = scope_; | |
115 scx = scope_; // save so we don't make redundant copies | |
116 scope_ = null; | |
117 } | |
118 | |
119 if (sc.stc & STC.STCdeprecated) | |
120 isdeprecated = true; | |
121 | |
122 parent = sc.parent; | |
123 | |
124 /* The separate, and distinct, cases are: | |
125 * 1. enum { ... } | |
126 * 2. enum : memtype { ... } | |
127 * 3. enum ident { ... } | |
128 * 4. enum ident : memtype { ... } | |
129 */ | |
130 | |
131 if (memtype) | |
132 { | |
133 memtype = memtype.semantic(loc, sc); | |
134 | |
135 /* Check to see if memtype is forward referenced | |
136 */ | |
137 if (memtype.ty == TY.Tenum) | |
138 { EnumDeclaration sym = cast(EnumDeclaration)memtype.toDsymbol(sc); | |
139 if (!sym.memtype || !sym.members || !sym.symtab || sym.scope_) | |
140 { | |
141 // memtype is forward referenced, so try again later | |
87
b17640f0e4e8
Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents:
79
diff
changeset
|
142 scope_ = scx ? scx : sc.clone(); |
0 | 143 scope_.setNoFree(); |
144 scope_.module_.addDeferredSemantic(this); | |
145 writef("\tdeferring %s\n", toChars()); | |
146 return; | |
147 } | |
148 } | |
149 static if (false) { | |
150 // Decided to abandon this restriction for D 2.0 | |
151 if (!memtype.isintegral()) | |
152 { error("base type must be of integral type, not %s", memtype.toChars()); | |
153 memtype = Type.tint32; | |
154 } | |
155 } | |
156 } | |
157 | |
158 type = type.semantic(loc, sc); | |
159 if (isAnonymous()) | |
160 sce = sc; | |
161 else | |
162 { sce = sc.push(this); | |
163 sce.parent = this; | |
164 } | |
165 if (members.dim == 0) | |
166 error("enum %s must have at least one member", toChars()); | |
167 int first = 1; | |
168 Expression elast = null; | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
169 foreach (Dsymbol s; members) |
0 | 170 { |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
171 EnumMember em = s.isEnumMember(); |
0 | 172 Expression e; |
173 | |
174 if (!em) | |
175 /* The e.semantic(sce) can insert other symbols, such as | |
176 * template instances and function literals. | |
177 */ | |
178 continue; | |
179 | |
180 //printf(" Enum member '%s'\n",em.toChars()); | |
181 if (em.type) | |
182 em.type = em.type.semantic(em.loc, sce); | |
183 e = em.value; | |
184 if (e) | |
185 { | |
186 assert(e.dyncast() == DYNCAST.DYNCAST_EXPRESSION); | |
187 e = e.semantic(sce); | |
188 e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
189 if (memtype) | |
190 { | |
191 e = e.implicitCastTo(sce, memtype); | |
192 e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
193 if (!isAnonymous()) | |
194 e = e.castTo(sce, type); | |
195 t = memtype; | |
196 } | |
197 else if (em.type) | |
198 { | |
199 e = e.implicitCastTo(sce, em.type); | |
200 e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
201 assert(isAnonymous()); | |
202 t = e.type; | |
203 } | |
204 else | |
205 t = e.type; | |
206 } | |
207 else if (first) | |
208 { | |
209 if (memtype) | |
210 t = memtype; | |
211 else if (em.type) | |
212 t = em.type; | |
213 else | |
214 t = Type.tint32; | |
215 e = new IntegerExp(em.loc, 0, Type.tint32); | |
216 e = e.implicitCastTo(sce, t); | |
217 e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
218 if (!isAnonymous()) | |
219 e = e.castTo(sce, type); | |
220 } | |
221 else | |
222 { | |
223 // Set value to (elast + 1). | |
224 // But first check that (elast != t.max) | |
225 assert(elast); | |
226 e = new EqualExp(TOK.TOKequal, em.loc, elast, t.getProperty(Loc(0), Id.max)); | |
227 e = e.semantic(sce); | |
228 e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
229 if (e.toInteger()) | |
230 error("overflow of enum value %s", elast.toChars()); | |
231 | |
232 // Now set e to (elast + 1) | |
233 e = new AddExp(em.loc, elast, new IntegerExp(em.loc, 1, Type.tint32)); | |
234 e = e.semantic(sce); | |
235 e = e.castTo(sce, elast.type); | |
236 e = e.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
237 } | |
238 elast = e; | |
239 em.value = e; | |
240 | |
241 // Add to symbol table only after evaluating 'value' | |
242 if (isAnonymous()) | |
243 { | |
244 /* Anonymous enum members get added to enclosing scope. | |
245 */ | |
246 for (Scope scxx = sce; scxx; scxx = scxx.enclosing) | |
247 { | |
248 if (scxx.scopesym) | |
249 { | |
250 if (!scxx.scopesym.symtab) | |
251 scxx.scopesym.symtab = new DsymbolTable(); | |
13 | 252 em.addMember(sce, scxx.scopesym, true); |
0 | 253 break; |
254 } | |
255 } | |
256 } | |
257 else | |
13 | 258 em.addMember(sc, this, true); |
0 | 259 |
260 /* Compute .min, .max and .default values. | |
261 * If enum doesn't have a name, we can never identify the enum type, | |
262 * so there is no purpose for a .min, .max or .default | |
263 */ | |
264 if (!isAnonymous()) | |
265 { | |
266 if (first) | |
267 { defaultval = e; | |
268 minval = e; | |
269 maxval = e; | |
270 } | |
271 else | |
272 { Expression ec; | |
273 | |
274 /* In order to work successfully with UDTs, | |
275 * build expressions to do the comparisons, | |
276 * and let the semantic analyzer and constant | |
277 * folder give us the result. | |
278 */ | |
279 | |
280 // Compute if(e < minval) | |
281 ec = new CmpExp(TOK.TOKlt, em.loc, e, minval); | |
282 ec = ec.semantic(sce); | |
283 ec = ec.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
284 if (ec.toInteger()) | |
285 minval = e; | |
286 | |
287 ec = new CmpExp(TOK.TOKgt, em.loc, e, maxval); | |
288 ec = ec.semantic(sce); | |
289 ec = ec.optimize(WANT.WANTvalue | WANT.WANTinterpret); | |
290 if (ec.toInteger()) | |
291 maxval = e; | |
292 } | |
293 } | |
294 first = 0; | |
295 } | |
296 //printf("defaultval = %lld\n", defaultval); | |
297 | |
298 //if (defaultval) printf("defaultval: %s %s\n", defaultval.toChars(), defaultval.type.toChars()); | |
299 if (sc != sce) | |
300 sce.pop(); | |
301 //members.print(); | |
302 } | |
303 | |
72 | 304 override bool oneMember(Dsymbol* ps) |
0 | 305 { |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
306 if (isAnonymous()) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
307 return Dsymbol.oneMembers(members, ps); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
308 return Dsymbol.oneMember(ps); |
0 | 309 } |
310 | |
72 | 311 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 312 { |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
313 buf.writestring("enum "); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
314 if (ident) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
315 { buf.writestring(ident.toChars()); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
316 buf.writeByte(' '); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
317 } |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
318 if (memtype) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
319 { |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
320 buf.writestring(": "); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
321 memtype.toCBuffer(buf, null, hgs); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
322 } |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
323 if (!members) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
324 { |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
325 buf.writeByte(';'); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
326 buf.writenl(); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
327 return; |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
328 } |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
329 buf.writenl(); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
330 buf.writeByte('{'); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
331 buf.writenl(); |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
332 foreach(Dsymbol s; members) |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
333 { |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
334 EnumMember em = s.isEnumMember(); |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
335 if (!em) |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
336 continue; |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
337 //buf.writestring(" "); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
338 em.toCBuffer(buf, hgs); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
339 buf.writeByte(','); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
340 buf.writenl(); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
341 } |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
342 buf.writeByte('}'); |
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
343 buf.writenl(); |
0 | 344 } |
345 | |
72 | 346 override Type getType() |
0 | 347 { |
348 return type; | |
349 } | |
350 | |
72 | 351 override string kind() |
0 | 352 { |
353 return "enum"; | |
354 } | |
355 | |
356 version (DMDV2) { | |
72 | 357 override Dsymbol search(Loc, Identifier ident, int flags) |
0 | 358 { |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
359 //printf("%s.EnumDeclaration.search('%s')\n", toChars(), ident.toChars()); |
0 | 360 if (scope_) |
361 // Try one last time to resolve this enum | |
362 semantic(scope_); | |
363 | |
364 if (!members || !symtab || scope_) | |
365 { | |
366 error("is forward referenced when looking for '%s'", ident.toChars()); | |
367 //*(char*)0=0; | |
368 return null; | |
369 } | |
370 | |
371 return ScopeDsymbol.search(loc, ident, flags); | |
372 } | |
373 } | |
72 | 374 override bool isDeprecated() // is Dsymbol deprecated? |
0 | 375 { |
376 return isdeprecated; | |
377 } | |
378 | |
72 | 379 override void emitComment(Scope sc) |
0 | 380 { |
381 assert(false); | |
382 } | |
79 | 383 |
384 override void toJsonBuffer(OutBuffer buf) | |
385 { | |
386 //writef("EnumDeclaration.toJsonBuffer()\n"); | |
387 if (isAnonymous()) | |
388 { | |
389 if (members) | |
390 { | |
391 foreach (Dsymbol s; members) | |
392 { | |
393 s.toJsonBuffer(buf); | |
394 buf.writestring(",\n"); | |
395 } | |
396 JsonRemoveComma(buf); | |
397 } | |
398 return; | |
399 } | |
0 | 400 |
79 | 401 buf.writestring("{\n"); |
402 | |
403 JsonProperty(buf, Pname, toChars()); | |
404 JsonProperty(buf, Pkind, kind()); | |
405 if (comment) | |
406 JsonProperty(buf, Pcomment, comment); | |
407 | |
408 if (loc.linnum) | |
409 JsonProperty(buf, Pline, loc.linnum); | |
410 | |
411 if (memtype) | |
412 JsonProperty(buf, "base", memtype.toChars()); | |
413 | |
414 JsonString(buf, Pmembers); | |
415 buf.writestring(" : [\n"); | |
416 size_t offset = buf.offset; | |
417 foreach (Dsymbol s; members) | |
418 { | |
419 if (offset != buf.offset) | |
420 { | |
96 | 421 buf.writestring(",\n"); |
79 | 422 offset = buf.offset; |
423 } | |
424 s.toJsonBuffer(buf); | |
425 } | |
96 | 426 JsonRemoveComma(buf); |
79 | 427 buf.writestring("]\n"); |
428 | |
429 buf.writestring("}\n"); | |
430 } | |
431 | |
72 | 432 override void toDocBuffer(OutBuffer buf) |
0 | 433 { |
434 assert(false); | |
435 } | |
436 | |
72 | 437 override EnumDeclaration isEnumDeclaration() { return this; } |
0 | 438 |
72 | 439 override void toObjFile(int multiobj) // compile to .obj file |
0 | 440 { |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
441 //printf("EnumDeclaration.toObjFile('%s')\n", toChars()); |
0 | 442 version (DMDV2) { |
443 if (isAnonymous()) | |
444 return; | |
445 } | |
446 | |
447 if (global.params.symdebug) | |
448 toDebug(); | |
449 | |
450 type.getTypeInfo(null); // generate TypeInfo | |
451 | |
452 TypeEnum tc = cast(TypeEnum)type; | |
453 if (!tc.sym.defaultval || type.isZeroInit(Loc(0))) { | |
454 ; | |
455 } else { | |
456 SC scclass = SCglobal; | |
457 if (inTemplateInstance()) | |
458 scclass = SCcomdat; | |
459 | |
460 // Generate static initializer | |
461 toInitializer(); | |
462 sinit.Sclass = scclass; | |
463 sinit.Sfl = FLdata; | |
464 version (ELFOBJ) { // Burton | |
465 sinit.Sseg = Segment.CDATA; | |
466 } | |
467 version (MACHOBJ) { | |
468 sinit.Sseg = Segment.DATA; | |
469 } | |
470 version (DMDV1) { | |
471 dtnbytes(&sinit.Sdt, tc.size(0), cast(char*)&tc.sym.defaultval); | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
472 //sinit.Sdt = tc.sym.init.toDt(); |
0 | 473 } |
474 version (DMDV2) { | |
475 tc.sym.defaultval.toDt(&sinit.Sdt); | |
476 } | |
477 outdata(sinit); | |
478 } | |
479 } | |
480 | |
481 void toDebug() | |
482 { | |
483 assert(false); | |
484 } | |
485 | |
72 | 486 override int cvMember(ubyte* p) |
0 | 487 { |
488 assert(false); | |
489 } | |
490 | |
491 Symbol* sinit; | |
492 | |
493 Symbol* toInitializer() | |
494 { | |
495 Symbol* s; | |
496 Classsym* stag; | |
497 | |
498 if (!sinit) | |
499 { | |
500 stag = fake_classsym(Id.ClassInfo); | |
501 Identifier ident_save = ident; | |
502 if (!ident) | |
503 ident = Lexer.uniqueId("__enum"); | |
504 s = toSymbolX("__init", SCextern, stag.Stype, "Z"); | |
505 ident = ident_save; | |
506 s.Sfl = FLextern; | |
507 s.Sflags |= SFLnodebug; | |
508 slist_add(s); | |
509 sinit = s; | |
510 } | |
511 | |
512 return sinit; | |
513 } | |
20
1628b221808d
Fleshed out more unimplemented methods.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
514 }; |