Mercurial > projects > ddmd
annotate dmd/VoidInitializer.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
rev | line source |
---|---|
0 | 1 module dmd.VoidInitializer; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Initializer; |
5 import dmd.Type; | |
6 import dmd.Loc; | |
7 import dmd.Scope; | |
8 import dmd.Expression; | |
9 import dmd.OutBuffer; | |
10 import dmd.HdrGenState; | |
11 | |
12 import dmd.backend.dt_t; | |
68
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
13 import dmd.backend.Util; |
0 | 14 |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
15 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
|
16 |
0 | 17 class VoidInitializer : Initializer |
18 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
19 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
|
20 |
0 | 21 Type type = null; // type that this will initialize to |
22 | |
23 this(Loc loc) | |
24 { | |
178 | 25 register(); |
0 | 26 super(loc); |
27 } | |
28 | |
72 | 29 override Initializer syntaxCopy() |
0 | 30 { |
51 | 31 return new VoidInitializer(loc); |
0 | 32 } |
33 | |
72 | 34 override Initializer semantic(Scope sc, Type t) |
0 | 35 { |
36 //printf("VoidInitializer.semantic(t = %p)\n", t); | |
37 type = t; | |
38 return this; | |
39 } | |
40 | |
72 | 41 override Expression toExpression() |
0 | 42 { |
43 assert(false); | |
44 } | |
45 | |
72 | 46 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 47 { |
174 | 48 buf.writestring("void"); |
0 | 49 } |
50 | |
72 | 51 override dt_t* toDt() |
0 | 52 { |
68
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
53 /* Void initializers are set to 0, just because we need something |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
54 * to set them to in the static data segment. |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
55 */ |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
56 dt_t *dt = null; |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
57 |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
58 dtnzeros(&dt, cast(uint)type.size()); |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
59 return dt; |
0 | 60 } |
61 | |
72 | 62 override VoidInitializer isVoidInitializer() { return this; } |
63 } |