annotate dmd/DeleteExp.d @ 174:af724d3510d7

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