Mercurial > projects > ddmd
annotate dmd/ComExp.d @ 130:60bb0fe4563e
dmdfe 2.037 first main iteration
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Thu, 09 Sep 2010 22:51:44 +0100 |
parents | 9e39c7de8438 |
children | e3afd1303184 |
rev | line source |
---|---|
72 | 1 module dmd.ComExp; |
2 | |
114 | 3 import dmd.common; |
72 | 4 import dmd.Expression; |
5 import dmd.Identifier; | |
6 import dmd.backend.elem; | |
7 import dmd.UnaExp; | |
8 import dmd.InterState; | |
9 import dmd.OutBuffer; | |
10 import dmd.Loc; | |
11 import dmd.Scope; | |
12 import dmd.IRState; | |
13 import dmd.ArrayTypes; | |
0 | 14 import dmd.TOK; |
15 import dmd.TY; | |
123 | 16 import dmd.Id; |
0 | 17 |
18 import dmd.backend.Util; | |
19 import dmd.backend.OPER; | |
20 | |
21 import dmd.expression.Util; | |
72 | 22 import dmd.expression.Com; |
23 | |
0 | 24 class ComExp : UnaExp |
25 { | |
26 this(Loc loc, Expression e) | |
27 { | |
28 super(loc, TOKtilde, ComExp.sizeof, e); | |
29 } | |
30 | |
72 | 31 override Expression semantic(Scope sc) |
0 | 32 { |
33 Expression e; | |
34 | |
35 if (!type) | |
36 { | |
37 UnaExp.semantic(sc); | |
38 e1 = resolveProperties(sc, e1); | |
39 e = op_overload(sc); | |
40 if (e) | |
41 return e; | |
42 | |
43 e1.checkNoBool(); | |
44 if (e1.op != TOKslice) | |
45 e1 = e1.checkIntegral(); | |
46 type = e1.type; | |
47 } | |
48 return this; | |
49 } | |
50 | |
72 | 51 override Expression optimize(int result) |
0 | 52 { |
53 Expression e; | |
54 | |
55 e1 = e1.optimize(result); | |
56 if (e1.isConst() == 1) | |
57 { | |
58 e = Com(type, e1); | |
59 } | |
60 else | |
61 e = this; | |
62 | |
63 return e; | |
64 } | |
65 | |
72 | 66 override Expression interpret(InterState istate) |
0 | 67 { |
68 assert(false); | |
69 } | |
70 | |
72 | 71 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
0 | 72 { |
123 | 73 e1.buildArrayIdent(buf, arguments); |
74 buf.writestring("Com"); | |
0 | 75 } |
76 | |
130
60bb0fe4563e
dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
123
diff
changeset
|
77 override Expression buildArrayLoop(Parameters fparams) |
0 | 78 { |
123 | 79 Expression ex1 = e1.buildArrayLoop(fparams); |
80 Expression e = new ComExp(Loc(0), ex1); | |
81 return e; | |
0 | 82 } |
83 | |
72 | 84 override Identifier opId() |
0 | 85 { |
123 | 86 return Id.com; |
0 | 87 } |
88 | |
72 | 89 override elem* toElem(IRState* irs) |
0 | 90 { |
91 elem *e; | |
92 | |
93 elem *e1 = this.e1.toElem(irs); | |
94 tym_t ty = type.totym(); | |
95 if (this.e1.type.toBasetype().ty == Tbool) | |
96 e = el_bin(OPxor, ty, e1, el_long(ty, 1)); | |
97 else | |
98 e = el_una(OPcom,ty,e1); | |
99 el_setLoc(e,loc); | |
100 return e; | |
101 } | |
102 } | |
103 |