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