Changeset 414

Show
Ignore:
Timestamp:
03/12/07 20:39:55 (1 year ago)
Author:
Gregor
Message:

MERGE: DMD 1.007

Files:

Legend:

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

    r360 r414  
    720720 
    721721        e = e->semantic(sc); 
     722        e = e->optimize(WANTvalue | WANTinterpret); 
    722723        if (e->op == TOKstring) 
    723724        { 
     
    741742 
    742743        e = e->semantic(sc); 
     744        e = e->optimize(WANTvalue | WANTinterpret); 
    743745        args->data[0] = (void *)e; 
    744746        if (e->op != TOKstring) 
     
    10651067    exp = exp->semantic(sc); 
    10661068    exp = resolveProperties(sc, exp); 
    1067     exp = exp->optimize(WANTvalue); 
     1069    exp = exp->optimize(WANTvalue | WANTinterpret); 
    10681070    if (exp->op != TOKstring) 
    10691071    {   error("argument to mixin must be a string, not (%s)", exp->toChars()); 
  • branches/dmdfe/cond.c

    r360 r414  
    241241    Expression *e = exp->semantic(sc); 
    242242    sc->pop(); 
    243     e = e->optimize(WANTvalue); 
     243    e = e->optimize(WANTvalue | WANTinterpret); 
    244244    if (e->isBool(TRUE)) 
    245245        inc = 1; 
  • branches/dmdfe/constfold.c

    r361 r414  
    3434 
    3535#define LOG 0 
     36 
     37Expression *expType(Type *type, Expression *e) 
     38{ 
     39    if (type != e->type) 
     40    { 
     41    e = e->copy(); 
     42    e->type = type; 
     43    } 
     44    return e; 
     45} 
    3646 
    3747/* ================================== isConst() ============================== */ 
     
    10201030    Loc loc = e1->loc; 
    10211031 
    1022     //printf("Index()\n"); 
     1032    //printf("Index(e1->type = %p)\n", e1->type); 
    10231033    if (e1->op == TOKstring && e2->op == TOKint64) 
    10241034    {   StringExp *es1 = (StringExp *)e1; 
     
    10761086#if LOG 
    10771087    printf("Slice()\n"); 
     1088    if (lwr) 
     1089    {   printf("\te1 = %s\n", e1->toChars()); 
     1090    printf("\tlwr = %s\n", lwr->toChars()); 
     1091    printf("\tupr = %s\n", upr->toChars()); 
     1092    } 
    10781093#endif 
    10791094    if (e1->op == TOKstring && lwr->op == TOKint64 && upr->op == TOKint64) 
     
    11311146    Loc loc = e1->loc; 
    11321147 
    1133     //printf("Cat()\n"); 
     1148    //printf("Cat(e1 = %s, e2 = %s)\n", e1->toChars(), e2->toChars()); 
     1149 
     1150    if (e1->op == TOKnull && e2->op == TOKint64) 
     1151    {   e = e2; 
     1152    goto L2; 
     1153    } 
     1154    else if (e1->op == TOKint64 && e2->op == TOKnull) 
     1155    {   e = e1; 
     1156     L2: 
     1157    Type *tn = e->type->toBasetype(); 
     1158    if (tn->ty == Tchar || tn->ty == Twchar || tn->ty == Tdchar) 
     1159    { 
     1160        // Create a StringExp 
     1161        void *s; 
     1162        StringExp *es; 
     1163        size_t len = 1; 
     1164        int sz = tn->size(); 
     1165        integer_t v = e->toInteger(); 
     1166 
     1167        s = mem.malloc((len + 1) * sz); 
     1168        memcpy((unsigned char *)s, &v, sz); 
     1169 
     1170        // Add terminating 0 
     1171        memset((unsigned char *)s + len * sz, 0, sz); 
     1172 
     1173        es = new StringExp(loc, s, len); 
     1174        es->sz = sz; 
     1175        es->committed = 1; 
     1176        e = es; 
     1177    } 
     1178    else 
     1179    {   // Create an ArrayLiteralExp 
     1180        Expressions *elements = new Expressions(); 
     1181        elements->push(e); 
     1182        e = new ArrayLiteralExp(e->loc, elements); 
     1183    } 
     1184    e->type = type; 
     1185    return e; 
     1186    } 
     1187 
    11341188    if (e1->op == TOKstring && e2->op == TOKstring) 
    11351189    { 
  • branches/dmdfe/declaration.h

    r361 r414  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    3131struct StructDeclaration; 
    3232struct TupleType; 
     33struct InterState; 
    3334 
    3435enum PROT; 
     
    437438    virtual int addPreInvariant(); 
    438439    virtual int addPostInvariant(); 
    439     Expression *interpret(Expressions *arguments); 
     440    Expression *interpret(InterState *istate, Expressions *arguments); 
    440441    void inlineScan(); 
    441442    int canInline(int hasthis, int hdrscan = 0); 
     
    445446 
    446447    static FuncDeclaration *genCfunc(Type *treturn, char *name); 
     448    static FuncDeclaration *genCfunc(Type *treturn, Identifier *id); 
    447449 
    448450    Symbol *toThunkSymbol(int offset);  // thunk version 
  • branches/dmdfe/expression.c

    r364 r414  
    110110    precedence[TOKassert] = PREC_primary; 
    111111    precedence[TOKfunction] = PREC_primary; 
     112    precedence[TOKvar] = PREC_primary; 
    112113 
    113114    // post 
     
    28352836        error("e.new is only for allocating nested classes"); 
    28362837    } 
     2838    else if (thisexp) 
     2839        error("e.new is only for allocating nested classes"); 
     2840 
    28372841    FuncDeclaration *f = cd->ctor; 
    28382842    if (f) 
     
    29322936        Expression *arg = (Expression *)arguments->data[i]; 
    29332937        arg = resolveProperties(sc, arg); 
    2934         arg = arg->implicitCastTo(sc, Type::tindex); 
     2938        arg = arg->implicitCastTo(sc, Type::tsize_t); 
    29352939        if (arg->op == TOKint64 && (long long)arg->toInteger() < 0) 
    29362940        error("negative array index %s", arg->toChars()); 
     
    33223326 
    33233327    expandTuples(exps); 
     3328    if (0 && exps->dim == 1) 
     3329    { 
     3330    return (Expression *)exps->data[0]; 
     3331    } 
    33243332    type = new TypeTuple(exps); 
    33253333    //printf("-TupleExp::semantic(%s)\n", toChars()); 
     
    33293337void TupleExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    33303338{ 
    3331     buf->writestring("tuple"); 
     3339    buf->writestring("tuple("); 
    33323340    argsToCBuffer(buf, exps, hgs); 
     3341    buf->writeByte(')'); 
    33333342} 
    33343343 
     
    40264035    UnaExp::semantic(sc); 
    40274036    e1 = resolveProperties(sc, e1); 
    4028     e1 = e1->optimize(WANTvalue); 
     4037    e1 = e1->optimize(WANTvalue | WANTinterpret); 
    40294038    if (e1->op != TOKstring) 
    40304039    {   error("argument to mixin must be a string, not (%s)", e1->toChars()); 
     
    59105919    {   lwr = lwr->semantic(sc); 
    59115920    lwr = resolveProperties(sc, lwr); 
    5912     lwr = lwr->implicitCastTo(sc, Type::tindex); 
     5921    lwr = lwr->implicitCastTo(sc, Type::tsize_t); 
    59135922    } 
    59145923    if (upr) 
    59155924    {   upr = upr->semantic(sc); 
    59165925    upr = resolveProperties(sc, upr); 
    5917     upr = upr->implicitCastTo(sc, Type::tindex); 
     5926    upr = upr->implicitCastTo(sc, Type::tsize_t); 
    59185927    } 
    59195928 
     
    60426051    e1 = resolveProperties(sc, e1); 
    60436052 
    6044     type = Type::tindex
     6053    type = Type::tsize_t
    60456054    } 
    60466055    return this; 
     
    62586267    case Tpointer: 
    62596268    case Tarray: 
    6260         e2 = e2->implicitCastTo(sc, Type::tindex); 
     6269        e2 = e2->implicitCastTo(sc, Type::tsize_t); 
    62616270        e->type = t1->next; 
    62626271        break; 
     
    62646273    case Tsarray: 
    62656274    { 
    6266         e2 = e2->implicitCastTo(sc, Type::tindex); 
     6275        e2 = e2->implicitCastTo(sc, Type::tsize_t); 
    62676276 
    62686277        TypeSArray *tsa = (TypeSArray *)t1; 
     
    62956304    case Ttuple: 
    62966305    { 
    6297         e2 = e2->implicitCastTo(sc, Type::tindex); 
     6306        e2 = e2->implicitCastTo(sc, Type::tsize_t); 
    62986307        e2 = e2->optimize(WANTvalue); 
    62996308        uinteger_t index = e2->toUInteger(); 
  • branches/dmdfe/expression.h

    r361 r414  
    12161216#define EXP_GOTO_INTERPRET  ((Expression *)4) 
    12171217 
     1218Expression *expType(Type *type, Expression *e); 
     1219 
    12181220Expression *Neg(Type *type, Expression *e1); 
    12191221Expression *Com(Type *type, Expression *e1); 
  • branches/dmdfe/func.c

    r361 r414  
    522522    } 
    523523    } 
    524     return; 
    525  
    526 Lassignerr: 
    527     error("identity assignment operator overload is illegal"); 
    528 
    529  
    530 void FuncDeclaration::semantic2(Scope *sc) 
    531 
     524 
    532525    /* Save scope for possible later use (if we need the 
    533526     * function internals) 
     
    535528    scope = new Scope(*sc); 
    536529    scope->setNoFree(); 
     530    return; 
     531 
     532Lassignerr: 
     533    error("identity assignment operator overload is illegal"); 
     534} 
     535 
     536void FuncDeclaration::semantic2(Scope *sc) 
     537{ 
    537538} 
    538539 
     
    17111712FuncDeclaration *FuncDeclaration::genCfunc(Type *treturn, char *name) 
    17121713{ 
     1714    return genCfunc(treturn, Lexer::idPool(name)); 
     1715} 
     1716 
     1717FuncDeclaration *FuncDeclaration::genCfunc(Type *treturn, Identifier *id) 
     1718{ 
    17131719    FuncDeclaration *fd; 
    17141720    TypeFunction *tf; 
    17151721    Dsymbol *s; 
    1716     Identifier *id; 
    17171722    static DsymbolTable *st = NULL; 
    17181723 
    1719     //printf("genCfunc(name = '%s')\n", name); 
     1724    //printf("genCfunc(name = '%s')\n", id->toChars()); 
    17201725    //printf("treturn\n\t"); treturn->print(); 
    1721  
    1722     id = Lexer::idPool(name); 
    17231726 
    17241727    // See if already in table 
  • branches/dmdfe/idgen.c

    r360 r414  
    194194    { "applyReverse", "opApplyReverse" }, 
    195195 
     196    { "adDup", "_adDupT" }, 
     197    { "adReverse", "_adReverse" }, 
     198 
    196199    // For pragma's 
    197200    { "lib" }, 
  • branches/dmdfe/interpret.c

    r361 r414  
    3030struct InterState 
    3131{ 
    32     Dsymbols vars;  // variables used in this function 
    33     Statement *start;   // if !=NULL, start execution at this statement 
     32    InterState *caller;     // calling function's InterState 
     33    FuncDeclaration *fd;    // function being interpreted 
     34    Dsymbols vars;      // variables used in this function 
     35    Statement *start;       // if !=NULL, start execution at this statement 
    3436    Statement *gotoTarget;  // target of EXP_GOTO_INTERPRET result 
    3537 
     
    4446/************************************* 
    4547 * Attempt to interpret a function given the arguments. 
     48 * Input: 
     49 *  istate  state for calling function (NULL if none) 
    4650 * Return result expression if successful, NULL if not. 
    4751 */ 
    4852 
    49 Expression *FuncDeclaration::interpret(Expressions *arguments) 
     53Expression *FuncDeclaration::interpret(InterState *istate, Expressions *arguments) 
    5054{ 
    5155#if LOG 
     
    8185    for (size_t i = 0; i < dim; i++) 
    8286    {   Argument *arg = Argument::getNth(tf->parameters, i); 
    83         if (arg->inout == Out || arg->inout == InOut || arg->inout == Lazy) 
     87        if (arg->inout == Lazy) 
    8488        {   cantInterpret = 1; 
    8589        return NULL; 
     
    8892    } 
    8993 
    90     InterState istate; 
     94    /* Save the values of the local variables used 
     95     */ 
     96    Expressions valueSaves; 
     97    if (istate) 
     98    { 
     99    valueSaves.setDim(istate->vars.dim); 
     100    for (size_t i = 0; i < istate->vars.dim; i++) 
     101    {   VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; 
     102        if (v) 
     103        {   valueSaves.data[i] = v->value; 
     104        v->value = NULL; 
     105        } 
     106    } 
     107    } 
     108 
     109    InterState istatex; 
     110    istatex.caller = istate; 
     111    istatex.fd = this; 
     112 
    91113    Expressions vsave; 
    92114    size_t dim = 0; 
     
    94116    { 
    95117    dim = arguments->dim; 
    96     assert(parameters && parameters->dim == dim); 
     118    assert(!dim || parameters->dim == dim); 
     119    vsave.setDim(dim); 
     120 
    97121    for (size_t i = 0; i < dim; i++) 
    98122    {   Expression *earg = (Expression *)arguments->data[i]; 
    99 #if LOG 
    100         printf("arg[%d] = %s\n", i, earg->toChars()); 
    101 #endif 
    102         earg = earg->interpret(&istate); 
    103         if (earg == EXP_CANT_INTERPRET) 
    104         return NULL; 
    105 #if LOG 
    106         printf("interpreted arg[%d] = %s\n", i, earg->toChars()); 
    107 #endif 
    108     } 
    109  
    110     vsave.setDim(dim); 
    111  
    112     for (size_t i = 0; i < dim; i++) 
    113     {   Expression *earg = (Expression *)arguments->data[i]; 
    114         earg = earg->interpret(&istate); 
     123        Argument *arg = Argument::getNth(tf->parameters, i); 
    115124        VarDeclaration *v = (VarDeclaration *)parameters->data[i]; 
    116125        vsave.data[i] = v->value; 
    117         v->value = earg; 
     126#if LOG 
     127        printf("arg[%d] = %s\n", i, earg->toChars()); 
     128#endif 
     129        if (arg->inout == Out || arg->inout == InOut) 
     130        { 
     131        /* Bind out or inout parameter to the corresponding 
     132         * variable v2 
     133         */ 
     134        if (!istate || earg->op != TOKvar) 
     135            return NULL;    // can't bind to non-interpreted vars 
     136 
     137        VarDeclaration *v2; 
     138        while (1) 
     139        { 
     140            VarExp *ve = (VarExp *)earg; 
     141            v2 = ve->var->isVarDeclaration(); 
     142            if (!v2) 
     143            return NULL; 
     144            if (!v2->value || v2->value->op != TOKvar) 
     145            break; 
     146            earg = v2->value; 
     147        } 
     148 
     149        v->value = new VarExp(earg->loc, v2); 
     150 
     151        /* Don't restore the value of v2 upon function return 
     152         */ 
     153        assert(istate); 
     154        for (size_t i = 0; i < istate->vars.dim; i++) 
     155        {   VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; 
     156            if (v == v2) 
     157            {   istate->vars.data[i] = NULL; 
     158            break; 
     159            } 
     160        } 
     161        } 
     162        else 
     163        {   /* Value parameters 
     164         */ 
     165        earg = earg->interpret(&istatex); 
     166        if (earg == EXP_CANT_INTERPRET) 
     167            return NULL; 
     168        v->value = earg; 
     169        } 
     170#if LOG 
     171        printf("interpreted arg[%d] = %s\n", i, earg->toChars()); 
     172#endif 
    118173    } 
    119174    } 
     
    123178    while (1) 
    124179    { 
    125     e = fbody->interpret(&istate); 
     180    e = fbody->interpret(&istatex); 
    126181    if (e == EXP_CANT_INTERPRET) 
    127182    { 
     
    140195    if (e == EXP_GOTO_INTERPRET) 
    141196    { 
    142         istate.start = istate.gotoTarget; // set starting statement 
    143         istate.gotoTarget = NULL; 
     197        istatex.start = istatex.gotoTarget;   // set starting statement 
     198        istatex.gotoTarget = NULL; 
    144199    } 
    145200    else 
     
    147202    } 
    148203 
     204    /* Restore the parameter values 
     205     */ 
    149206    for (size_t i = 0; i < dim; i++) 
    150207    { 
     
    152209    v->value = (Expression *)vsave.data[i]; 
    153210    } 
     211 
     212    if (istate) 
     213    { 
     214    /* Restore the variable values 
     215     */ 
     216    for (size_t i = 0; i < istate->vars.dim; i++) 
     217    {   VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; 
     218        if (v) 
     219        v->value = (Expression *)valueSaves.data[i]; 
     220    } 
     221    } 
     222 
    154223    return e; 
    155224} 
     
    759828 
    760829Expression *VarExp::interpret(InterState *istate) 
    761 {   Expression *e = EXP_CANT_INTERPRET; 
     830
     831#if LOG 
     832    printf("VarExp::interpret() %s\n", toChars()); 
     833#endif 
     834    Expression *e = EXP_CANT_INTERPRET; 
    762835    VarDeclaration *v = var->isVarDeclaration(); 
    763836    if (v) 
     
    766839        e = v->init->toExpression(); 
    767840    else 
    768         e = v->value; 
     841    {   e = v->value; 
     842        if (!e) 
     843        error("variable %s is used before initialization", v->toChars()); 
     844        else if (e != EXP_CANT_INTERPRET) 
     845        e = e->interpret(istate); 
     846    } 
    769847    if (!e) 
    770848        e = EXP_CANT_INTERPRET; 
     
    784862        if (ie) 
    785863        e = ie->exp->interpret(istate); 
     864        else if (v->init->isVoidInitializer()) 
     865        e = NULL; 
    786866    } 
    787867    } 
     
    9831063Expression *BinExp::interpretAssignCommon(InterState *istate, fp_t fp) 
    9841064{ 
     1065#if LOG 
     1066    printf("BinExp::interpretAssignCommon() %s\n", toChars()); 
     1067#endif 
    9851068    Expression *e = EXP_CANT_INTERPRET; 
    986  
    987     if (e1->op == TOKvar) 
     1069    Expression *e1 = this->e1; 
     1070 
     1071    if (fp) 
     1072    { 
     1073    if (e1->op == TOKcast) 
     1074    {   CastExp *ce = (CastExp *)e1; 
     1075        e1 = ce->e1; 
     1076    } 
     1077    } 
     1078    if (e1 != EXP_CANT_INTERPRET && e1->op == TOKvar) 
    9881079    { 
    9891080    VarExp *ve = (VarExp *)e1; 
    9901081    VarDeclaration *v = ve->var->isVarDeclaration(); 
    991     if (v && !v->isDataseg() && (!fp || v->value)) 
    992     { 
     1082    if (v && !v->isDataseg()) 
     1083    { 
     1084        /* Chase down rebinding of out and inout 
     1085         */ 
     1086        if (v->value && v->value->op == TOKvar) 
     1087        { 
     1088        ve = (VarExp *)v->value; 
     1089        v = ve->var->isVarDeclaration(); 
     1090        assert(v); 
     1091        } 
     1092 
     1093        if (fp && !v->value) 
     1094        {   error("variable %s is used before initialization", v->toChars()); 
     1095        return e; 
     1096        } 
    9931097        Expression *e2 = this->e2->interpret(istate); 
    9941098        if (e2 != EXP_CANT_INTERPRET) 
     
    10531157    VarExp *ve = (VarExp *)e1; 
    10541158    VarDeclaration *v = ve->var->isVarDeclaration(); 
    1055     if (v && !v->isDataseg() && v->value) 
    1056     { 
     1159    if (v && !v->isDataseg()) 
     1160    { 
     1161        /* Chase down rebinding of out and inout 
     1162         */ 
     1163        if (v->value && v->value->op == TOKvar) 
     1164        { 
     1165        ve = (VarExp *)v->value; 
     1166        v = ve->var->isVarDeclaration(); 
     1167        assert(v); 
     1168        } 
     1169 
     1170        if (!v->value) 
     1171        {   error("variable %s is used before initialization", v->toChars()); 
     1172        return e; 
     1173        } 
    10571174        Expression *e2 = this->e2->interpret(istate); 
    10581175        if (e2 != EXP_CANT_INTERPRET) 
     
    11381255{   Expression *e = EXP_CANT_INTERPRET; 
    11391256 
     1257#if LOG 
     1258    printf("CallExp::interpret() %s\n", toChars()); 
     1259#endif 
    11401260    if (e1->op == TOKvar) 
    11411261    { 
    11421262    FuncDeclaration *fd = ((VarExp *)e1)->var->isFuncDeclaration(); 
    11431263    if (fd) 
    1144     { 
    1145         /* Save the values of the variables used 
    1146          */ 
    1147         Expressions valueSaves; 
    1148         valueSaves.setDim(istate->vars.dim); 
    1149         for (size_t i = 0; i < istate->vars.dim; i++) 
    1150         {   VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; 
    1151         valueSaves.data[i] = v->value; 
    1152         v->value = NULL; 
    1153         } 
    1154  
    1155         Expression *eresult = fd->interpret(arguments); 
    1156         if (eresult) 
    1157         e = eresult; 
     1264    {   // Inline .dup 
     1265        if (fd->ident == Id::adDup && arguments && arguments->dim == 2) 
     1266        { 
     1267        e = (Expression *)arguments->data[1]; 
     1268        e = e->interpret(istate); 
     1269        if (e != EXP_CANT_INTERPRET) 
     1270        { 
     1271            e = expType(type, e); 
     1272        } 
     1273        } 
    11581274        else 
    1159         error("cannot evaluate %s at compile time", toChars()); 
    1160  
    1161         /* Restore the variable values 
    1162          */ 
    1163         for (size_t i = 0; i < istate->vars.dim; i++) 
    1164         {   VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; 
    1165         v->value = (Expression *)valueSaves.data[i]; 
     1275        { 
     1276        Expression *eresult = fd->interpret(istate, arguments); 
     1277        if (eresult) 
     1278            e = eresult; 
     1279        else 
     1280            error("cannot evaluate %s at compile time", toChars()); 
    11661281        } 
    11671282    } 
     
    11971312    Expression *e1; 
    11981313 
     1314#if LOG 
     1315    printf("ArrayLengthExp::interpret() %s\n", toChars()); 
     1316#endif 
    11991317    e1 = this->e1->interpret(istate); 
    12001318    if (e1 == EXP_CANT_INTERPRET) 
     
    12511369    if (e1 == EXP_CANT_INTERPRET) 
    12521370    goto Lcant; 
    1253     if (!lwr) 
     1371    if (!this->lwr) 
    12541372    { 
    12551373    e = e1->castTo(NULL, type); 
     
    12861404    Expression *e2; 
    12871405 
     1406#if LOG 
     1407    printf("CatExp::interpret() %s\n", toChars()); 
     1408#endif 
    12881409    e1 = this->e1->interpret(istate); 
    12891410    if (e1 == EXP_CANT_INTERPRET) 
  • branches/dmdfe/mars.c

    r364 r414  
    5656    copyright = "Copyright (c) 1999-2007 by Digital Mars"; 
    5757    written = "written by Walter Bright"; 
    58     version = "v1.006"; 
     58    version = "v1.007"; 
    5959    global.structalign = 8; 
    6060 
  • branches/dmdfe/mtype.c

    r361 r414  
    13941394    if (this == to) 
    13951395    return MATCHexact; 
    1396     if (to->ty == Tvoid) 
     1396 
     1397    if (ty == Tvoid || to->ty == Tvoid) 
    13971398    return MATCHnomatch; 
     1399    if (1 || global.params.Dversion == 1) 
     1400    { 
     1401    if (to->ty == Tbool) 
     1402        return MATCHnomatch; 
     1403    } 
     1404    else 
     1405    { 
     1406    if (ty == Tbool || to->ty == Tbool) 
     1407        return MATCHnomatch; 
     1408    } 
    13981409    if (!to->isTypeBasic()) 
    13991410    return MATCHnomatch; 
    1400     if (ty == Tvoid /*|| to->ty == Tvoid*/) 
    1401     return MATCHnomatch; 
    1402     if (to->ty == Tbit || to->ty == Tbool) 
    1403     return MATCHnomatch; 
     1411 
    14041412    TypeBasic *tob = (TypeBasic *)to; 
    14051413    if (flags & TFLAGSintegral) 
     
    14081416    if (tob->flags & (TFLAGSimaginary | TFLAGScomplex)) 
    14091417        return MATCHnomatch; 
     1418 
     1419    // If converting to integral 
     1420    if (0 && global.params.Dversion > 1 && tob->flags & TFLAGSintegral) 
     1421    {   d_uns64 sz = size(0); 
     1422        d_uns64 tosz = tob->size(0); 
     1423 
     1424        /* Can't convert to smaller size or, if same size, change sign 
     1425         */ 
     1426        if (sz > tosz) 
     1427        return MATCHnomatch; 
     1428 
     1429        /*if (sz == tosz && (flags ^ tob->flags) & TFLAGSunsigned) 
     1430        return MATCHnomatch;*/ 
     1431    } 
    14101432    } 
    14111433    else if (flags & TFLAGSfloating) 
     
    14941516    int size = next->size(e->loc); 
    14951517    int dup; 
    1496     char *nm; 
    1497     static char *name[2] = { "_adReverse", "_adDupT" }; 
    14981518 
    14991519    assert(size); 
    15001520    dup = (ident == Id::dup); 
    1501     nm = name[dup]; 
    1502     fd = FuncDeclaration::genCfunc(Type::tindex, nm); 
     1521    fd = FuncDeclaration::genCfunc(Type::tindex, dup ? Id::adDup : Id::adReverse); 
    15031522    ec = new VarExp(0, fd); 
    15041523    e = e->castTo(sc, n->arrayOf());    // convert to dynamic array 
     
    45964615    } 
    45974616 
    4598     // Allow conversion to (void *) 
    4599     if (to->ty == Tpointer && to->next->ty == Tvoid) 
    4600     return 1; 
    4601  
    4602 //    if (to->ty == Tvoid) 
    4603 //  return MATCHconvert; 
     4617    if (global.params.Dversion == 1) 
     4618    { 
     4619    // Allow conversion to (void *) 
     4620    if (to->ty == Tpointer && to->next->ty == Tvoid) 
     4621        return 1; 
     4622    } 
     4623 
    46044624    return 0; 
    46054625} 
  • branches/dmdfe/optimize.c

    r361 r414  
    4949    {   Expression *ei = v->init->toExpression(); 
    5050        if (ei) 
    51         e1 = ei; 
     51        {   e1 = ei; 
     52        if (!e1->type) 
     53            e1->type = v->type; 
     54        } 
    5255    } 
    5356    } 
     
    232235    if (fd) 
    233236    { 
    234         Expression *eresult = fd->interpret(arguments); 
     237        Expression *eresult = fd->interpret(NULL, arguments); 
    235238        if (eresult) 
    236239        e = eresult; 
  • branches/dmdfe/parse.c

    r361 r414  
    44234423 
    44244424        case TOKidentity: 
    4425         if (1 || !global.params.useDeprecated) 
    4426             error("'===' is no longer legal, use 'is' instead"); 
     4425        error("'===' is no longer legal, use 'is' instead"); 
    44274426        goto L1; 
    44284427 
    44294428        case TOKnotidentity: 
    4430         if (1 || !global.params.useDeprecated) 
    4431             error("'!==' is no longer legal, use '!is' instead"); 
     4429        error("'!==' is no longer legal, use '!is' instead"); 
    44324430        goto L1; 
    44334431 
     
    44594457} 
    44604458 
     4459Expression *Parser::parseCmpExp() 
     4460{   Expression *e; 
     4461    Expression *e2; 
     4462    Token *t; 
     4463    Loc loc = this->loc; 
     4464 
     4465    e = parseShiftExp(); 
     4466    enum TOK op = token.value; 
     4467 
     4468    switch (op) 
     4469    { 
     4470    case TOKequal: 
     4471    case TOKnotequal: 
     4472        nextToken(); 
     4473        e2 = parseShiftExp(); 
     4474        e = new EqualExp(op, loc, e, e2); 
     4475        break; 
     4476 
     4477    case TOKis: 
     4478        op = TOKidentity; 
     4479        goto L1; 
     4480 
     4481    case TOKnot: 
     4482        // Attempt to identify '!is' 
     4483        t = peek(&token); 
     4484        if (t->value != TOKis) 
     4485        break; 
     4486        nextToken(); 
     4487        op = TOKnotidentity; 
     4488        goto L1; 
     4489 
     4490    L1: 
     4491        nextToken(); 
     4492        e2 = parseShiftExp(); 
     4493        e = new IdentityExp(op, loc, e, e2); 
     4494        break; 
     4495 
     4496    case TOKlt: 
     4497    case TOKle: 
     4498    case TOKgt: 
     4499    case TOKge: 
     4500    case TOKunord: 
     4501    case TOKlg: 
     4502    case TOKleg: 
     4503    case TOKule: 
     4504    case TOKul: 
     4505    case TOKuge: 
     4506    case TOKug: 
     4507    case TOKue: 
     4508        nextToken(); 
     4509        e2 = parseShiftExp(); 
     4510        e = new CmpExp(op, loc, e, e2); 
     4511        break; 
     4512 
     4513    case TOKin: 
     4514        nextToken(); 
     4515        e2 = parseShiftExp(); 
     4516        e = new InExp(loc, e, e2); 
     4517        break; 
     4518 
     4519    default: 
     4520        break; 
     4521    } 
     4522    return e; 
     4523} 
     4524 
    44614525Expression *Parser::parseAndExp() 
    44624526{   Expression *e; 
     
    44644528    Loc loc = this->loc; 
    44654529 
    4466     e = parseEqualExp(); 
    4467     while (token.value == TOKand) 
    4468     { 
    4469     nextToken(); 
    4470     e2 = parseEqualExp(); 
    4471     e = new AndExp(loc,e,e2); 
    4472     loc = this->loc; 
     4530    if (global.params.Dversion == 1) 
     4531    { 
     4532    e = parseEqualExp(); 
     4533    while (token.value == TOKand) 
     4534    { 
     4535        nextToken(); 
     4536        e2 = parseEqualExp(); 
     4537        e = new AndExp(loc,e,e2); 
     4538        loc = this->loc; 
     4539    } 
     4540    } 
     4541    else 
     4542    { 
     4543    e = parseCmpExp(); 
     4544    while (token.value == TOKand) 
     4545    { 
     4546        nextToken(); 
     4547        e2 = parseCmpExp(); 
     4548        e = new AndExp(loc,e,e2); 
     4549        loc = this->loc; 
     4550    } 
    44734551    } 
    44744552    return e; 
  • branches/dmdfe/parse.h

    r360 r414  
    117117    Expression *parseRelExp(); 
    118118    Expression *parseEqualExp(); 
     119    Expression *parseCmpExp(); 
    119120    Expression *parseAndExp(); 
    120121    Expression *parseXorExp(); 
  • branches/dmdfe/statement.c

    r361 r414  
    243243    exp = exp->semantic(sc); 
    244244    exp = resolveProperties(sc, exp); 
    245     exp = exp->optimize(WANTvalue); 
     245    exp = exp->optimize(WANTvalue | WANTinterpret); 
    246246    if (exp->op != TOKstring) 
    247247    {   error("argument to mixin must be a string, not (%s)", exp->toChars()); 
     
    18211821 
    18221822                e = e->semantic(sc); 
     1823        e = e->optimize(WANTvalue | WANTinterpret); 
    18231824                if (e->op == TOKstring) 
    18241825                { 
     
    18411842 
    18421843        e = e->semantic(sc); 
     1844        e = e->optimize(WANTvalue | WANTinterpret); 
    18431845        args->data[0] = (void *)e; 
    18441846        if (e->op != TOKstring)