0
|
1 module dmd.AndExp;
|
|
2
|
|
3 import dmd.Expression;
|
|
4 import dmd.Identifier;
|
|
5 import dmd.InterState;
|
|
6 import dmd.OutBuffer;
|
|
7 import dmd.Loc;
|
|
8 import dmd.Scope;
|
|
9 import dmd.IntRange;
|
|
10 import dmd.IRState;
|
|
11 import dmd.BinExp;
|
|
12 import dmd.TOK;
|
|
13 import dmd.ArrayTypes;
|
|
14 import dmd.TY;
|
|
15 import dmd.Type;
|
|
16 import dmd.Id;
|
|
17 import dmd.Global;
|
|
18
|
|
19 import dmd.backend.elem;
|
|
20 import dmd.backend.Util;
|
|
21 import dmd.backend.OPER;
|
|
22 import dmd.expression.Util;
|
|
23 import dmd.expression.And;
|
|
24
|
|
25 class AndExp : BinExp
|
|
26 {
|
|
27 this(Loc loc, Expression e1, Expression e2)
|
|
28 {
|
|
29 super(loc, TOK.TOKand, AndExp.sizeof, e1, e2);
|
|
30 }
|
|
31
|
|
32 Expression semantic(Scope sc)
|
|
33 {
|
|
34 Expression e;
|
|
35
|
|
36 if (!type)
|
|
37 {
|
|
38 BinExp.semanticp(sc);
|
|
39 e = op_overload(sc);
|
|
40
|
|
41 if (e)
|
|
42 return e;
|
|
43
|
|
44 if (e1.type.toBasetype().ty == TY.Tbool && e2.type.toBasetype().ty == TY.Tbool)
|
|
45 {
|
|
46 type = e1.type;
|
|
47 e = this;
|
|
48 }
|
|
49 else
|
|
50 {
|
|
51 typeCombine(sc);
|
|
52 if (e1.op != TOK.TOKslice && e2.op != TOK.TOKslice)
|
|
53 {
|
|
54 e1.checkIntegral();
|
|
55 e2.checkIntegral();
|
|
56 }
|
|
57 }
|
|
58 }
|
|
59 return this;
|
|
60 }
|
|
61
|
|
62 Expression optimize(int result)
|
|
63 {
|
|
64 Expression e;
|
|
65
|
|
66 e1 = e1.optimize(result);
|
|
67 e2 = e2.optimize(result);
|
|
68 if (e1.isConst() == 1 && e2.isConst() == 1)
|
|
69 e = And(type, e1, e2);
|
|
70 else
|
|
71 e = this;
|
|
72
|
|
73 return e;
|
|
74 }
|
|
75
|
|
76 Expression interpret(InterState* istate)
|
|
77 {
|
|
78 assert(false);
|
|
79 }
|
|
80
|
|
81 void buildArrayIdent(OutBuffer buf, Expressions arguments)
|
|
82 {
|
|
83 assert(false);
|
|
84 }
|
|
85
|
|
86 Expression buildArrayLoop(Arguments fparams)
|
|
87 {
|
|
88 assert(false);
|
|
89 }
|
|
90
|
|
91 IntRange getIntRange()
|
|
92 {
|
|
93 assert(false);
|
|
94 }
|
|
95
|
|
96 bool isCommutative()
|
|
97 {
|
|
98 return true;
|
|
99 }
|
|
100
|
|
101 Identifier opId()
|
|
102 {
|
|
103 return Id.iand;
|
|
104 }
|
|
105
|
|
106 Identifier opId_r()
|
|
107 {
|
|
108 return Id.iand_r;
|
|
109 }
|
|
110
|
|
111 elem* toElem(IRState* irs)
|
|
112 {
|
|
113 return toElemBin(irs, OPER.OPand);
|
|
114 }
|
|
115 }
|
|
116
|