comparison dmd/RemoveExp.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 2e2a5c3f943a
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
1 module dmd.RemoveExp;
2
3 import dmd.Expression;
4 import dmd.backend.elem;
5 import dmd.Loc;
6 import dmd.IRState;
7 import dmd.BinExp;
8 import dmd.TOK;
9 import dmd.Type;
10 import dmd.TypeAArray;
11 import dmd.TY;
12
13 import dmd.backend.Util;
14 import dmd.backend.OPER;
15 import dmd.backend.Symbol;
16 import dmd.backend.TYM;
17 import dmd.backend.mTY;
18
19 /* This deletes the key e1 from the associative array e2
20 */
21
22 class RemoveExp : BinExp
23 {
24 this(Loc loc, Expression e1, Expression e2)
25 {
26 super(loc, TOKremove, RemoveExp.sizeof, e1, e2);
27 type = Type.tvoid;
28 }
29
30 elem* toElem(IRState* irs)
31 {
32 elem* e;
33 Type tb = e1.type.toBasetype();
34 assert(tb.ty == Taarray);
35 TypeAArray taa = cast(TypeAArray)tb;
36 elem* ea = e1.toElem(irs);
37 elem* ekey = e2.toElem(irs);
38 elem* ep;
39 elem* keyti;
40
41 if (tybasic(ekey.Ety) == TYstruct)
42 {
43 ekey = el_una(OPstrpar, TYstruct, ekey);
44 ekey.Enumbytes = ekey.E1.Enumbytes;
45 assert(ekey.Enumbytes);
46 }
47
48 Symbol* s = taa.aaGetSymbol("Del", 0);
49 keyti = taa.index.getInternalTypeInfo(null).toElem(irs);
50 ep = el_params(ekey, keyti, ea, null);
51 e = el_bin(OPcall, TYnptr, el_var(s), ep);
52
53 el_setLoc(e,loc);
54 return e;
55 }
56 }
57