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