Mercurial > projects > ddmd
annotate dmd/VoidInitializer.d @ 178:e3afd1303184
Many small bugs fixed
Made all classes derive from TObject to detect memory leaks (functionality is disabled for now)
Began work on overriding backend memory allocations (to avoid memory leaks)
author | korDen |
---|---|
date | Sun, 17 Oct 2010 07:42:00 +0400 |
parents | af724d3510d7 |
children | b0d41ff5e0df |
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 |
15 class VoidInitializer : Initializer | |
16 { | |
17 Type type = null; // type that this will initialize to | |
18 | |
19 this(Loc loc) | |
20 { | |
178 | 21 register(); |
0 | 22 super(loc); |
23 } | |
24 | |
72 | 25 override Initializer syntaxCopy() |
0 | 26 { |
51 | 27 return new VoidInitializer(loc); |
0 | 28 } |
29 | |
72 | 30 override Initializer semantic(Scope sc, Type t) |
0 | 31 { |
32 //printf("VoidInitializer.semantic(t = %p)\n", t); | |
33 type = t; | |
34 return this; | |
35 } | |
36 | |
72 | 37 override Expression toExpression() |
0 | 38 { |
39 assert(false); | |
40 } | |
41 | |
72 | 42 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 43 { |
174 | 44 buf.writestring("void"); |
0 | 45 } |
46 | |
72 | 47 override dt_t* toDt() |
0 | 48 { |
68
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
49 /* 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
|
50 * to set them to in the static data segment. |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
51 */ |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
52 dt_t *dt = null; |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
53 |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
54 dtnzeros(&dt, cast(uint)type.size()); |
ee3a9f34dc48
final bits of codegen implementation to compile Phobos
korDen
parents:
51
diff
changeset
|
55 return dt; |
0 | 56 } |
57 | |
72 | 58 override VoidInitializer isVoidInitializer() { return this; } |
59 } |