Changeset 1605:1d5721f9ae18
- Timestamp:
- 01/06/10 13:18:19
(2 years ago)
- Author:
- Leandro Lucarella <llucax@gmail.com>
- branch:
- default
- Message:
[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(-)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1604 |
r1605 |
|
| 8421 | 8421 | e2->rvalue(); |
|---|
| 8422 | 8422 | |
|---|
| | 8423 | Type *tb1next = tb1->nextOf(); |
|---|
| | 8424 | |
|---|
| 8423 | 8425 | if ((tb1->ty == Tarray) && |
|---|
| 8424 | 8426 | (tb2->ty == Tarray || tb2->ty == Tsarray) && |
|---|
| 8425 | | e2->implicitConvTo(e1->type) |
|---|
| 8426 | | //e1->type->next->equals(e2->type->next) |
|---|
| | 8427 | (e2->implicitConvTo(e1->type) |
|---|
| | 8428 | #if DMDV2 |
|---|
| | 8429 | || tb2->nextOf()->implicitConvTo(tb1next) |
|---|
| | 8430 | #endif |
|---|
| | 8431 | ) |
|---|
| 8427 | 8432 | ) |
|---|
| 8428 | 8433 | { // Append array |
|---|
| … | … | |
| 8432 | 8437 | } |
|---|
| 8433 | 8438 | else if ((tb1->ty == Tarray) && |
|---|
| 8434 | | e2->implicitConvTo(tb1->nextOf()) |
|---|
| | 8439 | e2->implicitConvTo(tb1next) |
|---|
| 8435 | 8440 | ) |
|---|
| 8436 | 8441 | { // Append element |
|---|
| 8437 | | e2 = e2->castTo(sc, tb1->nextOf()); |
|---|
| | 8442 | e2 = e2->castTo(sc, tb1next); |
|---|
| 8438 | 8443 | type = e1->type; |
|---|
| 8439 | 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 | 8459 | else |
|---|
| 8442 | 8460 | { |
|---|
| 8443 | 8461 | error("cannot append type %s to type %s", tb2->toChars(), tb1->toChars()); |
|---|
| 8444 | | type = Type::tint32; |
|---|
| 8445 | | e = this; |
|---|
| | 8462 | e = new ErrorExp(); |
|---|
| 8446 | 8463 | } |
|---|
| 8447 | 8464 | return e; |
|---|
| … | … | |
| 8464 | 8481 | if (e) |
|---|
| 8465 | 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 | 8493 | if (e1->op == TOKslice) |
|---|
| … | … | |
| 8531 | 8557 | if (e) |
|---|
| 8532 | 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 | 8569 | if (e1->op == TOKslice) |
|---|