Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Changeset 1605:1d5721f9ae18

Show
Ignore:
Timestamp:
01/06/10 13:18:19 (8 months 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
  • dmd/expression.c

    Revision 1604:2afcaab30a6a Revision 1605:1d5721f9ae18
    8403    e2 = resolveProperties(sc, e2); 8403    e2 = resolveProperties(sc, e2); 
    8404 8404 
    8405    e = op_overload(sc); 8405    e = op_overload(sc); 
    8406    if (e) 8406    if (e) 
    8407    return e; 8407    return e; 
    8408 8408 
    8409    if (e1->op == TOKslice) 8409    if (e1->op == TOKslice) 
    8410    {   SliceExp *se = (SliceExp *)e1; 8410    {   SliceExp *se = (SliceExp *)e1; 
    8411 8411 
    8412    if (se->e1->type->toBasetype()->ty == Tsarray) 8412    if (se->e1->type->toBasetype()->ty == Tsarray) 
    8413        error("cannot append to static array %s", se->e1->type->toChars()); 8413        error("cannot append to static array %s", se->e1->type->toChars()); 
    8414    } 8414    } 
    8415 8415 
    8416    e1 = e1->modifiableLvalue(sc, e1); 8416    e1 = e1->modifiableLvalue(sc, e1); 
    8417 8417 
    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/************************************************************/ 
    8451 8468 
    8452MulAssignExp::MulAssignExp(Loc loc, Expression *e1, Expression *e2) 8469MulAssignExp::MulAssignExp(Loc loc, Expression *e1, Expression *e2) 
    8453    : BinExp(loc, TOKmulass, sizeof(MulAssignExp), e1, e2) 8470    : BinExp(loc, TOKmulass, sizeof(MulAssignExp), e1, e2) 
    8454{ 8471{ 
    8455} 8472} 
    8456 8473 
    8457Expression *MulAssignExp::semantic(Scope *sc) 8474Expression *MulAssignExp::semantic(Scope *sc) 
    8458{   Expression *e; 8475{   Expression *e; 
    8459 8476 
    8460    BinExp::semantic(sc); 8477    BinExp::semantic(sc); 
    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; 
    8471    return arrayOp(sc); 8497    return arrayOp(sc); 
    8472    } 8498    } 
    8473 8499 
    8474    e1 = e1->modifiableLvalue(sc, e1); 8500    e1 = e1->modifiableLvalue(sc, e1); 
    8475    e1->checkScalar(); 8501    e1->checkScalar(); 
    8476    e1->checkNoBool(); 8502    e1->checkNoBool(); 
    8477    type = e1->type; 8503    type = e1->type; 
    8478    typeCombine(sc); 8504    typeCombine(sc); 
    8479    e1->checkArithmetic(); 8505    e1->checkArithmetic(); 
    8480    e2->checkArithmetic(); 8506    e2->checkArithmetic(); 
    8481    checkComplexMulAssign(); 8507    checkComplexMulAssign(); 
    8482    if (e2->type->isfloating()) 8508    if (e2->type->isfloating()) 
    8483    {   Type *t1; 8509    {   Type *t1; 
    8484    Type *t2; 8510    Type *t2; 
    8485 8511 
      
    8513    } 8539    } 
    8514    return this; 8540    return this; 
    8515} 8541} 
    8516 8542 
    8517/************************************************************/ 8543/************************************************************/ 
    8518 8544 
    8519DivAssignExp::DivAssignExp(Loc loc, Expression *e1, Expression *e2) 8545DivAssignExp::DivAssignExp(Loc loc, Expression *e1, Expression *e2) 
    8520    : BinExp(loc, TOKdivass, sizeof(DivAssignExp), e1, e2) 8546    : BinExp(loc, TOKdivass, sizeof(DivAssignExp), e1, e2) 
    8521{ 8547{ 
    8522} 8548} 
    8523 8549 
    8524Expression *DivAssignExp::semantic(Scope *sc) 8550Expression *DivAssignExp::semantic(Scope *sc) 
    8525{   Expression *e; 8551{   Expression *e; 
    8526 8552 
    8527    BinExp::semantic(sc); 8553    BinExp::semantic(sc); 
    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; 
    8538    return arrayOp(sc); 8573    return arrayOp(sc); 
    8539    } 8574    } 
    8540 8575 
    8541    e1 = e1->modifiableLvalue(sc, e1); 8576    e1 = e1->modifiableLvalue(sc, e1); 
    8542    e1->checkScalar(); 8577    e1->checkScalar(); 
    8543    e1->checkNoBool(); 8578    e1->checkNoBool(); 
    8544    type = e1->type; 8579    type = e1->type; 
    8545    typeCombine(sc); 8580    typeCombine(sc); 
    8546    e1->checkArithmetic(); 8581    e1->checkArithmetic(); 
    8547    e2->checkArithmetic(); 8582    e2->checkArithmetic(); 
    8548    checkComplexMulAssign(); 8583    checkComplexMulAssign(); 
    8549    if (e2->type->isimaginary()) 8584    if (e2->type->isimaginary()) 
    8550    {   Type *t1; 8585    {   Type *t1; 
    8551    Type *t2; 8586    Type *t2; 
    8552 8587 
Copyright © 2008, LDC Development Team.