Mercurial > projects > ddmd
annotate dmd/TypeInfoEnumDeclaration.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
72 | 1 module dmd.TypeInfoEnumDeclaration; |
0 | 2 |
114 | 3 import dmd.common; |
72 | 4 import dmd.TY; |
0 | 5 import dmd.Type; |
6 import dmd.Loc; | |
7 import dmd.TypeEnum; | |
174 | 8 import dmd.Type; |
9 import dmd.Global; | |
72 | 10 import dmd.EnumDeclaration; |
11 import dmd.TypeInfoDeclaration; | |
0 | 12 import dmd.backend.dt_t; |
13 import dmd.backend.Util; | |
14 import dmd.backend.TYM; | |
15 | |
72 | 16 import std.string : toStringz; |
17 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
18 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
19 |
0 | 20 class TypeInfoEnumDeclaration : TypeInfoDeclaration |
21 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
22 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
23 |
0 | 24 this(Type tinfo) |
25 { | |
178 | 26 register(); |
0 | 27 super(tinfo, 0); |
174 | 28 type = global.typeinfoenum.type; |
0 | 29 } |
30 | |
72 | 31 override void toDt(dt_t** pdt) |
0 | 32 { |
33 //printf("TypeInfoEnumDeclaration::toDt()\n"); | |
174 | 34 dtxoff(pdt, global.typeinfoenum.toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Enum |
0 | 35 dtdword(pdt, 0); // monitor |
36 | |
37 assert(tinfo.ty == Tenum); | |
38 | |
39 TypeEnum tc = cast(TypeEnum)tinfo; | |
40 EnumDeclaration sd = tc.sym; | |
41 | |
42 /* Put out: | |
43 * TypeInfo base; | |
44 * char[] name; | |
45 * void[] m_init; | |
46 */ | |
47 | |
48 if (sd.memtype) | |
174 | 49 { |
0 | 50 sd.memtype.getTypeInfo(null); |
51 dtxoff(pdt, sd.memtype.vtinfo.toSymbol(), 0, TYnptr); // TypeInfo for enum members | |
52 } | |
53 else | |
54 dtdword(pdt, 0); | |
55 | |
56 string name = sd.toPrettyChars(); | |
57 size_t namelen = name.length; | |
58 dtdword(pdt, namelen); | |
59 dtabytes(pdt, TYnptr, 0, namelen + 1, toStringz(name)); | |
60 | |
61 // void[] init; | |
62 if (!sd.defaultval || tinfo.isZeroInit(Loc(0))) | |
174 | 63 { |
0 | 64 // 0 initializer, or the same as the base type |
65 dtdword(pdt, 0); // init.length | |
66 dtdword(pdt, 0); // init.ptr | |
67 } | |
68 else | |
69 { | |
70 dtdword(pdt, cast(int)sd.type.size()); // init.length | |
71 dtxoff(pdt, sd.toInitializer(), 0, TYnptr); // init.ptr | |
72 } | |
73 } | |
74 } | |
75 |