72
|
1 module dmd.NotExp;
|
|
2
|
114
|
3 import dmd.common;
|
72
|
4 import dmd.Expression;
|
|
5 import dmd.backend.elem;
|
|
6 import dmd.UnaExp;
|
|
7 import dmd.InterState;
|
|
8 import dmd.Loc;
|
|
9 import dmd.Scope;
|
|
10 import dmd.IRState;
|
0
|
11 import dmd.TOK;
|
|
12 import dmd.Type;
|
|
13
|
|
14 import dmd.expression.Not;
|
|
15
|
|
16 import dmd.backend.OPER;
|
72
|
17 import dmd.backend.Util;
|
|
18
|
0
|
19 class NotExp : UnaExp
|
|
20 {
|
|
21 this(Loc loc, Expression e)
|
|
22 {
|
178
|
23 register();
|
0
|
24 super(loc, TOK.TOKnot, NotExp.sizeof, e);
|
|
25 }
|
|
26
|
72
|
27 override Expression semantic(Scope sc)
|
0
|
28 {
|
|
29 UnaExp.semantic(sc);
|
|
30 e1 = resolveProperties(sc, e1);
|
|
31 e1 = e1.checkToBoolean();
|
|
32 type = Type.tboolean;
|
|
33 return this;
|
|
34 }
|
|
35
|
72
|
36 override Expression optimize(int result)
|
0
|
37 {
|
|
38 Expression e;
|
|
39
|
|
40 e1 = e1.optimize(result);
|
|
41 if (e1.isConst() == 1)
|
|
42 e = Not(type, e1);
|
|
43 else
|
|
44 e = this;
|
|
45
|
|
46 return e;
|
|
47 }
|
|
48
|
72
|
49 override Expression interpret(InterState istate)
|
0
|
50 {
|
|
51 assert(false);
|
|
52 }
|
|
53
|
72
|
54 override int isBit()
|
0
|
55 {
|
|
56 assert(false);
|
|
57 }
|
|
58
|
72
|
59 override elem* toElem(IRState* irs)
|
0
|
60 {
|
|
61 elem* e = el_una(OPnot, type.totym(), e1.toElem(irs));
|
|
62 el_setLoc(e,loc);
|
|
63 return e;
|
|
64 }
|
72
|
65 }
|