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