annotate dmd/TypeInfoEnumDeclaration.d @ 174:af724d3510d7

lot os toCBuffer methods implemented moved shared Type.* stuff into Global
author korDen
date Sun, 10 Oct 2010 03:47:23 +0400
parents e28b18c23469
children e3afd1303184
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
1 module dmd.TypeInfoEnumDeclaration;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 73
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
4 import dmd.TY;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.TypeEnum;
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
8 import dmd.Type;
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
9 import dmd.Global;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
10 import dmd.EnumDeclaration;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
11 import dmd.TypeInfoDeclaration;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
16 import std.string : toStringz;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
17
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 class TypeInfoEnumDeclaration : TypeInfoDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 this(Type tinfo)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 super(tinfo, 0);
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
23 type = global.typeinfoenum.type;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
26 override void toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 //printf("TypeInfoEnumDeclaration::toDt()\n");
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
29 dtxoff(pdt, global.typeinfoenum.toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Enum
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 dtdword(pdt, 0); // monitor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 assert(tinfo.ty == Tenum);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 TypeEnum tc = cast(TypeEnum)tinfo;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 EnumDeclaration sd = tc.sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 /* Put out:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 * TypeInfo base;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 * char[] name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 * void[] m_init;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 if (sd.memtype)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
44 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 sd.memtype.getTypeInfo(null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 dtxoff(pdt, sd.memtype.vtinfo.toSymbol(), 0, TYnptr); // TypeInfo for enum members
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 dtdword(pdt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 string name = sd.toPrettyChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 size_t namelen = name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 dtdword(pdt, namelen);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 dtabytes(pdt, TYnptr, 0, namelen + 1, toStringz(name));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 // void[] init;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 if (!sd.defaultval || tinfo.isZeroInit(Loc(0)))
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
58 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 // 0 initializer, or the same as the base type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 dtdword(pdt, 0); // init.length
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 dtdword(pdt, 0); // init.ptr
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 dtdword(pdt, cast(int)sd.type.size()); // init.length
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 dtxoff(pdt, sd.toInitializer(), 0, TYnptr); // init.ptr
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70