72
|
1 module dmd.BoolExp;
|
|
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.Type;
|
|
9 import dmd.Loc;
|
|
10 import dmd.Scope;
|
0
|
11 import dmd.IRState;
|
72
|
12 import dmd.TOK;
|
0
|
13
|
|
14 import dmd.backend.OPER;
|
|
15 import dmd.backend.Util;
|
72
|
16
|
0
|
17 class BoolExp : UnaExp
|
|
18 {
|
|
19 this(Loc loc, Expression e, Type t)
|
|
20 {
|
36
|
21 super(loc, TOKtobool, BoolExp.sizeof, e);
|
0
|
22 type = t;
|
|
23 }
|
|
24
|
72
|
25 override Expression semantic(Scope sc)
|
0
|
26 {
|
141
|
27 super.semantic(sc);
|
0
|
28 e1 = resolveProperties(sc, e1);
|
|
29 e1 = e1.checkToBoolean();
|
|
30 type = Type.tboolean;
|
|
31 return this;
|
|
32 }
|
|
33
|
72
|
34 override Expression optimize(int result)
|
0
|
35 {
|
141
|
36 Expression e;
|
|
37
|
|
38 e1 = e1.optimize(result);
|
|
39 if (e1.isConst() == 1)
|
|
40 {
|
|
41 e = Bool(type, e1);
|
|
42 }
|
|
43 else
|
|
44 e = this;
|
|
45 return e;
|
0
|
46 }
|
|
47
|
72
|
48 override Expression interpret(InterState istate)
|
0
|
49 {
|
|
50 assert(false);
|
|
51 }
|
|
52
|
72
|
53 override int isBit()
|
0
|
54 {
|
|
55 return true;
|
|
56 }
|
|
57
|
72
|
58 override elem* toElem(IRState* irs)
|
0
|
59 {
|
|
60 elem* e1 = this.e1.toElem(irs);
|
|
61 return el_una(OPbool,type.totym(),e1);
|
|
62 }
|
|
63 }
|
|
64
|