Mercurial > projects > ldc
comparison dmd/expression.c @ 1605:1d5721f9ae18
[WIP] Merge DMD r251: bugzilla 111 (appending a dchar to a char[])
This patch needs some work in the code generation, because of the runtime
changes (functions "_d_arrayappendcd" and "_d_arrayappendwd" are added).
This doesn't affect existing code though, it just makes with patch
a little useless, because something like this:
char [] s;
s ~= '\u6211';
That failed to compile with a nice error message previously to this
change, now fails with and ugly error message (a failed assertion).
Apparently there is a regression introduced by this patch too, when
compiling Dil I get this assertion message:
ldc: /home/luca/tesis/ldc/gen/statements.cpp:132: virtual void ReturnStatement::toIR(IRState*): Assertion `p->topfunc()->getReturnType() == llvm::Type::getVoidTy(gIR->context())' failed.
0 ldc 0x08a91628
Thank god we have bisecting capabilities in VCSs now ;)
---
dmd/expression.c | 47 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 41 insertions(+), 6 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:19 -0300 |
parents | 2afcaab30a6a |
children | 207a8a438dea |
comparison
equal
deleted
inserted
replaced
1604:2afcaab30a6a | 1605:1d5721f9ae18 |
---|---|
8418 Type *tb1 = e1->type->toBasetype(); | 8418 Type *tb1 = e1->type->toBasetype(); |
8419 Type *tb2 = e2->type->toBasetype(); | 8419 Type *tb2 = e2->type->toBasetype(); |
8420 | 8420 |
8421 e2->rvalue(); | 8421 e2->rvalue(); |
8422 | 8422 |
8423 Type *tb1next = tb1->nextOf(); | |
8424 | |
8423 if ((tb1->ty == Tarray) && | 8425 if ((tb1->ty == Tarray) && |
8424 (tb2->ty == Tarray || tb2->ty == Tsarray) && | 8426 (tb2->ty == Tarray || tb2->ty == Tsarray) && |
8425 e2->implicitConvTo(e1->type) | 8427 (e2->implicitConvTo(e1->type) |
8426 //e1->type->next->equals(e2->type->next) | 8428 #if DMDV2 |
8429 || tb2->nextOf()->implicitConvTo(tb1next) | |
8430 #endif | |
8431 ) | |
8427 ) | 8432 ) |
8428 { // Append array | 8433 { // Append array |
8429 e2 = e2->castTo(sc, e1->type); | 8434 e2 = e2->castTo(sc, e1->type); |
8430 type = e1->type; | 8435 type = e1->type; |
8431 e = this; | 8436 e = this; |
8432 } | 8437 } |
8433 else if ((tb1->ty == Tarray) && | 8438 else if ((tb1->ty == Tarray) && |
8434 e2->implicitConvTo(tb1->nextOf()) | 8439 e2->implicitConvTo(tb1next) |
8435 ) | 8440 ) |
8436 { // Append element | 8441 { // Append element |
8437 e2 = e2->castTo(sc, tb1->nextOf()); | 8442 e2 = e2->castTo(sc, tb1next); |
8438 type = e1->type; | 8443 type = e1->type; |
8439 e = this; | 8444 e = this; |
8440 } | 8445 } |
8446 else if (tb1->ty == Tarray && | |
8447 (tb1next->ty == Tchar || tb1next->ty == Twchar) && | |
8448 e2->implicitConvTo(Type::tdchar) | |
8449 ) | |
8450 { // Append dchar to char[] or wchar[] | |
8451 e2 = e2->castTo(sc, Type::tdchar); | |
8452 type = e1->type; | |
8453 e = this; | |
8454 | |
8455 /* Do not allow appending wchar to char[] because if wchar happens | |
8456 * to be a surrogate pair, nothing good can result. | |
8457 */ | |
8458 } | |
8441 else | 8459 else |
8442 { | 8460 { |
8443 error("cannot append type %s to type %s", tb2->toChars(), tb1->toChars()); | 8461 error("cannot append type %s to type %s", tb2->toChars(), tb1->toChars()); |
8444 type = Type::tint32; | 8462 e = new ErrorExp(); |
8445 e = this; | |
8446 } | 8463 } |
8447 return e; | 8464 return e; |
8448 } | 8465 } |
8449 | 8466 |
8450 /************************************************************/ | 8467 /************************************************************/ |
8461 e2 = resolveProperties(sc, e2); | 8478 e2 = resolveProperties(sc, e2); |
8462 | 8479 |
8463 e = op_overload(sc); | 8480 e = op_overload(sc); |
8464 if (e) | 8481 if (e) |
8465 return e; | 8482 return e; |
8483 | |
8484 #if DMDV2 | |
8485 if (e1->op == TOKarraylength) | |
8486 { | |
8487 e = ArrayLengthExp::rewriteOpAssign(this); | |
8488 e = e->semantic(sc); | |
8489 return e; | |
8490 } | |
8491 #endif | |
8466 | 8492 |
8467 if (e1->op == TOKslice) | 8493 if (e1->op == TOKslice) |
8468 { // T[] -= ... | 8494 { // T[] -= ... |
8469 typeCombine(sc); | 8495 typeCombine(sc); |
8470 type = e1->type; | 8496 type = e1->type; |
8528 e2 = resolveProperties(sc, e2); | 8554 e2 = resolveProperties(sc, e2); |
8529 | 8555 |
8530 e = op_overload(sc); | 8556 e = op_overload(sc); |
8531 if (e) | 8557 if (e) |
8532 return e; | 8558 return e; |
8559 | |
8560 #if DMDV2 | |
8561 if (e1->op == TOKarraylength) | |
8562 { | |
8563 e = ArrayLengthExp::rewriteOpAssign(this); | |
8564 e = e->semantic(sc); | |
8565 return e; | |
8566 } | |
8567 #endif | |
8533 | 8568 |
8534 if (e1->op == TOKslice) | 8569 if (e1->op == TOKslice) |
8535 { // T[] -= ... | 8570 { // T[] -= ... |
8536 typeCombine(sc); | 8571 typeCombine(sc); |
8537 type = e1->type; | 8572 type = e1->type; |