Mercurial > projects > ddmd
annotate dmd/DtorDeclaration.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 |
---|---|
0 | 1 module dmd.DtorDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.FuncDeclaration; |
5 import dmd.Loc; | |
6 import dmd.Global; | |
7 import dmd.Identifier; | |
8 import dmd.Dsymbol; | |
9 import dmd.Scope; | |
10 import dmd.LINK; | |
11 import dmd.AggregateDeclaration; | |
12 import dmd.TypeFunction; | |
13 import dmd.Type; | |
14 import dmd.OutBuffer; | |
15 import dmd.HdrGenState; | |
16 import dmd.STC; | |
17 import dmd.Id; | |
18 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
19 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
20 |
0 | 21 class DtorDeclaration : FuncDeclaration |
22 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
23 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
24 |
98 | 25 this(Loc loc, Loc endloc) |
0 | 26 { |
178 | 27 register(); |
0 | 28 super(loc, endloc, Id.dtor, STCundefined, null); |
29 } | |
30 | |
98 | 31 this(Loc loc, Loc endloc, Identifier id) |
0 | 32 { |
178 | 33 register(); |
98 | 34 super(loc, endloc, id, STCundefined, null); |
0 | 35 } |
36 | |
98 | 37 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 38 { |
98 | 39 assert(!s); |
40 DtorDeclaration dd = new DtorDeclaration(loc, endloc, ident); | |
41 return super.syntaxCopy(dd); | |
0 | 42 } |
43 | |
98 | 44 override void semantic(Scope sc) |
0 | 45 { |
46 //printf("DtorDeclaration::semantic() %s\n", toChars()); | |
47 //printf("ident: %s, %s, %p, %p\n", ident.toChars(), Id::dtor.toChars(), ident, Id::dtor); | |
48 parent = sc.parent; | |
49 Dsymbol parent = toParent(); | |
50 AggregateDeclaration ad = parent.isAggregateDeclaration(); | |
51 if (!ad) | |
52 { | |
53 error("destructors are only for class/struct/union definitions, not %s %s", parent.kind(), parent.toChars()); | |
54 } | |
179 | 55 else if (ident == Id.dtor && semanticRun < PASSsemantic) |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
56 ad.dtors.push(this); |
0 | 57 |
179 | 58 if (!type) |
59 type = new TypeFunction(null, Type.tvoid, false, LINK.LINKd); | |
0 | 60 |
61 sc = sc.push(); | |
62 sc.stc &= ~STCstatic; // not a static destructor | |
63 sc.linkage = LINK.LINKd; | |
64 | |
98 | 65 super.semantic(sc); |
0 | 66 |
67 sc.pop(); | |
68 } | |
69 | |
98 | 70 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 71 { |
98 | 72 buf.writestring("~this()"); |
73 bodyToCBuffer(buf, hgs); | |
0 | 74 } |
98 | 75 |
79 | 76 override void toJsonBuffer(OutBuffer buf) |
77 { | |
98 | 78 // intentionally empty |
79 | 79 } |
0 | 80 |
98 | 81 override string kind() |
0 | 82 { |
98 | 83 return "destructor"; |
0 | 84 } |
85 | |
98 | 86 override string toChars() |
0 | 87 { |
88 return "~this"; | |
89 } | |
90 | |
98 | 91 override bool isVirtual() |
0 | 92 { |
93 /* This should be FALSE so that dtor's don't get put into the vtbl[], | |
94 * but doing so will require recompiling everything. | |
95 */ | |
96 version (BREAKABI) { | |
97 return false; | |
98 } else { | |
98 | 99 return super.isVirtual(); |
0 | 100 } |
101 } | |
102 | |
98 | 103 override bool addPreInvariant() |
0 | 104 { |
105 return (isThis() && vthis && global.params.useInvariants); | |
106 } | |
107 | |
98 | 108 override bool addPostInvariant() |
0 | 109 { |
110 return false; | |
111 } | |
112 | |
98 | 113 override bool overloadInsert(Dsymbol s) |
0 | 114 { |
98 | 115 return false; // cannot overload destructors |
0 | 116 } |
117 | |
98 | 118 override void emitComment(Scope sc) |
0 | 119 { |
98 | 120 // intentionally empty |
0 | 121 } |
122 | |
98 | 123 override DtorDeclaration isDtorDeclaration() { return this; } |
72 | 124 } |