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

Changeset 318

Show
Ignore:
Timestamp:
12/29/09 11:03:50 (15 years ago)
Author:
walter
Message:

bugzilla 2029 Typesafe variadic functions don't work in CTFE

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/aggregate.h

    r243 r318  
    114114    { 
    115115    } 
    116116 
    117117    AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } 
    118118}; 
    119119 
    120120struct StructDeclaration : AggregateDeclaration 
    121121{ 
    122122    int zeroInit;       // !=0 if initialize with 0 fill 
    123123#if DMDV2 
    124124    int hasIdentityAssign;  // !=0 if has identity opAssign 
    125125    FuncDeclaration *cpctor;    // generated copy-constructor, if any 
    126126 
    127127    FuncDeclarations postblits; // Array of postblit functions 
    128128    FuncDeclaration *postblit;  // aggregate postblit 
    129129#endif 
    130130 
    131131    StructDeclaration(Loc loc, Identifier *id); 
    132132    Dsymbol *syntaxCopy(Dsymbol *s); 
    133133    void semantic(Scope *sc); 
     134    Dsymbol *search(Loc, Identifier *ident, int flags); 
    134135    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    135136    char *mangle(); 
    136137    const char *kind(); 
    137138#if DMDV1 
    138139    Expression *cloneMembers(); 
    139140#endif 
    140141#if DMDV2 
    141142    int needOpAssign(); 
    142143    FuncDeclaration *buildOpAssign(Scope *sc); 
    143144    FuncDeclaration *buildPostBlit(Scope *sc); 
    144145    FuncDeclaration *buildCpCtor(Scope *sc); 
    145146#endif 
    146147    void toDocBuffer(OutBuffer *buf); 
    147148 
    148149    PROT getAccess(Dsymbol *smember);   // determine access to smember 
    149150 
    150151    void toObjFile(int multiobj);           // compile to .obj file 
    151152    void toDt(dt_t **pdt); 
    152153    void toDebug();         // to symbolic debug info 
    153154 
  • branches/dmd-1.x/src/struct.c

    r304 r318  
    433433        } 
    434434    } 
    435435    } 
    436436 
    437437    /* Look for special member functions. 
    438438     */ 
    439439#if DMDV2 
    440440    ctor =   (CtorDeclaration *)search(0, Id::ctor, 0); 
    441441#endif 
    442442    inv =    (InvariantDeclaration *)search(0, Id::classInvariant, 0); 
    443443    aggNew =       (NewDeclaration *)search(0, Id::classNew,       0); 
    444444    aggDelete = (DeleteDeclaration *)search(0, Id::classDelete,    0); 
    445445 
    446446    if (sc->func) 
    447447    { 
    448448    semantic2(sc); 
    449449    semantic3(sc); 
    450450    } 
    451451} 
    452452 
     453Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags) 
     454{ 
     455    //printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars()); 
     456 
     457    if (scope) 
     458        semantic(scope); 
     459 
     460    if (!members || !symtab) 
     461    { 
     462    error("is forward referenced when looking for '%s'", ident->toChars()); 
     463    return NULL; 
     464    } 
     465 
     466    return ScopeDsymbol::search(loc, ident, flags); 
     467} 
     468 
    453469void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    454470{   int i; 
    455471 
    456472    buf->printf("%s ", kind()); 
    457473    if (!isAnonymous()) 
    458474    buf->writestring(toChars()); 
    459475    if (!members) 
    460476    { 
    461477    buf->writeByte(';'); 
    462478    buf->writenl(); 
    463479    return; 
    464480    } 
    465481    buf->writenl(); 
    466482    buf->writeByte('{'); 
    467483    buf->writenl(); 
    468484    for (i = 0; i < members->dim; i++) 
    469485    { 
    470486    Dsymbol *s = (Dsymbol *)members->data[i]; 
    471487 
    472488    buf->writestring("    "); 
  • trunk/src/aggregate.h

    r260 r318  
    115115    } 
    116116 
    117117    AnonymousAggregateDeclaration *isAnonymousAggregateDeclaration() { return this; } 
    118118}; 
    119119 
    120120struct StructDeclaration : AggregateDeclaration 
    121121{ 
    122122    int zeroInit;       // !=0 if initialize with 0 fill 
    123123#if DMDV2 
    124124    int hasIdentityAssign;  // !=0 if has identity opAssign 
    125125    FuncDeclaration *cpctor;    // generated copy-constructor, if any 
    126126    FuncDeclaration *eq;    // bool opEquals(ref const T), if any 
    127127 
    128128    FuncDeclarations postblits; // Array of postblit functions 
    129129    FuncDeclaration *postblit;  // aggregate postblit 
    130130#endif 
    131131 
    132132    StructDeclaration(Loc loc, Identifier *id); 
    133133    Dsymbol *syntaxCopy(Dsymbol *s); 
    134134    void semantic(Scope *sc); 
     135    Dsymbol *search(Loc, Identifier *ident, int flags); 
    135136    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    136137    char *mangle(); 
    137138    const char *kind(); 
    138139#if DMDV1 
    139140    Expression *cloneMembers(); 
    140141#endif 
    141142#if DMDV2 
    142143    int needOpAssign(); 
    143144    int needOpEquals(); 
    144145    FuncDeclaration *buildOpAssign(Scope *sc); 
    145146    FuncDeclaration *buildOpEquals(Scope *sc); 
    146147    FuncDeclaration *buildPostBlit(Scope *sc); 
    147148    FuncDeclaration *buildCpCtor(Scope *sc); 
    148149#endif 
    149150    void toDocBuffer(OutBuffer *buf); 
    150151 
    151152    PROT getAccess(Dsymbol *smember);   // determine access to smember 
    152153 
    153154    void toObjFile(int multiobj);           // compile to .obj file 
    154155    void toDt(dt_t **pdt); 
  • trunk/src/struct.c

    r260 r318  
    537537        } 
    538538    } 
    539539    } 
    540540 
    541541    /* Look for special member functions. 
    542542     */ 
    543543#if DMDV2 
    544544    ctor = search(0, Id::ctor, 0); 
    545545#endif 
    546546    inv =    (InvariantDeclaration *)search(0, Id::classInvariant, 0); 
    547547    aggNew =       (NewDeclaration *)search(0, Id::classNew,       0); 
    548548    aggDelete = (DeleteDeclaration *)search(0, Id::classDelete,    0); 
    549549 
    550550    if (sc->func) 
    551551    { 
    552552    semantic2(sc); 
    553553    semantic3(sc); 
    554554    } 
    555555} 
    556556 
     557Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags) 
     558{ 
     559    //printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars()); 
     560 
     561    if (scope) 
     562        semantic(scope); 
     563 
     564    if (!members || !symtab) 
     565    { 
     566    error("is forward referenced when looking for '%s'", ident->toChars()); 
     567    return NULL; 
     568    } 
     569 
     570    return ScopeDsymbol::search(loc, ident, flags); 
     571} 
     572 
    557573void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    558574{   int i; 
    559575 
    560576    buf->printf("%s ", kind()); 
    561577    if (!isAnonymous()) 
    562578    buf->writestring(toChars()); 
    563579    if (!members) 
    564580    { 
    565581    buf->writeByte(';'); 
    566582    buf->writenl(); 
    567583    return; 
    568584    } 
    569585    buf->writenl(); 
    570586    buf->writeByte('{'); 
    571587    buf->writenl(); 
    572588    for (i = 0; i < members->dim; i++) 
    573589    { 
    574590    Dsymbol *s = (Dsymbol *)members->data[i]; 
    575591 
    576592    buf->writestring("    ");