Changeset 657

Show
Ignore:
Timestamp:
07/02/07 18:12:57 (1 year ago)
Author:
Gregor
Message:

MERGE: DMD 1.015

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmdfe/cast.c

    r523 r657  
    333333{   MATCH m; 
    334334 
    335     //printf("StringExp::implicitConvTo(t = %s), '%s' committed = %d\n", t->toChars(), toChars(), committed); 
     335#if 0 
     336    printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n", 
     337    toChars(), committed, type->toChars(), t->toChars()); 
     338#endif 
    336339    if (!committed) 
    337340    { 
     
    351354            ((TypeSArray *)t)->dim->toInteger()) 
    352355            return MATCHnomatch; 
     356            goto L1; 
    353357        case Tarray: 
     358            goto L1; 
    354359        case Tpointer: 
     360        L1: 
    355361            if (t->next->ty == Tchar) 
    356362            return MATCHexact; 
  • branches/dmdfe/declaration.c

    r523 r657  
    802802    if (init) 
    803803    { 
     804    ArrayInitializer *ai = init->isArrayInitializer(); 
     805    if (ai && type->toBasetype()->ty == Taarray) 
     806    { 
     807        init = ai->toAssocArrayInitializer(); 
     808    } 
     809 
    804810    ExpInitializer *ei = init->isExpInitializer(); 
    805811 
  • branches/dmdfe/expression.c

    r656 r657  
    24602460        error("%s has no value", e->toChars()); 
    24612461    e = resolveProperties(sc, e); 
     2462 
     2463    unsigned char committed = 1; 
     2464    if (e->op == TOKstring) 
     2465        committed = ((StringExp *)e)->committed; 
     2466 
    24622467    if (!t0) 
    24632468    {   t0 = e->type; 
     
    24712476    else 
    24722477        e = e->implicitCastTo(sc, t0); 
     2478    if (!committed && e->op == TOKstring) 
     2479    {   StringExp *se = (StringExp *)e; 
     2480        se->committed = 0; 
     2481    } 
    24732482    elements->data[i] = (void *)e; 
    24742483    } 
  • branches/dmdfe/init.c

    r460 r657  
    387387 
    388388 
     389/******************************** 
     390 * If possible, convert array initializer to associative array initializer. 
     391 */ 
     392 
     393Initializer *ArrayInitializer::toAssocArrayInitializer() 
     394{   Expressions *keys; 
     395    Expressions *values; 
     396    Expression *e; 
     397 
     398    //printf("ArrayInitializer::toAssocArrayInitializer()\n"); 
     399    //static int i; if (++i == 2) halt(); 
     400    keys = new Expressions(); 
     401    keys->setDim(value.dim); 
     402    values = new Expressions(); 
     403    values->setDim(value.dim); 
     404 
     405    for (size_t i = 0; i < value.dim; i++) 
     406    { 
     407    e = (Expression *)index.data[i]; 
     408    if (!e) 
     409        goto Lno; 
     410    keys->data[i] = (void *)e; 
     411 
     412    Initializer *iz = (Initializer *)value.data[i]; 
     413    if (!iz) 
     414        goto Lno; 
     415    e = iz->toExpression(); 
     416    if (!e) 
     417        goto Lno; 
     418    values->data[i] = (void *)e; 
     419    } 
     420    e = new AssocArrayLiteralExp(loc, keys, values); 
     421    return new ExpInitializer(loc, e); 
     422 
     423Lno: 
     424    delete keys; 
     425    delete values; 
     426    error(loc, "not an associative array initializer"); 
     427    return this; 
     428} 
     429 
     430 
    389431Type *ArrayInitializer::inferType(Scope *sc) 
    390432{ 
  • branches/dmdfe/init.h

    r460 r657  
    2424struct AggregateDeclaration; 
    2525struct VoidInitializer; 
     26struct ArrayInitializer; 
    2627struct ExpInitializer; 
    2728#ifdef _DH 
     
    4445 
    4546    virtual VoidInitializer *isVoidInitializer() { return NULL; } 
     47    virtual ArrayInitializer  *isArrayInitializer()  { return NULL; } 
    4648    virtual ExpInitializer  *isExpInitializer()  { return NULL; } 
    4749}; 
     
    9092    Type *inferType(Scope *sc); 
    9193    Expression *toExpression(); 
     94    Initializer *toAssocArrayInitializer(); 
    9295    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    9396 
    9497    dt_t *toDtBit();    // for bit arrays 
     98 
     99    ArrayInitializer *isArrayInitializer() { return this; } 
    95100}; 
    96101 
  • branches/dmdfe/interpret.c

    r656 r657  
    859859} 
    860860 
    861 Expression *getVarExp(InterState *istate, VarDeclaration *v
     861Expression *getVarExp(InterState *istate, Declaration *d
    862862{ 
    863863    Expression *e = EXP_CANT_INTERPRET; 
     864    VarDeclaration *v = d->isVarDeclaration(); 
     865    SymbolDeclaration *s = d->isSymbolDeclaration(); 
    864866    if (v) 
    865867    { 
     
    879881        e = EXP_CANT_INTERPRET; 
    880882    } 
     883    else if (s) 
     884    { 
     885    /* if (s->dsym->toInitializer() == s->sym) 
     886    {   Expressions *exps = new Expressions(); 
     887        e = new StructLiteralExp(0, s->dsym, exps); 
     888        e = e->semantic(NULL); 
     889    } */ 
     890    } 
    881891    return e; 
    882892} 
     
    887897    printf("VarExp::interpret() %s\n", toChars()); 
    888898#endif 
    889     return getVarExp(istate, var->isVarDeclaration()); 
     899    return getVarExp(istate, var); 
    890900} 
    891901 
     
    19311941    } 
    19321942    } 
     1943#if LOG 
     1944    if (e == EXP_CANT_INTERPRET) 
     1945    printf("PtrExp::interpret() %s = EXP_CANT_INTERPRET\n", toChars()); 
     1946#endif 
    19331947    return e; 
    19341948} 
  • branches/dmdfe/mars.c

    r656 r657  
    5656    copyright = "Copyright (c) 1999-2007 by Digital Mars"; 
    5757    written = "written by Walter Bright"; 
    58     version = "v1.014"; 
     58    version = "v1.015"; 
    5959    global.structalign = 8; 
    6060 
  • branches/dmdfe/parse.c

    r523 r657  
    767767 
    768768    nextToken(); 
    769     //check(TOKlparen);     // don't require () 
    770     //check(TOKrparen); 
     769    if (token.value == TOKlparen)   // optional () 
     770    { 
     771    nextToken(); 
     772    check(TOKrparen); 
     773    } 
    771774 
    772775    f = new InvariantDeclaration(loc, 0); 
  • branches/dmdfe/statement.c

    r523 r657  
    814814    condition = condition->semantic(sc); 
    815815    condition = resolveProperties(sc, condition); 
     816    condition = condition->optimize(WANTvalue); 
    816817    condition = condition->checkToBoolean(); 
    817818