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