comparison dmd/DtorDeclaration.d @ 98:5c859d5fbe27

and more
author Trass3r
date Tue, 31 Aug 2010 03:53:49 +0200
parents 43073c7c7769
children e28b18c23469
comparison
equal deleted inserted replaced
96:acd69f84627e 98:5c859d5fbe27
15 import dmd.STC; 15 import dmd.STC;
16 import dmd.Id; 16 import dmd.Id;
17 17
18 class DtorDeclaration : FuncDeclaration 18 class DtorDeclaration : FuncDeclaration
19 { 19 {
20 this(Loc loc, Loc endloc) 20 this(Loc loc, Loc endloc)
21 { 21 {
22 super(loc, endloc, Id.dtor, STCundefined, null); 22 super(loc, endloc, Id.dtor, STCundefined, null);
23 } 23 }
24 24
25 this(Loc loc, Loc endloc, Identifier id) 25 this(Loc loc, Loc endloc, Identifier id)
26 { 26 {
27 assert(false); 27 super(loc, endloc, id, STCundefined, null);
28 super(loc, endloc, null, STC.init, null);
29 } 28 }
30 29
31 override Dsymbol syntaxCopy(Dsymbol) 30 override Dsymbol syntaxCopy(Dsymbol s)
32 { 31 {
33 assert(false); 32 assert(!s);
33 DtorDeclaration dd = new DtorDeclaration(loc, endloc, ident);
34 return super.syntaxCopy(dd);
34 } 35 }
35 36
36 override void semantic(Scope sc) 37 override void semantic(Scope sc)
37 { 38 {
38 //printf("DtorDeclaration::semantic() %s\n", toChars()); 39 //printf("DtorDeclaration::semantic() %s\n", toChars());
39 //printf("ident: %s, %s, %p, %p\n", ident.toChars(), Id::dtor.toChars(), ident, Id::dtor); 40 //printf("ident: %s, %s, %p, %p\n", ident.toChars(), Id::dtor.toChars(), ident, Id::dtor);
40 parent = sc.parent; 41 parent = sc.parent;
41 Dsymbol parent = toParent(); 42 Dsymbol parent = toParent();
51 52
52 sc = sc.push(); 53 sc = sc.push();
53 sc.stc &= ~STCstatic; // not a static destructor 54 sc.stc &= ~STCstatic; // not a static destructor
54 sc.linkage = LINK.LINKd; 55 sc.linkage = LINK.LINKd;
55 56
56 FuncDeclaration.semantic(sc); 57 super.semantic(sc);
57 58
58 sc.pop(); 59 sc.pop();
59 } 60 }
60 61
61 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) 62 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
62 { 63 {
63 assert(false); 64 buf.writestring("~this()");
65 bodyToCBuffer(buf, hgs);
64 } 66 }
65 67
66 override void toJsonBuffer(OutBuffer buf) 68 override void toJsonBuffer(OutBuffer buf)
67 { 69 {
70 // intentionally empty
68 } 71 }
69 72
70 override string kind() 73 override string kind()
71 { 74 {
72 assert(false); 75 return "destructor";
73 } 76 }
74 77
75 override string toChars() 78 override string toChars()
76 { 79 {
77 return "~this"; 80 return "~this";
78 } 81 }
79 82
80 override bool isVirtual() 83 override bool isVirtual()
81 { 84 {
82 /* This should be FALSE so that dtor's don't get put into the vtbl[], 85 /* This should be FALSE so that dtor's don't get put into the vtbl[],
83 * but doing so will require recompiling everything. 86 * but doing so will require recompiling everything.
84 */ 87 */
85 version (BREAKABI) { 88 version (BREAKABI) {
86 return false; 89 return false;
87 } else { 90 } else {
88 return FuncDeclaration.isVirtual(); 91 return super.isVirtual();
89 } 92 }
90 } 93 }
91 94
92 override bool addPreInvariant() 95 override bool addPreInvariant()
93 { 96 {
94 return (isThis() && vthis && global.params.useInvariants); 97 return (isThis() && vthis && global.params.useInvariants);
95 } 98 }
96 99
97 override bool addPostInvariant() 100 override bool addPostInvariant()
98 { 101 {
99 return false; 102 return false;
100 } 103 }
101 104
102 override bool overloadInsert(Dsymbol s) 105 override bool overloadInsert(Dsymbol s)
103 { 106 {
104 assert(false); 107 return false; // cannot overload destructors
105 } 108 }
106 109
107 override void emitComment(Scope sc) 110 override void emitComment(Scope sc)
108 { 111 {
109 assert(false); 112 // intentionally empty
110 } 113 }
111 114
112 override DtorDeclaration isDtorDeclaration() { return this; } 115 override DtorDeclaration isDtorDeclaration() { return this; }
113 } 116 }