Mercurial > projects > ldc
comparison dmd2/arrayop.c @ 1577:e4f7b5d9c68a
DMD 2.032 Merge.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 08 Sep 2009 10:07:56 +0100 |
parents | 54b3c1394d62 |
children |
comparison
equal
deleted
inserted
replaced
1576:4551475bc6b6 | 1577:e4f7b5d9c68a |
---|---|
331 { | 331 { |
332 buf->writestring("Exp"); | 332 buf->writestring("Exp"); |
333 arguments->shift(this); | 333 arguments->shift(this); |
334 } | 334 } |
335 | 335 |
336 void CastExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments) | |
337 { | |
338 Type *tb = type->toBasetype(); | |
339 if (tb->ty == Tarray || tb->ty == Tsarray) | |
340 { | |
341 e1->buildArrayIdent(buf, arguments); | |
342 } | |
343 else | |
344 Expression::buildArrayIdent(buf, arguments); | |
345 } | |
346 | |
336 void SliceExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments) | 347 void SliceExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments) |
337 { | 348 { |
338 buf->writestring("Slice"); | 349 buf->writestring("Slice"); |
339 arguments->shift(this); | 350 arguments->shift(this); |
340 } | 351 } |
415 fparams->shift(param); | 426 fparams->shift(param); |
416 Expression *e = new IdentifierExp(0, id); | 427 Expression *e = new IdentifierExp(0, id); |
417 return e; | 428 return e; |
418 } | 429 } |
419 | 430 |
431 Expression *CastExp::buildArrayLoop(Arguments *fparams) | |
432 { | |
433 Type *tb = type->toBasetype(); | |
434 if (tb->ty == Tarray || tb->ty == Tsarray) | |
435 { | |
436 return e1->buildArrayLoop(fparams); | |
437 } | |
438 else | |
439 Expression::buildArrayLoop(fparams); | |
440 } | |
441 | |
420 Expression *SliceExp::buildArrayLoop(Arguments *fparams) | 442 Expression *SliceExp::buildArrayLoop(Arguments *fparams) |
421 { | 443 { |
422 Identifier *id = Identifier::generateId("p", fparams->dim); | 444 Identifier *id = Identifier::generateId("p", fparams->dim); |
423 Argument *param = new Argument(STCconst, type, id, NULL); | 445 Argument *param = new Argument(STCconst, type, id, NULL); |
424 fparams->shift(param); | 446 fparams->shift(param); |
433 Expression *AssignExp::buildArrayLoop(Arguments *fparams) | 455 Expression *AssignExp::buildArrayLoop(Arguments *fparams) |
434 { | 456 { |
435 /* Evaluate assign expressions right to left | 457 /* Evaluate assign expressions right to left |
436 */ | 458 */ |
437 Expression *ex2 = e2->buildArrayLoop(fparams); | 459 Expression *ex2 = e2->buildArrayLoop(fparams); |
460 #if DMDV2 | |
438 /* Need the cast because: | 461 /* Need the cast because: |
439 * b = c + p[i]; | 462 * b = c + p[i]; |
440 * where b is a byte fails because (c + p[i]) is an int | 463 * where b is a byte fails because (c + p[i]) is an int |
441 * which cannot be implicitly cast to byte. | 464 * which cannot be implicitly cast to byte. |
442 */ | 465 */ |
443 ex2 = new CastExp(0, ex2, e1->type->nextOf()); | 466 ex2 = new CastExp(0, ex2, e1->type->nextOf()); |
467 #endif | |
444 Expression *ex1 = e1->buildArrayLoop(fparams); | 468 Expression *ex1 = e1->buildArrayLoop(fparams); |
445 Argument *param = (Argument *)fparams->data[0]; | 469 Argument *param = (Argument *)fparams->data[0]; |
446 param->storageClass = 0; | 470 param->storageClass = 0; |
447 Expression *e = new AssignExp(0, ex1, ex2); | 471 Expression *e = new AssignExp(0, ex1, ex2); |
448 return e; | 472 return e; |