annotate dmd/DeleteExp.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
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.DeleteExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 108
diff changeset
3 import dmd.common;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
4 import dmd.Expression;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
5 import dmd.backend.elem;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
6 import dmd.UnaExp;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
7 import dmd.OutBuffer;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
8 import dmd.Loc;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
9 import dmd.Scope;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
10 import dmd.IRState;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.IndexExp;
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
14 import dmd.PREC;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.StructDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.Lexer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.TypeStruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.CallExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.DotVarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.DeclarationExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.ExpInitializer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.TypePointer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.ClassDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.TypeClass;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
30 import dmd.TY;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.TypeAArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
35 import dmd.expression.Util;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 import dmd.backend.OPER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.backend.RTLSYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 import dmd.backend.mTY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 import dmd.backend.Symbol;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
42 import dmd.backend.TYM;
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
43
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 class DeleteExp : UnaExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 this(Loc loc, Expression e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
48 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 super(loc, TOK.TOKdelete, DeleteExp.sizeof, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
52 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 Type tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 UnaExp.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 e1 = e1.toLvalue(sc, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 type = Type.tvoid;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 tb = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 switch (tb.ty)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
63 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 case Tclass:
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
65 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 TypeClass tc = cast(TypeClass)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 ClassDeclaration cd = tc.sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 if (cd.isCOMinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 { /* Because COM classes are deleted by IUnknown.Release()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 error("cannot delete instance of COM interface %s", cd.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 case Tpointer:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 tb = (cast(TypePointer)tb).next.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 if (tb.ty == Tstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 TypeStruct ts = cast(TypeStruct)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 StructDeclaration sd = ts.sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 FuncDeclaration f = sd.aggDelete;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 FuncDeclaration fd = sd.dtor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 if (!f && !fd)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 /* Construct:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 * ea = copy e1 to a tmp to do side effects only once
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 * eb = call destructor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 * ec = call deallocator
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 Expression ea = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 Expression eb = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 Expression ec = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 VarDeclaration v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 if (fd && f)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
99 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 Identifier id = Lexer.idPool("__tmp");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 v = new VarDeclaration(loc, e1.type, id, new ExpInitializer(loc, e1));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 v.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 v.parent = sc.parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 ea = new DeclarationExp(loc, v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 ea.type = v.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 if (fd)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
109 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 Expression e = ea ? new VarExp(loc, v) : e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 e = new DotVarExp(Loc(0), e, fd, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 eb = new CallExp(loc, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 eb = eb.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 if (f)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 Type tpv = Type.tvoid.pointerTo();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 Expression e = ea ? new VarExp(loc, v) : e1.castTo(sc, tpv);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 e = new CallExp(loc, new VarExp(loc, f), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 ec = e.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 ea = combine(ea, eb);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 ea = combine(ea, ec);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 assert(ea);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 return ea;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 case Tarray:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 /* BUG: look for deleting arrays of structs with dtors.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 if (e1.op == TOKindex)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 IndexExp ae = cast(IndexExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 Type tb1 = ae.e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 if (tb1.ty == Taarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 error("cannot delete type %s", e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 }
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
146
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 if (e1.op == TOKindex)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 IndexExp ae = cast(IndexExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 Type tb1 = ae.e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 if (tb1.ty == Taarray)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
152 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 if (!global.params.useDeprecated)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 error("delete aa[key] deprecated, use aa.remove(key)");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
161 override Expression checkToBoolean()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
166 override bool checkSideEffect(int flag)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
171 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 {
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
173 buf.writestring("delete ");
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
174 expToCBuffer(buf, hgs, e1, precedence[op]);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 0
diff changeset
177 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 elem* e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 int rtl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 Type tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 //printf("DeleteExp.toElem()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 if (e1.op == TOKindex)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 IndexExp ae = cast(IndexExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 tb = ae.e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 if (tb.ty == Taarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 TypeAArray taa = cast(TypeAArray)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 elem* ea = ae.e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 elem* ekey = ae.e2.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 elem* ep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 elem* keyti;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
108
6da99741178e e2ir.c changes, mainly accounts for static arrays being value types now
Trass3r
parents: 72
diff changeset
196 if (tybasic(ekey.Ety) == TYstruct || tybasic(ekey.Ety) == TYarray)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 ekey = el_una(OPstrpar, TYstruct, ekey);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 ekey.Enumbytes = ekey.E1.Enumbytes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 assert(ekey.Enumbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 Symbol *s = taa.aaGetSymbol("Del", 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 keyti = taa.index.getInternalTypeInfo(null).toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 ep = el_params(ekey, keyti, ea, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 e = el_bin(OPcall, TYnptr, el_var(s), ep);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 //e1.type.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 e = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 tb = e1.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 switch (tb.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 case Tarray:
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
216 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 e = addressElem(e, e1.type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 rtl = RTLSYM_DELARRAYT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 /* See if we need to run destructors on the array contents
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 elem *et = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 Type tv = tb.nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 while (tv.ty == Tsarray)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
225 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 TypeSArray ta = cast(TypeSArray)tv;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 tv = tv.nextOf().toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 if (tv.ty == Tstruct)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
230 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 TypeStruct ts = cast(TypeStruct)tv;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 StructDeclaration sd = ts.sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 if (sd.dtor)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 et = tb.nextOf().getTypeInfo(null).toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 if (!et) // if no destructors needed
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 et = el_long(TYnptr, 0); // pass null for TypeInfo
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 e = el_params(et, e, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 // call _d_delarray_t(e, et);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 e = el_bin(OPcall, TYvoid, el_var(rtlsym[rtl]), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 goto Lret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 case Tclass:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 if (e1.op == TOKvar)
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
245 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 VarExp ve = cast(VarExp)e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 if (ve.var.isVarDeclaration() &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 ve.var.isVarDeclaration().onstack)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 rtl = RTLSYM_CALLFINALIZER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 if (tb.isClassHandle().isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 rtl = RTLSYM_CALLINTERFACEFINALIZER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 e = addressElem(e, e1.type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 rtl = RTLSYM_DELCLASS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 if (tb.isClassHandle().isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 rtl = RTLSYM_DELINTERFACE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 case Tpointer:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 e = addressElem(e, e1.type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 rtl = RTLSYM_DELMEMORY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 e = el_bin(OPcall, TYvoid, el_var(rtlsym[rtl]), e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 Lret:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 el_setLoc(e,loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278