Changeset 838

Show
Ignore:
Timestamp:
11/17/07 17:28:07 (1 year ago)
Author:
Gregor
Message:

MERGE: DMD 2.007

Files:

Legend:

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

    r837 r838  
    969969        } 
    970970        if (f) 
    971         {   SymOffExp *se = new SymOffExp(loc, f, 0, 0); 
     971        {   f->tookAddressOf = 1; 
     972        SymOffExp *se = new SymOffExp(loc, f, 0, 0); 
    972973        se->semantic(sc); 
    973974        // Let SymOffExp::castTo() do the heavy lifting 
     
    11171118            e->type = t; 
    11181119            } 
     1120            f->tookAddressOf = 1; 
    11191121            return e; 
    11201122        } 
     
    11581160            if (f->tintro && f->tintro->nextOf()->isBaseOf(f->type->nextOf(), &offset) && offset) 
    11591161            error("%s", msg); 
     1162            f->tookAddressOf = 1; 
    11601163            e = new DelegateExp(loc, e1, f); 
    11611164            e->type = t; 
     
    11711174    {   int offset; 
    11721175 
     1176    func->tookAddressOf = 1; 
    11731177    if (func->tintro && func->tintro->nextOf()->isBaseOf(func->type->nextOf(), &offset) && offset) 
    11741178        error("%s", msg); 
     
    12481252    TY ty; 
    12491253 
    1250     //printf("BinExp::typeCombine()\n"); 
     1254    //printf("BinExp::typeCombine() %s\n", toChars()); 
    12511255    //dump(0); 
    12521256 
     
    13221326       ) 
    13231327    { 
    1324         t1 = t1->constOf(); 
    1325         t2 = t2->constOf(); 
     1328        t1 = t1->nextOf()->mutableOf()->constOf()->arrayOf(); 
     1329        t2 = t2->nextOf()->mutableOf()->constOf()->arrayOf(); 
     1330//t1 = t1->constOf(); 
     1331//t2 = t2->constOf(); 
     1332        e1 = e1->castTo(sc, t1); 
     1333        e2 = e2->castTo(sc, t2); 
     1334        goto Lagain; 
    13261335    } 
    13271336    } 
     
    13491358    else if (t1n->mod != t2n->mod) 
    13501359    { 
    1351         t1 = t1->constOf(); 
    1352         t2 = t2->constOf(); 
     1360        t1 = t1n->mutableOf()->constOf()->pointerTo(); 
     1361        t2 = t2n->mutableOf()->constOf()->pointerTo(); 
    13531362        goto Lagain; 
    13541363    } 
     
    14051414        ) 
    14061415    { 
    1407     t1 = t1->constOf(); 
    1408     t2 = t2->constOf(); 
     1416    if (t1->ty == Tpointer) 
     1417        t1 = t1->nextOf()->mutableOf()->constOf()->pointerTo(); 
     1418    else 
     1419        t1 = t1->nextOf()->mutableOf()->constOf()->arrayOf(); 
     1420 
     1421    if (t2->ty == Tpointer) 
     1422        t2 = t2->nextOf()->mutableOf()->constOf()->pointerTo(); 
     1423    else 
     1424        t2 = t2->nextOf()->mutableOf()->constOf()->arrayOf(); 
    14091425    goto Lagain; 
    14101426    } 
     
    14781494    if (!type) 
    14791495    type = t; 
     1496#if 0 
     1497    printf("-BinExp::typeCombine() %s\n", toChars()); 
     1498    if (e1->type) printf("\tt1 = %s\n", e1->type->toChars()); 
     1499    if (e2->type) printf("\tt2 = %s\n", e2->type->toChars()); 
     1500    printf("\ttype = %s\n", type->toChars()); 
     1501#endif 
    14801502    //dump(0); 
    14811503    return this; 
  • branches/dmdfe-2.0/declaration.c

    r837 r838  
    589589    offset = 0; 
    590590    noauto = 0; 
    591     nestedref = 0; 
    592591    inuse = 0; 
    593592    ctorinit = 0; 
     
    842841 
    843842    if (!init && !sc->inunion && !isStatic() && !isConst() && fd && 
    844     !(storage_class & (STCfield | STCin | STCforeach))) 
     843    !(storage_class & (STCfield | STCin | STCforeach)) && 
     844    type->size() != 0) 
    845845    { 
    846846    // Provide a default initializer 
     
    936936        if (t->ty == Tsarray) 
    937937        { 
    938             dim = ((TypeSArray *)t)->dim->toInteger(); 
    939             // If multidimensional static array, treat as one large array 
    940             while (1) 
     938            ei->exp = ei->exp->semantic(sc); 
     939            if (!ei->exp->implicitConvTo(type)) 
    941940            { 
    942             t = t->nextOf()->toBasetype(); 
    943             if (t->ty != Tsarray) 
    944                 break; 
    945             dim *= ((TypeSArray *)t)->dim->toInteger(); 
    946             e1->type = new TypeSArray(t->nextOf(), new IntegerExp(0, dim, Type::tindex)); 
     941            dim = ((TypeSArray *)t)->dim->toInteger(); 
     942            // If multidimensional static array, treat as one large array 
     943            while (1) 
     944            { 
     945                t = t->nextOf()->toBasetype(); 
     946                if (t->ty != Tsarray) 
     947                break; 
     948                dim *= ((TypeSArray *)t)->dim->toInteger(); 
     949                e1->type = new TypeSArray(t->nextOf(), new IntegerExp(0, dim, Type::tindex)); 
     950            } 
    947951            } 
    948952            e1 = new SliceExp(loc, e1, NULL, NULL); 
     
    11171121 
    11181122/************************************ 
    1119  * Check to see if variable is a reference to an enclosing function 
    1120  * or not
     1123 * Check to see if this variable is actually in an enclosing function 
     1124 * rather than the current one
    11211125 */ 
    11221126 
    11231127void VarDeclaration::checkNestedReference(Scope *sc, Loc loc) 
    11241128{ 
    1125     if (!isDataseg() && parent != sc->parent && parent) 
    1126     { 
     1129    if (parent && !isDataseg() && parent != sc->parent) 
     1130    { 
     1131    // The function that this variable is in 
    11271132    FuncDeclaration *fdv = toParent()->isFuncDeclaration(); 
     1133    // The current function 
    11281134    FuncDeclaration *fdthis = sc->parent->isFuncDeclaration(); 
    11291135 
    1130     if (fdv && fdthis
     1136    if (fdv && fdthis && fdv != fdthis
    11311137    { 
    11321138        if (loc.filename) 
    11331139        fdthis->getLevel(loc, fdv); 
    1134         nestedref = 1; 
    1135         fdv->nestedFrameRef = 1; 
     1140 
     1141        for (int i = 0; i < nestedrefs.dim; i++) 
     1142        {   FuncDeclaration *f = (FuncDeclaration *)nestedrefs.data[i]; 
     1143        if (f == fdthis) 
     1144            goto L1; 
     1145        } 
     1146        nestedrefs.push(fdthis); 
     1147      L1: ; 
     1148 
     1149 
     1150        for (int i = 0; i < fdv->closureVars.dim; i++) 
     1151        {   Dsymbol *s = (Dsymbol *)fdv->closureVars.data[i]; 
     1152        if (s == this) 
     1153            goto L2; 
     1154        } 
     1155        fdv->closureVars.push(this); 
     1156      L2: ; 
     1157 
    11361158        //printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars()); 
    11371159    } 
    11381160    } 
    11391161} 
     1162 
    11401163 
    11411164/******************************* 
     
    11531176    if (!parent && !(storage_class & (STCstatic | STCconst))) 
    11541177    {   error("forward referenced"); 
     1178halt(); 
    11551179    type = Type::terror; 
    11561180    return 0; 
     
    12621286/***************************** TypeInfoConstDeclaration **********************/ 
    12631287 
     1288#if V2 
    12641289TypeInfoConstDeclaration::TypeInfoConstDeclaration(Type *tinfo) 
    12651290    : TypeInfoDeclaration(tinfo, 0) 
    12661291{ 
    12671292} 
     1293#endif 
    12681294 
    12691295/***************************** TypeInfoInvariantDeclaration **********************/ 
    12701296 
     1297#if V2 
    12711298TypeInfoInvariantDeclaration::TypeInfoInvariantDeclaration(Type *tinfo) 
    12721299    : TypeInfoDeclaration(tinfo, 0) 
    12731300{ 
    12741301} 
     1302#endif 
    12751303 
    12761304/***************************** TypeInfoStructDeclaration **********************/ 
  • branches/dmdfe-2.0/declaration.h

    r837 r838  
    3232struct TupleType; 
    3333struct InterState; 
     34struct IRState; 
    3435 
    3536enum PROT; 
     
    211212    unsigned offset; 
    212213    int noauto;         // no auto semantics 
    213     int nestedref;     // referenced by a lexically nested function 
     214    FuncDeclarations nestedrefs; // referenced by these lexically nested functions 
    214215    int inuse; 
    215216    int ctorinit;       // it has been initialized in a ctor 
     
    386387 
    387388/**************************************************************/ 
     389#if V2 
    388390 
    389391enum BUILTIN 
     
    397399    BUILTINfabs,        // std.math.fabs 
    398400}; 
     401 
     402#endif 
    399403 
    400404struct FuncDeclaration : Declaration 
     
    427431    int cantInterpret;          // !=0 if cannot interpret function 
    428432    int semanticRun;            // !=0 if semantic3() had been run 
    429     int nestedFrameRef;            // !=0 if nested variables referenced frame ptr 
     433                   // this function's frame ptr 
    430434    ForeachStatement *fes;      // if foreach body, this is the foreach 
    431435    int introducing;            // !=0 if 'introducing' function 
     
    447451    Symbol *shidden;            // hidden pointer passed to function 
    448452 
     453#if V2 
    449454    enum BUILTIN builtin;       // set if this is a known, builtin 
    450455                    // function we can evaluate at compile 
    451456                    // time 
     457 
     458    int tookAddressOf;          // set if someone took the address of 
     459                    // this function 
     460    Dsymbols closureVars;       // local variables in this function 
     461                    // which are referenced by nested 
     462                    // functions 
     463#else 
     464    int nestedFrameRef;         // !=0 if nested variables referenced 
     465#endif 
    452466 
    453467    FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type); 
     
    490504    void toDocBuffer(OutBuffer *buf); 
    491505    FuncDeclaration *isUnique(); 
     506    int needsClosure(); 
    492507 
    493508    static FuncDeclaration *genCfunc(Type *treturn, char *name); 
     
    495510 
    496511    Symbol *toThunkSymbol(int offset);  // thunk version 
     512    void buildClosure(IRState *irs); 
    497513 
    498514    FuncDeclaration *isFuncDeclaration() { return this; } 
  • branches/dmdfe-2.0/expression.c

    r837 r838  
    872872} 
    873873 
    874 void Expression::checkArithmetic() 
     874Expression *Expression::checkArithmetic() 
    875875{ 
    876876    if (!type->isintegral() && !type->isfloating()) 
    877     error("'%s' is not an arithmetic type", toChars()); 
     877    {   error("'%s' is not of arithmetic type, it is a %s", toChars(), type->toChars()); 
     878    return new IntegerExp(0); 
     879    } 
     880    return this; 
    878881} 
    879882 
     
    19721975    type = var->type; 
    19731976    var->isVarDeclaration()->checkNestedReference(sc, loc); 
    1974 #if 0 
    1975     if (fd != fdthis)       // if nested 
    1976     { 
    1977     fdthis->getLevel(loc, fd); 
    1978     fd->vthis->nestedref = 1; 
    1979     fd->nestedFrameRef = 1; 
    1980     } 
    1981 #endif 
    19821977    sc->callSuper |= CSXthis; 
    19831978    return this; 
     
    20802075 
    20812076    var->isVarDeclaration()->checkNestedReference(sc, loc); 
    2082 #if 0 
    2083     if (fd != fdthis) 
    2084     { 
    2085     fdthis->getLevel(loc, fd); 
    2086     fd->vthis->nestedref = 1; 
    2087     fd->nestedFrameRef = 1; 
    2088     } 
    2089 #endif 
    20902077 
    20912078    sc->callSuper |= CSXsuper; 
     
    34403427} 
    34413428 
    3442 /********************** SymOffExp **************************************/ 
    3443  
    3444 SymOffExp::SymOffExp(Loc loc, Declaration *var, unsigned offset, int hasOverloads) 
    3445     : Expression(loc, TOKsymoff, sizeof(SymOffExp)
     3429/********************** SymbolExp **************************************/ 
     3430 
     3431SymbolExp::SymbolExp(Loc loc, enum TOK op, int size, Declaration *var, int hasOverloads) 
     3432    : Expression(loc, op, size
    34463433{ 
    34473434    assert(var); 
    34483435    this->var = var; 
     3436    this->hasOverloads = hasOverloads; 
     3437} 
     3438 
     3439/********************** SymOffExp **************************************/ 
     3440 
     3441SymOffExp::SymOffExp(Loc loc, Declaration *var, unsigned offset, int hasOverloads) 
     3442    : SymbolExp(loc, TOKsymoff, sizeof(SymOffExp), var, hasOverloads) 
     3443{ 
    34493444    this->offset = offset; 
    3450     this->hasOverloads = hasOverloads; 
    34513445 
    34523446    VarDeclaration *v = var->isVarDeclaration(); 
     
    34953489 
    34963490VarExp::VarExp(Loc loc, Declaration *var, int hasOverloads) 
    3497    : Expression(loc, TOKvar, sizeof(VarExp)
    3498 { 
    3499     //printf("VarExp(this = %p, '%s')\n", this, var->toChars()); 
     3491    : SymbolExp(loc, TOKvar, sizeof(VarExp), var, hasOverloads
     3492{ 
     3493    //printf("VarExp(this = %p, '%s', loc = %s)\n", this, var->toChars(), loc.toChars()); 
    35003494    //if (strcmp(var->ident->toChars(), "func") == 0) halt(); 
    3501     this->var = var; 
    35023495    this->type = var->type; 
    3503     this->hasOverloads = hasOverloads; 
    35043496} 
    35053497 
     
    38073799        type = fd->type->pointerTo(); 
    38083800    } 
     3801    fd->tookAddressOf++; 
    38093802    } 
    38103803    return this; 
     
    60055998        if (f) 
    60065999        { 
     6000        if (!dve->hasOverloads) 
     6001            f->tookAddressOf = 1; 
    60076002        Expression *e = new DelegateExp(loc, dve->e1, f, dve->hasOverloads); 
    60086003        e = e->semantic(sc); 
     
    60206015        if (f) 
    60216016        { 
     6017        if (!ve->hasOverloads) 
     6018            f->tookAddressOf = 1; 
    60226019        if (f->isNested()) 
    60236020        { 
     
    60546051    printf("PtrExp::semantic('%s')\n", toChars()); 
    60556052#endif 
    6056     UnaExp::semantic(sc); 
    6057     e1 = resolveProperties(sc, e1); 
    6058     if (type) 
    6059     return this; 
    6060     if (!e1->type) 
    6061     printf("PtrExp::semantic('%s')\n", toChars()); 
    6062     tb = e1->type->toBasetype(); 
    6063     switch (tb->ty) 
    6064     { 
    6065     case Tpointer: 
    6066         type = ((TypePointer *)tb)->next; 
    6067         break; 
    6068  
    6069     case Tsarray: 
    6070     case Tarray: 
    6071         type = ((TypeArray *)tb)->next; 
    6072         e1 = e1->castTo(sc, type->pointerTo()); 
    6073         break; 
    6074  
    6075     default: 
    6076         error("can only * a pointer, not a '%s'", e1->type->toChars()); 
    6077         type = Type::tint32; 
    6078         break; 
    6079     } 
    6080     rvalue(); 
     6053    if (!type) 
     6054    { 
     6055    UnaExp::semantic(sc); 
     6056    e1 = resolveProperties(sc, e1); 
     6057    if (!e1->type) 
     6058        printf("PtrExp::semantic('%s')\n", toChars()); 
     6059    Expression *e = op_overload(sc); 
     6060    if (e) 
     6061        return e; 
     6062    tb = e1->type->toBasetype(); 
     6063    switch (tb->ty) 
     6064    { 
     6065        case Tpointer: 
     6066        type = ((TypePointer *)tb)->next; 
     6067        break; 
     6068 
     6069        case Tsarray: 
     6070        case Tarray: 
     6071        type = ((TypeArray *)tb)->next; 
     6072        e1 = e1->castTo(sc, type->pointerTo()); 
     6073        break; 
     6074 
     6075        default: 
     6076        error("can only * a pointer, not a '%s'", e1->type->toChars()); 
     6077        type = Type::tint32; 
     6078        break; 
     6079    } 
     6080    rvalue(); 
     6081    } 
    60816082    return this; 
    60826083} 
     
    74107411    else 
    74117412    { 
     7413    e1 = e1->checkArithmetic(); 
     7414    e2 = e2->checkArithmetic(); 
    74127415    type = e1->type; 
    74137416    typeCombine(sc); 
    7414     e1->checkArithmetic(); 
    7415     e2->checkArithmetic(); 
    74167417    if (type->isreal() || type->isimaginary()) 
    74177418    { 
  • branches/dmdfe-2.0/expression.h

    r837 r838  
    109109    void checkNoBool(); 
    110110    Expression *checkIntegral(); 
    111     void checkArithmetic(); 
     111    Expression *checkArithmetic(); 
    112112    void checkDeprecated(Scope *sc, Dsymbol *s); 
    113113    virtual Expression *checkToBoolean(); 
     
    328328    Expression *interpret(InterState *istate); 
    329329    Expression *castTo(Scope *sc, Type *t); 
    330     elem *toElem(IRState *irs); 
    331330 
    332331    int inlineCost(InlineCostState *ics); 
     
    353352    MATCH implicitConvTo(Type *t); 
    354353    Expression *castTo(Scope *sc, Type *t); 
    355     dt_t **toDt(dt_t **pdt); 
    356354 
    357355    int inlineCost(InlineCostState *ics); 
     
    370368    Expression *semantic(Scope *sc); 
    371369    int isBool(int result); 
    372     elem *toElem(IRState *irs); 
    373370    int checkSideEffect(int flag); 
    374371    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    401398    Expression *getField(Type *type, unsigned offset); 
    402399    int getFieldIndex(Type *type, unsigned offset); 
    403     elem *toElem(IRState *irs); 
    404400    int checkSideEffect(int flag); 
    405401    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    408404    Expression *optimize(int result); 
    409405    Expression *interpret(InterState *istate); 
    410     dt_t **toDt(dt_t **pdt); 
    411406    Expression *toLvalue(Scope *sc, Expression *e); 
    412407 
     
    496491}; 
    497492 
     493struct SymbolExp : Expression 
     494{ 
     495    Declaration *var; 
     496    int hasOverloads; 
     497 
     498    SymbolExp(Loc loc, enum TOK op, int size, Declaration *var, int hasOverloads); 
     499}; 
     500 
    498501// Offset from symbol 
    499502 
    500 struct SymOffExp : Expression 
    501 
    502     Declaration *var; 
     503struct SymOffExp : SymbolExp 
     504
    503505    unsigned offset; 
    504     int hasOverloads; 
    505506 
    506507    SymOffExp(Loc loc, Declaration *var, unsigned offset, int hasOverloads = 0); 
     
    518519// Variable 
    519520 
    520 struct VarExp : Expression 
    521 
    522     Declaration *var; 
    523     int hasOverloads; 
    524  
     521struct VarExp : SymbolExp 
     522
    525523    VarExp(Loc loc, Declaration *var, int hasOverloads = 0); 
    526524    int equals(Object *o); 
     
    688686 
    689687    Expression *op_overload(Scope *sc); 
    690  
    691     elem *toElemBin(IRState *irs, int op); 
    692688}; 
    693689 
     
    824820    AddrExp(Loc loc, Expression *e); 
    825821    Expression *semantic(Scope *sc); 
    826     elem *toElem(IRState *irs); 
    827822    MATCH implicitConvTo(Type *t); 
    828823    Expression *castTo(Scope *sc, Type *t); 
     
    840835    Expression *optimize(int result); 
    841836    Expression *interpret(InterState *istate); 
     837 
     838    // For operator overloading 
     839    Identifier *opId(); 
    842840}; 
    843841 
  • branches/dmdfe-2.0/func.c

    r837 r838  
    6464    cantInterpret = 0; 
    6565    semanticRun = 0; 
    66     nestedFrameRef = 0; 
    6766    fes = NULL; 
    6867    introducing = 0; 
     
    7574    shidden = NULL; 
    7675    builtin = BUILTINunknown; 
     76    tookAddressOf = 0; 
    7777} 
    7878 
     
    556556    if (!parent) 
    557557    { 
     558    if (global.errors) 
     559        return; 
    558560    printf("FuncDeclaration::semantic3(%s '%s', sc = %p)\n", kind(), toChars(), sc); 
    559561    assert(0); 
    560562    } 
    561     //printf("FuncDeclaration::semantic3('%s.%s', sc = %p)\n", parent->toChars(), toChars(), sc); 
     563    //printf("FuncDeclaration::semantic3('%s.%s', sc = %p, loc = %s)\n", parent->toChars(), toChars(), sc, loc.toChars()); 
    562564    //fflush(stdout); 
    563565    //{ static int x; if (++x == 2) *(char*)0=0; } 
     
    747749            arg->ident = id; 
    748750        } 
    749         VarDeclaration *v = new VarDeclaration(0, arg->type, id, NULL); 
     751        VarDeclaration *v = new VarDeclaration(loc, arg->type, id, NULL); 
    750752        //printf("declaring parameter %s of type %s\n", v->toChars(), v->type->toChars()); 
    751753        v->storage_class |= STCparameter; 
     
    784786            VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration(); 
    785787            assert(v); 
    786             Expression *e = new VarExp(0, v); 
     788            Expression *e = new VarExp(v->loc, v); 
    787789            exps->data[j] = (void *)e; 
    788790            } 
    789791            assert(arg->ident); 
    790             TupleDeclaration *v = new TupleDeclaration(0, arg->ident, exps); 
     792            TupleDeclaration *v = new TupleDeclaration(loc, arg->ident, exps); 
    791793            //printf("declaring tuple %s\n", v->toChars()); 
    792794            v->isexp = 1; 
     
    18711873} 
    18721874 
     1875/******************************* 
     1876 * Look at all the variables in this function that are referenced 
     1877 * by nested functions, and determine if a closure needs to be 
     1878 * created for them. 
     1879 */ 
     1880 
     1881#if V2 
     1882int FuncDeclaration::needsClosure() 
     1883{ 
     1884    /* Need a closure for all the closureVars[] if any of the 
     1885     * closureVars[] are accessed by a 
     1886     * function that escapes the scope of this function. 
     1887     * We take the conservative approach and decide that any function that: 
     1888     * 1) is a virtual function 
     1889     * 2) has its address taken 
     1890     * 3) has a parent that escapes 
     1891     * escapes. 
     1892     */ 
     1893 
     1894    //printf("FuncDeclaration::needsClosure() %s\n", toChars()); 
     1895    for (int i = 0; i < closureVars.dim; i++) 
     1896    {   VarDeclaration *v = (VarDeclaration *)closureVars.data[i]; 
     1897    assert(v->isVarDeclaration()); 
     1898    //printf("\tv = %s\n", v->toChars()); 
     1899 
     1900    for (int j = 0; j < v->nestedrefs.dim; j++) 
     1901    {   FuncDeclaration *f = (FuncDeclaration *)v->nestedrefs.data[j]; 
     1902        assert(f != this); 
     1903 
     1904        //printf("\t\tf = %s, %d, %d\n", f->toChars(), f->isVirtual(), f->tookAddressOf); 
     1905        if (f->isVirtual() || f->tookAddressOf) 
     1906        goto Lyes;  // assume f escapes this function's scope 
     1907 
     1908        // Look to see if any parents of f that are below this escape 
     1909        for (Dsymbol *s = f->parent; s != this; s = s->parent) 
     1910        { 
     1911        f = s->isFuncDeclaration(); 
     1912        if (f && (f->isVirtual() || f->tookAddressOf)) 
     1913            goto Lyes; 
     1914        } 
     1915    } 
     1916    } 
     1917    return 0; 
     1918 
     1919Lyes: 
     1920    //printf("\tneeds closure\n"); 
     1921    return 1; 
     1922} 
     1923#endif 
     1924 
    18731925/****************************** FuncAliasDeclaration ************************/ 
    18741926 
  • branches/dmdfe-2.0/idgen.c

    r836 r838  
    191191    { "opIn" }, 
    192192    { "opIn_r" }, 
     193    { "opStar" }, 
    193194 
    194195    { "classNew", "new" }, 
  • branches/dmdfe-2.0/inline.c

    r740 r838  
    547547    else 
    548548    { 
    549         ExpInitializer *ie; 
    550         ExpInitializer *ieto; 
    551549        VarDeclaration *vto; 
    552550 
     
    560558        ids->to.push(vto); 
    561559 
    562         if (vd->init->isVoidInitializer()
     560        if (vd->init
    563561        { 
    564         vto->init = new VoidInitializer(vd->init->loc); 
    565         } 
    566         else 
    567         { 
    568         ie = vd->init->isExpInitializer(); 
    569         assert(ie); 
    570         ieto = new ExpInitializer(ie->loc, ie->exp->doInline(ids)); 
    571         vto->init = ieto; 
     562        if (vd->init->isVoidInitializer()) 
     563        { 
     564            vto->init = new VoidInitializer(vd->init->loc); 
     565        } 
     566        else 
     567        { 
     568            ExpInitializer *ie = vd->init->isExpInitializer(); 
     569            assert(ie); 
     570            vto->init = new ExpInitializer(ie->loc, ie->exp->doInline(ids)); 
     571        } 
    572572        } 
    573573        de->declaration = (Dsymbol *) (void *)vto; 
     
    855855{ 
    856856    aggr = aggr->inlineScan(iss); 
    857     body = body->inlineScan(iss); 
     857    if (body) 
     858    body = body->inlineScan(iss); 
    858859    return this; 
    859860} 
     
    865866    lwr = lwr->inlineScan(iss); 
    866867    upr = upr->inlineScan(iss); 
    867     body = body->inlineScan(iss); 
     868    if (body) 
     869    body = body->inlineScan(iss); 
    868870    return this; 
    869871} 
     
    12891291    isSynchronized() || 
    12901292    isImportedSymbol() || 
     1293#if V2 
     1294    closureVars.dim ||  // no nested references to this frame 
     1295#else 
    12911296    nestedFrameRef ||   // no nested references to this frame 
     1297#endif 
    12921298    (isVirtual() && !isFinal()) 
    12931299       )) 
  • branches/dmdfe-2.0/lexer.c

    r837 r838  
    30233023    Token::tochars[TOKdeclaration]  = "declaration"; 
    30243024    Token::tochars[TOKdottd]        = "dottd"; 
    3025 
     3025    Token::tochars[TOKon_scope_exit]    = "scope(exit)"; 
     3026
  • branches/dmdfe-2.0/mars.c

    r837 r838  
    5656    copyright = "Copyright (c) 1999-2007 by Digital Mars"; 
    5757    written = "written by Walter Bright"; 
    58     version = "v2.006"; 
     58    version = "v2.007"; 
    5959    global.structalign = 8; 
    6060 
     
    110110    fprintf(stdmsg, "\n"); 
    111111    fflush(stdmsg); 
    112 halt(); 
     112//halt(); 
    113113    } 
    114114    global.errors++; 
  • branches/dmdfe-2.0/mtype.c

    r837 r838  
    670670 
    671671 
    672 Expression *Type::defaultInit(
     672Expression *Type::defaultInit(Loc loc
    673673{ 
    674674#if LOGDEFAULTINIT 
     
    734734    if (ty == Tvoid) 
    735735        error(loc, "void does not have an initializer"); 
    736     e = defaultInit(); 
    737     e->loc = loc; 
     736    e = defaultInit(loc); 
    738737    } 
    739738    else if (ident == Id::mangleof) 
     
    812811                v->type->toBasetype()->ty == Tstruct) 
    813812            { 
    814                 e = v->type->defaultInit(); 
     813                e = v->type->defaultInit(e->loc); 
    815814            } 
    816815            } 
     
    822821        } 
    823822#endif 
    824         Expression *ex = defaultInit(); 
    825         ex->loc = e->loc; 
     823        Expression *ex = defaultInit(e->loc); 
    826824        return ex; 
    827825    } 
     
    978976    return cto; 
    979977    TypeNext *t = (TypeNext *)Type::makeConst(); 
    980     if (ty != Tfunction && ty != Tdelegate && next->deco) 
     978    if (ty != Tfunction && ty != Tdelegate && next->deco && 
     979        !next->isInvariant()) 
    981980    t->next = next->constOf(); 
    982981    return t; 
     
    15471546} 
    15481547 
    1549 Expression *TypeBasic::defaultInit(
     1548Expression *TypeBasic::defaultInit(Loc loc
    15501549{   integer_t value = 0; 
    15511550 
     
    15731572    case Tcomplex64: 
    15741573    case Tcomplex80: 
    1575         return getProperty(0, Id::nan); 
    1576     } 
    1577     return new IntegerExp(0, value, this); 
     1574        return getProperty(loc, Id::nan); 
     1575 
     1576    case Tvoid: 
     1577        error(loc, "void does not have a default initializer"); 
     1578    } 
     1579    return new IntegerExp(loc, value, this); 
    15781580} 
    15791581 
     
    19901992 
    19911993    dim = dim->optimize(WANTvalue | WANTinterpret); 
     1994    if (sc->parameterSpecialization && dim->op == TOKvar && 
     1995        ((VarExp *)dim)->var->storage_class & STCtemplateparameter) 
     1996    { 
     1997        /* It could be a template parameter N which has no value yet: 
     1998         *   template Foo(T : T[N], size_t N); 
     1999         */ 
     2000        return this; 
     2001    } 
    19922002    integer_t d1 = dim->toInteger(); 
    19932003    dim = dim->castTo(sc, tsize_t); 
     
    21712181} 
    21722182 
    2173 Expression *TypeSArray::defaultInit(
     2183Expression *TypeSArray::defaultInit(Loc loc
    21742184{ 
    21752185#if LOGDEFAULTINIT 
    21762186    printf("TypeSArray::defaultInit() '%s'\n", toChars()); 
    21772187#endif 
    2178     return next->defaultInit(); 
     2188    return next->defaultInit(loc); 
    21792189} 
    21802190 
     
    23592369} 
    23602370 
    2361 Expression *TypeDArray::defaultInit(
     2371Expression *TypeDArray::defaultInit(Loc loc
    23622372{ 
    23632373#if LOGDEFAULTINIT 
     
    23652375#endif 
    23662376    Expression *e; 
    2367     e = new NullExp(0); 
     2377    e = new NullExp(loc); 
    23682378    e->type = this; 
    23692379    return e; 
     
    25642574} 
    25652575 
    2566 Expression *TypeAArray::defaultInit(
     2576Expression *TypeAArray::defaultInit(Loc loc
    25672577{ 
    25682578#if LOGDEFAULTINIT 
     
    25702580#endif 
    25712581    Expression *e; 
    2572     e = new NullExp(0); 
     2582    e = new NullExp(loc); 
    25732583    e->type = this; 
    25742584    return e; 
     
    26802690} 
    26812691 
    2682 Expression *TypePointer::defaultInit(
     2692Expression *TypePointer::defaultInit(Loc loc
    26832693{ 
    26842694#if LOGDEFAULTINIT 
     
    26862696#endif 
    26872697    Expression *e; 
    2688     e = new NullExp(0); 
     2698    e = new NullExp(loc); 
    26892699    e->type = this; 
    26902700    return e; 
     
    27622772} 
    27632773 
    2764 Expression *TypeReference::defaultInit(
     2774Expression *TypeReference::defaultInit(Loc loc
    27652775{ 
    27662776#if LOGDEFAULTINIT 
     
    27682778#endif 
    27692779    Expression *e; 
    2770     e = new NullExp(0); 
     2780    e = new NullExp(loc); 
    27712781    e->type = this; 
    27722782    return e; 
     
    32953305} 
    32963306 
    3297 Expression *TypeDelegate::defaultInit(
     3307Expression *TypeDelegate::defaultInit(Loc loc
    32983308{ 
    32993309#if LOGDEFAULTINIT 
     
    33013311#endif 
    33023312    Expression *e; 
    3303     e = new NullExp(0); 
     3313    e = new NullExp(loc); 
    33043314    e->type = this; 
    33053315    return e; 
     
    40974107    if (!sym->symtab) 
    40984108        goto Lfwd; 
    4099     e = defaultInit(); 
     4109    e = defaultInit(loc); 
    41004110    } 
    41014111    else 
     
    41574167 
    41584168 
    4159 Expression *TypeEnum::defaultInit(
     4169Expression *TypeEnum::defaultInit(Loc loc
    41604170{ 
    41614171#if LOGDEFAULTINIT 
     
    41644174    // Initialize to first member of enum 
    41654175    Expression *e; 
    4166     e = new IntegerExp(0, sym->defaultval, this); 
     4176    e = new IntegerExp(loc, sym->defaultval, this); 
    41674177    return e; 
    41684178} 
     
    43514361 
    43524362 
    4353 Expression *TypeTypedef::defaultInit(
     4363Expression *TypeTypedef::defaultInit(Loc loc
    43544364{   Expression *e; 
    43554365    Type *bt; 
     
    43644374    } 
    43654375    bt = sym->basetype; 
    4366     e = bt->defaultInit(); 
     4376    e = bt->defaultInit(loc); 
    43674377    e->type = this; 
    43684378    while (bt->ty == Tsarray) 
     
    46444654} 
    46454655 
    4646 Expression *TypeStruct::defaultInit(
     4656Expression *TypeStruct::defaultInit(Loc loc
    46474657{   Symbol *s; 
    46484658    Declaration *d; 
     
    50745084} 
    50755085 
    5076 Expression *TypeClass::defaultInit(
     5086Expression *TypeClass::defaultInit(Loc loc
    50775087{ 
    50785088#if LOGDEFAULTINIT 
     
    50805090#endif 
    50815091    Expression *e; 
    5082     e = new NullExp(0); 
     5092    e = new NullExp(loc); 
    50835093    e->type = this; 
    50845094    return e; 
  • branches/dmdfe-2.0/mtype.h

    r836 r838  
    243243    virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 
    244244    virtual unsigned memalign(unsigned salign); 
    245     virtual Expression *defaultInit(); 
     245    virtual Expression *defaultInit(Loc loc = 0); 
    246246    virtual int isZeroInit();       // if initializer is 0 
    247247    Identifier *getTypeInfoIdent(int internal); 
     
    300300    int isunsigned(); 
    301301    MATCH implicitConvTo(Type *to); 
    302     Expression *defaultInit(); 
     302    Expression *defaultInit(Loc loc); 
    303303    int isZeroInit(); 
    304304 
     
    332332    MATCH constConv(Type *to)