Changeset 311

Show
Ignore:
Timestamp:
02/06/07 01:11:12 (2 years ago)
Author:
Gregor
Message:

*: Frontend updated to 1.005

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/rebuild/rebuild/Makefile

    r304 r311  
    1313ARFLAGS=rc 
    1414RANLIB=$(CROSS)ranlib 
     15 
     16PREFIX=/usr 
    1517 
    1618OBJS=\ 
     
    111113    $(CXX) $(CXXFLAGS) -D_DH -DIN_DMDFE -c $< -o $@ 
    112114 
     115install: 
     116    mkdir -p $(PREFIX)/bin 
     117    mkdir -p $(PREFIX)/etc/rebuild 
     118    cp -pf rebuild$(EXEEXT) $(PREFIX)/bin 
     119    cp -pRf rebuild.conf/* $(PREFIX)/etc/rebuild/ 
     120 
    113121clean: 
    114122    rm -f rebuild$(EXEEXT) libdmd.a $(OBJS) 
  • branches/rebuild/rebuild/attrib.c

    r305 r311  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    3030#include "aggregate.h" 
    3131#include "module.h" 
     32#include "parse.h" 
    3233#include "config.h" 
    3334 
     
    765766        if (e->op != TOKstring) 
    766767        error("string expected for library name, not '%s'", e->toChars()); 
     768        else if (global.params.verbose) 
     769        { 
     770        StringExp *se = (StringExp *)e; 
     771        char *name = (char *)mem.malloc(se->len + 1); 
     772        memcpy(name, se->string, se->len); 
     773        name[se->len] = 0; 
     774        printf("library   %s\n", name); 
     775        mem.free(name); 
     776        } 
    767777    } 
    768778    goto Lnodecl; 
     
    11281138 
    11291139 
     1140/***************************** CompileDeclaration *****************************/ 
     1141 
     1142CompileDeclaration::CompileDeclaration(Loc loc, Expression *exp) 
     1143    : AttribDeclaration(NULL) 
     1144{ 
     1145    this->exp = exp; 
     1146    this->sd = NULL; 
     1147} 
     1148 
     1149Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s) 
     1150{ 
     1151    //printf("CompileDeclaration::syntaxCopy('%s')\n", toChars()); 
     1152    CompileDeclaration *sc = new CompileDeclaration(loc, exp->syntaxCopy()); 
     1153    return sc; 
     1154} 
     1155 
     1156int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 
     1157{ 
     1158    this->sd = sd; 
     1159    return memnum; 
     1160} 
     1161 
     1162void CompileDeclaration::semantic(Scope *sc) 
     1163{ 
     1164    //printf("CompileDeclaration::semantic()\n"); 
     1165    exp = exp->semantic(sc); 
     1166    exp = resolveProperties(sc, exp); 
     1167    exp = exp->optimize(WANTvalue); 
     1168    if (exp->op != TOKstring) 
     1169    {   error("argument to mixin must be a string, not (%s)", exp->toChars()); 
     1170    return; 
     1171    } 
     1172    StringExp *se = (StringExp *)exp; 
     1173    se = se->toUTF8(sc); 
     1174    Parser p(sc->module, (unsigned char *)se->string, se->len, 0); 
     1175    p.loc = loc; 
     1176    decl = p.parseDeclDefs(0); 
     1177    if (p.token.value != TOKeof) 
     1178    { 
     1179    error("incomplete mixin declaration (%s)", se->toChars()); 
     1180    } 
     1181 
     1182    AttribDeclaration::addMember(sc, sd, 0); 
     1183    AttribDeclaration::semantic(sc); 
     1184} 
     1185 
     1186void CompileDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     1187{ 
     1188    buf->writestring("mixin("); 
     1189    exp->toCBuffer(buf, hgs); 
     1190    buf->writestring(");"); 
     1191    buf->writenl(); 
     1192} 
  • branches/rebuild/rebuild/attrib.h

    r298 r311  
    151151}; 
    152152 
     153// Mixin declarations 
     154 
     155struct CompileDeclaration : AttribDeclaration 
     156{ 
     157    Expression *exp; 
     158 
     159    ScopeDsymbol *sd; 
     160 
     161    CompileDeclaration(Loc loc, Expression *exp); 
     162    Dsymbol *syntaxCopy(Dsymbol *s); 
     163    int addMember(Scope *sc, ScopeDsymbol *sd, int memnum); 
     164    void semantic(Scope *sc); 
     165    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     166}; 
     167 
    153168#endif /* DMD_ATTRIB_H */ 
  • branches/rebuild/rebuild/cast.c

    r297 r311  
    5050    return castTo(sc, t); 
    5151    } 
     52 
     53    Expression *e = optimize(WANTflags | WANTvalue); 
     54    if (e != this) 
     55    return e->implicitCastTo(sc, t); 
     56 
    5257#if 0 
    5358print(); 
     
    7075    //error("forward reference to type %s", t->toChars()); 
    7176    } 
    72     /*else 
    73     error("cannot implicitly convert expression (%s) of type %s to %s", 
    74         toChars(), type->toChars(), t->toChars()); */ 
    75 //*(char*)0=0; 
     77    /*else if (t->reliesOnTident()) 
     78    error("forward reference to type %s", t->reliesOnTident()->toChars()); */ 
     79 
     80    error("cannot implicitly convert expression (%s) of type %s to %s", 
     81    toChars(), type->toChars(), t->toChars()); 
    7682    return castTo(sc, t); 
    7783} 
     
    628634 
    629635    tb = t->toBasetype(); 
     636    //printf("\ttype = %s\n", type->toChars()); 
    630637    if (tb->ty == Tdelegate && type->toBasetype()->ty != Tdelegate) 
    631638    return Expression::castTo(sc, t); 
  • branches/rebuild/rebuild/cond.c

    r297 r311  
    320320        parameters.data[0] = (void *)&tp; 
    321321 
    322         Array dedtypes; 
     322        Objects dedtypes; 
    323323        dedtypes.setDim(1); 
    324324 
  • branches/rebuild/rebuild/constfold.c

    r297 r311  
    907907    real_t r2; 
    908908 
     909    //printf("EqualExp::constFold() %s\n", toChars()); 
    909910    assert(op == TOKequal || op == TOKnotequal); 
    910911    e1 = e1->constFold(); 
  • branches/rebuild/rebuild/dsymbol.c

    r297 r311  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    737737    exp = e; 
    738738    type = NULL; 
     739    td = NULL; 
    739740} 
    740741 
     
    744745    exp = NULL; 
    745746    type = t; 
     747    td = NULL; 
     748} 
     749 
     750ArrayScopeSymbol::ArrayScopeSymbol(TupleDeclaration *s) 
     751    : ScopeDsymbol() 
     752{ 
     753    exp = NULL; 
     754    type = NULL; 
     755    td = s; 
    746756} 
    747757 
     
    754764 
    755765    L1: 
     766 
     767    if (td) 
     768    { 
     769        VarDeclaration *v = new VarDeclaration(0, Type::tsize_t, Id::dollar, NULL); 
     770        Expression *e = new IntegerExp(0, td->objects->dim, Type::tsize_t); 
     771        v->init = new ExpInitializer(0, e); 
     772        v->storage_class |= STCconst; 
     773        return v; 
     774    } 
     775 
    756776    if (type) 
    757777    { 
  • branches/rebuild/rebuild/dsymbol.h

    r291 r311  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    250250    Expression *exp;    // IndexExp or SliceExp 
    251251    TypeTuple *type;    // for tuple[length] 
     252    TupleDeclaration *td;   // for tuples of objects 
    252253 
    253254    ArrayScopeSymbol(Expression *e); 
    254255    ArrayScopeSymbol(TypeTuple *t); 
     256    ArrayScopeSymbol(TupleDeclaration *td); 
    255257    Dsymbol *search(Loc loc, Identifier *ident, int flags); 
    256258 
  • branches/rebuild/rebuild/expression.c

    r297 r311  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    5858#include "attrib.h" 
    5959#include "hdrgen.h" 
     60#include "parse.h" 
    6061 
    6162//Expression *createTypeInfoArray(Scope *sc, Expression *args[], int dim); 
     
    19131914#endif 
    19141915    if (type) 
    1915     {   assert(global.errors || var); 
     1916    {   //assert(global.errors || var); 
    19161917    return this; 
    19171918    } 
     
    22582259    } 
    22592260    type = type->semantic(loc, sc); 
     2261    } 
     2262    return this; 
     2263} 
     2264 
     2265/**************************************** 
     2266 * Convert string to char[]. 
     2267 */ 
     2268 
     2269StringExp *StringExp::toUTF8(Scope *sc) 
     2270{ 
     2271    if (sz != 1) 
     2272    {   // Convert to UTF-8 string 
     2273    committed = 0; 
     2274    Expression *e = castTo(sc, Type::tchar->arrayOf()); 
     2275    e = e->optimize(WANTvalue); 
     2276    assert(e->op == TOKstring); 
     2277    StringExp *se = (StringExp *)e; 
     2278    assert(se->sz == 1); 
     2279    return se; 
    22602280    } 
    22612281    return this; 
     
    31343154        { 
    31353155        //ei->exp->implicitCastTo(sc, type)->print(); 
    3136 printf("test3: %s\n", ei->exp->toChars()); 
    31373156        return ei->exp->implicitCastTo(sc, type); 
    31383157        } 
     
    37283747    parameters.data[0] = (void *)&tp; 
    37293748 
    3730     Array dedtypes; 
     3749    Objects dedtypes; 
    37313750    dedtypes.setDim(1); 
    37323751    dedtypes.data[0] = NULL; 
     
    39944013/************************************************************/ 
    39954014 
     4015CompileExp::CompileExp(Loc loc, Expression *e) 
     4016    : UnaExp(loc, TOKmixin, sizeof(CompileExp), e) 
     4017{ 
     4018} 
     4019 
     4020Expression *CompileExp::semantic(Scope *sc) 
     4021{ 
     4022#if LOGSEMANTIC 
     4023    printf("CompileExp::semantic('%s')\n", toChars()); 
     4024#endif 
     4025    UnaExp::semantic(sc); 
     4026    e1 = resolveProperties(sc, e1); 
     4027    e1 = e1->optimize(WANTvalue); 
     4028    if (e1->op != TOKstring) 
     4029    {   error("argument to mixin must be a string, not (%s)", e1->toChars()); 
     4030    return this; 
     4031    } 
     4032    StringExp *se = (StringExp *)e1; 
     4033    se = se->toUTF8(sc); 
     4034    Parser p(sc->module, (unsigned char *)se->string, se->len, 0); 
     4035    p.loc = loc; 
     4036    Expression *e = p.parseExpression(); 
     4037    if (p.token.value != TOKeof) 
     4038    error("incomplete mixin expression (%s)", se->toChars()); 
     4039    return e->semantic(sc); 
     4040} 
     4041 
     4042void CompileExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     4043{ 
     4044    buf->writestring("mixin("); 
     4045    expToCBuffer(buf, hgs, e1, PREC_assign); 
     4046    buf->writeByte(')'); 
     4047} 
     4048 
     4049/************************************************************/ 
     4050 
     4051FileExp::FileExp(Loc loc, Expression *e) 
     4052    : UnaExp(loc, TOKmixin, sizeof(FileExp), e) 
     4053{ 
     4054} 
     4055 
     4056Expression *FileExp::semantic(Scope *sc) 
     4057{ 
     4058#if LOGSEMANTIC 
     4059    printf("FileExp::semantic('%s')\n", toChars()); 
     4060#endif 
     4061    UnaExp::semantic(sc); 
     4062    e1 = resolveProperties(sc, e1); 
     4063    e1 = e1->optimize(WANTvalue); 
     4064    if (e1->op != TOKstring) 
     4065    {   error("file name argument must be a string, not (%s)", e1->toChars()); 
     4066    return this; 
     4067    } 
     4068    StringExp *se = (StringExp *)e1; 
     4069    se = se->toUTF8(sc); 
     4070 
     4071    if (global.params.verbose) 
     4072    printf("file      %s\n", se->string); 
     4073 
     4074    File f((char *)se->string); 
     4075    if (f.read()) 
     4076    {   error("cannot read file %s", f.toChars()); 
     4077    se = new StringExp(loc, ""); 
     4078    } 
     4079    else 
     4080    { 
     4081    f.ref = 1; 
     4082    se = new StringExp(loc, f.buffer, f.len); 
     4083    } 
     4084    return se->semantic(sc); 
     4085} 
     4086 
     4087void FileExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     4088{ 
     4089    buf->writestring("import("); 
     4090    expToCBuffer(buf, hgs, e1, PREC_assign); 
     4091    buf->writeByte(')'); 
     4092} 
     4093 
     4094/************************************************************/ 
     4095 
    39964096AssertExp::AssertExp(Loc loc, Expression *e, Expression *msg) 
    39974097    : UnaExp(loc, TOKassert, sizeof(AssertExp), e) 
     
    40754175 
    40764176//{ static int z; fflush(stdout); if (++z == 10) *(char*)0=0; } 
     4177 
     4178#if 0 
     4179    /* Don't do semantic analysis if we'll be converting 
     4180     * it to a string. 
     4181     */ 
     4182    if (ident == Id::stringof) 
     4183    {   char *s = e1->toChars(); 
     4184    e = new StringExp(loc, s, strlen(s), 'c'); 
     4185    e = e->semantic(sc); 
     4186    return e; 
     4187    } 
     4188#endif 
    40774189 
    40784190    /* Special case: rewrite this.id and super.id 
     
    42724384         ident != Id::init && ident != Id::__sizeof && 
    42734385         ident != Id::alignof && ident != Id::offsetof && 
    4274          ident != Id::mangleof
     4386         ident != Id::mangleof && ident != Id::stringof
    42754387    { 
    42764388    e = new PtrExp(loc, e1); 
     
    56465758} 
    56475759 
     5760void CastExp::checkEscape() 
     5761{   Type *tb = type->toBasetype(); 
     5762    if (tb->ty == Tarray && e1->op == TOKvar && 
     5763    e1->type->toBasetype()->ty == Tsarray) 
     5764    {   VarExp *ve = (VarExp *)e1; 
     5765    VarDeclaration *v = ve->var->isVarDeclaration(); 
     5766    if (v) 
     5767    { 
     5768        if (!v->isDataseg()) 
     5769        error("escaping reference to local %s", v->toChars()); 
     5770    } 
     5771    } 
     5772} 
     5773 
    56485774void CastExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    56495775{ 
     
    77547880    Type *t2; 
    77557881 
     7882    //printf("EqualExp::semantic('%s')\n", toChars()); 
    77567883    if (type) 
    77577884    return this; 
  • branches/rebuild/rebuild/expression.h

    r272 r311  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    285285    char *toChars(); 
    286286    Expression *semantic(Scope *sc); 
     287    StringExp *toUTF8(Scope *sc); 
    287288    int implicitConvTo(Type *t); 
    288289    Expression *castTo(Scope *sc, Type *t); 
     
    453454    void scanForNestedRef(Scope *sc); 
    454455 
    455     //int inlineCost(InlineCostState *ics); 
     456    int inlineCost(InlineCostState *ics); 
    456457    Expression *doInline(InlineDoState *ids); 
    457458    //Expression *inlineScan(InlineScanState *iss); 
     
    588589/****************************************************************/ 
    589590 
     591struct CompileExp : UnaExp 
     592{ 
     593    CompileExp(Loc loc, Expression *e); 
     594    Expression *semantic(Scope *sc); 
     595    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     596}; 
     597 
     598struct FileExp : UnaExp 
     599{ 
     600    FileExp(Loc loc, Expression *e); 
     601    Expression *semantic(Scope *sc); 
     602    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     603}; 
     604 
    590605struct AssertExp : UnaExp 
    591606{ 
     
    772787    Expression *optimize(int result); 
    773788    int checkSideEffect(int flag); 
     789    void checkEscape(); 
    774790    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    775791    Expression *constFold(); 
  • branches/rebuild/rebuild/func.c

    r297 r311  
    930930 
    931931        // Verify that all the ctorinit fields got initialized 
    932         if (!(sc->callSuper & CSXthis_ctor)) 
     932        if (!(sc2->callSuper & CSXthis_ctor)) 
    933933        { 
    934934            for (int i = 0; i < cd->fields.dim; i++) 
     
    16441644int FuncDeclaration::isAbstract() 
    16451645{ 
    1646     return storage_class & STCabstract && !fbody
     1646    return storage_class & STCabstract
    16471647} 
    16481648 
     
    19401940{ 
    19411941    ClassDeclaration *cd; 
    1942     Type *tret; 
    1943  
    1944     sc = sc->push(); 
    1945     sc->stc &= ~STCstatic;      // not a static destructor 
    19461942 
    19471943    parent = sc->parent; 
     
    19551951    cd->dtors.push(this); 
    19561952    type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); 
     1953 
     1954    sc = sc->push(); 
     1955    sc->stc &= ~STCstatic;      // not a static destructor 
     1956    sc->linkage = LINKd; 
    19571957 
    19581958    FuncDeclaration::semantic(sc); 
     
    21792179    type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd); 
    21802180 
     2181    sc = sc->push(); 
     2182    sc->stc &= ~STCstatic;      // not a static invariant 
    21812183    sc->incontract++; 
     2184    sc->linkage = LINKd; 
     2185 
    21822186    FuncDeclaration::semantic(sc); 
    2183     sc->incontract--; 
     2187 
     2188    sc->pop(); 
    21842189} 
    21852190 
  • branches/rebuild/rebuild/idgen.c

    r272 r311  
    4646    { "alignof" }, 
    4747    { "mangleof" }, 
     48    { "stringof" }, 
    4849    { "tupleof" }, 
    4950    { "length" }, 
  • branches/rebuild/rebuild/inline.c

    r272 r311  
    147147int Expression::inlineCost(InlineCostState *ics) 
    148148{ 
     149    return 1; 
     150} 
     151 
     152int VarExp::inlineCost(InlineCostState *ics) 
     153{ 
     154    //printf("VarExp::inlineCost() %s\n", toChars()); 
    149155    return 1; 
    150156} 
     
    471477Expression *ThisExp::doInline(InlineDoState *ids) 
    472478{ 
     479    //if (!ids->vthis) 
     480    //error("no 'this' when inlining %s", ids->parent->toChars()); 
    473481    assert(ids->vthis); 
    474482 
     
    11331141 
    11341142#if CANINLINE_LOG 
    1135     printf("FuncDeclaration::canInline('%s')\n", toChars()); 
     1143    printf("FuncDeclaration::canInline(hasthis = %d, '%s')\n", hasthis, toChars()); 
    11361144#endif 
     1145 
     1146    if (needThis() && !hasthis) 
     1147    return 0; 
    11371148 
    11381149    if (inlineNest || (!semanticRun && !hdrscan)) 
  • branches/rebuild/rebuild/lexer.c

    r301 r311  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2006 by Digital Mars 
     3// Copyright (c) 1999-2007 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    10011001        if (*p == '=') 
    10021002        {   p++; 
    1003             if (*p == '='
     1003            if (*p == '=' && global.params.Dversion == 1
    10041004            {   p++; 
    10051005            t->value = TOKnotidentity;  // !== 
     
    10431043        if (*p == '=') 
    10441044        {   p++; 
    1045             if (*p == '='
     1045            if (*p == '=' && global.params.Dversion == 1
    10461046            {   p++; 
    10471047            t->value = TOKidentity;     // === 
     
    25072507    {   "typeof",   TOKtypeof   }, 
    25082508    {   "typeid",   TOKtypeid   }, 
    2509     {   "iftype",   TOKiftype   }, 
    25102509 
    25112510    {   "template", TOKtemplate }, 
     
    25262525    {   "real",     TOKfloat80  }, 
    25272526 
    2528 /*  {   "bit",      TOKbit      }, */ 
    25292527    {   "bool",     TOKbool     }, 
    25302528    {   "char",     TOKchar     }, 
     
    25652563    {   "foreach_reverse",  TOKforeach_reverse  }, 
    25662564    {   "scope",    TOKscope    }, 
    2567     {   "on_scope_exit",    TOKon_scope_exit }, 
    2568     {   "on_scope_failure", TOKon_scope_failure }, 
    2569     {   "on_scope_success", TOKon_scope_success }, 
    25702565 
    25712566    {   "struct",   TOKstruct   }, 
     
    25772572    {   "mixin",    TOKmixin    }, 
    25782573    {   "static",   TOKstatic   }, 
    2579     /*{ "virtual",  TOKvirtual  },*/ 
    25802574    {   "final",    TOKfinal    }, 
    25812575    {   "const",    TOKconst    }, 
  • branches/rebuild/rebuild/lexer.h

    r272 r311  
    6565    TOKpragma,  TOKdsymbol, 
    6666    TOKtypeid,  TOKuadd, 
    67     TOKiftype, TOKremove, 
     67    TOKremove, 
    6868    TOKnewanonclass, TOKcomment, 
    6969    TOKarrayliteral, 
  • branches/rebuild/rebuild/mars.c

    r306 r311  
    5757    doc_ext  = "html"; 
    5858    ddoc_ext = "ddoc"; 
     59 
    5960    obj_ext  = "o"; 
    60      
     61 
    6162    copyright = "Copyright (c) 1999-2007 by Digital Mars and Gregor Richards,"; 
    6263    written = "written by Walter Bright and Gregor Richards"; 
    63     version = "version 0.1 (based on DMD 1.004)"; 
     64    version = "version 0.1 (based on DMD 1.005)"; 
    6465    global.structalign = 8; 
    6566    cmodules = NULL; 
     
    251252    global.params.useInline = 0; 
    252253    global.params.obj = 1; 
     254    global.params.Dversion = 2; 
    253255 
    254256    global.params.linkswitches = new Array(); 
  • branches/rebuild/rebuild/module.c

    r300 r311  
    289289    result = sdi; 
    290290    else if (FileName::exists(sd)) 
    291     result =sd; 
     291    result = sd; 
    292292    else if (FileName::absolute(filename)) 
    293293    ; 
  • branches/rebuild/rebuild/mtype.c

    r297 r311  
    540540    e = e->semantic(&sc); 
    541541    } 
     542    else if (ident == Id::stringof) 
     543    {   char *s = toChars(); 
     544    e = new StringExp(loc, s, strlen(s), 'c'); 
     545    Scope sc; 
     546    e = e->semantic(&sc); 
     547    } 
    542548    else 
    543549    { 
     
    613619        error(e->loc, ".typeinfo deprecated, use typeid(type)"); */ 
    614620    e = getTypeInfo(sc); 
     621    return e; 
     622    } 
     623    if (ident == Id::stringof) 
     624    {   char *s = e->toChars(); 
     625    e = new StringExp(e->loc, s, strlen(s), 'c'); 
     626    Scope sc; 
     627    e = e->semantic(&sc); 
    615628    return e; 
    616629    } 
     
    16531666    *pe = e; 
    16541667    } 
     1668    else if (*ps) 
     1669    {   Dsymbol *s = *ps; 
     1670    TupleDeclaration *td = s->isTupleDeclaration(); 
     1671    if (td) 
     1672    { 
     1673        ScopeDsymbol *sym = new ArrayScopeSymbol(td); 
     1674        sym->parent = sc->scopesym; 
     1675        sc = sc->push(sym); 
     1676 
     1677        dim = dim->semantic(sc); 
     1678        dim = dim->constFold(); 
     1679        uinteger_t d = dim->toUInteger(); 
     1680 
     1681        sc = sc->pop(); 
     1682 
     1683        if (d >= td->objects->dim) 
     1684        {   error(loc, "tuple index %ju exceeds %u", d, td->objects->dim); 
     1685        goto Ldefault; 
     1686        } 
     1687 
     1688        /* Create a new TupleDeclaration which 
     1689         * is a slice [d..d+1] out of the old one. 
     1690         * Do it this way because TemplateInstance::semanticTiargs() 
     1691         * can handle unresolved Objects this way. 
     1692         */ 
     1693        Objects *objects = new Objects; 
     1694        objects->setDim(1); 
     1695        objects->data[0] = td->objects->data[(size_t)d]; 
     1696 
     1697        TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); 
     1698        *ps = tds; 
     1699    } 
     1700    else 
     1701        goto Ldefault; 
     1702    } 
    16551703    else 
     1704    { 
     1705     Ldefault: 
    16561706    Type::resolve(loc, sc, pe, pt, ps); 
     1707    } 
    16571708} 
    16581709 
     
    29713022    VarDeclaration *v; 
    29723023    EnumMember *em; 
     3024    TupleDeclaration *td; 
    29733025    Type *t; 
    29743026    Expression *e; 
     
    39353987    return 0;       // assume not 
    39363988    } 
    3937     return sym->basetype->isZeroInit(); 
     3989    if (sym->inuse) 
     3990    { 
     3991    sym->error("circular definition"); 
     3992    sym->basetype = Type::terror; 
     3993    } 
     3994    sym->inuse = 1; 
     3995    int result = sym->basetype->isZeroInit(); 
     3996    sym->inuse = 0; 
     3997    return result; 
    39383998} 
    39393999 
     
    47734833    *pe = e; 
    47744834    } 
     4835    else if (*ps) 
     4836    {   Dsymbol *s = *ps; 
     4837    TupleDeclaration *td = s->isTupleDeclaration(); 
     4838    if (td) 
     4839    { 
     4840        /* It's a slice of a TupleDeclaration 
     4841         */ 
     4842        ScopeDsymbol *sym = new ArrayScopeSymbol(td); 
     4843        sym->parent = sc->scopesym; 
     4844        sc = sc->push(sym); 
     4845 
     4846        lwr = lwr->semantic(sc); 
     4847        lwr = lwr->constFold(); 
     4848        uinteger_t i1 = lwr->toUInteger(); 
     4849 
     4850        upr = upr->semantic(sc); 
     4851        upr = upr->constFold(); 
     4852        uinteger_t i2 = upr->toUInteger(); 
     4853 
     4854        sc = sc->pop(); 
     4855 
     4856        if (!(i1 <= i2 && i2 <= td->objects->dim)) 
     4857        {   error(loc, "slice [%ju..%ju] is out of range of [0..%u]", i1, i2, td->objects->dim); 
     4858        goto Ldefault; 
     4859        } 
     4860 
     4861        if (i1 == 0 && i2 == td->objects->dim) 
     4862        { 
     4863        *ps = td; 
     4864        return; 
     4865        } 
     4866 
     4867        /* Create a new TupleDeclaration which 
     4868         * is a slice [i1..i2] out of the old one. 
     4869         */ 
     4870        Objects *objects = new Objects; 
     4871        objects->setDim(i2 - i1); 
     4872        for (size_t i = 0; i < objects->dim; i++) 
     4873        { 
     4874        objects->data[i] = td->objects->data[(size_t)i1 + i]; 
     4875        } 
     4876 
     4877        TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); 
     4878        *ps = tds; 
     4879    } 
     4880    else 
     4881        goto Ldefault; 
     4882    } 
    47754883    else 
     4884    { 
     4885     Ldefault: 
    47764886    Type::resolve(loc, sc, pe, pt, ps); 
     4887    } 
    47774888} 
    47784889 
     
    49805091    for (size_t i = 0; i < args->dim; i++) 
    49815092    {   Argument *arg = (Argument *)args->data[i]; 
    4982  
    4983         if (arg->type->ty == Ttuple) 
    4984         {   TypeTuple *t = (TypeTuple *)arg->type; 
    4985         n += dim(t->arguments); 
     5093        Type *t = arg->type->toBasetype(); 
     5094 
     5095        if (t->ty == Ttuple) 
     5096        {   TypeTuple *tu = (TypeTuple *)t; 
     5097        n += dim(tu->arguments); 
    49865098        } 
    49875099        else 
     
    50085120    for (size_t i = 0; i < args->dim; i++) 
    50095121    {   Argument *arg = (Argument *)args->data[i]; 
    5010  
    5011     if (arg->type->ty == Ttuple) 
    5012     {   TypeTuple *t = (TypeTuple *)arg->type; 
    5013         arg = getNth(t->arguments, nth - n, &n); 
     5122    Type *t = arg->type->toBasetype(); 
     5123 
     5124    if (t->ty == Ttuple) 
     5125    {   TypeTuple *tu = (TypeTuple *)t; 
     5126        arg = getNth(tu->arguments, nth - n, &n); 
    50145127        if (arg) 
    50155128        return arg; 
  • branches/rebuild/rebuild/mtype.h

    r291 r311  
    232232    virtual int isZeroInit();       // if initializer is 0 
    233233    Identifier *getTypeInfoIdent(int internal); 
    234     virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     234    virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    235235    virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 
    236236    Expression *getInternalTypeInfo(Scope *sc); 
     
    305305    Expression *defaultInit(); 
    306306    dt_t **toDtElem(dt_t **pdt, Expression *e); 
    307     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     307    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    308308    Expression *toExpression(); 
    309309    int hasPointers(); 
     
    343343    Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 
    344344    Expression *defaultInit(); 
    345     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     345    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    346346    int checkBoolean(); 
    347347    int hasPointers(); 
     
    396396    void toDecoBuffer(OutBuffer *buf); 
    397397    void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 
    398     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     398    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    399399    Type *reliesOnTident(); 
    400400 
     
    442442    Dsymbol *toDsymbol(Scope *sc); 
    443443    Type *semantic(Loc loc, Scope *sc); 
    444     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     444    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    445445    Type *reliesOnTident(); 
    446446    Expression *toExpression(); 
     
    460460    void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 
    461461    Type *semantic(Loc loc, Scope *sc); 
    462     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     462    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    463463}; 
    464464 
     
    494494    int isZeroInit(); 
    495495    int checkBoolean(); 
    496     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     496    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    497497    int hasPointers(); 
    498498}; 
     
    521521    Expression *defaultInit(); 
    522522    int isZeroInit(); 
    523     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     523    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    524524    int hasPointers(); 
    525525}; 
     
    553553    Expression *defaultInit(); 
    554554    int isZeroInit(); 
    555     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     555    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    556556    int hasPointers(); 
    557557}; 
     
    575575    Expression *defaultInit(); 
    576576    int isZeroInit(); 
    577     MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Array *atypes); 
     577    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    578578    int isauto(); 
    579579    int checkBoolean(); 
  • branches/rebuild/rebuild/optimize.c

    r297 r311  
    355355        Expression *v = eq.constFold(); 
    356356        value = v->toInteger(); 
    357         if (value
     357        if (value == 0
    358358            break; 
    359359        } 
  • branches/rebuild/rebuild/parse.c

    r272 r311  <