annotate dmd/CondExp.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 2e2a5c3f943a
children 9e39c7de8438
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.CondExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 72
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.BinExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.InterState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.InlineCostState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.InlineDoState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.InlineScanState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.IRState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.WANT;
50
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
20 import dmd.PREC;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.backend.elem;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.backend.OPER;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.backend.mTY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
50
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
30 import dmd.expression.Util;
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
31
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 class CondExp : BinExp
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 Expression econd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 this(Loc loc, Expression econd, Expression e1, Expression e2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 super(loc, TOK.TOKquestion, CondExp.sizeof, e1, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 this.econd = econd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
42 override Expression syntaxCopy()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 {
43
a509c8688fbd CondExp.syntaxCopy
korDen
parents: 0
diff changeset
44 return new CondExp(loc, econd.syntaxCopy(), e1.syntaxCopy(), e2.syntaxCopy());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
47 override Expression semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 Type t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 Type t2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 uint cs0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 uint cs1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 version (LOGSEMANTIC) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 printf("CondExp.semantic('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 if (type)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 econd = econd.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 econd = resolveProperties(sc, econd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 econd = econd.checkToPointer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 econd = econd.checkToBoolean();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 /* this cannot work right because the types of e1 and e2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 * both contribute to the type of the result.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 if (sc.flags & SCOPEstaticif)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 /* If in static if, don't evaluate what we don't have to.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 econd = econd.optimize(WANTflags);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 if (econd.isBool(TRUE))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 e1 = e1.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 return e1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 else if (econd.isBool(FALSE))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 e2 = e2.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 e2 = resolveProperties(sc, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 return e2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 cs0 = sc.callSuper;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 e1 = e1.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 e1 = resolveProperties(sc, e1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 cs1 = sc.callSuper;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 sc.callSuper = cs0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 e2 = e2.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 e2 = resolveProperties(sc, e2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 sc.mergeCallSuper(loc, cs1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 // If either operand is void, the result is void
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 t1 = e1.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 t2 = e2.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 if (t1.ty == Tvoid || t2.ty == Tvoid)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 type = Type.tvoid;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 else if (t1 == t2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 type = t1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 typeCombine(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 switch (e1.type.toBasetype().ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 case Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 case Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 case Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 e2 = e2.castTo(sc, e1.type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 switch (e2.type.toBasetype().ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 case Tcomplex32:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 case Tcomplex64:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 case Tcomplex80:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 e1 = e1.castTo(sc, e2.type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 if (type.toBasetype().ty == Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 e1 = e1.castTo(sc, type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 e2 = e2.castTo(sc, type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 printf("res: %s\n", type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 printf("e1 : %s\n", e1.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 printf("e2 : %s\n", e2.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
142 override Expression optimize(int result)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 econd = econd.optimize(WANTflags | (result & WANTinterpret));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 if (econd.isBool(true))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 e = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 else if (econd.isBool(false))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 e = e2.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 e1 = e1.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 e2 = e2.optimize(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
161 override Expression interpret(InterState istate)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
166 override void checkEscape()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 e1.checkEscape();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 e2.checkEscape();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
172 override int isLvalue()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
177 override Expression toLvalue(Scope sc, Expression e)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
182 override Expression modifiableLvalue(Scope sc, Expression e)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
187 override Expression checkToBoolean()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
192 override bool checkSideEffect(int flag)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 {
64
4290d870944a More fixes
korDen
parents: 50
diff changeset
194 if (flag == 2)
4290d870944a More fixes
korDen
parents: 50
diff changeset
195 {
4290d870944a More fixes
korDen
parents: 50
diff changeset
196 return econd.checkSideEffect(2) || e1.checkSideEffect(2) || e2.checkSideEffect(2);
4290d870944a More fixes
korDen
parents: 50
diff changeset
197 }
4290d870944a More fixes
korDen
parents: 50
diff changeset
198 else
4290d870944a More fixes
korDen
parents: 50
diff changeset
199 {
4290d870944a More fixes
korDen
parents: 50
diff changeset
200 econd.checkSideEffect(1);
4290d870944a More fixes
korDen
parents: 50
diff changeset
201 e1.checkSideEffect(flag);
4290d870944a More fixes
korDen
parents: 50
diff changeset
202 return e2.checkSideEffect(flag);
4290d870944a More fixes
korDen
parents: 50
diff changeset
203 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
206 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
50
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
208 expToCBuffer(buf, hgs, econd, PREC_oror);
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
209 buf.writestring(" ? ");
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
210 expToCBuffer(buf, hgs, e1, PREC_expr);
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
211 buf.writestring(" : ");
adf6f7f216ea CondExp.toCBuffer
korDen
parents: 43
diff changeset
212 expToCBuffer(buf, hgs, e2, PREC_cond);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
215 override MATCH implicitConvTo(Type t)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 MATCH m1 = e1.implicitConvTo(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 MATCH m2 = e2.implicitConvTo(t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 //printf("CondExp: m1 %d m2 %d\n", m1, m2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 // Pick the worst match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 return (m1 < m2) ? m1 : m2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
225 override Expression castTo(Scope sc, Type t)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 Expression e = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 if (type !is t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 if (1 || e1.op == TOKstring || e2.op == TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 e = new CondExp(loc, econd, e1.castTo(sc, t), e2.castTo(sc, t));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 e.type = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 e = Expression.castTo(sc, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
242 override void scanForNestedRef(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
247 override bool canThrow()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 return econd.canThrow() || e1.canThrow() || e2.canThrow();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
252 override int inlineCost(InlineCostState* ics)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 return 1 + e1.inlineCost(ics) + e2.inlineCost(ics) + econd.inlineCost(ics);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
257 override Expression doInline(InlineDoState ids)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 CondExp ce = cast(CondExp)copy();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 ce.econd = econd.doInline(ids);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 ce.e1 = e1.doInline(ids);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 ce.e2 = e2.doInline(ids);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 return ce;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
267 override Expression inlineScan(InlineScanState* iss)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 econd = econd.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 e1 = e1.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 e2 = e2.inlineScan(iss);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
275 override elem* toElem(IRState* irs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 elem* eleft;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 elem* eright;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 elem* ec = econd.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 eleft = e1.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 tym_t ty = eleft.Ety;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 if (global.params.cov && e1.loc.linnum)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 eleft = el_combine(incUsageElem(irs, e1.loc), eleft);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 eright = e2.toElem(irs);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 if (global.params.cov && e2.loc.linnum)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 eright = el_combine(incUsageElem(irs, e2.loc), eright);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 elem* e = el_bin(OPcond, ty, ec, el_bin(OPcolon, ty, eleft, eright));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 if (tybasic(ty) == TYstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 e.Enumbytes = cast(uint)e1.type.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 el_setLoc(e, loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
298 }