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