Mercurial > projects > ddmd
annotate dmd/BinExp.d @ 84:be2ab491772e
Expressions -> Vector!Expression
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 16:12:19 +0100 |
parents | 43073c7c7769 |
children | 39648eb578f6 |
rev | line source |
---|---|
0 | 1 module dmd.BinExp; |
2 | |
63 | 3 import dmd.SliceExp; |
4 import dmd.IndexExp; | |
5 import dmd.StructDeclaration; | |
6 import dmd.expression.ArrayLength; | |
7 import dmd.expression.Equal; | |
8 import dmd.expression.Index; | |
9 import dmd.ArrayLiteralExp; | |
10 import dmd.AssocArrayLiteralExp; | |
11 import dmd.StringExp; | |
12 import dmd.TypeSArray; | |
13 import dmd.PtrExp; | |
14 import dmd.SymOffExp; | |
15 import dmd.Declaration; | |
16 import dmd.StructLiteralExp; | |
0 | 17 import dmd.Expression; |
63 | 18 import dmd.interpret.Util; |
19 import dmd.GlobalExpressions; | |
20 import dmd.Cast; | |
21 import dmd.CastExp; | |
22 import dmd.VarDeclaration; | |
23 import dmd.DotVarExp; | |
0 | 24 import dmd.Loc; |
25 import dmd.ClassDeclaration; | |
26 import dmd.OutBuffer; | |
27 import dmd.HdrGenState; | |
28 import dmd.TOK; | |
29 import dmd.IRState; | |
30 import dmd.Scope; | |
31 import dmd.Type; | |
32 import dmd.InterState; | |
33 import dmd.InlineCostState; | |
34 import dmd.InlineScanState; | |
35 import dmd.InlineDoState; | |
36 import dmd.AggregateDeclaration; | |
37 import dmd.Identifier; | |
38 import dmd.MATCH; | |
39 import dmd.declaration.Match; | |
40 import dmd.ArrayTypes; | |
41 import dmd.TY; | |
42 import dmd.TypeClass; | |
43 import dmd.TypeStruct; | |
44 import dmd.Dsymbol; | |
45 import dmd.FuncDeclaration; | |
46 import dmd.TemplateDeclaration; | |
47 import dmd.DotIdExp; | |
48 import dmd.ErrorExp; | |
49 import dmd.WANT; | |
50 import dmd.IntegerExp; | |
51 import dmd.MulExp; | |
52 import dmd.Token; | |
53 import dmd.PREC; | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
54 import dmd.StringValue; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
55 import dmd.StringTable; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
56 import dmd.Argument; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
57 import dmd.Statement; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
58 import dmd.ForeachRangeStatement; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
59 import dmd.ArrayLengthExp; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
60 import dmd.IdentifierExp; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
61 import dmd.ExpStatement; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
62 import dmd.CompoundStatement; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
63 import dmd.TypeFunction; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
64 import dmd.LINK; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
65 import dmd.Lexer; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
66 import dmd.ReturnStatement; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
67 import dmd.Id; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
68 import dmd.STC; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
69 import dmd.PROT; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
70 import dmd.VarExp; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
71 import dmd.CallExp; |
0 | 72 |
73 import dmd.expression.Util; | |
74 | |
75 import dmd.backend.elem; | |
76 import dmd.backend.Util; | |
77 | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
78 import dmd.backend.iasm : binary; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
79 |
63 | 80 import std.exception : assumeUnique; |
81 import core.stdc.stdlib : calloc; | |
0 | 82 import std.stdio : writef; |
83 | |
84 /************************************** | |
85 * Combine types. | |
86 * Output: | |
87 * *pt merged type, if *pt is not null | |
88 * *pe1 rewritten e1 | |
89 * *pe2 rewritten e2 | |
90 * Returns: | |
91 * !=0 success | |
92 * 0 failed | |
93 */ | |
94 | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
95 /************************************** |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
96 * Hash table of array op functions already generated or known about. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
97 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
98 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
99 __gshared StringTable arrayfuncs; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
100 |
0 | 101 int typeMerge(Scope sc, Expression e, Type* pt, Expression* pe1, Expression* pe2) |
102 { | |
60 | 103 //printf("typeMerge() %.*s op %.*s\n", (*pe1).toChars(), (*pe2).toChars()); |
0 | 104 //dump(0); |
105 | |
106 Expression e1 = (*pe1).integralPromotions(sc); | |
107 Expression e2 = (*pe2).integralPromotions(sc); | |
108 | |
109 Type t1 = e1.type; | |
110 Type t2 = e2.type; | |
111 assert(t1); | |
112 Type t = t1; | |
113 | |
114 //if (t1) printf("\tt1 = %s\n", t1.toChars()); | |
115 //if (t2) printf("\tt2 = %s\n", t2.toChars()); | |
116 debug { | |
117 if (!t2) writef("\te2 = '%s'\n", e2.toChars()); | |
118 } | |
119 assert(t2); | |
120 | |
121 Type t1b = t1.toBasetype(); | |
122 Type t2b = t2.toBasetype(); | |
123 | |
124 TY ty = cast(TY)Type.impcnvResult[t1b.ty][t2b.ty]; | |
125 if (ty != TY.Terror) | |
126 { | |
127 TY ty1; | |
128 TY ty2; | |
129 | |
130 ty1 = cast(TY)Type.impcnvType1[t1b.ty][t2b.ty]; | |
131 ty2 = cast(TY)Type.impcnvType2[t1b.ty][t2b.ty]; | |
132 | |
133 if (t1b.ty == ty1) // if no promotions | |
134 { | |
135 if (t1 == t2) | |
136 { | |
137 t = t1; | |
138 goto Lret; | |
139 } | |
140 | |
141 if (t1b == t2b) | |
142 { | |
143 t = t1b; | |
144 goto Lret; | |
145 } | |
146 } | |
147 | |
148 t = Type.basic[ty]; | |
149 | |
150 t1 = Type.basic[ty1]; | |
151 t2 = Type.basic[ty2]; | |
152 | |
153 e1 = e1.castTo(sc, t1); | |
154 e2 = e2.castTo(sc, t2); | |
155 //printf("after typeCombine():\n"); | |
156 //dump(0); | |
157 //printf("ty = %d, ty1 = %d, ty2 = %d\n", ty, ty1, ty2); | |
158 goto Lret; | |
159 } | |
160 | |
161 t1 = t1b; | |
162 t2 = t2b; | |
163 | |
164 Lagain: | |
165 if (t1 == t2) | |
166 { | |
167 } | |
168 else if (t1.ty == TY.Tpointer && t2.ty == TY.Tpointer) | |
169 { | |
170 // Bring pointers to compatible type | |
171 Type t1n = t1.nextOf(); | |
172 Type t2n = t2.nextOf(); | |
173 | |
174 if (t1n == t2n) { | |
175 ; | |
176 } else if (t1n.ty == TY.Tvoid) {// pointers to void are always compatible | |
177 t = t2; | |
178 } else if (t2n.ty == TY.Tvoid) { | |
179 ; | |
180 } else if (t1n.mod != t2n.mod) { | |
181 t1 = t1n.mutableOf().constOf().pointerTo(); | |
182 t2 = t2n.mutableOf().constOf().pointerTo(); | |
183 t = t1; | |
184 goto Lagain; | |
185 } else if (t1n.ty == TY.Tclass && t2n.ty == TY.Tclass) { | |
186 ClassDeclaration cd1 = t1n.isClassHandle(); | |
187 ClassDeclaration cd2 = t2n.isClassHandle(); | |
188 int offset; | |
189 | |
190 if (cd1.isBaseOf(cd2, &offset)) | |
191 { | |
192 if (offset) | |
193 e2 = e2.castTo(sc, t); | |
194 } | |
195 else if (cd2.isBaseOf(cd1, &offset)) | |
196 { | |
197 t = t2; | |
198 if (offset) | |
199 e1 = e1.castTo(sc, t); | |
200 } | |
201 else | |
202 goto Lincompatible; | |
203 } else { | |
204 goto Lincompatible; | |
205 } | |
206 } | |
207 else if ((t1.ty == TY.Tsarray || t1.ty == TY.Tarray) && | |
208 e2.op == TOK.TOKnull && t2.ty == TY.Tpointer && t2.nextOf().ty == TY.Tvoid) | |
209 { /* (T[n] op void*) | |
210 * (T[] op void*) | |
211 */ | |
212 goto Lx1; | |
213 } | |
214 else if ((t2.ty == TY.Tsarray || t2.ty == TY.Tarray) && | |
215 e1.op == TOK.TOKnull && t1.ty == TY.Tpointer && t1.nextOf().ty == TY.Tvoid) | |
216 { /* (void* op T[n]) | |
217 * (void* op T[]) | |
218 */ | |
219 goto Lx2; | |
220 } | |
221 else if ((t1.ty == TY.Tsarray || t1.ty == TY.Tarray) && t1.implicitConvTo(t2)) | |
222 { | |
223 goto Lt2; | |
224 } | |
225 else if ((t2.ty == TY.Tsarray || t2.ty == TY.Tarray) && t2.implicitConvTo(t1)) | |
226 { | |
227 goto Lt1; | |
228 } | |
229 /* If one is mutable and the other invariant, then retry | |
230 * with both of them as const | |
231 */ | |
232 else if ((t1.ty == TY.Tsarray || t1.ty == TY.Tarray || t1.ty == TY.Tpointer) && | |
233 (t2.ty == TY.Tsarray || t2.ty == TY.Tarray || t2.ty == TY.Tpointer) && | |
234 t1.nextOf().mod != t2.nextOf().mod | |
235 ) | |
236 { | |
237 if (t1.ty == TY.Tpointer) | |
238 t1 = t1.nextOf().mutableOf().constOf().pointerTo(); | |
239 else | |
240 t1 = t1.nextOf().mutableOf().constOf().arrayOf(); | |
241 | |
242 if (t2.ty == TY.Tpointer) | |
243 t2 = t2.nextOf().mutableOf().constOf().pointerTo(); | |
244 else | |
245 t2 = t2.nextOf().mutableOf().constOf().arrayOf(); | |
246 t = t1; | |
247 goto Lagain; | |
248 } | |
249 else if (t1.ty == TY.Tclass || t2.ty == TY.Tclass) | |
250 { | |
251 while (1) | |
252 { | |
253 int i1 = e2.implicitConvTo(t1); | |
254 int i2 = e1.implicitConvTo(t2); | |
255 | |
256 if (i1 && i2) | |
257 { | |
258 // We have the case of class vs. void*, so pick class | |
259 if (t1.ty == TY.Tpointer) | |
260 i1 = 0; | |
261 else if (t2.ty == TY.Tpointer) | |
262 i2 = 0; | |
263 } | |
264 | |
265 if (i2) | |
266 { | |
267 goto Lt2; | |
268 } | |
269 else if (i1) | |
270 { | |
271 goto Lt1; | |
272 } | |
273 else if (t1.ty == TY.Tclass && t2.ty == TY.Tclass) | |
274 { | |
275 TypeClass tc1 = cast(TypeClass)t1; | |
276 TypeClass tc2 = cast(TypeClass)t2; | |
277 | |
278 /* Pick 'tightest' type | |
279 */ | |
280 ClassDeclaration cd1 = tc1.sym.baseClass; | |
281 ClassDeclaration cd2 = tc2.sym.baseClass; | |
282 | |
283 if (cd1 && cd2) | |
284 { t1 = cd1.type; | |
285 t2 = cd2.type; | |
286 } | |
287 else if (cd1) | |
288 t1 = cd1.type; | |
289 else if (cd2) | |
290 t2 = cd2.type; | |
291 else | |
292 goto Lincompatible; | |
293 } | |
294 else | |
295 goto Lincompatible; | |
296 } | |
297 } | |
298 else if (t1.ty == TY.Tstruct && t2.ty == TY.Tstruct) | |
299 { | |
300 if ((cast(TypeStruct)t1).sym != (cast(TypeStruct)t2).sym) | |
301 goto Lincompatible; | |
302 } | |
303 else if ((e1.op == TOK.TOKstring || e1.op == TOK.TOKnull) && e1.implicitConvTo(t2)) | |
304 { | |
305 goto Lt2; | |
306 } | |
307 else if ((e2.op == TOK.TOKstring || e2.op == TOK.TOKnull) && e2.implicitConvTo(t1)) | |
308 { | |
309 goto Lt1; | |
310 } | |
311 else if (t1.ty == TY.Tsarray && t2.ty == TY.Tsarray && | |
312 e2.implicitConvTo(t1.nextOf().arrayOf())) | |
313 { | |
314 Lx1: | |
315 t = t1.nextOf().arrayOf(); | |
316 e1 = e1.castTo(sc, t); | |
317 e2 = e2.castTo(sc, t); | |
318 } | |
319 else if (t1.ty == TY.Tsarray && t2.ty == TY.Tsarray && | |
320 e1.implicitConvTo(t2.nextOf().arrayOf())) | |
321 { | |
322 Lx2: | |
323 t = t2.nextOf().arrayOf(); | |
324 e1 = e1.castTo(sc, t); | |
325 e2 = e2.castTo(sc, t); | |
326 } | |
327 else if (t1.isintegral() && t2.isintegral()) | |
328 { | |
329 assert(0); | |
330 } | |
331 else if (e1.op == TOK.TOKslice && t1.ty == TY.Tarray && | |
332 e2.implicitConvTo(t1.nextOf())) | |
333 { // T[] op T | |
334 e2 = e2.castTo(sc, t1.nextOf()); | |
335 t = t1.nextOf().arrayOf(); | |
336 } | |
337 else if (e2.op == TOK.TOKslice && t2.ty == TY.Tarray && | |
338 e1.implicitConvTo(t2.nextOf())) | |
339 { // T op T[] | |
340 e1 = e1.castTo(sc, t2.nextOf()); | |
341 t = t2.nextOf().arrayOf(); | |
342 | |
343 //printf("test %s\n", e.toChars()); | |
344 e1 = e1.optimize(WANT.WANTvalue); | |
345 if (e && e.isCommutative() && e1.isConst()) | |
346 { /* Swap operands to minimize number of functions generated | |
347 */ | |
348 //printf("swap %s\n", e.toChars()); | |
349 Expression tmp = e1; | |
350 e1 = e2; | |
351 e2 = tmp; | |
352 } | |
353 } | |
354 else | |
355 { | |
356 Lincompatible: | |
357 return 0; | |
358 } | |
359 Lret: | |
360 if (!*pt) | |
361 *pt = t; | |
362 *pe1 = e1; | |
363 *pe2 = e2; | |
364 static if (false) { | |
365 printf("-typeMerge() %s op %s\n", e1.toChars(), e2.toChars()); | |
366 if (e1.type) printf("\tt1 = %s\n", e1.type.toChars()); | |
367 if (e2.type) printf("\tt2 = %s\n", e2.type.toChars()); | |
368 printf("\ttype = %s\n", t.toChars()); | |
369 } | |
370 //dump(0); | |
371 return 1; | |
372 | |
373 | |
374 Lt1: | |
375 e2 = e2.castTo(sc, t1); | |
376 t = t1; | |
377 goto Lret; | |
378 | |
379 Lt2: | |
380 e1 = e1.castTo(sc, t2); | |
381 t = t2; | |
382 goto Lret; | |
383 } | |
384 | |
385 class BinExp : Expression | |
386 { | |
387 Expression e1; | |
388 Expression e2; | |
389 | |
390 this(Loc loc, TOK op, int size, Expression e1, Expression e2) | |
391 { | |
392 super(loc, op, size); | |
393 this.e1 = e1; | |
394 this.e2 = e2; | |
395 } | |
396 | |
72 | 397 override Expression syntaxCopy() |
0 | 398 { |
399 BinExp e = cast(BinExp)copy(); | |
400 e.type = null; | |
401 e.e1 = e.e1.syntaxCopy(); | |
402 e.e2 = e.e2.syntaxCopy(); | |
403 | |
404 return e; | |
405 } | |
406 | |
72 | 407 override Expression semantic(Scope sc) |
0 | 408 { |
409 version (LOGSEMANTIC) { | |
60 | 410 printf("BinExp.semantic('%.*s')\n", toChars()); |
0 | 411 } |
412 e1 = e1.semantic(sc); | |
413 if (!e1.type && !(op == TOK.TOKassign && e1.op == TOK.TOKdottd)) // a.template = e2 | |
414 { | |
415 error("%s has no value", e1.toChars()); | |
416 e1.type = Type.terror; | |
417 } | |
418 e2 = e2.semantic(sc); | |
419 if (!e2.type) | |
420 { | |
421 error("%s has no value", e2.toChars()); | |
422 e2.type = Type.terror; | |
423 } | |
424 return this; | |
425 } | |
426 | |
427 Expression semanticp(Scope sc) | |
428 { | |
60 | 429 BinExp.semantic(sc); |
430 | |
431 e1 = resolveProperties(sc, e1); | |
432 e2 = resolveProperties(sc, e2); | |
0 | 433 return this; |
434 } | |
435 | |
56 | 436 /*************************** |
437 * Common semantic routine for some xxxAssignExp's. | |
438 */ | |
0 | 439 Expression commonSemanticAssign(Scope sc) |
440 { | |
56 | 441 Expression e; |
442 | |
443 if (!type) | |
444 { | |
445 BinExp.semantic(sc); | |
446 e2 = resolveProperties(sc, e2); | |
447 | |
448 e = op_overload(sc); | |
449 if (e) | |
450 return e; | |
451 | |
452 if (e1.op == TOKslice) | |
453 { | |
454 // T[] op= ... | |
455 typeCombine(sc); | |
456 type = e1.type; | |
457 return arrayOp(sc); | |
458 } | |
459 | |
460 e1 = e1.modifiableLvalue(sc, e1); | |
461 e1.checkScalar(); | |
462 type = e1.type; | |
463 if (type.toBasetype().ty == Tbool) | |
464 { | |
465 error("operator not allowed on bool expression %s", toChars()); | |
466 } | |
467 typeCombine(sc); | |
468 e1.checkArithmetic(); | |
469 e2.checkArithmetic(); | |
470 | |
471 if (op == TOKmodass && e2.type.iscomplex()) | |
472 { error("cannot perform modulo complex arithmetic"); | |
473 return new ErrorExp(); | |
474 } | |
475 } | |
476 return this; | |
0 | 477 } |
478 | |
479 Expression commonSemanticAssignIntegral(Scope sc) | |
480 { | |
481 Expression e; | |
482 | |
483 if (!type) | |
484 { | |
485 BinExp.semantic(sc); | |
486 e2 = resolveProperties(sc, e2); | |
487 | |
488 e = op_overload(sc); | |
489 if (e) | |
490 return e; | |
491 | |
492 if (e1.op == TOK.TOKslice) | |
493 { // T[] op= ... | |
494 typeCombine(sc); | |
495 type = e1.type; | |
496 return arrayOp(sc); | |
497 } | |
498 | |
499 e1 = e1.modifiableLvalue(sc, e1); | |
500 e1.checkScalar(); | |
501 type = e1.type; | |
502 if (type.toBasetype().ty == TY.Tbool) | |
503 { | |
504 e2 = e2.implicitCastTo(sc, type); | |
505 } | |
506 | |
507 typeCombine(sc); | |
508 e1.checkIntegral(); | |
509 e2.checkIntegral(); | |
510 } | |
511 | |
512 return this; | |
513 } | |
514 | |
72 | 515 override bool checkSideEffect(int flag) |
0 | 516 { |
517 switch (op) { | |
518 case TOK.TOKplusplus: | |
519 case TOK.TOKminusminus: | |
520 case TOK.TOKassign: | |
521 case TOK.TOKconstruct: | |
522 case TOK.TOKblit: | |
523 case TOK.TOKaddass: | |
524 case TOK.TOKminass: | |
525 case TOK.TOKcatass: | |
526 case TOK.TOKmulass: | |
527 case TOK.TOKdivass: | |
528 case TOK.TOKmodass: | |
529 case TOK.TOKshlass: | |
530 case TOK.TOKshrass: | |
531 case TOK.TOKushrass: | |
532 case TOK.TOKandass: | |
533 case TOK.TOKorass: | |
534 case TOK.TOKxorass: | |
535 case TOK.TOKin: | |
536 case TOK.TOKremove: | |
537 return true; | |
538 | |
539 default: | |
540 return Expression.checkSideEffect(flag); | |
541 } | |
542 } | |
543 | |
72 | 544 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 545 { |
546 expToCBuffer(buf, hgs, e1, precedence[op]); | |
547 buf.writeByte(' '); | |
548 buf.writestring(Token.toChars(op)); | |
549 buf.writeByte(' '); | |
550 expToCBuffer(buf, hgs, e2, cast(PREC)(precedence[op] + 1)); | |
551 } | |
552 | |
553 /**************************************** | |
554 * Scale addition/subtraction to/from pointer. | |
555 */ | |
556 Expression scaleFactor(Scope sc) | |
557 { | |
558 ulong stride; | |
559 Type t1b = e1.type.toBasetype(); | |
560 Type t2b = e2.type.toBasetype(); | |
561 | |
562 if (t1b.ty == Tpointer && t2b.isintegral()) | |
563 { | |
564 // Need to adjust operator by the stride | |
565 // Replace (ptr + int) with (ptr + (int * stride)) | |
566 Type t = Type.tptrdiff_t; | |
567 | |
568 stride = t1b.nextOf().size(loc); | |
569 if (!t.equals(t2b)) | |
570 e2 = e2.castTo(sc, t); | |
571 e2 = new MulExp(loc, e2, new IntegerExp(Loc(0), stride, t)); | |
572 e2.type = t; | |
573 type = e1.type; | |
574 } | |
575 else if (t2b.ty == Tpointer && t1b.isintegral()) | |
576 { | |
577 // Need to adjust operator by the stride | |
578 // Replace (int + ptr) with (ptr + (int * stride)) | |
579 Type t = Type.tptrdiff_t; | |
580 Expression e; | |
581 | |
582 stride = t2b.nextOf().size(loc); | |
583 if (!t.equals(t1b)) | |
584 e = e1.castTo(sc, t); | |
585 else | |
586 e = e1; | |
587 e = new MulExp(loc, e, new IntegerExp(Loc(0), stride, t)); | |
588 e.type = t; | |
589 type = e2.type; | |
590 e1 = e2; | |
591 e2 = e; | |
592 } | |
593 return this; | |
594 } | |
595 | |
596 /************************************ | |
597 * Bring leaves to common type. | |
598 */ | |
599 Expression typeCombine(Scope sc) | |
600 { | |
601 Type t1 = e1.type.toBasetype(); | |
602 Type t2 = e2.type.toBasetype(); | |
603 | |
604 if (op == TOK.TOKmin || op == TOK.TOKadd) | |
605 { | |
606 if (t1.ty == TY.Tstruct) | |
607 { | |
608 if (t2.ty == TY.Tstruct && (cast(TypeStruct)t1).sym is (cast(TypeStruct)t2).sym) | |
609 goto Lerror; | |
610 } | |
611 else if (t1.ty == TY.Tclass) | |
612 { | |
613 if (t2.ty == TY.Tclass) | |
614 goto Lerror; | |
615 } | |
616 } | |
617 | |
618 if (!typeMerge(sc, this, &type, &e1, &e2)) | |
619 goto Lerror; | |
620 return this; | |
621 | |
622 Lerror: | |
623 incompatibleTypes(); | |
624 type = Type.terror; | |
625 e1 = new ErrorExp(); | |
626 e2 = new ErrorExp(); | |
627 return this; | |
628 } | |
629 | |
72 | 630 override Expression optimize(int result) |
0 | 631 { |
632 //printf("BinExp.optimize(result = %d) %s\n", result, toChars()); | |
633 if (op != TOK.TOKconstruct && op != TOK.TOKblit) // don't replace const variable with its initializer | |
634 e1 = e1.optimize(result); | |
635 | |
636 e2 = e2.optimize(result); | |
637 if (op == TOK.TOKshlass || op == TOK.TOKshrass || op == TOK.TOKushrass) | |
638 { | |
639 if (e2.isConst() == 1) | |
640 { | |
641 long i2 = e2.toInteger(); | |
642 ulong sz = e1.type.size() * 8; | |
643 | |
644 if (i2 < 0 || i2 > sz) | |
645 { | |
646 error("shift assign by %jd is outside the range 0..%zu", i2, sz); | |
647 e2 = new IntegerExp(0); | |
648 } | |
649 } | |
650 } | |
651 | |
652 return this; | |
653 } | |
654 | |
655 bool isunsigned() | |
656 { | |
657 assert(false); | |
658 } | |
659 | |
660 void incompatibleTypes() | |
661 { | |
662 error("incompatible types for ((%s) %s (%s)): '%s' and '%s'", | |
663 e1.toChars(), Token.toChars(op), e2.toChars(), | |
664 e1.type.toChars(), e2.type.toChars()); | |
665 } | |
666 | |
72 | 667 override void dump(int indent) |
0 | 668 { |
669 assert(false); | |
670 } | |
671 | |
672 void scanForNestedRef(Scope *sc) | |
673 { | |
674 assert(false); | |
675 } | |
676 | |
63 | 677 Expression interpretCommon(InterState istate, Expression *(*fp)(Type *, Expression *, Expression *)) |
0 | 678 { |
679 assert(false); | |
680 } | |
681 | |
63 | 682 Expression interpretCommon2(InterState istate, Expression *(*fp)(TOK, Type *, Expression *, Expression *)) |
0 | 683 { |
684 assert(false); | |
685 } | |
686 | |
63 | 687 Expression interpretAssignCommon(InterState istate, Expression (*fp)(Type, Expression, Expression), int post = 0) |
0 | 688 { |
63 | 689 version (LOG) { |
690 printf("BinExp.interpretAssignCommon() %.*s\n", toChars()); | |
691 } | |
692 Expression e = EXP_CANT_INTERPRET; | |
693 Expression e1 = this.e1; | |
694 | |
695 if (fp) | |
696 { | |
697 if (e1.op == TOKcast) | |
698 { | |
699 CastExp ce = cast(CastExp)e1; | |
700 e1 = ce.e1; | |
701 } | |
702 } | |
703 if (e1 is EXP_CANT_INTERPRET) | |
704 return e1; | |
705 Expression e2 = this.e2.interpret(istate); | |
706 if (e2 is EXP_CANT_INTERPRET) | |
707 return e2; | |
708 | |
709 // Chase down rebinding of out and ref. | |
710 if (e1.op == TOKvar) | |
711 { | |
712 VarExp ve = cast(VarExp)e1; | |
713 VarDeclaration v = ve.var.isVarDeclaration(); | |
714 if (v && v.value && v.value.op == TOKvar) | |
715 { | |
716 VarExp ve2 = cast(VarExp)v.value; | |
717 if (ve2.var.isSymbolDeclaration()) | |
718 { | |
719 // This can happen if v is a struct initialized to | |
720 // 0 using an __initZ SymbolDeclaration from | |
721 // TypeStruct.defaultInit() | |
722 } | |
723 else | |
724 e1 = v.value; | |
725 } | |
726 else if (v && v.value && (v.value.op==TOKindex || v.value.op == TOKdotvar)) | |
727 { | |
728 // It is no longer be a TOKvar, eg when a[4] is passed by ref. | |
729 e1 = v.value; | |
730 } | |
731 } | |
732 | |
733 // To reduce code complexity of handling dotvar expressions, | |
734 // extract the aggregate now. | |
735 Expression aggregate; | |
736 if (e1.op == TOKdotvar) { | |
737 aggregate = (cast(DotVarExp)e1).e1; | |
738 // Get rid of 'this'. | |
739 if (aggregate.op == TOKthis && istate.localThis) | |
740 aggregate = istate.localThis; | |
741 } | |
742 | |
743 /* Assignment to variable of the form: | |
744 * v = e2 | |
745 */ | |
746 if (e1.op == TOKvar) | |
747 { | |
748 VarExp ve = cast(VarExp)e1; | |
749 VarDeclaration v = ve.var.isVarDeclaration(); | |
750 assert(v); | |
751 if (v && v.isDataseg()) | |
752 { | |
753 // Can't modify global or static data | |
754 error("%s cannot be modified at compile time", v.toChars()); | |
755 return EXP_CANT_INTERPRET; | |
756 } | |
757 if (v && !v.isDataseg()) | |
758 { | |
759 Expression ev = v.value; | |
760 if (fp && !ev) | |
761 { | |
762 error("variable %s is used before initialization", v.toChars()); | |
763 return e; | |
764 } | |
765 if (fp) | |
766 e2 = (*fp)(v.type, ev, e2); | |
767 else | |
768 { | |
769 /* Look for special case of struct being initialized with 0. | |
770 */ | |
771 if (v.type.toBasetype().ty == Tstruct && e2.op == TOKint64) | |
772 { | |
773 e2 = v.type.defaultInit(Loc(0)); | |
774 } | |
775 e2 = Cast(v.type, v.type, e2); | |
776 } | |
777 if (e2 is EXP_CANT_INTERPRET) | |
778 return e2; | |
779 | |
780 addVarToInterstate(istate, v); | |
781 v.value = e2; | |
782 e = Cast(type, type, post ? ev : e2); | |
783 } | |
784 } | |
785 else if (e1.op == TOKdotvar && aggregate.op == TOKdotvar) | |
786 { | |
787 // eg v.u.var = e2, v[3].u.var = e2, etc. | |
788 error("Nested struct assignment %s is not yet supported in CTFE", toChars()); | |
789 } | |
790 /* Assignment to struct member of the form: | |
791 * v.var = e2 | |
792 */ | |
793 else if (e1.op == TOKdotvar && aggregate.op == TOKvar) | |
794 { | |
795 VarDeclaration v = (cast(VarExp)aggregate).var.isVarDeclaration(); | |
796 | |
797 if (v.isDataseg()) | |
798 { | |
799 // Can't modify global or static data | |
800 error("%s cannot be modified at compile time", v.toChars()); | |
801 return EXP_CANT_INTERPRET; | |
802 } else { | |
803 // Chase down rebinding of out and ref | |
804 if (v.value && v.value.op == TOKvar) | |
805 { | |
806 VarExp ve2 = cast(VarExp)v.value; | |
807 if (ve2.var.isSymbolDeclaration()) | |
808 { | |
809 // This can happen if v is a struct initialized to | |
810 // 0 using an __initZ SymbolDeclaration from | |
811 // TypeStruct.defaultInit() | |
812 } | |
813 else | |
814 v = ve2.var.isVarDeclaration(); | |
815 assert(v); | |
816 } | |
817 } | |
818 if (fp && !v.value) | |
819 { | |
820 error("variable %s is used before initialization", v.toChars()); | |
821 return e; | |
822 } | |
823 if (v.value is null && v.init.isVoidInitializer()) | |
824 { | |
825 /* Since a void initializer initializes to undefined | |
826 * values, it is valid here to use the default initializer. | |
827 * No attempt is made to determine if someone actually relies | |
828 * on the void value - to do that we'd need a VoidExp. | |
829 * That's probably a good enhancement idea. | |
830 */ | |
831 v.value = v.type.defaultInit(Loc(0)); | |
832 } | |
833 Expression vie = v.value; | |
834 if (vie.op == TOKvar) | |
835 { | |
836 Declaration d = (cast(VarExp)vie).var; | |
837 vie = getVarExp(e1.loc, istate, d); | |
838 } | |
839 if (vie.op != TOKstructliteral) | |
840 return EXP_CANT_INTERPRET; | |
841 StructLiteralExp se = cast(StructLiteralExp)vie; | |
842 VarDeclaration vf = (cast(DotVarExp)e1).var.isVarDeclaration(); | |
843 if (!vf) | |
844 return EXP_CANT_INTERPRET; | |
845 int fieldi = se.getFieldIndex(type, vf.offset); | |
846 if (fieldi == -1) | |
847 return EXP_CANT_INTERPRET; | |
848 Expression ev = se.getField(type, vf.offset); | |
849 if (fp) | |
850 e2 = (*fp)(type, ev, e2); | |
851 else | |
852 e2 = Cast(type, type, e2); | |
853 if (e2 is EXP_CANT_INTERPRET) | |
854 return e2; | |
855 | |
856 addVarToInterstate(istate, v); | |
857 | |
858 /* Create new struct literal reflecting updated fieldi | |
859 */ | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
860 auto expsx = changeOneElement(se.elements, fieldi, e2); |
63 | 861 v.value = new StructLiteralExp(se.loc, se.sd, expsx); |
862 v.value.type = se.type; | |
863 | |
864 e = Cast(type, type, post ? ev : e2); | |
865 } | |
866 /* Assignment to struct member of the form: | |
867 * *(symoffexp) = e2 | |
868 */ | |
869 else if (e1.op == TOKstar && (cast(PtrExp)e1).e1.op == TOKsymoff) | |
870 { | |
871 SymOffExp soe = cast(SymOffExp)(cast(PtrExp)e1).e1; | |
872 VarDeclaration v = soe.var.isVarDeclaration(); | |
873 | |
874 if (v.isDataseg()) | |
875 { | |
876 error("%s cannot be modified at compile time", v.toChars()); | |
877 return EXP_CANT_INTERPRET; | |
878 } | |
879 if (fp && !v.value) | |
880 { | |
881 error("variable %s is used before initialization", v.toChars()); | |
882 return e; | |
883 } | |
884 Expression vie = v.value; | |
885 if (vie.op == TOKvar) | |
886 { | |
887 Declaration d = (cast(VarExp)vie).var; | |
888 vie = getVarExp(e1.loc, istate, d); | |
889 } | |
890 if (vie.op != TOKstructliteral) | |
891 return EXP_CANT_INTERPRET; | |
892 StructLiteralExp se = cast(StructLiteralExp)vie; | |
893 int fieldi = se.getFieldIndex(type, soe.offset); | |
894 if (fieldi == -1) | |
895 return EXP_CANT_INTERPRET; | |
896 Expression ev = se.getField(type, soe.offset); | |
897 if (fp) | |
898 e2 = (*fp)(type, ev, e2); | |
899 else | |
900 e2 = Cast(type, type, e2); | |
901 if (e2 is EXP_CANT_INTERPRET) | |
902 return e2; | |
903 | |
904 addVarToInterstate(istate, v); | |
905 | |
906 /* Create new struct literal reflecting updated fieldi | |
907 */ | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
908 auto expsx = changeOneElement(se.elements, fieldi, e2); |
63 | 909 v.value = new StructLiteralExp(se.loc, se.sd, expsx); |
910 v.value.type = se.type; | |
911 | |
912 e = Cast(type, type, post ? ev : e2); | |
913 } | |
914 /* Assignment to array element of the form: | |
915 * a[i] = e2 | |
916 */ | |
917 else if (e1.op == TOKindex && (cast(IndexExp)e1).e1.op == TOKvar) | |
918 { | |
919 IndexExp ie = cast(IndexExp)e1; | |
920 VarExp ve = cast(VarExp)ie.e1; | |
921 VarDeclaration v = ve.var.isVarDeclaration(); | |
922 if (!v || v.isDataseg()) | |
923 { | |
924 error("%s cannot be modified at compile time", v ? v.toChars(): "void"); | |
925 return EXP_CANT_INTERPRET; | |
926 } | |
927 if (v.value && v.value.op == TOKvar) | |
928 { | |
929 VarExp ve2 = cast(VarExp)v.value; | |
930 if (ve2.var.isSymbolDeclaration()) | |
931 { | |
932 // This can happen if v is a struct initialized to | |
933 // 0 using an __initZ SymbolDeclaration from | |
934 // TypeStruct.defaultInit() | |
935 } | |
936 else | |
937 v = ve2.var.isVarDeclaration(); | |
938 assert(v); | |
939 } | |
940 if (!v.value) | |
941 { | |
942 if (fp) | |
943 { | |
944 error("variable %s is used before initialization", v.toChars()); | |
945 return e; | |
946 } | |
947 | |
948 Type t = v.type.toBasetype(); | |
949 if (t.ty == Tsarray) | |
950 { | |
951 /* This array was void initialized. Create a | |
952 * default initializer for it. | |
953 * What we should do is fill the array literal with | |
954 * null data, so use-before-initialized can be detected. | |
955 * But we're too lazy at the moment to do it, as that | |
956 * involves redoing Index() and whoever calls it. | |
957 */ | |
958 | |
959 size_t dim = cast(size_t)(cast(TypeSArray)t).dim.toInteger(); | |
960 v.value = createBlockDuplicatedArrayLiteral(v.type, | |
961 v.type.defaultInit(Loc(0)), dim); | |
962 } | |
963 else | |
964 return EXP_CANT_INTERPRET; | |
965 } | |
966 | |
967 ArrayLiteralExp ae = null; | |
968 AssocArrayLiteralExp aae = null; | |
969 StringExp se = null; | |
970 if (v.value.op == TOKarrayliteral) | |
971 ae = cast(ArrayLiteralExp)v.value; | |
972 else if (v.value.op == TOKassocarrayliteral) | |
973 aae = cast(AssocArrayLiteralExp)v.value; | |
974 else if (v.value.op == TOKstring) | |
975 se = cast(StringExp)v.value; | |
976 else if (v.value.op == TOKnull) | |
977 { | |
978 // This would be a runtime segfault | |
979 error("Cannot index null array %.*s", v.toChars()); | |
980 return EXP_CANT_INTERPRET; | |
981 } | |
982 else | |
983 return EXP_CANT_INTERPRET; | |
984 | |
985 /* Set the $ variable | |
986 */ | |
987 Expression ee = ArrayLength(Type.tsize_t, v.value); | |
988 if (ee !is EXP_CANT_INTERPRET && ie.lengthVar) | |
989 ie.lengthVar.value = ee; | |
990 Expression index = ie.e2.interpret(istate); | |
991 if (index is EXP_CANT_INTERPRET) | |
992 return EXP_CANT_INTERPRET; | |
993 Expression ev; | |
994 if (fp || ae || se) // not for aae, because key might not be there | |
995 { | |
996 ev = Index(type, v.value, index); | |
997 if (ev is EXP_CANT_INTERPRET) | |
998 return EXP_CANT_INTERPRET; | |
999 } | |
1000 | |
1001 if (fp) | |
1002 e2 = (*fp)(type, ev, e2); | |
1003 else | |
1004 e2 = Cast(type, type, e2); | |
1005 if (e2 is EXP_CANT_INTERPRET) | |
1006 return e2; | |
1007 | |
1008 addVarToInterstate(istate, v); | |
1009 if (ae) | |
1010 { | |
1011 /* Create new array literal reflecting updated elem | |
1012 */ | |
1013 int elemi = cast(int)index.toInteger(); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1014 auto expsx = changeOneElement(ae.elements, elemi, e2); |
63 | 1015 v.value = new ArrayLiteralExp(ae.loc, expsx); |
1016 v.value.type = ae.type; | |
1017 } | |
1018 else if (aae) | |
1019 { | |
1020 /* Create new associative array literal reflecting updated key/value | |
1021 */ | |
1022 Expressions keysx = aae.keys; | |
1023 Expressions valuesx = new Expressions(); | |
1024 valuesx.setDim(aae.values.dim); | |
1025 int updated = 0; | |
1026 for (size_t j = valuesx.dim; j; ) | |
1027 { | |
1028 j--; | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1029 Expression ekey = aae.keys[j]; |
63 | 1030 Expression ex = Equal(TOKequal, Type.tbool, ekey, index); |
1031 if (ex is EXP_CANT_INTERPRET) | |
1032 return EXP_CANT_INTERPRET; | |
1033 if (ex.isBool(true)) | |
1034 { | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1035 valuesx[j] = e2; |
63 | 1036 updated = 1; |
1037 } | |
1038 else | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1039 valuesx[j] = aae.values[j]; |
63 | 1040 } |
1041 if (!updated) | |
1042 { | |
1043 // Append index/e2 to keysx[]/valuesx[] | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1044 valuesx.push(e2); |
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1045 keysx = keysx.copy(); |
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1046 keysx.push(index); |
63 | 1047 } |
1048 v.value = new AssocArrayLiteralExp(aae.loc, keysx, valuesx); | |
1049 v.value.type = aae.type; | |
1050 } | |
1051 else if (se) | |
1052 { | |
1053 /* Create new string literal reflecting updated elem | |
1054 */ | |
1055 int elemi = cast(int)index.toInteger(); | |
1056 char* s; | |
1057 s = cast(char*)calloc(se.len + 1, se.sz); | |
1058 memcpy(s, se.string_, se.len * se.sz); | |
1059 dchar value = cast(dchar)e2.toInteger(); | |
1060 switch (se.sz) | |
1061 { | |
1062 case 1: s[elemi] = cast(char)value; break; | |
1063 case 2: (cast(wchar*)s)[elemi] = cast(wchar)value; break; | |
1064 case 4: (cast(dchar*)s)[elemi] = value; break; | |
1065 default: | |
1066 assert(0); | |
1067 break; | |
1068 } | |
1069 StringExp se2 = new StringExp(se.loc, assumeUnique(s[0..se.len])); | |
1070 se2.committed = se.committed; | |
1071 se2.postfix = se.postfix; | |
1072 se2.type = se.type; | |
1073 v.value = se2; | |
1074 } | |
1075 else | |
1076 assert(0); | |
1077 | |
1078 e = Cast(type, type, post ? ev : e2); | |
1079 } | |
1080 | |
1081 /* Assignment to struct element in array, of the form: | |
1082 * a[i].var = e2 | |
1083 */ | |
1084 else if (e1.op == TOKdotvar && aggregate.op == TOKindex && | |
1085 (cast(IndexExp)aggregate).e1.op == TOKvar) | |
1086 { | |
1087 IndexExp ie = cast(IndexExp)aggregate; | |
1088 VarExp ve = cast(VarExp)(ie.e1); | |
1089 VarDeclaration v = ve.var.isVarDeclaration(); | |
1090 if (!v || v.isDataseg()) | |
1091 { | |
1092 error("%s cannot be modified at compile time", v ? v.toChars(): "void"); | |
1093 return EXP_CANT_INTERPRET; | |
1094 } | |
1095 Type t = ve.type.toBasetype(); | |
1096 ArrayLiteralExp ae = cast(ArrayLiteralExp)v.value; | |
1097 if (!ae) | |
1098 { | |
1099 // assignment to one element in an uninitialized (static) array. | |
1100 // This is quite difficult, because defaultInit() for a struct is a VarExp, | |
1101 // not a StructLiteralExp. | |
1102 Type t2 = v.type.toBasetype(); | |
1103 if (t2.ty != Tsarray) | |
1104 { | |
1105 error("Cannot index an uninitialized variable"); | |
1106 return EXP_CANT_INTERPRET; | |
1107 } | |
1108 | |
1109 Type telem = (cast(TypeSArray)t2).nextOf().toBasetype(); | |
1110 if (telem.ty != Tstruct) { return EXP_CANT_INTERPRET; } | |
1111 | |
1112 // Create a default struct literal... | |
1113 StructDeclaration sym = (cast(TypeStruct)telem).sym; | |
1114 StructLiteralExp structinit = createDefaultInitStructLiteral(v.loc, sym); | |
1115 | |
1116 // ... and use to create a blank array literal | |
1117 size_t dim = cast(size_t)(cast(TypeSArray)t2).dim.toInteger(); | |
1118 ae = createBlockDuplicatedArrayLiteral(v.type, structinit, dim); | |
1119 v.value = ae; | |
1120 } | |
1121 if (cast(Expression)(ae.elements) is EXP_CANT_INTERPRET) | |
1122 { | |
1123 // Note that this would be a runtime segfault | |
1124 error("Cannot index null array %s", v.toChars()); | |
1125 return EXP_CANT_INTERPRET; | |
1126 } | |
1127 // Set the $ variable | |
1128 Expression ee = ArrayLength(Type.tsize_t, v.value); | |
1129 if (ee !is EXP_CANT_INTERPRET && ie.lengthVar) | |
1130 ie.lengthVar.value = ee; | |
1131 // Determine the index, and check that it's OK. | |
1132 Expression index = ie.e2.interpret(istate); | |
1133 if (index is EXP_CANT_INTERPRET) | |
1134 return EXP_CANT_INTERPRET; | |
1135 | |
1136 int elemi = cast(int)index.toInteger(); | |
1137 if (elemi >= ae.elements.dim) | |
1138 { | |
1139 error("array index %d is out of bounds %s[0..%d]", elemi, | |
1140 v.toChars(), ae.elements.dim); | |
1141 return EXP_CANT_INTERPRET; | |
1142 } | |
1143 // Get old element | |
1144 Expression vie = cast(Expression)(ae.elements.data[elemi]); | |
1145 if (vie.op != TOKstructliteral) | |
1146 return EXP_CANT_INTERPRET; | |
1147 | |
1148 // Work out which field needs to be changed | |
1149 StructLiteralExp se = cast(StructLiteralExp)vie; | |
1150 VarDeclaration vf = (cast(DotVarExp)e1).var.isVarDeclaration(); | |
1151 if (!vf) | |
1152 return EXP_CANT_INTERPRET; | |
1153 | |
1154 int fieldi = se.getFieldIndex(type, vf.offset); | |
1155 if (fieldi == -1) | |
1156 return EXP_CANT_INTERPRET; | |
1157 | |
1158 Expression ev = se.getField(type, vf.offset); | |
1159 if (fp) | |
1160 e2 = (*fp)(type, ev, e2); | |
1161 else | |
1162 e2 = Cast(type, type, e2); | |
1163 if (e2 == EXP_CANT_INTERPRET) | |
1164 return e2; | |
1165 | |
1166 // Create new struct literal reflecting updated field | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1167 auto expsx = changeOneElement(se.elements, fieldi, e2); |
63 | 1168 Expression newstruct = new StructLiteralExp(se.loc, se.sd, expsx); |
1169 | |
1170 // Create new array literal reflecting updated struct elem | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1171 ae.elements = changeOneElement(ae.elements, elemi, newstruct); |
63 | 1172 return ae; |
1173 } | |
1174 /* Slice assignment, initialization of static arrays | |
1175 * a[] = e | |
1176 */ | |
1177 else if (e1.op == TOKslice && (cast(SliceExp)e1).e1.op == TOKvar) | |
1178 { | |
1179 SliceExp sexp = cast(SliceExp)e1; | |
1180 VarExp ve = cast(VarExp)(sexp.e1); | |
1181 VarDeclaration v = ve.var.isVarDeclaration(); | |
1182 if (!v || v.isDataseg()) | |
1183 { | |
1184 error("%s cannot be modified at compile time", v.toChars()); | |
1185 return EXP_CANT_INTERPRET; | |
1186 } | |
1187 // Chase down rebinding of out and ref | |
1188 if (v.value && v.value.op == TOKvar) | |
1189 { | |
1190 VarExp ve2 = cast(VarExp)v.value; | |
1191 if (ve2.var.isSymbolDeclaration()) | |
1192 { | |
1193 // This can happen if v is a struct initialized to | |
1194 // 0 using an __initZ SymbolDeclaration from | |
1195 // TypeStruct.defaultInit() | |
1196 } | |
1197 else | |
1198 v = ve2.var.isVarDeclaration(); | |
1199 assert(v); | |
1200 } | |
1201 /* Set the $ variable | |
1202 */ | |
1203 Expression ee = v.value ? ArrayLength(Type.tsize_t, v.value) | |
1204 : EXP_CANT_INTERPRET; | |
1205 if (ee !is EXP_CANT_INTERPRET && sexp.lengthVar) | |
1206 sexp.lengthVar.value = ee; | |
1207 Expression upper = null; | |
1208 Expression lower = null; | |
1209 if (sexp.upr) | |
1210 { | |
1211 upper = sexp.upr.interpret(istate); | |
1212 if (upper is EXP_CANT_INTERPRET) | |
1213 return EXP_CANT_INTERPRET; | |
1214 } | |
1215 if (sexp.lwr) | |
1216 { | |
1217 lower = sexp.lwr.interpret(istate); | |
1218 if (lower is EXP_CANT_INTERPRET) | |
1219 return EXP_CANT_INTERPRET; | |
1220 } | |
1221 Type t = v.type.toBasetype(); | |
1222 size_t dim; | |
1223 if (t.ty == Tsarray) | |
1224 dim = cast(size_t)(cast(TypeSArray)t).dim.toInteger(); | |
1225 else if (t.ty == Tarray) | |
1226 { | |
1227 if (!v.value || v.value.op == TOKnull) | |
1228 { | |
1229 error("cannot assign to null array %s", v.toChars()); | |
1230 return EXP_CANT_INTERPRET; | |
1231 } | |
1232 if (v.value.op == TOKarrayliteral) | |
1233 dim = (cast(ArrayLiteralExp)v.value).elements.dim; | |
1234 else if (v.value.op ==TOKstring) | |
1235 { | |
1236 error("String slice assignment is not yet supported in CTFE"); | |
1237 return EXP_CANT_INTERPRET; | |
1238 } | |
1239 } | |
1240 else | |
1241 { | |
1242 error("%s cannot be evaluated at compile time", toChars()); | |
1243 return EXP_CANT_INTERPRET; | |
1244 } | |
1245 int upperbound = upper ? cast(int)upper.toInteger() : dim; | |
1246 int lowerbound = lower ? cast(int)lower.toInteger() : 0; | |
1247 | |
1248 ArrayLiteralExp existing; | |
1249 if ((cast(int)lowerbound < 0) || (upperbound > dim)) | |
1250 { | |
1251 error("Array bounds [0..%d] exceeded in slice [%d..%d]", dim, lowerbound, upperbound); | |
1252 return EXP_CANT_INTERPRET; | |
1253 } | |
1254 if (upperbound-lowerbound != dim) | |
1255 { | |
1256 // Only modifying part of the array. Must create a new array literal. | |
1257 // If the existing array is uninitialized (this can only happen | |
1258 // with static arrays), create it. | |
1259 if (v.value && v.value.op == TOKarrayliteral) | |
1260 existing = cast(ArrayLiteralExp)v.value; | |
1261 else | |
1262 { | |
1263 // this can only happen with static arrays | |
1264 existing = createBlockDuplicatedArrayLiteral(v.type, v.type.defaultInit(Loc(0)), dim); | |
1265 } | |
1266 } | |
1267 | |
1268 if (e2.op == TOKarrayliteral) | |
1269 { | |
1270 // Static array assignment from literal | |
1271 ArrayLiteralExp ae = cast(ArrayLiteralExp)e2; | |
1272 if (ae.elements.dim != (upperbound - lowerbound)) | |
1273 { | |
1274 error("Array length mismatch assigning [0..%d] to [%d..%d]", ae.elements.dim, lowerbound, upperbound); | |
1275 return e; | |
1276 } | |
1277 if (upperbound - lowerbound == dim) | |
1278 v.value = ae; | |
1279 else | |
1280 { | |
1281 // value[] = value[0..lower] ~ ae ~ value[upper..$] | |
1282 existing.elements = spliceElements(existing.elements, ae.elements, lowerbound); | |
1283 v.value = existing; | |
1284 } | |
1285 return e2; | |
1286 } | |
1287 else if (t.nextOf().ty == e2.type.ty) | |
1288 { | |
1289 // Static array block assignment | |
1290 if (upperbound-lowerbound ==dim) | |
1291 v.value = createBlockDuplicatedArrayLiteral(v.type, e2, dim); | |
1292 else | |
1293 { | |
1294 // value[] = value[0..lower] ~ ae ~ value[upper..$] | |
1295 existing.elements = spliceElements(existing.elements, createBlockDuplicatedArrayLiteral(v.type, e2, upperbound-lowerbound).elements, lowerbound); | |
1296 v.value = existing; | |
1297 } | |
1298 return e2; | |
1299 } | |
1300 else if (e2.op == TOKstring) | |
1301 { | |
1302 StringExp se = cast(StringExp)e2; | |
1303 // This is problematic. char[8] should be storing | |
1304 // values as a string literal, not | |
1305 // as an array literal. Then, for static arrays, we | |
1306 // could do modifications | |
1307 // in-place, with a dramatic memory and speed improvement. | |
1308 error("String slice assignment is not yet supported in CTFE"); | |
1309 return e2; | |
1310 } | |
1311 else | |
1312 { | |
1313 error("Slice operation %s cannot be evaluated at compile time", toChars()); | |
1314 return e; | |
1315 } | |
1316 } | |
1317 else | |
1318 { | |
1319 error("%s cannot be evaluated at compile time", toChars()); | |
1320 version (DEBUG) { | |
1321 dump(0); | |
1322 } | |
1323 } | |
1324 return e; | |
0 | 1325 } |
1326 | |
72 | 1327 override bool canThrow() |
0 | 1328 { |
1329 return e1.canThrow() || e2.canThrow(); | |
1330 } | |
73 | 1331 |
1332 // generate an error if this is a nonsensical *=,/=, or %=, eg real *= imaginary | |
1333 void checkComplexMulAssign() | |
1334 { | |
1335 // Any multiplication by an imaginary or complex number yields a complex result. | |
1336 // r *= c, i*=c, r*=i, i*=i are all forbidden operations. | |
1337 string opstr = Token.toChars(op); | |
1338 if ( e1.type.isreal() && e2.type.iscomplex()) | |
1339 { | |
1340 error("%s %s %s is undefined. Did you mean %s %s %s.re ?", | |
1341 e1.type.toChars(), opstr, e2.type.toChars(), | |
1342 e1.type.toChars(), opstr, e2.type.toChars()); | |
1343 } | |
1344 else if (e1.type.isimaginary() && e2.type.iscomplex()) | |
1345 { | |
1346 error("%s %s %s is undefined. Did you mean %s %s %s.im ?", | |
1347 e1.type.toChars(), opstr, e2.type.toChars(), | |
1348 e1.type.toChars(), opstr, e2.type.toChars()); | |
1349 } | |
1350 else if ((e1.type.isreal() || e1.type.isimaginary()) && e2.type.isimaginary()) | |
1351 { | |
1352 error("%s %s %s is an undefined operation", e1.type.toChars(), | |
1353 opstr, e2.type.toChars()); | |
1354 } | |
1355 } | |
1356 | |
1357 // generate an error if this is a nonsensical += or -=, eg real += imaginary | |
1358 void checkComplexAddAssign() | |
1359 { | |
1360 // Addition or subtraction of a real and an imaginary is a complex result. | |
1361 // Thus, r+=i, r+=c, i+=r, i+=c are all forbidden operations. | |
1362 if ( (e1.type.isreal() && (e2.type.isimaginary() || e2.type.iscomplex())) || | |
1363 (e1.type.isimaginary() && (e2.type.isreal() || e2.type.iscomplex())) | |
1364 ) | |
1365 { | |
1366 error("%s %s %s is undefined (result is complex)", | |
1367 e1.type.toChars(), Token.toChars(op), e2.type.toChars()); | |
1368 } | |
1369 } | |
1370 | |
0 | 1371 |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1372 /*********************************** |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1373 * Construct the array operation expression. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1374 */ |
0 | 1375 Expression arrayOp(Scope sc) |
1376 { | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1377 //printf("BinExp.arrayOp() %s\n", toChars()); |
73 | 1378 |
1379 if (type.toBasetype().nextOf().toBasetype().ty == Tvoid) | |
1380 { | |
1381 error("Cannot perform array operations on void[] arrays"); | |
1382 return new ErrorExp(); | |
1383 } | |
79 | 1384 |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1385 Expressions arguments = new Expressions(); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1386 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1387 /* The expression to generate an array operation for is mangled |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1388 * into a name to use as the array operation function name. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1389 * Mangle in the operands and operators in RPN order, and type. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1390 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1391 scope OutBuffer buf = new OutBuffer(); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1392 buf.writestring("_array"); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1393 buildArrayIdent(buf, arguments); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1394 buf.writeByte('_'); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1395 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1396 /* Append deco of array element type |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1397 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1398 version (DMDV2) { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1399 buf.writestring(type.toBasetype().nextOf().toBasetype().mutableOf().deco); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1400 } else { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1401 buf.writestring(type.toBasetype().nextOf().toBasetype().deco); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1402 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1403 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1404 size_t namelen = buf.offset; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1405 buf.writeByte(0); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1406 immutable(char)* name = cast(immutable(char)*)buf.extractData(); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1407 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1408 /* Look up name in hash table |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1409 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1410 if (arrayfuncs is null) arrayfuncs = new StringTable(); /// HACK! |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1411 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1412 StringValue* sv = arrayfuncs.update(name[0..namelen]); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1413 FuncDeclaration fd = cast(FuncDeclaration)sv.ptrvalue; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1414 if (!fd) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1415 { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1416 /* Some of the array op functions are written as library functions, |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1417 * presumably to optimize them with special CPU vector instructions. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1418 * List those library functions here, in alpha order. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1419 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1420 static const(char)*[] libArrayopFuncs = |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1421 [ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1422 "_arrayExpSliceAddass_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1423 "_arrayExpSliceAddass_d", // T[]+=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1424 "_arrayExpSliceAddass_f", // T[]+=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1425 "_arrayExpSliceAddass_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1426 "_arrayExpSliceAddass_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1427 "_arrayExpSliceAddass_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1428 "_arrayExpSliceAddass_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1429 "_arrayExpSliceAddass_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1430 "_arrayExpSliceAddass_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1431 "_arrayExpSliceAddass_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1432 "_arrayExpSliceAddass_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1433 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1434 "_arrayExpSliceDivass_d", // T[]/=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1435 "_arrayExpSliceDivass_f", // T[]/=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1436 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1437 "_arrayExpSliceMinSliceAssign_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1438 "_arrayExpSliceMinSliceAssign_d", // T[]=T-T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1439 "_arrayExpSliceMinSliceAssign_f", // T[]=T-T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1440 "_arrayExpSliceMinSliceAssign_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1441 "_arrayExpSliceMinSliceAssign_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1442 "_arrayExpSliceMinSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1443 "_arrayExpSliceMinSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1444 "_arrayExpSliceMinSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1445 "_arrayExpSliceMinSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1446 "_arrayExpSliceMinSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1447 "_arrayExpSliceMinSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1448 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1449 "_arrayExpSliceMinass_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1450 "_arrayExpSliceMinass_d", // T[]-=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1451 "_arrayExpSliceMinass_f", // T[]-=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1452 "_arrayExpSliceMinass_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1453 "_arrayExpSliceMinass_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1454 "_arrayExpSliceMinass_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1455 "_arrayExpSliceMinass_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1456 "_arrayExpSliceMinass_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1457 "_arrayExpSliceMinass_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1458 "_arrayExpSliceMinass_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1459 "_arrayExpSliceMinass_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1460 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1461 "_arrayExpSliceMulass_d", // T[]*=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1462 "_arrayExpSliceMulass_f", // T[]*=T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1463 "_arrayExpSliceMulass_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1464 "_arrayExpSliceMulass_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1465 "_arrayExpSliceMulass_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1466 "_arrayExpSliceMulass_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1467 "_arrayExpSliceMulass_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1468 "_arrayExpSliceMulass_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1469 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1470 "_arraySliceExpAddSliceAssign_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1471 "_arraySliceExpAddSliceAssign_d", // T[]=T[]+T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1472 "_arraySliceExpAddSliceAssign_f", // T[]=T[]+T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1473 "_arraySliceExpAddSliceAssign_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1474 "_arraySliceExpAddSliceAssign_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1475 "_arraySliceExpAddSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1476 "_arraySliceExpAddSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1477 "_arraySliceExpAddSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1478 "_arraySliceExpAddSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1479 "_arraySliceExpAddSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1480 "_arraySliceExpAddSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1481 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1482 "_arraySliceExpDivSliceAssign_d", // T[]=T[]/T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1483 "_arraySliceExpDivSliceAssign_f", // T[]=T[]/T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1484 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1485 "_arraySliceExpMinSliceAssign_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1486 "_arraySliceExpMinSliceAssign_d", // T[]=T[]-T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1487 "_arraySliceExpMinSliceAssign_f", // T[]=T[]-T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1488 "_arraySliceExpMinSliceAssign_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1489 "_arraySliceExpMinSliceAssign_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1490 "_arraySliceExpMinSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1491 "_arraySliceExpMinSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1492 "_arraySliceExpMinSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1493 "_arraySliceExpMinSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1494 "_arraySliceExpMinSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1495 "_arraySliceExpMinSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1496 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1497 "_arraySliceExpMulSliceAddass_d", // T[] += T[]*T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1498 "_arraySliceExpMulSliceAddass_f", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1499 "_arraySliceExpMulSliceAddass_r", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1500 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1501 "_arraySliceExpMulSliceAssign_d", // T[]=T[]*T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1502 "_arraySliceExpMulSliceAssign_f", // T[]=T[]*T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1503 "_arraySliceExpMulSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1504 "_arraySliceExpMulSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1505 "_arraySliceExpMulSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1506 "_arraySliceExpMulSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1507 "_arraySliceExpMulSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1508 "_arraySliceExpMulSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1509 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1510 "_arraySliceExpMulSliceMinass_d", // T[] -= T[]*T |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1511 "_arraySliceExpMulSliceMinass_f", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1512 "_arraySliceExpMulSliceMinass_r", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1513 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1514 "_arraySliceSliceAddSliceAssign_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1515 "_arraySliceSliceAddSliceAssign_d", // T[]=T[]+T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1516 "_arraySliceSliceAddSliceAssign_f", // T[]=T[]+T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1517 "_arraySliceSliceAddSliceAssign_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1518 "_arraySliceSliceAddSliceAssign_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1519 "_arraySliceSliceAddSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1520 "_arraySliceSliceAddSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1521 "_arraySliceSliceAddSliceAssign_r", // T[]=T[]+T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1522 "_arraySliceSliceAddSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1523 "_arraySliceSliceAddSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1524 "_arraySliceSliceAddSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1525 "_arraySliceSliceAddSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1526 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1527 "_arraySliceSliceAddass_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1528 "_arraySliceSliceAddass_d", // T[]+=T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1529 "_arraySliceSliceAddass_f", // T[]+=T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1530 "_arraySliceSliceAddass_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1531 "_arraySliceSliceAddass_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1532 "_arraySliceSliceAddass_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1533 "_arraySliceSliceAddass_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1534 "_arraySliceSliceAddass_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1535 "_arraySliceSliceAddass_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1536 "_arraySliceSliceAddass_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1537 "_arraySliceSliceAddass_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1538 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1539 "_arraySliceSliceMinSliceAssign_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1540 "_arraySliceSliceMinSliceAssign_d", // T[]=T[]-T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1541 "_arraySliceSliceMinSliceAssign_f", // T[]=T[]-T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1542 "_arraySliceSliceMinSliceAssign_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1543 "_arraySliceSliceMinSliceAssign_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1544 "_arraySliceSliceMinSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1545 "_arraySliceSliceMinSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1546 "_arraySliceSliceMinSliceAssign_r", // T[]=T[]-T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1547 "_arraySliceSliceMinSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1548 "_arraySliceSliceMinSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1549 "_arraySliceSliceMinSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1550 "_arraySliceSliceMinSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1551 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1552 "_arraySliceSliceMinass_a", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1553 "_arraySliceSliceMinass_d", // T[]-=T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1554 "_arraySliceSliceMinass_f", // T[]-=T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1555 "_arraySliceSliceMinass_g", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1556 "_arraySliceSliceMinass_h", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1557 "_arraySliceSliceMinass_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1558 "_arraySliceSliceMinass_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1559 "_arraySliceSliceMinass_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1560 "_arraySliceSliceMinass_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1561 "_arraySliceSliceMinass_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1562 "_arraySliceSliceMinass_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1563 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1564 "_arraySliceSliceMulSliceAssign_d", // T[]=T[]*T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1565 "_arraySliceSliceMulSliceAssign_f", // T[]=T[]*T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1566 "_arraySliceSliceMulSliceAssign_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1567 "_arraySliceSliceMulSliceAssign_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1568 "_arraySliceSliceMulSliceAssign_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1569 "_arraySliceSliceMulSliceAssign_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1570 "_arraySliceSliceMulSliceAssign_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1571 "_arraySliceSliceMulSliceAssign_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1572 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1573 "_arraySliceSliceMulass_d", // T[]*=T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1574 "_arraySliceSliceMulass_f", // T[]*=T[] |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1575 "_arraySliceSliceMulass_i", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1576 "_arraySliceSliceMulass_k", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1577 "_arraySliceSliceMulass_s", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1578 "_arraySliceSliceMulass_t", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1579 "_arraySliceSliceMulass_u", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1580 "_arraySliceSliceMulass_w", |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1581 ]; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1582 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1583 int i = binary(name, libArrayopFuncs.ptr, libArrayopFuncs.length); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1584 if (i == -1) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1585 { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1586 debug { // Make sure our array is alphabetized |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1587 for (i = 0; i < libArrayopFuncs.length; i++) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1588 { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1589 if (strcmp(name, libArrayopFuncs[i]) == 0) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1590 assert(false); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1591 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1592 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1593 /* Not in library, so generate it. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1594 * Construct the function body: |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1595 * foreach (i; 0 .. p.length) for (size_t i = 0; i < p.length; i++) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1596 * loopbody; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1597 * return p; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1598 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1599 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1600 Arguments fparams = new Arguments(); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1601 Expression loopbody = buildArrayLoop(fparams); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1602 Argument p = cast(Argument)fparams.data[0 /*fparams.dim - 1*/]; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1603 version (DMDV1) { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1604 // for (size_t i = 0; i < p.length; i++) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1605 Initializer init = new ExpInitializer(0, new IntegerExp(0, 0, Type.tsize_t)); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1606 Dsymbol d = new VarDeclaration(0, Type.tsize_t, Id.p, init); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1607 Statement s1 = new ForStatement(0, |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1608 new DeclarationStatement(0, d), |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1609 new CmpExp(TOKlt, 0, new IdentifierExp(0, Id.p), new ArrayLengthExp(0, new IdentifierExp(0, p.ident))), |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1610 new PostExp(TOKplusplus, 0, new IdentifierExp(0, Id.p)), |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1611 new ExpStatement(0, loopbody)); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1612 } else { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1613 // foreach (i; 0 .. p.length) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1614 Statement s1 = new ForeachRangeStatement(Loc(0), TOKforeach, |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1615 new Argument(STC.STCundefined, null, Id.p, null), |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1616 new IntegerExp(Loc(0), 0, Type.tint32), |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1617 new ArrayLengthExp(Loc(0), new IdentifierExp(Loc(0), p.ident)), |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1618 new ExpStatement(Loc(0), loopbody)); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1619 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1620 Statement s2 = new ReturnStatement(Loc(0), new IdentifierExp(Loc(0), p.ident)); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1621 //printf("s2: %s\n", s2.toChars()); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1622 Statement fbody = new CompoundStatement(Loc(0), s1, s2); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1623 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1624 /* Construct the function |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1625 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1626 TypeFunction ftype = new TypeFunction(fparams, type, 0, LINKc); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1627 //printf("ftype: %s\n", ftype.toChars()); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1628 fd = new FuncDeclaration(Loc(0), Loc(0), Lexer.idPool(name[0..namelen]), STCundefined, ftype); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1629 fd.fbody = fbody; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1630 fd.protection = PROT.PROTpublic; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1631 fd.linkage = LINKc; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1632 |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
1633 sc.module_.importedFrom.members.push(fd); |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1634 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1635 sc = sc.push(); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1636 sc.parent = sc.module_.importedFrom; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1637 sc.stc = STCundefined; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1638 sc.linkage = LINKc; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1639 fd.semantic(sc); |
79 | 1640 fd.semantic2(sc); |
1641 fd.semantic3(sc); | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1642 sc.pop(); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1643 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1644 else |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1645 { /* In library, refer to it. |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1646 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1647 fd = FuncDeclaration.genCfunc(type, name[0..namelen]); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1648 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1649 sv.ptrvalue = cast(void*)fd; // cache symbol in hash table |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1650 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1651 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1652 /* Call the function fd(arguments) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1653 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1654 Expression ec = new VarExp(Loc(0), fd); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1655 Expression e = new CallExp(loc, ec, arguments); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1656 e.type = type; |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1657 return e; |
0 | 1658 } |
1659 | |
72 | 1660 override int inlineCost(InlineCostState* ics) |
0 | 1661 { |
1662 return 1 + e1.inlineCost(ics) + e2.inlineCost(ics); | |
1663 } | |
1664 | |
72 | 1665 override Expression doInline(InlineDoState ids) |
0 | 1666 { |
1667 BinExp be = cast(BinExp)copy(); | |
1668 | |
1669 be.e1 = e1.doInline(ids); | |
1670 be.e2 = e2.doInline(ids); | |
1671 return be; | |
1672 } | |
1673 | |
72 | 1674 override Expression inlineScan(InlineScanState* iss) |
0 | 1675 { |
1676 e1 = e1.inlineScan(iss); | |
1677 e2 = e2.inlineScan(iss); | |
1678 return this; | |
1679 } | |
1680 | |
1681 Expression op_overload(Scope sc) | |
1682 { | |
1683 //printf("BinExp.op_overload() (%s)\n", toChars()); | |
1684 | |
1685 AggregateDeclaration ad; | |
1686 Type t1 = e1.type.toBasetype(); | |
1687 Type t2 = e2.type.toBasetype(); | |
1688 Identifier id = opId(); | |
1689 Identifier id_r = opId_r(); | |
1690 | |
1691 Match m; | |
1692 scope Expressions args1 = new Expressions(); | |
1693 scope Expressions args2 = new Expressions(); | |
1694 int argsset = 0; | |
1695 | |
1696 AggregateDeclaration ad1; | |
1697 if (t1.ty == TY.Tclass) | |
1698 ad1 = (cast(TypeClass)t1).sym; | |
1699 else if (t1.ty == TY.Tstruct) | |
1700 ad1 = (cast(TypeStruct)t1).sym; | |
1701 else | |
1702 ad1 = null; | |
1703 | |
1704 AggregateDeclaration ad2; | |
1705 if (t2.ty == TY.Tclass) | |
1706 ad2 = (cast(TypeClass)t2).sym; | |
1707 else if (t2.ty == TY.Tstruct) | |
1708 ad2 = (cast(TypeStruct)t2).sym; | |
1709 else | |
1710 ad2 = null; | |
1711 | |
1712 Dsymbol s = null; | |
1713 Dsymbol s_r = null; | |
1714 FuncDeclaration fd = null; | |
1715 TemplateDeclaration td = null; | |
1716 if (ad1 && id) | |
1717 { | |
1718 s = search_function(ad1, id); | |
1719 } | |
1720 if (ad2 && id_r) | |
1721 { | |
1722 s_r = search_function(ad2, id_r); | |
1723 } | |
1724 | |
1725 if (s || s_r) | |
1726 { | |
1727 /* Try: | |
1728 * a.opfunc(b) | |
1729 * b.opfunc_r(a) | |
1730 * and see which is better. | |
1731 */ | |
1732 Expression e; | |
1733 FuncDeclaration lastf; | |
1734 | |
1735 args1.setDim(1); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1736 args1[0] = e1; |
0 | 1737 args2.setDim(1); |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1738 args2[0] = e2; |
0 | 1739 argsset = 1; |
1740 | |
1741 ///memset(&m, 0, sizeof(m)); | |
1742 m.last = MATCH.MATCHnomatch; | |
1743 | |
1744 if (s) | |
1745 { | |
1746 fd = s.isFuncDeclaration(); | |
1747 if (fd) | |
1748 { | |
1749 overloadResolveX(&m, fd, null, args2); | |
1750 } | |
1751 else | |
1752 { | |
1753 td = s.isTemplateDeclaration(); | |
1754 templateResolve(&m, td, sc, loc, null, null, args2); | |
1755 } | |
1756 } | |
1757 | |
1758 lastf = m.lastf; | |
1759 | |
1760 if (s_r) | |
1761 { | |
1762 fd = s_r.isFuncDeclaration(); | |
1763 if (fd) | |
1764 { | |
1765 overloadResolveX(&m, fd, null, args1); | |
1766 } | |
1767 else | |
1768 { | |
1769 td = s_r.isTemplateDeclaration(); | |
1770 templateResolve(&m, td, sc, loc, null, null, args1); | |
1771 } | |
1772 } | |
1773 | |
1774 if (m.count > 1) | |
1775 { | |
1776 // Error, ambiguous | |
1777 error("overloads %s and %s both match argument list for %s", | |
1778 m.lastf.type.toChars(), | |
1779 m.nextf.type.toChars(), | |
1780 m.lastf.toChars()); | |
1781 } | |
1782 else if (m.last == MATCH.MATCHnomatch) | |
1783 { | |
1784 m.lastf = m.anyf; | |
1785 } | |
1786 | |
1787 if (op == TOK.TOKplusplus || op == TOK.TOKminusminus) | |
1788 // Kludge because operator overloading regards e++ and e-- | |
1789 // as unary, but it's implemented as a binary. | |
1790 // Rewrite (e1 ++ e2) as e1.postinc() | |
1791 // Rewrite (e1 -- e2) as e1.postdec() | |
1792 e = build_overload(loc, sc, e1, null, id); | |
1793 else if (lastf && m.lastf == lastf || m.last == MATCH.MATCHnomatch) | |
1794 // Rewrite (e1 op e2) as e1.opfunc(e2) | |
1795 e = build_overload(loc, sc, e1, e2, id); | |
1796 else | |
1797 // Rewrite (e1 op e2) as e2.opfunc_r(e1) | |
1798 e = build_overload(loc, sc, e2, e1, id_r); | |
1799 return e; | |
1800 } | |
1801 | |
1802 if (isCommutative()) | |
1803 { | |
1804 s = null; | |
1805 s_r = null; | |
1806 if (ad1 && id_r) | |
1807 { | |
1808 s_r = search_function(ad1, id_r); | |
1809 } | |
1810 if (ad2 && id) | |
1811 { | |
1812 s = search_function(ad2, id); | |
1813 } | |
1814 | |
1815 if (s || s_r) | |
1816 { | |
1817 /* Try: | |
1818 * a.opfunc_r(b) | |
1819 * b.opfunc(a) | |
1820 * and see which is better. | |
1821 */ | |
1822 | |
1823 if (!argsset) | |
1824 { | |
1825 args1.setDim(1); | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1826 args1[0] = e1; |
0 | 1827 args2.setDim(1); |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
1828 args2[0] = e2; |
0 | 1829 } |
1830 | |
1831 ///memset(&m, 0, sizeof(m)); | |
1832 m.last = MATCH.MATCHnomatch; | |
1833 | |
1834 if (s_r) | |
1835 { | |
1836 fd = s_r.isFuncDeclaration(); | |
1837 if (fd) | |
1838 { | |
1839 overloadResolveX(&m, fd, null, args2); | |
1840 } | |
1841 else | |
1842 { td = s_r.isTemplateDeclaration(); | |
1843 templateResolve(&m, td, sc, loc, null, null, args2); | |
1844 } | |
1845 } | |
1846 FuncDeclaration lastf = m.lastf; | |
1847 | |
1848 if (s) | |
1849 { | |
1850 fd = s.isFuncDeclaration(); | |
1851 if (fd) | |
1852 { | |
1853 overloadResolveX(&m, fd, null, args1); | |
1854 } | |
1855 else | |
1856 { td = s.isTemplateDeclaration(); | |
1857 templateResolve(&m, td, sc, loc, null, null, args1); | |
1858 } | |
1859 } | |
1860 | |
1861 if (m.count > 1) | |
1862 { | |
1863 // Error, ambiguous | |
1864 error("overloads %s and %s both match argument list for %s", | |
1865 m.lastf.type.toChars(), | |
1866 m.nextf.type.toChars(), | |
1867 m.lastf.toChars()); | |
1868 } | |
1869 else if (m.last == MATCH.MATCHnomatch) | |
1870 { | |
1871 m.lastf = m.anyf; | |
1872 } | |
1873 | |
1874 Expression e; | |
1875 if (lastf && m.lastf == lastf || id_r && m.last == MATCH.MATCHnomatch) | |
1876 // Rewrite (e1 op e2) as e1.opfunc_r(e2) | |
1877 e = build_overload(loc, sc, e1, e2, id_r); | |
1878 else | |
1879 // Rewrite (e1 op e2) as e2.opfunc(e1) | |
1880 e = build_overload(loc, sc, e2, e1, id); | |
1881 | |
1882 // When reversing operands of comparison operators, | |
1883 // need to reverse the sense of the op | |
1884 switch (op) | |
1885 { | |
1886 case TOK.TOKlt: op = TOK.TOKgt; break; | |
1887 case TOK.TOKgt: op = TOK.TOKlt; break; | |
1888 case TOK.TOKle: op = TOK.TOKge; break; | |
1889 case TOK.TOKge: op = TOK.TOKle; break; | |
1890 | |
1891 // Floating point compares | |
1892 case TOK.TOKule: op = TOK.TOKuge; break; | |
1893 case TOK.TOKul: op = TOK.TOKug; break; | |
1894 case TOK.TOKuge: op = TOK.TOKule; break; | |
1895 case TOK.TOKug: op = TOK.TOKul; break; | |
1896 | |
1897 // These are symmetric | |
1898 case TOK.TOKunord: | |
1899 case TOK.TOKlg: | |
1900 case TOK.TOKleg: | |
1901 case TOK.TOKue: | |
1902 break; | |
1903 } | |
1904 | |
1905 return e; | |
1906 } | |
1907 } | |
1908 | |
1909 version (DMDV2) { | |
1910 // Try alias this on first operand | |
1911 if (ad1 && ad1.aliasthis) | |
1912 { | |
1913 /* Rewrite (e1 op e2) as: | |
1914 * (e1.aliasthis op e2) | |
1915 */ | |
1916 Expression e1 = new DotIdExp(loc, this.e1, ad1.aliasthis.ident); | |
1917 Expression e = copy(); | |
1918 (cast(BinExp)e).e1 = e1; | |
1919 e = e.semantic(sc); | |
1920 return e; | |
1921 } | |
1922 | |
1923 // Try alias this on second operand | |
1924 if (ad2 && ad2.aliasthis) | |
1925 { | |
1926 /* Rewrite (e1 op e2) as: | |
1927 * (e1 op e2.aliasthis) | |
1928 */ | |
1929 Expression e2 = new DotIdExp(loc, this.e2, ad2.aliasthis.ident); | |
1930 Expression e = copy(); | |
1931 (cast(BinExp)e).e2 = e2; | |
1932 e = e.semantic(sc); | |
1933 return e; | |
1934 } | |
1935 } | |
1936 return null; | |
1937 } | |
1938 | |
1939 elem* toElemBin(IRState* irs, int op) | |
1940 { | |
1941 //printf("toElemBin() '%s'\n", toChars()); | |
1942 | |
1943 tym_t tym = type.totym(); | |
1944 | |
1945 elem* el = e1.toElem(irs); | |
1946 elem* er = e2.toElem(irs); | |
1947 elem* e = el_bin(op,tym,el,er); | |
1948 el_setLoc(e,loc); | |
1949 | |
1950 return e; | |
1951 } | |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1952 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1953 final void Exp_buildArrayIdent(OutBuffer buf, Expressions arguments, string Str) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1954 { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1955 /* Evaluate assign expressions left to right |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1956 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1957 e1.buildArrayIdent(buf, arguments); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1958 e2.buildArrayIdent(buf, arguments); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1959 buf.writestring(Str); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1960 } |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1961 |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1962 final void AssignExp_buildArrayIdent(OutBuffer buf, Expressions arguments, string Str) |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1963 { |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1964 /* Evaluate assign expressions right to left |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1965 */ |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1966 e2.buildArrayIdent(buf, arguments); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1967 e1.buildArrayIdent(buf, arguments); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1968 buf.writestring(Str); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1969 buf.writestring("ass"); |
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
1970 } |
72 | 1971 } |