annotate dmd/DeleteExp.d @ 187:b0d41ff5e0df

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