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