Mercurial > projects > ddmd
annotate dmd/TypeInfoTypedefDeclaration.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.TypeInfoTypedefDeclaration; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Type; |
0 | 5 import dmd.TypeInfoDeclaration; |
6 import dmd.TypedefDeclaration; | |
7 import dmd.TypeTypedef; | |
8 import dmd.TY; | |
174 | 9 import dmd.Global; |
72 | 10 import dmd.Loc; |
0 | 11 import dmd.backend.dt_t; |
12 import dmd.backend.TYM; | |
72 | 13 import dmd.backend.Util; |
0 | 14 |
15 import std.string; | |
72 | 16 |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
17 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
|
18 |
0 | 19 class TypeInfoTypedefDeclaration : TypeInfoDeclaration |
20 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
21 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
|
22 |
0 | 23 this(Type tinfo) |
24 { | |
178 | 25 register(); |
0 | 26 super(tinfo, 0); |
174 | 27 type = global.typeinfotypedef.type; |
0 | 28 } |
29 | |
72 | 30 override void toDt(dt_t** pdt) |
0 | 31 { |
32 //printf("TypeInfoTypedefDeclaration.toDt() %s\n", toChars()); | |
33 | |
174 | 34 dtxoff(pdt, global.typeinfotypedef.toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Typedef |
0 | 35 dtdword(pdt, 0); // monitor |
36 | |
37 assert(tinfo.ty == Ttypedef); | |
38 | |
39 TypeTypedef tc = cast(TypeTypedef)tinfo; | |
40 TypedefDeclaration sd = tc.sym; | |
41 //printf("basetype = %s\n", sd.basetype.toChars()); | |
42 | |
43 /* Put out: | |
44 * TypeInfo base; | |
45 * char[] name; | |
46 * void[] m_init; | |
47 */ | |
48 | |
49 sd.basetype = sd.basetype.merge(); | |
50 sd.basetype.getTypeInfo(null); // generate vtinfo | |
51 assert(sd.basetype.vtinfo); | |
52 dtxoff(pdt, sd.basetype.vtinfo.toSymbol(), 0, TYnptr); // TypeInfo for basetype | |
53 | |
54 string name = sd.toPrettyChars(); | |
55 size_t namelen = name.length; | |
56 dtdword(pdt, namelen); | |
57 dtabytes(pdt, TYnptr, 0, namelen + 1, toStringz(name)); | |
58 | |
59 // void[] init; | |
60 if (tinfo.isZeroInit(Loc(0)) || !sd.init) | |
174 | 61 { |
0 | 62 // 0 initializer, or the same as the base type |
63 dtdword(pdt, 0); // init.length | |
64 dtdword(pdt, 0); // init.ptr | |
65 } | |
66 else | |
67 { | |
68 dtdword(pdt, cast(int)sd.type.size()); // init.length | |
69 dtxoff(pdt, sd.toInitializer(), 0, TYnptr); // init.ptr | |
70 } | |
71 } | |
72 } | |
73 |