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

Changeset 842

Show
Ignore:
Timestamp:
01/03/11 08:32:46 (14 years ago)
Author:
walter
Message:

bugzilla 190 and 4753

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/backend/cgen.c

    r827 r842  
    1515#include        <stdio.h> 
    1616#include        <string.h> 
    1717#include        <time.h> 
    1818#include        "cc.h" 
    1919#include        "el.h" 
    2020#include        "oper.h" 
    2121#include        "code.h" 
    2222#include        "type.h" 
    2323#include        "global.h" 
    2424 
    2525static char __file__[] = __FILE__;      /* for tassert.h                */ 
    2626#include        "tassert.h" 
    2727 
    2828/************************************* 
    2929 * Handy function to answer the question: who the heck is generating this piece of code? 
    3030 */ 
    3131inline void ccheck(code *cs) 
    3232{ 
    3333//    if (cs->Iop == LEA && (cs->Irm & 0x3F) == 0x34 && cs->Isib == 7) *(char*)0=0; 
    3434//    if (cs->Iop == 0x31) *(char*)0=0; 
     35//    if (cs->Iop == 0xF6 && cs->Irm == 0xD6) *(char*)0=0; 
    3536} 
    3637 
    3738/***************************** 
    3839 * Find last code in list. 
    3940 */ 
    4041 
    4142code *code_last(code *c) 
    4243{ 
    4344    if (c) 
    4445    {   while (c->next) 
    4546            c = c->next; 
    4647    } 
    4748    return c; 
    4849} 
    4950 
    5051/***************************** 
    5152 * Set flag bits on last code in list. 
    5253 */ 
    5354 
    5455void code_orflag(code *c,unsigned flag) 
  • branches/dmd-1.x/src/expression.c

    r798 r842  
    39353935    return 0; 
    39363936} 
    39373937 
    39383938Expression *VarExp::semantic(Scope *sc) 
    39393939{   FuncLiteralDeclaration *fd; 
    39403940 
    39413941#if LOGSEMANTIC 
    39423942    printf("VarExp::semantic(%s)\n", toChars()); 
    39433943#endif 
    39443944    if (!type) 
    39453945    {   type = var->type; 
    39463946#if 0 
    39473947        if (var->storage_class & STClazy) 
    39483948        { 
    39493949            TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 
    39503950            type = new TypeDelegate(tf); 
    39513951            type = type->semantic(loc, sc); 
    39523952        } 
    39533953#endif 
    39543954    } 
     3955 
     3956    if (type && !type->deco) 
     3957        type = type->semantic(loc, sc); 
    39553958 
    39563959    /* Fix for 1161 doesn't work because it causes protection 
    39573960     * problems when instantiating imported templates passing private 
    39583961     * variables as alias template parameters. 
    39593962     */ 
    39603963    //accessCheck(loc, sc, NULL, var); 
    39613964 
    39623965    VarDeclaration *v = var->isVarDeclaration(); 
    39633966    if (v) 
    39643967    { 
    39653968        if (v->isConst() && v->type && type->toBasetype()->ty != Tsarray && v->init) 
    39663969        { 
    39673970            ExpInitializer *ei = v->init->isExpInitializer(); 
    39683971            if (ei && ei->exp->type) 
    39693972            { 
    39703973                //ei->exp->implicitCastTo(sc, type)->print(); 
    39713974                return ei->exp->implicitCastTo(sc, type); 
    39723975            } 
    39733976        } 
    39743977        v->checkNestedReference(sc, loc); 
     
    55155518                        e = type->defaultInit(); 
    55165519                        e->loc = loc; 
    55175520                        return e; 
    55185521                    } 
    55195522                } 
    55205523                if (v->needThis()) 
    55215524                { 
    55225525                    if (!eleft) 
    55235526                        eleft = new ThisExp(loc); 
    55245527                    e = new DotVarExp(loc, eleft, v); 
    55255528                    e = e->semantic(sc); 
    55265529                } 
    55275530                else 
    55285531                { 
    55295532                    e = new VarExp(loc, v); 
    55305533                    if (eleft) 
    55315534                    {   e = new CommaExp(loc, eleft, e); 
    55325535                        e->type = v->type; 
    55335536                    } 
    55345537                } 
    5535                 return e->deref(); 
     5538                e = e->deref(); 
     5539                return e->semantic(sc); 
    55365540            } 
    55375541 
    55385542            FuncDeclaration *f = s->isFuncDeclaration(); 
    55395543            if (f) 
    55405544            { 
    55415545                //printf("it's a function\n"); 
    55425546                if (f->needThis()) 
    55435547                { 
    55445548                    if (!eleft) 
    55455549                        eleft = new ThisExp(loc); 
    55465550                    e = new DotVarExp(loc, eleft, f); 
    55475551                    e = e->semantic(sc); 
    55485552                } 
    55495553                else 
    55505554                { 
    55515555                    e = new VarExp(loc, f); 
    55525556                    if (eleft) 
    55535557                    {   e = new CommaExp(loc, eleft, e); 
    55545558                        e->type = f->type; 
    55555559                    } 
  • branches/dmd-1.x/src/linux.mak

    r840 r842  
    7777    $C/type.c $C/melf.h $C/mach.h $C/bcomplex.h \ 
    7878    $C/cdeflnx.h $C/outbuf.h $C/token.h $C/tassert.h \ 
    7979    $C/elfobj.c $C/cv4.h $C/dwarf2.h $C/cpp.h $C/exh.h $C/go.h \ 
    8080    $C/dwarf.c $C/dwarf.h $C/aa.h $C/aa.c $C/tinfo.h $C/ti_achar.c \ 
    8181    $C/machobj.c \ 
    8282    $(TK)/filespec.h $(TK)/mem.h $(TK)/list.h $(TK)/vec.h \ 
    8383    $(TK)/filespec.c $(TK)/mem.c $(TK)/vec.c $(TK)/list.c \ 
    8484    $(ROOT)/dchar.h $(ROOT)/dchar.c $(ROOT)/lstring.h \ 
    8585    $(ROOT)/lstring.c $(ROOT)/root.h $(ROOT)/root.c $(ROOT)/array.c \ 
    8686    $(ROOT)/rmem.h $(ROOT)/rmem.c $(ROOT)/port.h $(ROOT)/port.c \ 
    8787    $(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \ 
    8888    $(ROOT)/stringtable.h $(ROOT)/stringtable.c \ 
    8989    $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \ 
    9090    $(ROOT)/aav.h $(ROOT)/aav.c \ 
    9191    $(ROOT)/speller.h $(ROOT)/speller.c 
    9292 
    9393 
    9494all: dmd 
    9595 
    9696dmd: $(DMD_OBJS) 
    97     $(CC) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd 
     97    gcc $(MODEL) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd 
    9898 
    9999clean: 
    100100    rm -f $(DMD_OBJS) dmd optab.o id.o impcnvgen idgen id.c id.h \ 
    101101    impcnvtab.c optabgen debtab.c optab.c cdxxx.c elxxx.c fltables.c \ 
    102102    tytab.c core \ 
    103103    *.cov *.gcda *.gcno 
    104104 
    105105######## optabgen generates some source 
    106106 
    107107optabgen: $C/optabgen.c $C/cc.h $C/oper.h 
    108108    $(CC) $(MFLAGS) $< -o optabgen 
    109109    ./optabgen 
    110110 
    111111optabgen_output = debtab.c optab.c cdxxx.c elxxx.c fltables.c tytab.c 
    112112$(optabgen_output) : optabgen 
    113113 
    114114######## idgen generates some source 
    115115 
    116116idgen_output = id.h id.c 
    117117$(idgen_output) : idgen 
     
    450450 
    451451s2ir.o : $C/rtlsym.h statement.h s2ir.c 
    452452    $(CC) -c -I$(ROOT) $(MFLAGS) s2ir.c 
    453453 
    454454scope.o: scope.c 
    455455    $(CC) -c $(CFLAGS) $< 
    456456 
    457457speller.o: $(ROOT)/speller.c 
    458458    $(CC) -c $(GFLAGS) -I$(ROOT) $< 
    459459 
    460460statement.o: statement.c 
    461461    $(CC) -c $(CFLAGS) $< 
    462462 
    463463staticassert.o: staticassert.h staticassert.c 
    464464    $(CC) -c $(CFLAGS) staticassert.c 
    465465 
    466466stringtable.o: $(ROOT)/stringtable.c 
    467467    $(CC) -c $(GFLAGS) -I$(ROOT) $< 
    468468 
    469469strtold.o: $C/strtold.c 
    470     $(CC) -c $C/strtold.c 
     470    gcc $(MODEL) -c $C/strtold.c 
    471471 
    472472struct.o: struct.c 
    473473    $(CC) -c $(CFLAGS) $< 
    474474 
    475475template.o: template.c 
    476476    $(CC) -c $(CFLAGS) $< 
    477477 
    478478ti_achar.o: $C/tinfo.h $C/ti_achar.c 
    479479    $(CC) -c $(MFLAGS) -I. $C/ti_achar.c 
    480480 
    481481tk.o: tk.c 
    482482    $(CC) -c $(MFLAGS) tk.c 
    483483 
    484484tocsym.o: $(CH) $(TOTALH) mars.h module.h tocsym.c 
    485485    $(CC) -c $(MFLAGS) -I$(ROOT) tocsym.c 
    486486 
    487487toctype.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h toctype.c 
    488488    $(CC) -c $(MFLAGS) -I$(ROOT) toctype.c 
    489489 
    490490todt.o : mtype.h expression.h $C/dt.h todt.c 
  • branches/dmd-1.x/src/mtype.c

    r828 r842  
    37353735        global.gag--; 
    37363736        if (errors != global.errors) 
    37373737        {   if (global.gag == 0) 
    37383738                global.errors = errors; 
    37393739            return NULL; 
    37403740        } 
    37413741    } 
    37423742    else 
    37433743        resolve(loc, sc, &e, &t, &s); 
    37443744 
    37453745    return s; 
    37463746} 
    37473747 
    37483748 
    37493749/***************************** TypeTypeof *****************************/ 
    37503750 
    37513751TypeTypeof::TypeTypeof(Loc loc, Expression *exp) 
    37523752        : TypeQualified(Ttypeof, loc) 
    37533753{ 
    37543754    this->exp = exp; 
     3755    inuse = 0; 
    37553756} 
    37563757 
    37573758Type *TypeTypeof::syntaxCopy() 
    37583759{ 
    37593760    //printf("TypeTypeof::syntaxCopy() %s\n", toChars()); 
    37603761    TypeTypeof *t; 
    37613762 
    37623763    t = new TypeTypeof(loc, exp->syntaxCopy()); 
    37633764    t->syntaxCopyHelper(this); 
    37643765    return t; 
    37653766} 
    37663767 
    37673768Dsymbol *TypeTypeof::toDsymbol(Scope *sc) 
    37683769{ 
    37693770    Type *t; 
    37703771 
    37713772    t = semantic(loc, sc); 
    37723773    if (t == this) 
    37733774        return NULL; 
    37743775    return t->toDsymbol(sc); 
     
    37813782        return; 
    37823783    } 
    37833784    buf->writestring("typeof("); 
    37843785    exp->toCBuffer(buf, hgs); 
    37853786    buf->writeByte(')'); 
    37863787    toCBuffer2Helper(buf, hgs); 
    37873788} 
    37883789 
    37893790void TypeTypeof::toDecoBuffer(OutBuffer *buf) 
    37903791{ 
    37913792    assert(0); 
    37923793} 
    37933794 
    37943795Type *TypeTypeof::semantic(Loc loc, Scope *sc) 
    37953796{   Expression *e; 
    37963797    Type *t; 
    37973798 
    37983799    //printf("TypeTypeof::semantic() %p\n", this); 
    37993800 
    38003801    //static int nest; if (++nest == 50) *(char*)0=0; 
     3802    if (inuse) 
     3803    { 
     3804        inuse = 2; 
     3805        error(loc, "circular typeof definition"); 
     3806        return Type::terror; 
     3807    } 
     3808    inuse++; 
    38013809 
    38023810#if 0 
    38033811    /* Special case for typeof(this) and typeof(super) since both 
    38043812     * should work even if they are not inside a non-static member function 
    38053813     */ 
    38063814    if (exp->op == TOKthis || exp->op == TOKsuper) 
    38073815    { 
    38083816        // Find enclosing struct or class 
    38093817        for (Dsymbol *s = sc->parent; 1; s = s->parent) 
    38103818        { 
    38113819            ClassDeclaration *cd; 
    38123820            StructDeclaration *sd; 
    38133821 
    38143822            if (!s) 
    38153823            { 
    38163824                error(loc, "%s is not in a struct or class scope", exp->toChars()); 
    38173825                goto Lerr; 
    38183826            } 
    38193827            cd = s->isClassDeclaration(); 
    38203828            if (cd) 
     
    38773885        for (size_t i = 0; i < idents.dim; i++) 
    38783886        { 
    38793887            if (!s) 
    38803888                break; 
    38813889            Identifier *id = (Identifier *)idents.data[i]; 
    38823890            s = s->searchX(loc, sc, id); 
    38833891        } 
    38843892        if (s) 
    38853893        { 
    38863894            t = s->getType(); 
    38873895            if (!t) 
    38883896            {   error(loc, "%s is not a type", s->toChars()); 
    38893897                goto Lerr; 
    38903898            } 
    38913899        } 
    38923900        else 
    38933901        {   error(loc, "cannot resolve .property for %s", toChars()); 
    38943902            goto Lerr; 
    38953903        } 
    38963904    } 
     3905    inuse--; 
    38973906    return t; 
    38983907 
    38993908Lerr: 
     3909    inuse--; 
    39003910    return terror; 
    39013911} 
    39023912 
    39033913d_uns64 TypeTypeof::size(Loc loc) 
    39043914{ 
    39053915    if (exp->type) 
    39063916        return exp->type->size(loc); 
    39073917    else 
    39083918        return TypeQualified::size(loc); 
    39093919} 
    39103920 
    39113921 
    39123922 
    39133923/***************************** TypeEnum *****************************/ 
    39143924 
    39153925TypeEnum::TypeEnum(EnumDeclaration *sym) 
    39163926        : Type(Tenum, NULL) 
    39173927{ 
    39183928    this->sym = sym; 
    39193929} 
  • branches/dmd-1.x/src/mtype.h

    r768 r842  
    540540/* Similar to TypeIdentifier, but with a TemplateInstance as the root 
    541541 */ 
    542542struct TypeInstance : TypeQualified 
    543543{ 
    544544    TemplateInstance *tempinst; 
    545545 
    546546    TypeInstance(Loc loc, TemplateInstance *tempinst); 
    547547    Type *syntaxCopy(); 
    548548    //char *toChars(); 
    549549    //void toDecoBuffer(OutBuffer *buf); 
    550550    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    551551    void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 
    552552    Type *semantic(Loc loc, Scope *sc); 
    553553    Dsymbol *toDsymbol(Scope *sc); 
    554554    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    555555}; 
    556556 
    557557struct TypeTypeof : TypeQualified 
    558558{ 
    559559    Expression *exp; 
     560    int inuse; 
    560561 
    561562    TypeTypeof(Loc loc, Expression *exp); 
    562563    Type *syntaxCopy(); 
    563564    Dsymbol *toDsymbol(Scope *sc); 
    564565    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    565566    void toDecoBuffer(OutBuffer *buf); 
    566567    Type *semantic(Loc loc, Scope *sc); 
    567568    d_uns64 size(Loc loc); 
    568569}; 
    569570 
    570571struct TypeStruct : Type 
    571572{ 
    572573    StructDeclaration *sym; 
    573574 
    574575    TypeStruct(StructDeclaration *sym); 
    575576    d_uns64 size(Loc loc); 
    576577    unsigned alignsize(); 
    577578    char *toChars(); 
    578579    Type *syntaxCopy(); 
    579580    Type *semantic(Loc loc, Scope *sc); 
  • trunk/src/backend/cgen.c

    r827 r842  
    1515#include        <stdio.h> 
    1616#include        <string.h> 
    1717#include        <time.h> 
    1818#include        "cc.h" 
    1919#include        "el.h" 
    2020#include        "oper.h" 
    2121#include        "code.h" 
    2222#include        "type.h" 
    2323#include        "global.h" 
    2424 
    2525static char __file__[] = __FILE__;      /* for tassert.h                */ 
    2626#include        "tassert.h" 
    2727 
    2828/************************************* 
    2929 * Handy function to answer the question: who the heck is generating this piece of code? 
    3030 */ 
    3131inline void ccheck(code *cs) 
    3232{ 
    3333//    if (cs->Iop == LEA && (cs->Irm & 0x3F) == 0x34 && cs->Isib == 7) *(char*)0=0; 
    3434//    if (cs->Iop == 0x31) *(char*)0=0; 
     35//    if (cs->Iop == 0xF6 && cs->Irm == 0xD6) *(char*)0=0; 
    3536} 
    3637 
    3738/***************************** 
    3839 * Find last code in list. 
    3940 */ 
    4041 
    4142code *code_last(code *c) 
    4243{ 
    4344    if (c) 
    4445    {   while (c->next) 
    4546            c = c->next; 
    4647    } 
    4748    return c; 
    4849} 
    4950 
    5051/***************************** 
    5152 * Set flag bits on last code in list. 
    5253 */ 
    5354 
    5455void code_orflag(code *c,unsigned flag) 
  • trunk/src/expression.c

    r812 r842  
    42164216Expression *VarExp::semantic(Scope *sc) 
    42174217{   FuncLiteralDeclaration *fd; 
    42184218 
    42194219#if LOGSEMANTIC 
    42204220    printf("VarExp::semantic(%s)\n", toChars()); 
    42214221#endif 
    42224222//    if (var->sem == SemanticStart && var->scope)      // if forward referenced 
    42234223//      var->semantic(sc); 
    42244224    if (!type) 
    42254225    {   type = var->type; 
    42264226#if 0 
    42274227        if (var->storage_class & STClazy) 
    42284228        { 
    42294229            TypeFunction *tf = new TypeFunction(NULL, type, 0, LINKd); 
    42304230            type = new TypeDelegate(tf); 
    42314231            type = type->semantic(loc, sc); 
    42324232        } 
    42334233#endif 
    42344234    } 
    42354235 
     4236    if (type && !type->deco) 
     4237        type = type->semantic(loc, sc); 
     4238 
    42364239    /* Fix for 1161 doesn't work because it causes protection 
    42374240     * problems when instantiating imported templates passing private 
    42384241     * variables as alias template parameters. 
    42394242     */ 
    42404243    //accessCheck(loc, sc, NULL, var); 
    42414244 
    42424245    VarDeclaration *v = var->isVarDeclaration(); 
    42434246    if (v) 
    42444247    { 
    42454248#if 0 
    42464249        if ((v->isConst() || v->isImmutable()) && 
    42474250            type->toBasetype()->ty != Tsarray && v->init) 
    42484251        { 
    42494252            ExpInitializer *ei = v->init->isExpInitializer(); 
    42504253            if (ei) 
    42514254            { 
    42524255                //ei->exp->implicitCastTo(sc, type)->print(); 
    42534256                return ei->exp->implicitCastTo(sc, type); 
    42544257            } 
    42554258        } 
     
    59405943                { 
    59415944                    error("circular reference to '%s'", v->toChars()); 
    59425945                    return new ErrorExp(); 
    59435946                } 
    59445947                type = v->type; 
    59455948                if (v->needThis()) 
    59465949                { 
    59475950                    if (!eleft) 
    59485951                        eleft = new ThisExp(loc); 
    59495952                    e = new DotVarExp(loc, eleft, v); 
    59505953                    e = e->semantic(sc); 
    59515954                } 
    59525955                else 
    59535956                { 
    59545957                    e = new VarExp(loc, v); 
    59555958                    if (eleft) 
    59565959                    {   e = new CommaExp(loc, eleft, e); 
    59575960                        e->type = v->type; 
    59585961                    } 
    59595962                } 
    5960                 return e->deref(); 
     5963                e = e->deref(); 
     5964                return e->semantic(sc); 
    59615965            } 
    59625966 
    59635967            FuncDeclaration *f = s->isFuncDeclaration(); 
    59645968            if (f) 
    59655969            { 
    59665970                //printf("it's a function\n"); 
    59675971                if (f->needThis()) 
    59685972                { 
    59695973                    if (!eleft) 
    59705974                        eleft = new ThisExp(loc); 
    59715975                    e = new DotVarExp(loc, eleft, f); 
    59725976                    e = e->semantic(sc); 
    59735977                } 
    59745978                else 
    59755979                { 
    59765980                    e = new VarExp(loc, f, 1); 
    59775981                    if (eleft) 
    59785982                    {   e = new CommaExp(loc, eleft, e); 
    59795983                        e->type = f->type; 
    59805984                    } 
  • trunk/src/linux.mak

    r840 r842  
    7777    $C/type.c $C/melf.h $C/mach.h $C/bcomplex.h \ 
    7878    $C/cdeflnx.h $C/outbuf.h $C/token.h $C/tassert.h \ 
    7979    $C/elfobj.c $C/cv4.h $C/dwarf2.h $C/cpp.h $C/exh.h $C/go.h \ 
    8080    $C/dwarf.c $C/dwarf.h $C/aa.h $C/aa.c $C/tinfo.h $C/ti_achar.c \ 
    8181    $C/machobj.c \ 
    8282    $(TK)/filespec.h $(TK)/mem.h $(TK)/list.h $(TK)/vec.h \ 
    8383    $(TK)/filespec.c $(TK)/mem.c $(TK)/vec.c $(TK)/list.c \ 
    8484    $(ROOT)/dchar.h $(ROOT)/dchar.c $(ROOT)/lstring.h \ 
    8585    $(ROOT)/lstring.c $(ROOT)/root.h $(ROOT)/root.c $(ROOT)/array.c \ 
    8686    $(ROOT)/rmem.h $(ROOT)/rmem.c $(ROOT)/port.h $(ROOT)/port.c \ 
    8787    $(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \ 
    8888    $(ROOT)/stringtable.h $(ROOT)/stringtable.c \ 
    8989    $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \ 
    9090    $(ROOT)/aav.h $(ROOT)/aav.c \ 
    9191    $(ROOT)/speller.h $(ROOT)/speller.c 
    9292 
    9393 
    9494all: dmd 
    9595 
    9696dmd: $(DMD_OBJS) 
    97     $(CC) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd 
     97    gcc $(MODEL) -lstdc++ -lpthread $(COV) $(DMD_OBJS) -o dmd 
    9898 
    9999clean: 
    100100    rm -f $(DMD_OBJS) dmd optab.o id.o impcnvgen idgen id.c id.h \ 
    101101    impcnvtab.c optabgen debtab.c optab.c cdxxx.c elxxx.c fltables.c \ 
    102102    tytab.c core \ 
    103103    *.cov *.gcda *.gcno 
    104104 
    105105######## optabgen generates some source 
    106106 
    107107optabgen: $C/optabgen.c $C/cc.h $C/oper.h 
    108108    $(CC) $(MFLAGS) $< -o optabgen 
    109109    ./optabgen 
    110110 
    111111optabgen_output = debtab.c optab.c cdxxx.c elxxx.c fltables.c tytab.c 
    112112$(optabgen_output) : optabgen 
    113113 
    114114######## idgen generates some source 
    115115 
    116116idgen_output = id.h id.c 
    117117$(idgen_output) : idgen 
     
    450450 
    451451s2ir.o : $C/rtlsym.h statement.h s2ir.c 
    452452    $(CC) -c -I$(ROOT) $(MFLAGS) s2ir.c 
    453453 
    454454scope.o: scope.c 
    455455    $(CC) -c $(CFLAGS) $< 
    456456 
    457457speller.o: $(ROOT)/speller.c 
    458458    $(CC) -c $(GFLAGS) -I$(ROOT) $< 
    459459 
    460460statement.o: statement.c 
    461461    $(CC) -c $(CFLAGS) $< 
    462462 
    463463staticassert.o: staticassert.h staticassert.c 
    464464    $(CC) -c $(CFLAGS) staticassert.c 
    465465 
    466466stringtable.o: $(ROOT)/stringtable.c 
    467467    $(CC) -c $(GFLAGS) -I$(ROOT) $< 
    468468 
    469469strtold.o: $C/strtold.c 
    470     $(CC) -c $C/strtold.c 
     470    gcc $(MODEL) -c $C/strtold.c 
    471471 
    472472struct.o: struct.c 
    473473    $(CC) -c $(CFLAGS) $< 
    474474 
    475475template.o: template.c 
    476476    $(CC) -c $(CFLAGS) $< 
    477477 
    478478ti_achar.o: $C/tinfo.h $C/ti_achar.c 
    479479    $(CC) -c $(MFLAGS) -I. $C/ti_achar.c 
    480480 
    481481tk.o: tk.c 
    482482    $(CC) -c $(MFLAGS) tk.c 
    483483 
    484484tocsym.o: $(CH) $(TOTALH) mars.h module.h tocsym.c 
    485485    $(CC) -c $(MFLAGS) -I$(ROOT) tocsym.c 
    486486 
    487487toctype.o: $(CH) $(TOTALH) $C/rtlsym.h mars.h module.h toctype.c 
    488488    $(CC) -c $(MFLAGS) -I$(ROOT) toctype.c 
    489489 
    490490todt.o : mtype.h expression.h $C/dt.h todt.c 
  • trunk/src/mtype.c

    r818 r842  
    59635963        global.gag--; 
    59645964        if (errors != global.errors) 
    59655965        {   if (global.gag == 0) 
    59665966                global.errors = errors; 
    59675967            return NULL; 
    59685968        } 
    59695969    } 
    59705970    else 
    59715971        resolve(loc, sc, &e, &t, &s); 
    59725972 
    59735973    return s; 
    59745974} 
    59755975 
    59765976 
    59775977/***************************** TypeTypeof *****************************/ 
    59785978 
    59795979TypeTypeof::TypeTypeof(Loc loc, Expression *exp) 
    59805980        : TypeQualified(Ttypeof, loc) 
    59815981{ 
    59825982    this->exp = exp; 
     5983    inuse = 0; 
    59835984} 
    59845985 
    59855986Type *TypeTypeof::syntaxCopy() 
    59865987{ 
    59875988    //printf("TypeTypeof::syntaxCopy() %s\n", toChars()); 
    59885989    TypeTypeof *t; 
    59895990 
    59905991    t = new TypeTypeof(loc, exp->syntaxCopy()); 
    59915992    t->syntaxCopyHelper(this); 
    59925993    t->mod = mod; 
    59935994    return t; 
    59945995} 
    59955996 
    59965997Dsymbol *TypeTypeof::toDsymbol(Scope *sc) 
    59975998{ 
    59985999    Type *t; 
    59996000 
    60006001    t = semantic(loc, sc); 
    60016002    if (t == this) 
    60026003        return NULL; 
     
    60056006 
    60066007void TypeTypeof::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) 
    60076008{ 
    60086009    if (mod != this->mod) 
    60096010    {   toCBuffer3(buf, hgs, mod); 
    60106011        return; 
    60116012    } 
    60126013    buf->writestring("typeof("); 
    60136014    exp->toCBuffer(buf, hgs); 
    60146015    buf->writeByte(')'); 
    60156016    toCBuffer2Helper(buf, hgs); 
    60166017} 
    60176018 
    60186019Type *TypeTypeof::semantic(Loc loc, Scope *sc) 
    60196020{   Expression *e; 
    60206021    Type *t; 
    60216022 
    60226023    //printf("TypeTypeof::semantic() %s\n", toChars()); 
    60236024 
    60246025    //static int nest; if (++nest == 50) *(char*)0=0; 
     6026    if (inuse) 
     6027    { 
     6028        inuse = 2; 
     6029        error(loc, "circular typeof definition"); 
     6030        return Type::terror; 
     6031    } 
     6032    inuse++; 
    60256033 
    60266034#if 0 
    60276035    /* Special case for typeof(this) and typeof(super) since both 
    60286036     * should work even if they are not inside a non-static member function 
    60296037     */ 
    60306038    if (exp->op == TOKthis || exp->op == TOKsuper) 
    60316039    { 
    60326040        // Find enclosing struct or class 
    60336041        for (Dsymbol *s = sc->parent; 1; s = s->parent) 
    60346042        { 
    60356043            ClassDeclaration *cd; 
    60366044            StructDeclaration *sd; 
    60376045 
    60386046            if (!s) 
    60396047            { 
    60406048                error(loc, "%s is not in a struct or class scope", exp->toChars()); 
    60416049                goto Lerr; 
    60426050            } 
    60436051            cd = s->isClassDeclaration(); 
    60446052            if (cd) 
     
    61076115        { 
    61086116            if (!s) 
    61096117                break; 
    61106118            Identifier *id = (Identifier *)idents.data[i]; 
    61116119            s = s->searchX(loc, sc, id); 
    61126120        } 
    61136121 
    61146122        if (s) 
    61156123        { 
    61166124            t = s->getType(); 
    61176125            if (!t) 
    61186126            {   error(loc, "%s is not a type", s->toChars()); 
    61196127                goto Lerr; 
    61206128            } 
    61216129        } 
    61226130        else 
    61236131        {   error(loc, "cannot resolve .property for %s", toChars()); 
    61246132            goto Lerr; 
    61256133        } 
    61266134    } 
     6135    inuse--; 
    61276136    return t; 
    61286137 
    61296138Lerr: 
     6139    inuse--; 
    61306140    return terror; 
    61316141} 
    61326142 
    61336143d_uns64 TypeTypeof::size(Loc loc) 
    61346144{ 
    61356145    if (exp->type) 
    61366146        return exp->type->size(loc); 
    61376147    else 
    61386148        return TypeQualified::size(loc); 
    61396149} 
    61406150 
    61416151 
    61426152 
    61436153/***************************** TypeReturn *****************************/ 
    61446154 
    61456155TypeReturn::TypeReturn(Loc loc) 
    61466156        : TypeQualified(Treturn, loc) 
    61476157{ 
    61486158} 
    61496159 
  • trunk/src/mtype.h

    r769 r842  
    660660/* Similar to TypeIdentifier, but with a TemplateInstance as the root 
    661661 */ 
    662662struct TypeInstance : TypeQualified 
    663663{ 
    664664    TemplateInstance *tempinst; 
    665665 
    666666    TypeInstance(Loc loc, TemplateInstance *tempinst); 
    667667    Type *syntaxCopy(); 
    668668    //char *toChars(); 
    669669    //void toDecoBuffer(OutBuffer *buf, int flag); 
    670670    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    671671    void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 
    672672    Type *semantic(Loc loc, Scope *sc); 
    673673    Dsymbol *toDsymbol(Scope *sc); 
    674674    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    675675}; 
    676676 
    677677struct TypeTypeof : TypeQualified 
    678678{ 
    679679    Expression *exp; 
     680    int inuse; 
    680681 
    681682    TypeTypeof(Loc loc, Expression *exp); 
    682683    Type *syntaxCopy(); 
    683684    Dsymbol *toDsymbol(Scope *sc); 
    684685    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    685686    Type *semantic(Loc loc, Scope *sc); 
    686687    d_uns64 size(Loc loc); 
    687688}; 
    688689 
    689690struct TypeReturn : TypeQualified 
    690691{ 
    691692    TypeReturn(Loc loc); 
    692693    Type *syntaxCopy(); 
    693694    Dsymbol *toDsymbol(Scope *sc); 
    694695    Type *semantic(Loc loc, Scope *sc); 
    695696    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    696697}; 
    697698 
    698699struct TypeStruct : Type 
    699700{