Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 812

Show
Ignore:
Timestamp:
12/23/10 04:52:15 (14 years ago)
Author:
walter
Message:

harmonize some 64 bit patches from dmd1, other fixes from Brad

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/e2ir.c

    r775 r812  
    24502450    else 
    24512451        e = toElemBin(irs, eop); 
    24522452 
    24532453    return e; 
    24542454} 
    24552455 
    24562456 
    24572457/*************************************** 
    24582458 */ 
    24592459 
    24602460elem *InExp::toElem(IRState *irs) 
    24612461{   elem *e; 
    24622462    elem *key = e1->toElem(irs); 
    24632463    elem *aa = e2->toElem(irs); 
    24642464    elem *ep; 
    24652465    elem *keyti; 
    24662466    TypeAArray *taa = (TypeAArray *)e2->type->toBasetype(); 
    24672467 
    24682468 
    24692469    // set to: 
    2470     //  aaIn(aa, keyti, key); 
    2471  
    2472     if (tybasic(key->Ety) == TYstruct) 
    2473     { 
    2474         key = el_una(OPstrpar, TYstruct, key); 
    2475         key->ET = key->E1->ET; 
    2476     } 
    2477     else if (tybasic(key->Ety) == TYarray && taa->index->ty == Tsarray) 
    2478     {   // e2->elem() turns string literals into a TYarray, so the 
    2479         // length is lost. Restore it. 
    2480         key = el_una(OPstrpar, TYstruct, key); 
    2481         assert(e1->type->size() == taa->index->size()); 
    2482         key->ET = taa->index->toCtype(); 
    2483     } 
    2484  
    2485     Symbol *s = taa->aaGetSymbol("In", 0); 
     2470    Symbol *s; 
     2471    if (I64) 
     2472    { 
     2473        // aaInX(aa, keyti, key); 
     2474        key = addressElem(key, e1->type); 
     2475        s = taa->aaGetSymbol("InX", 0); 
     2476    } 
     2477    else 
     2478    { 
     2479        //  aaIn(aa, keyti, key); 
     2480        if (tybasic(key->Ety) == TYstruct) 
     2481        { 
     2482            key = el_una(OPstrpar, TYstruct, key); 
     2483            key->ET = key->E1->ET; 
     2484        } 
     2485        else if (tybasic(key->Ety) == TYarray && taa->index->ty == Tsarray) 
     2486        {   // e2->elem() turns string literals into a TYarray, so the 
     2487            // length is lost. Restore it. 
     2488            key = el_una(OPstrpar, TYstruct, key); 
     2489            assert(e1->type->size() == taa->index->size()); 
     2490            key->ET = taa->index->toCtype(); 
     2491        } 
     2492 
     2493        s = taa->aaGetSymbol("In", 0); 
     2494    } 
    24862495    keyti = taa->index->getInternalTypeInfo(NULL)->toElem(irs); 
    24872496    ep = el_params(key, keyti, aa, NULL); 
    24882497    e = el_bin(OPcall, type->totym(), el_var(s), ep); 
    24892498 
    24902499    el_setLoc(e,loc); 
    24912500    return e; 
    24922501} 
    24932502 
    24942503/*************************************** 
    24952504 */ 
    24962505 
    24972506elem *RemoveExp::toElem(IRState *irs) 
    24982507{   elem *e; 
    24992508    Type *tb = e1->type->toBasetype(); 
    25002509    assert(tb->ty == Taarray); 
    25012510    TypeAArray *taa = (TypeAArray *)tb; 
    25022511    elem *ea = e1->toElem(irs); 
    25032512    elem *ekey = e2->toElem(irs); 
    25042513    elem *ep; 
    25052514    elem *keyti; 
    25062515 
    2507     if (tybasic(ekey->Ety) == TYstruct || tybasic(ekey->Ety) == TYarray) 
    2508     { 
    2509         ekey = el_una(OPstrpar, TYstruct, ekey); 
    2510         ekey->ET = ekey->E1->ET; 
    2511     } 
    2512  
    2513     Symbol *s = taa->aaGetSymbol("Del", 0); 
     2516    Symbol *s; 
     2517    if (I64) 
     2518    { 
     2519        ekey = addressElem(ekey, e1->type); 
     2520        s = taa->aaGetSymbol("DelX", 0); 
     2521    } 
     2522    else 
     2523    { 
     2524        if (tybasic(ekey->Ety) == TYstruct || tybasic(ekey->Ety) == TYarray) 
     2525        { 
     2526            ekey = el_una(OPstrpar, TYstruct, ekey); 
     2527            ekey->ET = ekey->E1->ET; 
     2528        } 
     2529 
     2530        s = taa->aaGetSymbol("Del", 0); 
     2531    } 
    25142532    keyti = taa->index->getInternalTypeInfo(NULL)->toElem(irs); 
    25152533    ep = el_params(ekey, keyti, ea, NULL); 
    25162534    e = el_bin(OPcall, TYnptr, el_var(s), ep); 
    25172535 
    25182536    el_setLoc(e,loc); 
    25192537    return e; 
    25202538} 
    25212539 
    25222540/*************************************** 
    25232541 */ 
    25242542 
    25252543elem *AssignExp::toElem(IRState *irs) 
    25262544{ 
    25272545    //printf("AssignExp::toElem('%s')\n", toChars()); 
    25282546    Type *t1b = e1->type->toBasetype(); 
    25292547 
    25302548    // Look for array.length = n 
    25312549    if (e1->op == TOKarraylength) 
    25322550    { 
    25332551        // Generate: 
     
    43674385        e = el_combine(einit, e); 
    43684386    } 
    43694387    else if (t1->ty == Tsarray) 
    43704388    { 
    43714389        e = sarray_toDarray(loc, t1, NULL, e); 
    43724390    } 
    43734391    el_setLoc(e,loc); 
    43744392    return e; 
    43754393} 
    43764394 
    43774395elem *IndexExp::toElem(IRState *irs) 
    43784396{   elem *e; 
    43794397    elem *n1 = e1->toElem(irs); 
    43804398    elem *eb = NULL; 
    43814399 
    43824400    //printf("IndexExp::toElem() %s\n", toChars()); 
    43834401    Type *t1 = e1->type->toBasetype(); 
    43844402    if (t1->ty == Taarray) 
    43854403    { 
    43864404        // set to: 
    4387         //      *aaGet(aa, keyti, valuesize, index); 
     4405        //      *aaGetX(aa, keyti, valuesize, &key); 
    43884406 
    43894407        TypeAArray *taa = (TypeAArray *)t1; 
    4390         elem *keyti; 
    4391         elem *ep; 
    43924408        int vsize = taa->next->size(); 
    43934409        Symbol *s; 
    43944410 
    43954411        // n2 becomes the index, also known as the key 
    43964412        elem *n2 = e2->toElem(irs); 
    4397         if (tybasic(n2->Ety) == TYstruct || tybasic(n2->Ety) == TYarray) 
    4398         { 
    4399             n2 = el_una(OPstrpar, TYstruct, n2); 
    4400             n2->ET = n2->E1->ET; 
    4401             if (taa->index->ty == Tsarray) 
    4402             { 
    4403                 assert(e2->type->size() == taa->index->size()); 
    4404             } 
    4405             //printf("numbytes = %d\n", n2->Enumbytes); 
    4406         } 
    4407         elem *valuesize = el_long(TYuint, vsize);       // BUG: should be TYsize_t 
     4413 
     4414        if (I64) 
     4415        { 
     4416            /* Turn n2 into a pointer to the index.  If it's an lvalue, 
     4417             * take the address of it. If not, copy it to a temp and 
     4418             * take the address of that. 
     4419             */ 
     4420            n2 = addressElem(n2, taa->index); 
     4421        } 
     4422        else 
     4423        { 
     4424            if (tybasic(n2->Ety) == TYstruct || tybasic(n2->Ety) == TYarray) 
     4425            { 
     4426                n2 = el_una(OPstrpar, TYstruct, n2); 
     4427                n2->ET = n2->E1->ET; 
     4428                if (taa->index->ty == Tsarray) 
     4429                { 
     4430                    assert(e2->type->size() == taa->index->size()); 
     4431                } 
     4432                //printf("numbytes = %d\n", n2->Enumbytes); 
     4433            } 
     4434        } 
     4435 
     4436        elem *valuesize = el_long(TYsize_t, vsize); 
    44084437        //printf("valuesize: "); elem_print(valuesize); 
    44094438        if (modifiable) 
    44104439        { 
    44114440            n1 = el_una(OPaddr, TYnptr, n1); 
    4412             s = taa->aaGetSymbol("Get", 1); 
     4441            s = taa->aaGetSymbol(I64 ? "GetX" : "Get", 1); 
    44134442        } 
    44144443        else 
    44154444        { 
    4416             s = taa->aaGetSymbol("GetRvalue", 1); 
     4445            s = taa->aaGetSymbol(I64 ? "GetRvalueX" : "GetRvalue", 1); 
    44174446        } 
    44184447        //printf("taa->index = %s\n", taa->index->toChars()); 
    4419         keyti = taa->index->getInternalTypeInfo(NULL)->toElem(irs); 
     4448        elem* keyti = taa->index->getInternalTypeInfo(NULL)->toElem(irs); 
    44204449        //keyti = taa->index->getTypeInfo(NULL)->toElem(irs); 
    44214450        //printf("keyti:\n"); 
    44224451        //elem_print(keyti); 
    4423         ep = el_params(n2, valuesize, keyti, n1, NULL); 
     4452        elem* ep = el_params(n2, valuesize, keyti, n1, NULL); 
    44244453        e = el_bin(OPcall, TYnptr, el_var(s), ep); 
    44254454        if (irs->arrayBoundsCheck()) 
    44264455        { 
    44274456            elem *ea; 
    44284457 
    44294458            elem *n = el_same(&e); 
    44304459 
    44314460            // Construct: ((e || ModuleAssert(line)),n) 
    44324461            Symbol *sassert = irs->blx->module->toModuleArray(); 
    44334462            ea = el_bin(OPcall,TYvoid,el_var(sassert), 
    44344463                el_long(TYint, loc.linnum)); 
    44354464            e = el_bin(OPoror,TYvoid,e,ea); 
    44364465            e = el_bin(OPcomma, TYnptr, e, n); 
    44374466        } 
    44384467        e = el_una(OPind, type->totym(), e); 
    44394468        if (tybasic(e->Ety) == TYstruct) 
    44404469            e->ET = type->toCtype(); 
    44414470    } 
    44424471    else 
    44434472    { 
  • trunk/src/expression.c

    r798 r812  
    53225322} 
    53235323 
    53245324Expression *BinExp::semantic(Scope *sc) 
    53255325{ 
    53265326#if LOGSEMANTIC 
    53275327    printf("BinExp::semantic('%s')\n", toChars()); 
    53285328#endif 
    53295329    e1 = e1->semantic(sc); 
    53305330    if (!e1->type && 
    53315331        !(op == TOKassign && e1->op == TOKdottd))       // a.template = e2 
    53325332    { 
    53335333        error("%s has no value", e1->toChars()); 
    53345334        return new ErrorExp(); 
    53355335    } 
    53365336    e2 = e2->semantic(sc); 
    53375337    if (!e2->type) 
    53385338    { 
    53395339        error("%s has no value", e2->toChars()); 
    53405340        return new ErrorExp(); 
    53415341    } 
     5342    if (e1->op == TOKerror || e2->op == TOKerror) 
     5343        return new ErrorExp(); 
    53425344    return this; 
    53435345} 
    53445346 
    53455347Expression *BinExp::semanticp(Scope *sc) 
    53465348{ 
    53475349    BinExp::semantic(sc); 
    53485350    e1 = resolveProperties(sc, e1); 
    53495351    e2 = resolveProperties(sc, e2); 
    53505352    return this; 
    53515353} 
    53525354 
    53535355int BinExp::checkSideEffect(int flag) 
    53545356{ 
    53555357    if (op == TOKplusplus || 
    53565358           op == TOKminusminus || 
    53575359           op == TOKassign || 
    53585360           op == TOKconstruct || 
    53595361           op == TOKblit || 
    53605362           op == TOKaddass || 
    53615363           op == TOKminass || 
     
    85288530    //printf("IndexExp::IndexExp('%s')\n", toChars()); 
    85298531    lengthVar = NULL; 
    85308532    modifiable = 0;     // assume it is an rvalue 
    85318533} 
    85328534 
    85338535Expression *IndexExp::semantic(Scope *sc) 
    85348536{   Expression *e; 
    85358537    BinExp *b; 
    85368538    UnaExp *u; 
    85378539    Type *t1; 
    85388540    ScopeDsymbol *sym; 
    85398541 
    85408542#if LOGSEMANTIC 
    85418543    printf("IndexExp::semantic('%s')\n", toChars()); 
    85428544#endif 
    85438545    if (type) 
    85448546        return this; 
    85458547    if (!e1->type) 
    85468548        e1 = e1->semantic(sc); 
    85478549    assert(e1->type);           // semantic() should already be run on it 
     8550    if (e1->op == TOKerror) 
     8551        goto Lerr; 
    85488552    e = this; 
    85498553 
    85508554    // Note that unlike C we do not implement the int[ptr] 
    85518555 
    85528556    t1 = e1->type->toBasetype(); 
    85538557 
    85548558    if (t1->ty == Tsarray || t1->ty == Tarray || t1->ty == Ttuple) 
    85558559    {   // Create scope for 'length' variable 
    85568560        sym = new ArrayScopeSymbol(sc, this); 
    85578561        sym->loc = loc; 
    85588562        sym->parent = sc->scopesym; 
    85598563        sc = sc->push(sym); 
    85608564    } 
    85618565 
    85628566    e2 = e2->semantic(sc); 
    85638567    if (!e2->type) 
    85648568    { 
    85658569        error("%s has no value", e2->toChars()); 
    85668570        goto Lerr; 
    85678571    } 
     
    86378641                assert(0); 
    86388642 
    86398643            if (index < length) 
    86408644            { 
    86418645 
    86428646                if (e1->op == TOKtuple) 
    86438647                    e = (Expression *)te->exps->data[(size_t)index]; 
    86448648                else 
    86458649                    e = new TypeExp(e1->loc, Parameter::getNth(tup->arguments, (size_t)index)->type); 
    86468650            } 
    86478651            else 
    86488652            { 
    86498653                error("array index [%ju] is outside array bounds [0 .. %zu]", 
    86508654                        index, length); 
    86518655                e = e1; 
    86528656            } 
    86538657            break; 
    86548658        } 
    86558659 
    86568660        default: 
     8661            if (e1->op == TOKerror) 
     8662                goto Lerr; 
    86578663            error("%s must be an array or pointer type, not %s", 
    86588664                e1->toChars(), e1->type->toChars()); 
    86598665        case Terror: 
    86608666            goto Lerr; 
    86618667    } 
    86628668    return e; 
    86638669 
    86648670Lerr: 
    86658671    return new ErrorExp(); 
    86668672} 
    86678673 
    86688674#if DMDV2 
    86698675int IndexExp::isLvalue() 
    86708676{ 
    86718677    return 1; 
    86728678} 
    86738679#endif 
    86748680 
    86758681Expression *IndexExp::toLvalue(Scope *sc, Expression *e) 
    86768682{ 
     
    89248930            // Rewrite (a[i..j] = value) to (a.opSliceAssign(value, i, j)) 
    89258931            if (search_function(ad, Id::sliceass)) 
    89268932            {   Expression *e = new DotIdExp(loc, ae->e1, Id::sliceass); 
    89278933                Expressions *a = new Expressions(); 
    89288934 
    89298935                a->push(e2); 
    89308936                if (ae->lwr) 
    89318937                {   a->push(ae->lwr); 
    89328938                    assert(ae->upr); 
    89338939                    a->push(ae->upr); 
    89348940                } 
    89358941                else 
    89368942                    assert(!ae->upr); 
    89378943                e = new CallExp(loc, e, a); 
    89388944                e = e->semantic(sc); 
    89398945                return e; 
    89408946            } 
    89418947        } 
    89428948    } 
    89438949 
    8944     BinExp::semantic(sc); 
     8950    Expression *e = BinExp::semantic(sc); 
     8951    if (e->op == TOKerror) 
     8952        return e; 
    89458953 
    89468954    if (e1->op == TOKdottd) 
    89478955    {   // Rewrite a.b=e2, when b is a template, as a.b(e2) 
    89488956        Expression *e = new CallExp(loc, e1, e2); 
    89498957        e = e->semantic(sc); 
    89508958        return e; 
    89518959    } 
    89528960 
    89538961    e2 = resolveProperties(sc, e2); 
    89548962    assert(e1->type); 
    89558963 
    89568964    /* Rewrite tuple assignment as a tuple of assignments. 
    89578965     */ 
    89588966    if (e1->op == TOKtuple && e2->op == TOKtuple) 
    89598967    {   TupleExp *tup1 = (TupleExp *)e1; 
    89608968        TupleExp *tup2 = (TupleExp *)e2; 
    89618969        size_t dim = tup1->exps->dim; 
    89628970        if (dim != tup2->exps->dim) 
    89638971        { 
    89648972            error("mismatched tuple lengths, %d and %d", (int)dim, (int)tup2->exps->dim); 
  • trunk/src/func.c

    r809 r812  
    912912        { 
    913913            /* The 'this' for a nested function is the link to the 
    914914             * enclosing function's stack frame. 
    915915             * Note that nested functions and member functions are disjoint. 
    916916             */ 
    917917            VarDeclaration *v = new ThisDeclaration(loc, Type::tvoid->pointerTo()); 
    918918            v->storage_class |= STCparameter; 
    919919            v->semantic(sc2); 
    920920            if (!sc2->insert(v)) 
    921921                assert(0); 
    922922            v->parent = this; 
    923923            vthis = v; 
    924924        } 
    925925 
    926926        // Declare hidden variable _arguments[] and _argptr 
    927927        if (f->varargs == 1) 
    928928        { 
    929929#if TARGET_NET 
    930930        varArgs(sc2, f, argptr, _arguments); 
    931931#else 
    932         Type *t; 
     932            Type *t; 
     933 
     934            if (global.params.isX86_64) 
     935            {   // Declare save area for varargs registers 
     936                Type *t = new TypeIdentifier(loc, Id::va_argsave_t); 
     937                t = t->semantic(loc, sc); 
     938                if (t == Type::terror) 
     939                    error("must import core.vararg to use variadic functions"); 
     940                else 
     941                { 
     942                    v_argsave = new VarDeclaration(loc, t, Id::va_argsave, NULL); 
     943                    v_argsave->semantic(sc2); 
     944                    sc2->insert(v_argsave); 
     945                    v_argsave->parent = this; 
     946                } 
     947            } 
    933948 
    934949            if (f->linkage == LINKd) 
    935950            {   // Declare _arguments[] 
    936951#if BREAKABI 
    937952                v_arguments = new VarDeclaration(0, Type::typeinfotypelist->type, Id::_arguments_typeinfo, NULL); 
    938953                v_arguments->storage_class = STCparameter; 
    939954                v_arguments->semantic(sc2); 
    940955                sc2->insert(v_arguments); 
    941956                v_arguments->parent = this; 
    942957 
    943958                //t = Type::typeinfo->type->constOf()->arrayOf(); 
    944959                t = Type::typeinfo->type->arrayOf(); 
    945960                _arguments = new VarDeclaration(0, t, Id::_arguments, NULL); 
    946961                _arguments->semantic(sc2); 
    947962                sc2->insert(_arguments); 
    948963                _arguments->parent = this; 
    949964#else 
    950965                t = Type::typeinfo->type->arrayOf(); 
    951966                v_arguments = new VarDeclaration(0, t, Id::_arguments, NULL); 
    952967                v_arguments->storage_class = STCparameter | STCin; 
    953968                v_arguments->semantic(sc2); 
    954969                sc2->insert(v_arguments); 
    955970                v_arguments->parent = this; 
    956971#endif 
    957972            } 
    958973            if (f->linkage == LINKd || (parameters && parameters->dim)) 
    959974            {   // Declare _argptr 
    960975#if IN_GCC 
    961976                t = d_gcc_builtin_va_list_d_type; 
    962977#else 
    963978                t = Type::tvoid->pointerTo(); 
    964979#endif 
    965980                argptr = new VarDeclaration(0, t, Id::_argptr, NULL); 
    966981                argptr->semantic(sc2); 
    967982                sc2->insert(argptr); 
    968983                argptr->parent = this; 
    969984            } 
    970985#endif 
    971         } 
    972         if (global.params.isX86_64 && f->varargs && f->linkage == LINKc) 
    973         {   // Declare save area for varargs registers 
    974             Type *t = new TypeIdentifier(loc, Id::va_argsave_t); 
    975             t = t->semantic(loc, sc); 
    976             if (t == Type::terror) 
    977                 error("must import std.c.stdarg to use variadic functions"); 
    978             else 
    979             { 
    980                 v_argsave = new VarDeclaration(loc, t, Id::va_argsave, NULL); 
    981                 v_argsave->semantic(sc2); 
    982                 sc2->insert(v_argsave); 
    983                 v_argsave->parent = this; 
    984             } 
    985986        } 
    986987 
    987988#if 0 
    988989        // Propagate storage class from tuple parameters to their element-parameters. 
    989990        if (f->parameters) 
    990991        { 
    991992            for (size_t i = 0; i < f->parameters->dim; i++) 
    992993            {   Parameter *arg = (Parameter *)f->parameters->data[i]; 
    993994 
    994995                //printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars()); 
    995996                if (arg->type->ty == Ttuple) 
    996997                {   TypeTuple *t = (TypeTuple *)arg->type; 
    997998                    size_t dim = Parameter::dim(t->arguments); 
    998999                    for (size_t j = 0; j < dim; j++) 
    9991000                    {   Parameter *narg = Parameter::getNth(t->arguments, j); 
    10001001                        narg->storageClass = arg->storageClass; 
    10011002                    } 
    10021003                } 
    10031004            } 
    10041005        } 
     
    13671368            Statements *a = new Statements(); 
    13681369 
    13691370            // Merge in initialization of 'out' parameters 
    13701371            if (parameters) 
    13711372            {   for (size_t i = 0; i < parameters->dim; i++) 
    13721373                { 
    13731374                    VarDeclaration *v = (VarDeclaration *)parameters->data[i]; 
    13741375                    if (v->storage_class & STCout) 
    13751376                    { 
    13761377                        assert(v->init); 
    13771378                        ExpInitializer *ie = v->init->isExpInitializer(); 
    13781379                        assert(ie); 
    13791380                        if (ie->exp->op == TOKconstruct) 
    13801381                            ie->exp->op = TOKassign; // construction occured in parameter processing 
    13811382                        a->push(new ExpStatement(0, ie->exp)); 
    13821383                    } 
    13831384                } 
    13841385            } 
    13851386 
    13861387            if (argptr) 
    1387             {   // Initialize _argptr to point past non-variadic arg 
     1388            {   // Initialize _argptr 
    13881389#if IN_GCC 
    13891390                // Handled in FuncDeclaration::toObjFile 
    13901391                v_argptr = argptr; 
    13911392                v_argptr->init = new VoidInitializer(loc); 
    13921393#else 
    13931394                Type *t = argptr->type; 
    1394                 VarDeclaration *p; 
    1395                 unsigned offset = 0; 
    1396  
    1397                 Expression *e1 = new VarExp(0, argptr); 
    1398                 // Find the last non-ref parameter 
    1399                 if (parameters && parameters->dim) 
    1400                 { 
    1401                     int lastNonref = parameters->dim -1; 
    1402                     p = (VarDeclaration *)parameters->data[lastNonref]; 
    1403                     /* The trouble with out and ref parameters is that taking 
    1404                      * the address of it doesn't work, because later processing 
    1405                      * adds in an extra level of indirection. So we skip over them. 
    1406                      */ 
    1407                     while (p->storage_class & (STCout | STCref)) 
    1408                     { 
    1409                         --lastNonref; 
    1410                         offset += PTRSIZE; 
    1411                         if (lastNonref < 0) 
    1412                         { 
    1413                             p = v_arguments; 
    1414                             break; 
    1415                         } 
    1416                         p = (VarDeclaration *)parameters->data[lastNonref]; 
    1417                     } 
     1395                if (global.params.isX86_64) 
     1396                {   // Initialize _argptr to point to v_argsave 
     1397                    Expression *e1 = new VarExp(0, argptr); 
     1398                    Expression *e = new SymOffExp(0, v_argsave, 6*8 + 8*16); 
     1399                    e->type = argptr->type; 
     1400                    e = new AssignExp(0, e1, e); 
     1401                    e = e->semantic(sc); 
     1402                    a->push(new ExpStatement(0, e)); 
    14181403                } 
    14191404                else 
    1420                     p = v_arguments;            // last parameter is _arguments[] 
    1421                 if (p->storage_class & STClazy) 
    1422                     // If the last parameter is lazy, it's the size of a delegate 
    1423                     offset += PTRSIZE * 2; 
    1424                 else 
    1425                     offset += p->type->size(); 
    1426                 offset = (offset + PTRSIZE - 1) & ~(PTRSIZE - 1);  // assume stack aligns on pointer size 
    1427                 Expression *e = new SymOffExp(0, p, offset); 
    1428                 e->type = Type::tvoidptr; 
    1429                 //e = e->semantic(sc); 
    1430                 e = new AssignExp(0, e1, e); 
    1431                 e->type = t; 
    1432                 a->push(new ExpStatement(0, e)); 
    1433                 p->isargptr = TRUE; 
     1405                {   // Initialize _argptr to point past non-variadic arg 
     1406                    VarDeclaration *p; 
     1407                    unsigned offset = 0; 
     1408 
     1409                    Expression *e1 = new VarExp(0, argptr); 
     1410                    // Find the last non-ref parameter 
     1411                    if (parameters && parameters->dim) 
     1412                    { 
     1413                        int lastNonref = parameters->dim -1; 
     1414                        p = (VarDeclaration *)parameters->data[lastNonref]; 
     1415                        /* The trouble with out and ref parameters is that taking 
     1416                         * the address of it doesn't work, because later processing 
     1417                         * adds in an extra level of indirection. So we skip over them. 
     1418                         */ 
     1419                        while (p->storage_class & (STCout | STCref)) 
     1420                        { 
     1421                            --lastNonref; 
     1422                            offset += PTRSIZE; 
     1423                            if (lastNonref < 0) 
     1424                            { 
     1425                                p = v_arguments; 
     1426                                break; 
     1427                            } 
     1428                            p = (VarDeclaration *)parameters->data[lastNonref]; 
     1429                        } 
     1430                    } 
     1431                    else 
     1432                        p = v_arguments;            // last parameter is _arguments[] 
     1433                    if (p->storage_class & STClazy) 
     1434                        // If the last parameter is lazy, it's the size of a delegate 
     1435                        offset += PTRSIZE * 2; 
     1436                    else 
     1437                        offset += p->type->size(); 
     1438                    offset = (offset + PTRSIZE - 1) & ~(PTRSIZE - 1);  // assume stack aligns on pointer size 
     1439                    Expression *e = new SymOffExp(0, p, offset); 
     1440                    e->type = Type::tvoidptr; 
     1441                    //e = e->semantic(sc); 
     1442                    e = new AssignExp(0, e1, e); 
     1443                    e->type = t; 
     1444                    a->push(new ExpStatement(0, e)); 
     1445                    p->isargptr = TRUE; 
     1446                } 
    14341447#endif 
    14351448            } 
    14361449 
    14371450            if (_arguments) 
    14381451            { 
    14391452                /* Advance to elements[] member of TypeInfo_Tuple with: 
    14401453                 *  _arguments = v_arguments.elements; 
    14411454                 */ 
    14421455                Expression *e = new VarExp(0, v_arguments); 
    14431456                e = new DotIdExp(0, e, Id::elements); 
    14441457                Expression *e1 = new VarExp(0, _arguments); 
    14451458                e = new ConstructExp(0, e1, e); 
    14461459                e = e->semantic(sc2); 
    14471460                a->push(new ExpStatement(0, e)); 
    14481461            } 
    14491462 
    14501463            // Merge contracts together with body into one compound statement 
    14511464 
    14521465#ifdef _DH 
    14531466            if (frequire && global.params.useIn) 
  • trunk/src/imphint.c

    r767 r812  
    2929{ 
    3030#if DMDV1 
    3131    static const char *modules[] = 
    3232    {   "std.c.stdio", 
    3333        "std.stdio", 
    3434        "std.math", 
    3535        "std.c.stdarg", 
    3636    }; 
    3737    static const char *names[] = 
    3838    { 
    3939        "printf", NULL, 
    4040        "writefln", NULL, 
    4141        "sin", "cos", "sqrt", "fabs", NULL, 
    4242        "__va_argsave_t", NULL, 
    4343    }; 
    4444#else 
    4545    static const char *modules[] = 
    4646    {   "core.stdc.stdio", 
    4747        "std.stdio", 
    4848        "std.math", 
    49         "std.c.stdarg", 
     49        "core.vararg", 
    5050    }; 
    5151    static const char *names[] = 
    5252    { 
    5353        "printf", NULL, 
    5454        "writeln", NULL, 
    5555        "sin", "cos", "sqrt", "fabs", NULL, 
    5656        "__va_argsave_t", NULL, 
    5757    }; 
    5858#endif 
    5959    int m = 0; 
    6060    for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++) 
    6161    { 
    6262        const char *p = names[n]; 
    6363        if (p == NULL) 
    6464        {   m++; 
    6565            continue; 
    6666        } 
    6767        assert(m < sizeof(modules)/sizeof(modules[0])); 
    6868        if (strcmp(s, p) == 0) 
    6969            return modules[m]; 
  • trunk/src/mtype.c

    r809 r812  
    17031703        } 
    17041704        else 
    17051705            s = deco; 
    17061706        e = new StringExp(loc, (char *)s, strlen(s), 'c'); 
    17071707        Scope sc; 
    17081708        e = e->semantic(&sc); 
    17091709    } 
    17101710    else if (ident == Id::stringof) 
    17111711    {   char *s = toChars(); 
    17121712        e = new StringExp(loc, s, strlen(s), 'c'); 
    17131713        Scope sc; 
    17141714        e = e->semantic(&sc); 
    17151715    } 
    17161716    else 
    17171717    { 
    17181718        Dsymbol *s = NULL; 
    17191719        if (ty == Tstruct || ty == Tclass || ty == Tenum || ty == Ttypedef) 
    17201720            s = toDsymbol(NULL); 
    17211721        if (s) 
    17221722            s = s->search_correct(ident); 
    1723         if (s) 
    1724             error(loc, "no property '%s' for type '%s', did you mean '%s'?", ident->toChars(), toChars(), s->toChars()); 
    1725         else 
    1726             error(loc, "no property '%s' for type '%s'", ident->toChars(), toChars()); 
     1723        if (this != Type::terror) 
     1724        { 
     1725            if (s) 
     1726                error(loc, "no property '%s' for type '%s', did you mean '%s'?", ident->toChars(), toChars(), s->toChars()); 
     1727            else 
     1728                error(loc, "no property '%s' for type '%s'", ident->toChars(), toChars()); 
     1729        } 
    17271730        e = new ErrorExp(); 
    17281731    } 
    17291732    return e; 
    17301733} 
    17311734 
    17321735Expression *Type::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    17331736{   VarDeclaration *v = NULL; 
    17341737 
    17351738#if LOGDOTEXP 
    17361739    printf("Type::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
    17371740#endif 
    17381741    if (e->op == TOKdotvar) 
    17391742    { 
    17401743        DotVarExp *dv = (DotVarExp *)e; 
    17411744        v = dv->var->isVarDeclaration(); 
    17421745    } 
    17431746    else if (e->op == TOKvar) 
    17441747    { 
    17451748        VarExp *ve = (VarExp *)e; 
    17461749        v = ve->var->isVarDeclaration(); 
  • trunk/src/toir.c

    r767 r812  
    424424        "9intrinsic4outpFkhZh", 
    425425        "9intrinsic5bswapFkZk", 
    426426        "9intrinsic5outplFkkZk", 
    427427        "9intrinsic5outpwFktZt", 
    428428#elif DMDV2 
    429429        /* The names are mangled differently because of the pure and 
    430430         * nothrow attributes. 
    431431         */ 
    432432        "4math3cosFNaNbNfeZe", 
    433433        "4math3sinFNaNbNfeZe", 
    434434        "4math4fabsFNaNbNfeZe", 
    435435        "4math4rintFNaNbNfeZe", 
    436436        "4math4sqrtFNaNbNfdZd", 
    437437        "4math4sqrtFNaNbNfeZe", 
    438438        "4math4sqrtFNaNbNffZf", 
    439439        "4math4yl2xFNaNbNfeeZe", 
    440440        "4math5ldexpFNaNbNfeiZe", 
    441441        "4math6rndtolFNaNbNfeZl", 
    442442        "4math6yl2xp1FNaNbNfeeZe", 
    443443 
    444         "9intrinsic2btFNaNbxPkkZi", 
    445         "9intrinsic3bsfFNaNbkZi", 
    446         "9intrinsic3bsrFNaNbkZi", 
     444        "9intrinsic2btFNaNbxPmmZi", 
     445        "9intrinsic3bsfFNaNbmZi", 
     446        "9intrinsic3bsrFNaNbmZi", 
    447447        "9intrinsic3btcFNbPmmZi", 
    448448        "9intrinsic3btrFNbPmmZi", 
    449449        "9intrinsic3btsFNbPmmZi", 
    450450        "9intrinsic3inpFNbkZh", 
    451451        "9intrinsic4inplFNbkZk", 
    452452        "9intrinsic4inpwFNbkZt", 
    453453        "9intrinsic4outpFNbkhZh", 
    454454        "9intrinsic5bswapFNaNbkZk", 
    455455        "9intrinsic5outplFNbkkZk", 
    456456        "9intrinsic5outpwFNbktZt", 
    457457#endif 
    458458    }; 
    459459    static unsigned char ioptab[] = 
    460460    { 
    461461        OPcos, 
    462462        OPsin, 
    463463        OPabs, 
    464464        OPrint, 
    465465        OPsqrt, 
    466466        OPsqrt,