72
|
1 module dmd.ComExp;
|
|
2
|
|
3 import dmd.Expression;
|
|
4 import dmd.Identifier;
|
|
5 import dmd.backend.elem;
|
|
6 import dmd.UnaExp;
|
|
7 import dmd.InterState;
|
|
8 import dmd.OutBuffer;
|
|
9 import dmd.Loc;
|
|
10 import dmd.Scope;
|
|
11 import dmd.IRState;
|
|
12 import dmd.ArrayTypes;
|
0
|
13 import dmd.TOK;
|
|
14 import dmd.TY;
|
|
15
|
|
16 import dmd.backend.Util;
|
|
17 import dmd.backend.OPER;
|
|
18
|
|
19 import dmd.expression.Util;
|
72
|
20 import dmd.expression.Com;
|
|
21
|
0
|
22 class ComExp : UnaExp
|
|
23 {
|
|
24 this(Loc loc, Expression e)
|
|
25 {
|
|
26 super(loc, TOKtilde, ComExp.sizeof, e);
|
|
27 }
|
|
28
|
72
|
29 override Expression semantic(Scope sc)
|
0
|
30 {
|
|
31 Expression e;
|
|
32
|
|
33 if (!type)
|
|
34 {
|
|
35 UnaExp.semantic(sc);
|
|
36 e1 = resolveProperties(sc, e1);
|
|
37 e = op_overload(sc);
|
|
38 if (e)
|
|
39 return e;
|
|
40
|
|
41 e1.checkNoBool();
|
|
42 if (e1.op != TOKslice)
|
|
43 e1 = e1.checkIntegral();
|
|
44 type = e1.type;
|
|
45 }
|
|
46 return this;
|
|
47 }
|
|
48
|
72
|
49 override Expression optimize(int result)
|
0
|
50 {
|
|
51 Expression e;
|
|
52
|
|
53 e1 = e1.optimize(result);
|
|
54 if (e1.isConst() == 1)
|
|
55 {
|
|
56 e = Com(type, e1);
|
|
57 }
|
|
58 else
|
|
59 e = this;
|
|
60
|
|
61 return e;
|
|
62 }
|
|
63
|
72
|
64 override Expression interpret(InterState istate)
|
0
|
65 {
|
|
66 assert(false);
|
|
67 }
|
|
68
|
72
|
69 override void buildArrayIdent(OutBuffer buf, Expressions arguments)
|
0
|
70 {
|
|
71 assert(false);
|
|
72 }
|
|
73
|
72
|
74 override Expression buildArrayLoop(Arguments fparams)
|
0
|
75 {
|
|
76 assert(false);
|
|
77 }
|
|
78
|
72
|
79 override Identifier opId()
|
0
|
80 {
|
|
81 assert(false);
|
|
82 }
|
|
83
|
72
|
84 override elem* toElem(IRState* irs)
|
0
|
85 {
|
|
86 elem *e;
|
|
87
|
|
88 elem *e1 = this.e1.toElem(irs);
|
|
89 tym_t ty = type.totym();
|
|
90 if (this.e1.type.toBasetype().ty == Tbool)
|
|
91 e = el_bin(OPxor, ty, e1, el_long(ty, 1));
|
|
92 else
|
|
93 e = el_una(OPcom,ty,e1);
|
|
94 el_setLoc(e,loc);
|
|
95 return e;
|
|
96 }
|
|
97 }
|
|
98
|