Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #125: forwardref-1434-noexception.diff

File forwardref-1434-noexception.diff, 177.6 kB (added by ChristianK, 3 years ago)

another try

  • a/dmd/aggregate.h

    old new  
    6262                // 1: size is correct 
    6363                // 2: cannot determine size; fwd referenced 
    6464    int isdeprecated;       // !=0 if deprecated 
    65     Scope *scope;       // !=NULL means context to use 
    6665 
    6766    // Special member functions 
    6867    InvariantDeclaration *inv;      // invariant 
     
    7776#endif 
    7877 
    7978    AggregateDeclaration(Loc loc, Identifier *id); 
    80     void semantic2(Scope *sc); 
    81     void semantic3(Scope *sc); 
     79    DeferStatus<void> semantic2(Scope *sc); 
     80    DeferStatus<void> semantic3(Scope *sc); 
    8281    void inlineScan(); 
    8382    unsigned size(Loc loc); 
    8483    static void alignmember(unsigned salign, unsigned size, unsigned *poffset); 
    8584    Type *getType(); 
    86     void addField(Scope *sc, VarDeclaration *v); 
     85    DeferStatus<void> addField(Scope *sc, VarDeclaration *v); 
    8786    int isDeprecated();     // is aggregate deprecated? 
    8887    FuncDeclaration *buildDtor(Scope *sc); 
    8988 
     
    106105#endif 
    107106 
    108107    AggregateDeclaration *isAggregateDeclaration() { return this; } 
     108 
     109    // LDC 
     110    int sc_offset;      // saved next offset in aggregate 
    109111}; 
    110112 
    111113struct AnonymousAggregateDeclaration : AggregateDeclaration 
     
    131133 
    132134    StructDeclaration(Loc loc, Identifier *id); 
    133135    Dsymbol *syntaxCopy(Dsymbol *s); 
    134     void semantic(Scope *sc); 
     136    DeferStatus<void> semantic(Scope *sc); 
    135137    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     138 
     139    //LDC, override to allow searching in partially semantic'ed structs 
     140    DeferStatus<Dsymbol*> search(Loc, Identifier *ident, int flags); 
     141 
     142    //LDC, for deferring 
     143    int deferState; 
     144    virtual bool isMemberReorderable(Dsymbol* s); 
     145 
    136146    char *mangle(); 
    137147    const char *kind(); 
    138148    Expression *cloneMembers(); 
     
    160170    const char *kind(); 
    161171 
    162172    UnionDeclaration *isUnionDeclaration() { return this; } 
     173 
     174    // LDC, overload to reset offset to zero after each member 
     175    virtual void postMemberSemantic(Scope* sc); 
    163176}; 
    164177 
    165178// warning: two classes with the same base class share the same 
     
    225238 
    226239    int inuse;              // to prevent recursive attempts 
    227240 
     241    //LDC, for deferring 
     242    int deferState; 
     243 
    228244    ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); 
    229245    Dsymbol *syntaxCopy(Dsymbol *s); 
    230     void semantic(Scope *sc); 
     246    DeferStatus<void> semantic(Scope *sc); 
    231247    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    232248    int isBaseOf2(ClassDeclaration *cd); 
    233249 
    234250    #define OFFSET_RUNTIME 0x76543210 
    235251    virtual int isBaseOf(ClassDeclaration *cd, int *poffset); 
    236252 
    237     Dsymbol *search(Loc, Identifier *ident, int flags); 
     253    DeferStatus<Dsymbol*> search(Loc, Identifier *ident, int flags); 
    238254#if DMDV2 
    239255    int isFuncHidden(FuncDeclaration *fd); 
    240256#endif 
     
    283299#endif 
    284300    InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses); 
    285301    Dsymbol *syntaxCopy(Dsymbol *s); 
    286     void semantic(Scope *sc); 
     302    DeferStatus<void> semantic(Scope *sc); 
    287303    int isBaseOf(ClassDeclaration *cd, int *poffset); 
    288304    int isBaseOf(BaseClass *bc, int *poffset); 
    289305    const char *kind(); 
  • a/dmd/attrib.c

    old new  
    5252    : Dsymbol() 
    5353{ 
    5454    this->decl = decl; 
     55    member_semantic_started = false; 
     56    included_decls = NULL; 
    5557} 
    5658 
    5759Array *AttribDeclaration::include(Scope *sc, ScopeDsymbol *sd) 
     
    7476    return m; 
    7577} 
    7678 
    77 void AttribDeclaration::semantic(Scope *sc) 
     79// shares code with ScopeDsymbol::callSemanticOnMembers 
     80DeferStatus<void> AttribDeclaration::callSemanticOnMembers(Scope* sc, Array* members) 
    7881{ 
    79     Array *d = include(sc, NULL); 
     82    if (!members) 
     83    return nodefer(); 
     84 
     85    // first add everything to remaining_semantic 
     86    if (!member_semantic_started) { 
     87    for (int i = 0; i < members->dim; i++) 
     88        remaining_semantic.push_back( (Dsymbol*)members->data[i] ); 
     89    member_semantic_started = true; 
     90    } 
     91 
     92    int failed = 0; 
     93 
     94    DeferStatus<void> lastdefer; 
     95 
     96    // if we deferred an order dependent member, save it here 
     97    // we will then skip all order dependent members until this is reached again 
     98    Dsymbol *deferredOrderDependent = NULL; 
     99 
     100    while (!remaining_semantic.empty() && failed != remaining_semantic.size()) 
     101    {   Dsymbol *s; 
     102    s = remaining_semantic[0]; 
     103    remaining_semantic.pop_front(); 
     104 
     105    // if we deferred something order dependent, skip other 
     106    // order dependent ones for one iteration 
     107    if (deferredOrderDependent == s) 
     108        deferredOrderDependent = NULL; 
     109    if (deferredOrderDependent && !isMemberReorderable(s)) { 
     110        ++failed; 
     111        remaining_semantic.push_back(s); 
     112        continue; 
     113    } 
     114 
     115    DeferStatus<void> result = runSemantic(s, sc); 
     116    if (result.defer()) { 
     117        lastdefer = result; 
     118        ++failed; 
     119        remaining_semantic.push_back(s); 
     120        if (!isMemberReorderable(s)) 
     121        deferredOrderDependent = s; 
     122        continue; 
     123    } 
     124 
     125    failed = 0; 
     126    postMemberSemantic(sc); 
     127    } 
     128 
     129    if (!remaining_semantic.empty()) 
     130    { 
     131    assert(lastdefer.defer()); 
     132 
     133    // reorder members into a valid state if necessary 
     134    if (deferredOrderDependent) 
     135        while (remaining_semantic[0] != deferredOrderDependent) { 
     136        Dsymbol* s = remaining_semantic[0]; 
     137        remaining_semantic.pop_front(); 
     138        remaining_semantic.push_back(s); 
     139        } 
     140    return lastdefer; 
     141    } 
     142     
     143    lastdefer.handled = true; 
     144    return nodefer(); 
     145
     146 
     147DeferStatus<void> AttribDeclaration::semantic(Scope *sc) 
     148
     149    if (!included_decls) 
     150    included_decls = include(sc, NULL); 
    80151 
    81152    //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); 
    82     if (d) 
    83     { 
    84     for (unsigned i = 0; i < d->dim; i++) 
    85     { 
    86         Dsymbol *s = (Dsymbol *)d->data[i]; 
    87  
    88         s->semantic(sc); 
    89     } 
    90     } 
     153    return callSemanticOnMembers(sc, included_decls); 
    91154} 
    92155 
    93 void AttribDeclaration::semantic2(Scope *sc) 
     156DeferStatus<void> AttribDeclaration::semantic2(Scope *sc) 
    94157{ 
    95158    Array *d = include(sc, NULL); 
    96159 
     
    101164        s->semantic2(sc); 
    102165    } 
    103166    } 
     167    return nodefer(); 
    104168} 
    105169 
    106 void AttribDeclaration::semantic3(Scope *sc) 
     170DeferStatus<void> AttribDeclaration::semantic3(Scope *sc) 
    107171{ 
    108172    Array *d = include(sc, NULL); 
    109173 
     
    114178        s->semantic3(sc); 
    115179    } 
    116180    } 
     181    return nodefer(); 
    117182} 
    118183 
    119184void AttribDeclaration::inlineScan() 
     
    302367    return scd; 
    303368} 
    304369 
    305 void StorageClassDeclaration::semantic(Scope *sc) 
     370DeferStatus<void> StorageClassDeclaration::semantic(Scope *sc) 
    306371{ 
    307372    if (decl) 
    308373    {   unsigned stc_save = sc->stc; 
     
    310375    if (stc & (STCauto | STCscope | STCstatic | STCextern)) 
    311376        sc->stc &= ~(STCauto | STCscope | STCstatic | STCextern); 
    312377    sc->stc |= stc; 
    313     for (unsigned i = 0; i < decl->dim; i++) 
    314     { 
    315         Dsymbol *s = (Dsymbol *)decl->data[i]; 
    316  
    317         s->semantic(sc); 
    318     } 
     378    callSemanticOnMembers(sc, decl); 
    319379    sc->stc = stc_save; 
    320380    } 
    321381    else 
    322382    sc->stc = stc; 
     383    return nodefer(); 
    323384} 
    324385 
    325386void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, int stc) 
     
    384445    return ld; 
    385446} 
    386447 
    387 void LinkDeclaration::semantic(Scope *sc) 
     448DeferStatus<void> LinkDeclaration::semantic(Scope *sc) 
    388449{ 
    389450    //printf("LinkDeclaration::semantic(linkage = %d, decl = %p)\n", linkage, decl); 
    390451    if (decl) 
    391452    {   enum LINK linkage_save = sc->linkage; 
    392453 
    393454    sc->linkage = linkage; 
    394     for (unsigned i = 0; i < decl->dim; i++) 
    395     { 
    396         Dsymbol *s = (Dsymbol *)decl->data[i]; 
    397  
    398         s->semantic(sc); 
    399     } 
     455    callSemanticOnMembers(sc, decl); 
    400456    sc->linkage = linkage_save; 
    401457    } 
    402458    else 
    403459    { 
    404460    sc->linkage = linkage; 
    405461    } 
     462    return nodefer(); 
    406463} 
    407464 
    408 void LinkDeclaration::semantic3(Scope *sc) 
     465DeferStatus<void> LinkDeclaration::semantic3(Scope *sc) 
    409466{ 
    410467    //printf("LinkDeclaration::semantic3(linkage = %d, decl = %p)\n", linkage, decl); 
    411468    if (decl) 
     
    424481    { 
    425482    sc->linkage = linkage; 
    426483    } 
     484    return nodefer(); 
    427485} 
    428486 
    429487void LinkDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     
    473531    return pd; 
    474532} 
    475533 
    476 void ProtDeclaration::semantic(Scope *sc) 
     534DeferStatus<void> ProtDeclaration::semantic(Scope *sc) 
    477535{ 
    478536    if (decl) 
    479537    {   enum PROT protection_save = sc->protection; 
     
    481539 
    482540    sc->protection = protection; 
    483541    sc->explicitProtection = 1; 
    484     for (unsigned i = 0; i < decl->dim; i++) 
    485     { 
    486         Dsymbol *s = (Dsymbol *)decl->data[i]; 
    487  
    488         s->semantic(sc); 
    489     } 
     542    callSemanticOnMembers(sc, decl); 
    490543    sc->protection = protection_save; 
    491544    sc->explicitProtection = explicitProtection_save; 
    492545    } 
     
    494547    {   sc->protection = protection; 
    495548    sc->explicitProtection = 1; 
    496549    } 
     550    return nodefer(); 
    497551} 
    498552 
    499553void ProtDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     
    532586    return ad; 
    533587} 
    534588 
    535 void AlignDeclaration::semantic(Scope *sc) 
     589DeferStatus<void> AlignDeclaration::semantic(Scope *sc) 
    536590{ 
    537591// LDC 
    538592// we only support packed structs, as from the spec: align(1) struct Packed { ... } 
     
    540594 
    541595    //printf("\tAlignDeclaration::semantic '%s'\n",toChars()); 
    542596    if (decl) 
    543     {   unsigned salign_save = sc->structalign; 
     597    {    
     598    callSemanticOnMembers(sc, decl); 
     599    } 
     600    else 
     601    assert(0 && "what kind of align use triggers this?"); 
     602    return nodefer(); 
     603
    544604 
    545     for (unsigned i = 0; i < decl->dim; i++) 
    546     { 
    547         Dsymbol *s = (Dsymbol *)decl->data[i]; 
     605DeferStatus<void> AlignDeclaration::runSemantic(Dsymbol* s, Scope* sc) 
     606
     607    unsigned salign_save = sc->structalign; 
     608    DeferStatus<void> ret; 
    548609 
    549         if (s->isStructDeclaration() && salign == 1) 
    550         { 
    551             sc->structalign = salign; 
    552             s->semantic(sc); 
    553             sc->structalign = salign_save; 
    554         } 
    555         else 
    556         { 
    557             s->semantic(sc); 
    558         } 
    559     } 
     610    if (s->isStructDeclaration() && salign == 1) 
     611    { 
     612    sc->structalign = salign; 
     613    ret = s->semantic(sc); 
    560614    sc->structalign = salign_save; 
    561615    } 
    562616    else 
    563     assert(0 && "what kind of align use triggers this?"); 
     617    { 
     618    ret = s->semantic(sc); 
     619    } 
     620    return ret; 
    564621} 
    565622 
    566  
    567623void AlignDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    568624{ 
    569625    buf->printf("align (%d)", salign); 
     
    577633{ 
    578634    this->loc = loc; 
    579635    this->isunion = isunion; 
    580     this->scope = NULL; 
    581636    this->sem = 0; 
     637 
     638    sc_offset = -1; 
    582639} 
    583640 
    584641Dsymbol *AnonDeclaration::syntaxCopy(Dsymbol *s) 
     
    590647    return ad; 
    591648} 
    592649 
    593 void AnonDeclaration::semantic(Scope *sc) 
     650// copied from StructDeclaration::isMemberReorderable 
     651bool AnonDeclaration::isMemberReorderable(Dsymbol* s) 
     652
     653    if ( 
     654    s->isVarDeclaration() || 
     655    s->isAttribDeclaration() 
     656    ) 
     657    return false; 
     658    return true; 
     659
     660 
     661void AnonDeclaration::postMemberSemantic(Scope* sc) 
     662
     663    if (isunion) 
     664    sc->offset = 0; 
     665
     666 
     667DeferStatus<void> AnonDeclaration::semantic(Scope *sc) 
    594668{ 
    595669    //printf("\tAnonDeclaration::semantic %s %p\n", isunion ? "union" : "struct", this); 
    596670 
    597     Scope *scx = NULL; 
    598     if (scope) 
    599     {   sc = scope; 
    600     scx = scope; 
    601     scope = NULL; 
    602     } 
    603  
    604671    assert(sc->parent); 
    605672 
    606673    Dsymbol *parent = sc->parent->pastMixin(); 
     
    609676    if (!ad || (!ad->isStructDeclaration() && !ad->isClassDeclaration())) 
    610677    { 
    611678    error("can only be a part of an aggregate"); 
    612     return
     679    return nodefer()
    613680    } 
    614681 
    615682    if (decl) 
    616683    { 
    617     AnonymousAggregateDeclaration aad; 
    618684    int adisunion; 
    619685 
    620686    if (sc->anonAgg) 
     
    633699    sc->stc &= ~(STCauto | STCscope | STCstatic | STCtls); 
    634700    sc->inunion = isunion; 
    635701    sc->offset = 0; 
     702    if (sc_offset >= 0) 
     703        sc->offset = sc_offset; 
     704  
    636705    sc->flags = 0; 
    637706    aad.structalign = sc->structalign; 
    638707    aad.parent = ad; 
    639708 
    640     for (unsigned i = 0; i < decl->dim; i++) 
    641     { 
    642         Dsymbol *s = (Dsymbol *)decl->data[i]; 
    643  
    644         s->semantic(sc); 
    645         if (isunion) 
    646         sc->offset = 0; 
    647         if (aad.sizeok == 2) 
    648         { 
    649         break; 
    650         } 
     709    DeferStatus<void> res = callSemanticOnMembers(sc, decl); 
     710    if (res.defer()) { 
     711        sc_offset = sc->offset; 
     712        sc->pop(); 
     713        return res; 
    651714    } 
     715     
    652716    sc = sc->pop(); 
    653717 
    654     // If failed due to forward references, unwind and try again later 
    655     if (aad.sizeok == 2) 
    656     { 
    657         ad->sizeok = 2; 
    658         //printf("\tsetting ad->sizeok %p to 2\n", ad); 
    659         if (!sc->anonAgg) 
    660         { 
    661         scope = scx ? scx : new Scope(*sc); 
    662         scope->setNoFree(); 
    663         scope->module->addDeferredSemantic(this); 
    664         } 
    665         //printf("\tforward reference %p\n", this); 
    666         return; 
    667     } 
    668718    if (sem == 0) 
    669719    {   Module::dprogress++; 
    670720        sem = 1; 
     
    720770    if (ad->alignsize < aad.alignsize) 
    721771        ad->alignsize = aad.alignsize; 
    722772    } 
     773    return nodefer(); 
    723774} 
    724775 
    725776 
     
    780831    return pd; 
    781832} 
    782833 
    783 void PragmaDeclaration::semantic(Scope *sc) 
     834DeferStatus<void> PragmaDeclaration::semantic(Scope *sc) 
    784835{   // Should be merged with PragmaStatement 
    785836 
    786837#if IN_LLVM 
     
    11661217 
    11671218    } 
    11681219    } 
    1169     return
     1220    return nodefer()
    11701221 
    11711222Lnodecl: 
    11721223    if (decl) 
    11731224    error("pragma is missing closing ';'"); 
     1225    return nodefer(); 
    11741226} 
    11751227 
    11761228int PragmaDeclaration::oneMember(Dsymbol **ps) 
     
    14181470} 
    14191471 
    14201472 
    1421 void StaticIfDeclaration::semantic(Scope *sc) 
     1473DeferStatus<void> StaticIfDeclaration::semantic(Scope *sc) 
    14221474{ 
    1423     Array *d = include(sc, sd); 
     1475    if (!included_decls) 
     1476    included_decls = include(sc, sd); 
    14241477 
    14251478    //printf("\tStaticIfDeclaration::semantic '%s', d = %p\n",toChars(), d); 
    1426     if (d
     1479    if (included_decls
    14271480    { 
    14281481    if (!addisdone) 
    14291482    {   AttribDeclaration::addMember(sc, sd, 1); 
    14301483        addisdone = 1; 
    14311484    } 
    14321485 
    1433     for (unsigned i = 0; i < d->dim; i++) 
    1434     { 
    1435         Dsymbol *s = (Dsymbol *)d->data[i]; 
    1436  
    1437         s->semantic(sc); 
    1438     } 
     1486    callSemanticOnMembers(sc, included_decls); 
    14391487    } 
     1488    return nodefer(); 
    14401489} 
    14411490 
    14421491const char *StaticIfDeclaration::kind() 
     
    15001549    } 
    15011550} 
    15021551 
    1503 void CompileDeclaration::semantic(Scope *sc) 
     1552DeferStatus<void> CompileDeclaration::semantic(Scope *sc) 
    15041553{ 
    15051554    //printf("CompileDeclaration::semantic()\n"); 
    15061555 
     
    15111560    compiled = 1; 
    15121561    } 
    15131562    AttribDeclaration::semantic(sc); 
     1563    return nodefer(); 
    15141564} 
    15151565 
    15161566void CompileDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
  • a/dmd/attrib.h

    old new  
    1616#endif /* __DMC__ */ 
    1717 
    1818#include "dsymbol.h" 
     19#include "aggregate.h" 
    1920 
    2021struct Expression; 
    2122struct Statement; 
     
    3637    AttribDeclaration(Array *decl); 
    3738    virtual Array *include(Scope *sc, ScopeDsymbol *s); 
    3839    int addMember(Scope *sc, ScopeDsymbol *s, int memnum); 
    39     void semantic(Scope *sc); 
    40     void semantic2(Scope *sc); 
    41     void semantic3(Scope *sc); 
     40    DeferStatus<void> semantic(Scope *sc); 
     41    DeferStatus<void> semantic2(Scope *sc); 
     42    DeferStatus<void> semantic3(Scope *sc); 
    4243    void inlineScan(); 
    4344    void addComment(unsigned char *comment); 
    4445    void emitComment(Scope *sc); 
     
    5859#if IN_LLVM 
    5960    virtual void codegen(Ir*); 
    6061#endif 
     62  
     63     // LDC 
     64     Array *included_decls; 
     65     std::deque<Dsymbol*> remaining_semantic; 
     66     bool member_semantic_started; 
     67  
     68     DeferStatus<void> callSemanticOnMembers(Scope* sc, Array* members); 
     69     virtual DeferStatus<void> runSemantic(Dsymbol* s, Scope* sc) { return s->semantic(sc); } 
     70     virtual void postMemberSemantic(Scope* sc) {}; 
     71     virtual bool isMemberReorderable(Dsymbol* sym) { return true; } 
    6172}; 
    6273 
    6374struct StorageClassDeclaration: AttribDeclaration 
     
    6677 
    6778    StorageClassDeclaration(unsigned stc, Array *decl); 
    6879    Dsymbol *syntaxCopy(Dsymbol *s); 
    69     void semantic(Scope *sc); 
     80    DeferStatus<void> semantic(Scope *sc); 
    7081    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    7182 
    7283    static void stcToCBuffer(OutBuffer *buf, int stc); 
     
    7889 
    7990    LinkDeclaration(enum LINK p, Array *decl); 
    8091    Dsymbol *syntaxCopy(Dsymbol *s); 
    81     void semantic(Scope *sc); 
    82     void semantic3(Scope *sc); 
     92    DeferStatus<void> semantic(Scope *sc); 
     93    DeferStatus<void> semantic3(Scope *sc); 
    8394    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    8495    char *toChars(); 
    8596}; 
     
    90101 
    91102    ProtDeclaration(enum PROT p, Array *decl); 
    92103    Dsymbol *syntaxCopy(Dsymbol *s); 
    93     void semantic(Scope *sc); 
     104    DeferStatus<void> semantic(Scope *sc); 
    94105    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    95106}; 
    96107 
     
    100111 
    101112    AlignDeclaration(Loc loc, unsigned sa, Array *decl); 
    102113    Dsymbol *syntaxCopy(Dsymbol *s); 
    103     void semantic(Scope *sc); 
     114    DeferStatus<void> semantic(Scope *sc); 
    104115    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     116 
     117    DeferStatus<void> runSemantic(Dsymbol* s, Scope* sc); 
    105118}; 
    106119 
    107120struct AnonDeclaration : AttribDeclaration 
    108121{ 
    109122    int isunion; 
    110     Scope *scope;       // !=NULL means context to use 
    111123    int sem;            // 1 if successful semantic() 
    112124 
    113125    AnonDeclaration(Loc loc, int isunion, Array *decl); 
    114126    Dsymbol *syntaxCopy(Dsymbol *s); 
    115     void semantic(Scope *sc); 
     127    DeferStatus<void> semantic(Scope *sc); 
    116128    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    117129    const char *kind(); 
     130 
     131    void postMemberSemantic(Scope* sc); 
     132    bool isMemberReorderable(Dsymbol* sym); 
     133    int sc_offset;            // saved next offset in aggregate 
     134    AnonymousAggregateDeclaration aad; 
    118135}; 
    119136 
    120137struct PragmaDeclaration : AttribDeclaration 
     
    123140 
    124141    PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Array *decl); 
    125142    Dsymbol *syntaxCopy(Dsymbol *s); 
    126     void semantic(Scope *sc); 
     143    DeferStatus<void> semantic(Scope *sc); 
    127144    int oneMember(Dsymbol **ps); 
    128145    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    129146    const char *kind(); 
     
    159176    StaticIfDeclaration(Condition *condition, Array *decl, Array *elsedecl); 
    160177    Dsymbol *syntaxCopy(Dsymbol *s); 
    161178    int addMember(Scope *sc, ScopeDsymbol *s, int memnum); 
    162     void semantic(Scope *sc); 
     179    DeferStatus<void> semantic(Scope *sc); 
    163180    const char *kind(); 
    164181}; 
    165182 
     
    176193    Dsymbol *syntaxCopy(Dsymbol *s); 
    177194    int addMember(Scope *sc, ScopeDsymbol *sd, int memnum); 
    178195    void compileIt(Scope *sc); 
    179     void semantic(Scope *sc); 
     196    DeferStatus<void> semantic(Scope *sc); 
    180197    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    181198}; 
    182199 
  • a/dmd/class.c

    old new  
    4141    this->baseclasses = *baseclasses; 
    4242    baseClass = NULL; 
    4343 
     44    deferState = 0; 
     45 
    4446    interfaces_dim = 0; 
    4547    interfaces = NULL; 
    4648 
     
    215217    return cd; 
    216218} 
    217219 
    218 void ClassDeclaration::semantic(Scope *sc) 
     220DeferStatus<void> ClassDeclaration::semantic(Scope *sc) 
    219221{   int i; 
    220222    unsigned offset; 
     223    Scope scsave; 
     224    Scope *scx = NULL; 
     225    DeferStatus<void> defers; 
    221226 
    222227    //printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this); 
    223228    //printf("\tparent = %p, '%s'\n", sc->parent, sc->parent ? sc->parent->toChars() : ""); 
     
    225230 
    226231    //{ static int n;  if (++n == 20) *(char*)0=0; } 
    227232 
     233int continueAt = deferState; 
     234if (deferState > 0)  
     235    deferState = 0; 
     236switch (continueAt) { 
     237case 0: 
     238 
    228239    if (!ident)     // if anonymous class 
    229240    {   char *id = "__anonclass"; 
    230241 
    231242    ident = Identifier::generateId(id); 
    232243    } 
    233244 
    234     if (!scope) 
    235     { 
    236     if (!parent && sc->parent && !sc->parent->isModule()) 
    237         parent = sc->parent; 
     245    if (!parent && sc->parent && !sc->parent->isModule()) 
     246    parent = sc->parent; 
    238247 
    239    type = type->semantic(loc, sc); 
    240    handle = handle->semantic(loc, sc); 
    241     } 
     248    type = type->semantic(loc, sc); 
     249    handle = handle->semantic(loc, sc); 
     250 
    242251    if (!members)           // if forward reference 
    243252    {   //printf("\tclass '%s' is forward referenced\n", toChars()); 
    244     return
     253    return nodefer()
    245254    } 
    246255    if (symtab) 
    247     {   if (!scope) 
    248     {   //printf("\tsemantic for '%s' is already completed\n", toChars()); 
    249         return;     // semantic() already completed 
    250     } 
     256    { 
     257    return nodefer();       // semantic() already completed 
    251258    } 
    252259    else 
    253260    symtab = new DsymbolTable(); 
    254261 
    255     Scope *scx = NULL; 
    256     if (scope) 
    257     {   sc = scope; 
    258     scx = scope;        // save so we don't make redundant copies 
    259     scope = NULL; 
    260     } 
    261262#ifdef IN_GCC 
    262263    methods.setDim(0); 
    263264#endif 
     
    288289        i++; 
    289290    } 
    290291 
     292case 1: 
    291293    // See if there's a base class as first in baseclasses[] 
    292294    if (baseclasses.dim) 
    293295    {   TypeClass *tc; 
     
    329331            goto L7; 
    330332            } 
    331333        } 
    332         if (!tc->sym->symtab || tc->sym->scope || tc->sym->sizeok == 0) 
     334        if (!tc->sym->symtab || tc->sym->deferState > 0 || tc->sym->sizeok == 0) 
    333335        { 
    334336            //error("forward reference of base class %s", baseClass->toChars()); 
    335337            // Forward reference of base class, try again later 
    336338            //printf("\ttry later, forward reference of base class %s\n", tc->sym->toChars()); 
    337             scope = scx ? scx : new Scope(*sc)
    338             scope->setNoFree(); 
    339             scope->module->addDeferredSemantic(this); 
    340             return
     339            deferState = 1
     340            sc->module->addDeferredSemantic(this, sc); 
     341            return nodefer(); 
     342            //throw new DeferException(loc, "forward reference of base class %s", tc->sym->toChars())
    341343        } 
    342344        else 
    343345        {   baseClass = tc->sym; 
     
    348350    } 
    349351    } 
    350352 
     353case 2: 
    351354    // Treat the remaining entries in baseclasses as interfaces 
    352355    // Check for errors, handle forward references 
    353356    for (i = (baseClass ? 1 : 0); i < baseclasses.dim; ) 
     
    390393        } 
    391394 
    392395        b->base = tc->sym; 
    393         if (!b->base->symtab || b->base->scope
     396        if (!b->base->symtab || b->base->deferState > 0
    394397        { 
    395398        //error("forward reference of base class %s", baseClass->toChars()); 
    396399        // Forward reference of base, try again later 
    397400        //printf("\ttry later, forward reference of base %s\n", baseClass->toChars()); 
    398         scope = scx ? scx : new Scope(*sc)
    399         scope->setNoFree(); 
    400         scope->module->addDeferredSemantic(this); 
    401         return
     401        deferState = 2
     402        sc->module->addDeferredSemantic(this, sc); 
     403        return nodefer(); 
     404        //throw new DeferException(loc, "forward reference of interface %s", baseClass->toChars())
    402405        } 
    403406    } 
    404407    i++; 
     
    534537    if (storage_class & STCabstract) 
    535538    isabstract = 1; 
    536539 
     540    structalign = 8; 
     541    if (baseClass) 
     542    {   sc_offset = baseClass->structsize; 
     543    alignsize = baseClass->alignsize; 
     544//  if (isnested) 
     545//      sc->offset += PTRSIZE;  // room for uplevel context pointer 
     546    } 
     547    else 
     548    {   sc_offset = PTRSIZE * 2;    // allow room for vptr[] and monitor 
     549    alignsize = PTRSIZE; 
     550    } 
     551    structsize = sc_offset; 
     552    sizeok = 0; 
     553 
     554case 3: 
    537555    sc = sc->push(this); 
    538556    sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic | 
    539557         STCabstract | STCdeprecated); 
     
    554572    sc->protection = PROTpublic; 
    555573    sc->explicitProtection = 0; 
    556574    sc->structalign = 8; 
    557     structalign = sc->structalign; 
    558     if (baseClass) 
    559     {   sc->offset = baseClass->structsize; 
    560     alignsize = baseClass->alignsize; 
    561 //  if (isnested) 
    562 //      sc->offset += PTRSIZE;  // room for uplevel context pointer 
    563     } 
    564     else 
    565     {   sc->offset = PTRSIZE * 2;   // allow room for vptr[] and monitor 
    566     alignsize = PTRSIZE; 
    567     } 
    568     structsize = sc->offset; 
    569     Scope scsave = *sc; 
    570     int members_dim = members->dim; 
    571     sizeok = 0; 
    572     for (i = 0; i < members_dim; i++) 
    573     { 
    574     Dsymbol *s = (Dsymbol *)members->data[i]; 
    575     s->semantic(sc); 
    576     } 
    577  
    578     if (sizeok == 2) 
    579     {   // semantic() failed because of forward references. 
    580     // Unwind what we did, and defer it for later 
    581     fields.setDim(0); 
    582     structsize = 0; 
    583     alignsize = 0; 
    584     structalign = 0; 
    585  
     575     
     576    if (sc_offset >= 0) 
     577    sc->offset = sc_offset; 
     578  
     579    scsave = *sc; 
     580  
     581    defers = callSemanticOnMembers(sc); 
     582    if (defers.defer()) { 
     583    sc_offset = sc->offset; 
     584    deferState = 3; 
    586585    sc = sc->pop(); 
    587  
    588     scope = scx ? scx : new Scope(*sc); 
    589     scope->setNoFree(); 
    590     scope->module->addDeferredSemantic(this); 
    591  
    592     //printf("\tsemantic('%s') failed due to forward references\n", toChars()); 
    593     return; 
     586    return defers; 
    594587    } 
    595588 
    596589    //printf("\tsemantic('%s') successful\n", toChars()); 
     
    601594    /* Look for special member functions. 
    602595     * They must be in this class, not in a base class. 
    603596     */ 
    604     ctor = (CtorDeclaration *)search(0, Id::ctor, 0); 
     597    ctor = (CtorDeclaration *)(Dsymbol *)search(0, Id::ctor, 0); 
    605598    if (ctor && (ctor->toParent() != this || !ctor->isCtorDeclaration())) 
    606599    ctor = NULL; 
    607600 
     
    614607//  inv = NULL; 
    615608 
    616609    // Can be in base class 
    617     aggNew    = (NewDeclaration *)search(0, Id::classNew, 0); 
    618     aggDelete = (DeleteDeclaration *)search(0, Id::classDelete, 0); 
     610    aggNew    = (NewDeclaration *)(Dsymbol *)search(0, Id::classNew, 0); 
     611    aggDelete = (DeleteDeclaration *)(Dsymbol *)search(0, Id::classDelete, 0); 
    619612 
    620613    // If this class has no constructor, but base class does, create 
    621614    // a constructor: 
     
    681674    } 
    682675#endif 
    683676    //printf("-ClassDeclaration::semantic(%s), type = %p\n", toChars(), type); 
     677 
     678    deferState = -1; 
     679case -1: 
     680    break; 
     681default: 
     682    assert(0 && "deferState for classes must be between -1 and 3"); 
     683} // switch for deferred calling 
     684    return nodefer(); 
    684685} 
    685686 
    686687void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     
    772773    return 0; 
    773774} 
    774775 
    775 Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags) 
     776DeferStatus<Dsymbol*> ClassDeclaration::search(Loc loc, Identifier *ident, int flags) 
    776777{ 
    777778    Dsymbol *s; 
    778779 
    779780    //printf("%s.ClassDeclaration::search('%s')\n", toChars(), ident->toChars()); 
    780     if (scope) 
    781     semantic(scope); 
     781    s = ScopeDsymbol::search(loc, ident, flags); 
    782782 
    783     if (!members || !symtab || scope) 
    784     {   error("is forward referenced when looking for '%s'", ident->toChars()); 
    785     //*(char*)0=0; 
    786     return NULL; 
     783    if (!s && (!members || !symtab || deferState > 0)) 
     784    { 
     785    return defer<Dsymbol*>(loc, "%s is forward referenced when looking for '%s'", toChars(), ident->toChars()); 
    787786    } 
    788787 
    789     s = ScopeDsymbol::search(loc, ident, flags); 
    790788    if (!s) 
    791789    { 
    792790    // Search bases classes in depth-first, left to right order 
     
    998996    return id; 
    999997} 
    1000998 
    1001 void InterfaceDeclaration::semantic(Scope *sc) 
     999DeferStatus<void> InterfaceDeclaration::semantic(Scope *sc) 
    10021000{   int i; 
     1001    Scope *scx = NULL; 
     1002    DeferStatus<void> defers; 
    10031003 
     1004int continueAt = deferState; 
     1005if (deferState > 0) 
     1006    deferState = 0; 
     1007switch (continueAt) { 
     1008case 0: 
    10041009    //printf("InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type); 
    10051010    if (inuse) 
    1006     return
    1007     if (!scope) 
    1008     type = type->semantic(loc, sc); 
    1009    handle = handle->semantic(loc, sc); 
    1010     } 
     1011    return nodefer()
     1012 
     1013    type = type->semantic(loc, sc); 
     1014    handle = handle->semantic(loc, sc); 
     1015 
    10111016    if (!members)           // if forward reference 
    10121017    {   //printf("\tinterface '%s' is forward referenced\n", toChars()); 
    1013     return
     1018    return nodefer()
    10141019    } 
    10151020    if (symtab)         // if already done 
    1016     {  if (!scope) 
    1017         return
     1021    { 
     1022    return nodefer()
    10181023    } 
    10191024    else 
    10201025    symtab = new DsymbolTable(); 
    10211026 
    1022     Scope *scx = NULL; 
    1023     if (scope) 
    1024     {   sc = scope; 
    1025     scx = scope;        // save so we don't make redundant copies 
    1026     scope = NULL; 
    1027     } 
    1028  
    10291027    if (sc->stc & STCdeprecated) 
    10301028    { 
    10311029    isdeprecated = 1; 
     
    10521050        i++; 
    10531051    } 
    10541052 
     1053case 1: 
    10551054    // Check for errors, handle forward references 
    10561055    for (i = 0; i < baseclasses.dim; ) 
    10571056    {   TypeClass *tc; 
     
    10881087        baseclasses.remove(i); 
    10891088        continue; 
    10901089        } 
    1091         if (!b->base->symtab || b->base->scope || b->base->inuse) 
     1090        if (!b->base->symtab || b->base->deferState > 0 || b->base->inuse) 
    10921091        { 
    10931092        //error("forward reference of base class %s", baseClass->toChars()); 
    10941093        // Forward reference of base, try again later 
    10951094        //printf("\ttry later, forward reference of base %s\n", b->base->toChars()); 
    1096         scope = scx ? scx : new Scope(*sc)
    1097         scope->setNoFree(); 
    1098         scope->module->addDeferredSemantic(this); 
    1099         return
     1095        deferState = 1
     1096        sc->module->addDeferredSemantic(this, sc); 
     1097        return nodefer(); 
     1098        //throw new DeferException(loc, "forward reference of interface %s", baseClass->toChars())
    11001099        } 
    11011100    } 
    11021101    i++; 
     
    11461145    s->addMember(sc, this, 1); 
    11471146    } 
    11481147 
     1148case 2: 
    11491149    sc = sc->push(this); 
    11501150    sc->parent = this; 
    11511151    if (isCOMinterface()) 
     
    11531153    sc->structalign = 8; 
    11541154    structalign = sc->structalign; 
    11551155    sc->offset = PTRSIZE * 2; 
     1156    if (sc_offset >= 0) 
     1157    sc->offset = sc_offset; 
     1158 
    11561159    inuse++; 
    1157     for (i = 0; i < members->dim; i++) 
    1158     { 
    1159     Dsymbol *s = (Dsymbol *)members->data[i]; 
    1160     s->semantic(sc); 
     1160 
     1161    defers = callSemanticOnMembers(sc); 
     1162    if (defers.defer()) { 
     1163    sc_offset = sc->offset; 
     1164    deferState = 2; 
     1165    sc = sc->pop(); 
     1166    inuse--; 
     1167    return defers; 
    11611168    } 
    11621169    inuse--; 
    11631170    //members->print(); 
    11641171    sc->pop(); 
    11651172    //printf("-InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type); 
     1173 
     1174    deferState = -1; 
     1175case -1: 
     1176    break; 
     1177default: 
     1178    assert(0 && "deferState for interfaces must be between -1 and 2"); 
     1179} // switch for deferStatus 
     1180    return nodefer(); 
    11661181} 
    11671182 
    11681183 
  • a/dmd/declaration.c

    old new  
    3636    inuse = 0; 
    3737} 
    3838 
    39 void Declaration::semantic(Scope *sc) 
     39DeferStatus<void> Declaration::semantic(Scope *sc) 
    4040{ 
     41    return nodefer(); 
    4142} 
    4243 
    4344const char *Declaration::kind() 
     
    293294    return st; 
    294295} 
    295296 
    296 void TypedefDeclaration::semantic(Scope *sc) 
     297DeferStatus<void> TypedefDeclaration::semantic(Scope *sc) 
    297298{ 
    298299    //printf("TypedefDeclaration::semantic(%s) sem = %d\n", toChars(), sem); 
    299300    if (sem == 0) 
     
    309310    { 
    310311    error("circular definition"); 
    311312    } 
     313    return nodefer(); 
    312314} 
    313315 
    314 void TypedefDeclaration::semantic2(Scope *sc) 
     316DeferStatus<void> TypedefDeclaration::semantic2(Scope *sc) 
    315317{ 
    316318    //printf("TypedefDeclaration::semantic2(%s) sem = %d\n", toChars(), sem); 
    317319    if (sem == 2) 
     
    328330        } 
    329331    } 
    330332    } 
     333    return nodefer(); 
    331334} 
    332335 
    333336const char *TypedefDeclaration::kind() 
     
    421424    return sa; 
    422425} 
    423426 
    424 void AliasDeclaration::semantic(Scope *sc) 
     427DeferStatus<void> AliasDeclaration::semantic(Scope *sc) 
    425428{ 
    426429    //printf("AliasDeclaration::semantic() %s\n", toChars()); 
    427430    if (aliassym) 
    428431    { 
    429432    if (aliassym->isTemplateInstance()) 
    430433        aliassym->semantic(sc); 
    431     return
     434    return nodefer()
    432435    } 
    433436    this->inSemantic = 1; 
    434437 
     
    488491    if (overnext) 
    489492    ScopeDsymbol::multiplyDefined(0, this, overnext); 
    490493    this->inSemantic = 0; 
    491     return
     494    return nodefer()
    492495 
    493496  L2: 
    494497    //printf("alias is a symbol %s %s\n", s->kind(), s->toChars()); 
     
    525528    } 
    526529    aliassym = s; 
    527530    this->inSemantic = 0; 
     531    return nodefer(); 
    528532} 
    529533 
    530534int AliasDeclaration::overloadInsert(Dsymbol *s) 
     
    680684    return sv; 
    681685} 
    682686 
    683 void VarDeclaration::semantic(Scope *sc) 
     687DeferStatus<void> VarDeclaration::semantic(Scope *sc) 
    684688{ 
    685689    //printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars()); 
    686690    //printf(" type = %s\n", type ? type->toChars() : "null"); 
     
    698702    int inferred = 0; 
    699703    if (!type) 
    700704    {   inuse++; 
    701     type = init->inferType(sc); 
     705    DeferStatus<Type*> res = init->inferType(sc); 
     706    if (res.defer()) { 
     707        inuse--; 
     708        return res; 
     709    } 
     710    type = res; 
    702711    inuse--; 
    703712    inferred = 1; 
    704713 
     
    711720    else 
    712721    {   if (!originalType) 
    713722        originalType = type; 
    714     type = type->semantic(loc, sc); 
     723    DeferStatus<Type*> ret = type->semantic(loc, sc); 
     724    if (ret.defer()) 
     725        return ret; 
     726    type = ret; 
    715727    } 
    716728    //printf(" semantic type = %s\n", type ? type->toChars() : "null"); 
    717729 
     
    793805    TupleDeclaration *v2 = new TupleDeclaration(loc, ident, exps); 
    794806    v2->isexp = 1; 
    795807    aliassym = v2; 
    796     return
     808    return nodefer()
    797809    } 
    798810 
    799811    if (storage_class & STCconst && !init && !fd) 
     
    828840        aad = parent->isAggregateDeclaration(); 
    829841    if (aad) 
    830842    { 
    831         aad->addField(sc, this); 
     843        DeferStatus<void> ret = aad->addField(sc, this); 
     844        if (ret.defer()) 
     845        return ret; 
    832846    } 
    833847 
    834848    InterfaceDeclaration *id = parent->isInterfaceDeclaration(); 
     
    894908        e = new AssignExp(loc, e1, e); 
    895909        e->type = e1->type; 
    896910        init = new ExpInitializer(loc, e/*->type->defaultInit()*/); 
    897         return
     911        return nodefer()
    898912    } 
    899913    else if (type->ty == Ttypedef) 
    900914    {   TypeTypedef *td = (TypeTypedef *)type; 
     
    956970            e = init->toExpression(); 
    957971            if (!e) 
    958972            {   error("is not a static and cannot have static initializer"); 
    959                 return
     973                return nodefer()
    960974            } 
    961975            } 
    962976            ei = new ExpInitializer(init->loc, e); 
     
    10251039        if (ei) 
    10261040        { 
    10271041            e = ei->exp->syntaxCopy(); 
    1028             e = e->semantic(sc); 
     1042            DeferStatus<Expression*> res = e->semantic(sc); 
     1043            if (res.defer()) { 
     1044            inuse--; 
     1045            global.gag--; 
     1046            return res; 
     1047            } 
     1048            e = res; 
    10291049            e = e->implicitCastTo(sc, type); 
    10301050        } 
    10311051        else if (si || ai) 
     
    10541074    } 
    10551075    sc = sc->pop(); 
    10561076    } 
     1077    return nodefer(); 
    10571078} 
    10581079 
    10591080ExpInitializer *VarDeclaration::getExpInitializer() 
     
    10731094    return ei; 
    10741095} 
    10751096 
    1076 void VarDeclaration::semantic2(Scope *sc) 
     1097DeferStatus<void> VarDeclaration::semantic2(Scope *sc) 
    10771098{ 
    10781099    //printf("VarDeclaration::semantic2('%s')\n", toChars()); 
    10791100    if (init && !toParent()->isFuncDeclaration()) 
     
    10891110    init = init->semantic(sc, type); 
    10901111    inuse--; 
    10911112    } 
     1113    return nodefer(); 
    10921114} 
    10931115 
    10941116const char *VarDeclaration::kind() 
     
    12491271    return NULL; 
    12501272} 
    12511273 
    1252 void ClassInfoDeclaration::semantic(Scope *sc) 
     1274DeferStatus<void> ClassInfoDeclaration::semantic(Scope *sc) 
    12531275{ 
     1276    return nodefer(); 
    12541277} 
    12551278 
    12561279/********************************* ModuleInfoDeclaration ****************************/ 
     
    12681291    return NULL; 
    12691292} 
    12701293 
    1271 void ModuleInfoDeclaration::semantic(Scope *sc) 
     1294DeferStatus<void> ModuleInfoDeclaration::semantic(Scope *sc) 
    12721295{ 
     1296    return nodefer(); 
    12731297} 
    12741298 
    12751299/********************************* TypeInfoDeclaration ****************************/ 
     
    12891313    return NULL; 
    12901314} 
    12911315 
    1292 void TypeInfoDeclaration::semantic(Scope *sc) 
     1316DeferStatus<void> TypeInfoDeclaration::semantic(Scope *sc) 
    12931317{ 
    12941318    assert(linkage == LINKc); 
     1319    return nodefer(); 
    12951320} 
    12961321 
    12971322/***************************** TypeInfoConstDeclaration **********************/ 
  • a/dmd/declaration.h

    old new  
    109109    int inuse;          // used to detect cycles 
    110110 
    111111    Declaration(Identifier *id); 
    112     void semantic(Scope *sc); 
     112    DeferStatus<void> semantic(Scope *sc); 
    113113    const char *kind(); 
    114114    unsigned size(Loc loc); 
    115115    void checkModify(Loc loc, Scope *sc, Type *t); 
     
    186186 
    187187    TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init); 
    188188    Dsymbol *syntaxCopy(Dsymbol *); 
    189     void semantic(Scope *sc); 
    190     void semantic2(Scope *sc); 
     189    DeferStatus<void> semantic(Scope *sc); 
     190    DeferStatus<void> semantic2(Scope *sc); 
    191191    char *mangle(); 
    192192    const char *kind(); 
    193193    Type *getType(); 
     
    230230    AliasDeclaration(Loc loc, Identifier *ident, Type *type); 
    231231    AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s); 
    232232    Dsymbol *syntaxCopy(Dsymbol *); 
    233     void semantic(Scope *sc); 
     233    DeferStatus<void> semantic(Scope *sc); 
    234234    int overloadInsert(Dsymbol *s); 
    235235    const char *kind(); 
    236236    Type *getType(); 
     
    265265 
    266266    VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init); 
    267267    Dsymbol *syntaxCopy(Dsymbol *); 
    268     void semantic(Scope *sc); 
    269     void semantic2(Scope *sc); 
     268    DeferStatus<void> semantic(Scope *sc); 
     269    DeferStatus<void> semantic2(Scope *sc); 
    270270    const char *kind(); 
    271271    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    272272#ifdef _DH 
     
    333333 
    334334    ClassInfoDeclaration(ClassDeclaration *cd); 
    335335    Dsymbol *syntaxCopy(Dsymbol *); 
    336     void semantic(Scope *sc); 
     336    DeferStatus<void> semantic(Scope *sc); 
    337337 
    338338    void emitComment(Scope *sc); 
    339339 
     
    350350 
    351351    ModuleInfoDeclaration(Module *mod); 
    352352    Dsymbol *syntaxCopy(Dsymbol *); 
    353     void semantic(Scope *sc); 
     353    DeferStatus<void> semantic(Scope *sc); 
    354354 
    355355    void emitComment(Scope *sc); 
    356356 
     
    365365 
    366366    TypeInfoDeclaration(Type *tinfo, int internal); 
    367367    Dsymbol *syntaxCopy(Dsymbol *); 
    368     void semantic(Scope *sc); 
     368    DeferStatus<void> semantic(Scope *sc); 
    369369 
    370370    void emitComment(Scope *sc); 
    371371 
     
    680680 
    681681    FuncDeclaration(Loc loc, Loc endloc, Identifier *id, enum STC storage_class, Type *type); 
    682682    Dsymbol *syntaxCopy(Dsymbol *); 
    683     void semantic(Scope *sc); 
    684     void semantic2(Scope *sc); 
    685     void semantic3(Scope *sc); 
     683    DeferStatus<void> semantic(Scope *sc); 
     684    DeferStatus<void> semantic2(Scope *sc); 
     685    DeferStatus<void> semantic3(Scope *sc); 
    686686    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    687687    void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    688688    int overrides(FuncDeclaration *fd); 
     
    794794 
    795795    CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); 
    796796    Dsymbol *syntaxCopy(Dsymbol *); 
    797     void semantic(Scope *sc); 
     797    DeferStatus<void> semantic(Scope *sc); 
    798798    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    799799    const char *kind(); 
    800800    char *toChars(); 
     
    812812    PostBlitDeclaration(Loc loc, Loc endloc); 
    813813    PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id); 
    814814    Dsymbol *syntaxCopy(Dsymbol *); 
    815     void semantic(Scope *sc); 
     815    DeferStatus<void> semantic(Scope *sc); 
    816816    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    817817    int isVirtual(); 
    818818    int addPreInvariant(); 
     
    829829    DtorDeclaration(Loc loc, Loc endloc); 
    830830    DtorDeclaration(Loc loc, Loc endloc, Identifier *id); 
    831831    Dsymbol *syntaxCopy(Dsymbol *); 
    832     void semantic(Scope *sc); 
     832    DeferStatus<void> semantic(Scope *sc); 
    833833    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    834834    int isVirtual(); 
    835835    int addPreInvariant(); 
     
    844844{ 
    845845    StaticCtorDeclaration(Loc loc, Loc endloc); 
    846846    Dsymbol *syntaxCopy(Dsymbol *); 
    847     void semantic(Scope *sc); 
     847    DeferStatus<void> semantic(Scope *sc); 
    848848    AggregateDeclaration *isThis(); 
    849849    int isStaticConstructor(); 
    850850    int isVirtual(); 
     
    861861 
    862862    StaticDtorDeclaration(Loc loc, Loc endloc); 
    863863    Dsymbol *syntaxCopy(Dsymbol *); 
    864     void semantic(Scope *sc); 
     864    DeferStatus<void> semantic(Scope *sc); 
    865865    AggregateDeclaration *isThis(); 
    866866    int isStaticDestructor(); 
    867867    int isVirtual(); 
     
    877877{ 
    878878    InvariantDeclaration(Loc loc, Loc endloc); 
    879879    Dsymbol *syntaxCopy(Dsymbol *); 
    880     void semantic(Scope *sc); 
     880    DeferStatus<void> semantic(Scope *sc); 
    881881    int isVirtual(); 
    882882    int addPreInvariant(); 
    883883    int addPostInvariant(); 
     
    892892{ 
    893893    UnitTestDeclaration(Loc loc, Loc endloc); 
    894894    Dsymbol *syntaxCopy(Dsymbol *); 
    895     void semantic(Scope *sc); 
     895    DeferStatus<void> semantic(Scope *sc); 
    896896    AggregateDeclaration *isThis(); 
    897897    int isVirtual(); 
    898898    int addPreInvariant(); 
     
    908908 
    909909    NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs); 
    910910    Dsymbol *syntaxCopy(Dsymbol *); 
    911     void semantic(Scope *sc); 
     911    DeferStatus<void> semantic(Scope *sc); 
    912912    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    913913    const char *kind(); 
    914914    int isVirtual(); 
     
    924924 
    925925    DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments); 
    926926    Dsymbol *syntaxCopy(Dsymbol *); 
    927     void semantic(Scope *sc); 
     927    DeferStatus<void> semantic(Scope *sc); 
    928928    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    929929    const char *kind(); 
    930930    int isDelete(); 
  • a/dmd/dsymbol.c

    old new  
    266266    return ident ? 0 : 1; 
    267267} 
    268268 
    269 void Dsymbol::semantic(Scope *sc) 
     269DeferStatus<void> Dsymbol::semantic(Scope *sc) 
    270270{ 
    271271    error("%p has no semantic routine", this); 
     272    return nodefer(); 
    272273} 
    273274 
    274 void Dsymbol::semantic2(Scope *sc) 
     275DeferStatus<void> Dsymbol::semantic2(Scope *sc) 
    275276{ 
    276277    // Most Dsymbols have no further semantic analysis needed 
     278    return nodefer(); 
    277279} 
    278280 
    279 void Dsymbol::semantic3(Scope *sc) 
     281DeferStatus<void> Dsymbol::semantic3(Scope *sc) 
    280282{ 
    281283    // Most Dsymbols have no further semantic analysis needed 
     284    return nodefer(); 
    282285} 
    283286 
    284287void Dsymbol::inlineScan() 
     
    296299 *  NULL if not found 
    297300 */ 
    298301 
    299 Dsymbol *Dsymbol::search(Loc loc, Identifier *ident, int flags) 
     302DeferStatus<Dsymbol*> Dsymbol::search(Loc loc, Identifier *ident, int flags) 
    300303{ 
    301304    //printf("Dsymbol::search(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); 
    302305    return NULL; 
     
    309312 *  symbol found, NULL if not 
    310313 */ 
    311314 
    312 Dsymbol *Dsymbol::searchX(Loc loc, Scope *sc, Identifier *id) 
     315DeferStatus<Dsymbol*> Dsymbol::searchX(Loc loc, Scope *sc, Identifier *id) 
    313316{ 
    314317    //printf("Dsymbol::searchX(this=%p,%s, ident='%s')\n", this, toChars(), ident->toChars()); 
    315318    Dsymbol *s = toAlias(); 
     
    318321    switch (id->dyncast()) 
    319322    { 
    320323    case DYNCAST_IDENTIFIER: 
    321         sm = s->search(loc, id, 0); 
    322         break; 
     324        return s->search(loc, id, 0); 
    323325 
    324326    case DYNCAST_DSYMBOL: 
    325327    {   // It's a template instance 
     
    654656    symtab = NULL; 
    655657    imports = NULL; 
    656658    prots = NULL; 
     659    member_semantic_started = false; 
    657660} 
    658661 
    659662ScopeDsymbol::ScopeDsymbol(Identifier *id) 
     
    663666    symtab = NULL; 
    664667    imports = NULL; 
    665668    prots = NULL; 
     669    member_semantic_started = false; 
    666670} 
    667671 
    668672Dsymbol *ScopeDsymbol::syntaxCopy(Dsymbol *s) 
     
    678682    return sd; 
    679683} 
    680684 
    681 Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags) 
     685DeferStatus<Dsymbol*> ScopeDsymbol::search(Loc loc, Identifier *ident, int flags) 
    682686{ 
    683687    //printf("%s->ScopeDsymbol::search(ident='%s', flags=x%x)\n", toChars(), ident->toChars(), flags); 
    684688 
     
    779783        } 
    780784        } 
    781785    } 
    782     imports->push(s); 
    783     prots = (unsigned char *)mem.realloc(prots, imports->dim * sizeof(prots[0])); 
    784     prots[imports->dim - 1] = protection; 
     786    bool in_imports = false; 
     787    for (int i = 0; i < imports->dim; ++i) 
     788        if (imports->data[i] == s) 
     789        in_imports = true; 
     790    if (!in_imports) 
     791    { 
     792        imports->push(s); 
     793        prots = (unsigned char *)mem.realloc(prots, imports->dim * sizeof(prots[0])); 
     794        prots[imports->dim - 1] = protection; 
     795    } 
    785796    } 
    786797} 
    787798 
     
    849860    return "ScopeDsymbol"; 
    850861} 
    851862 
     863// shares code with AttribDeclaration::callSemanticOnMembers 
     864DeferStatus<void> ScopeDsymbol::callSemanticOnMembers(Scope* sc) 
     865{ 
     866    // first add everything to remaining_semantic 
     867    if (!member_semantic_started) { 
     868    for (int i = 0; i < members->dim; i++) 
     869        remaining_semantic.push_back( (Dsymbol*)members->data[i] ); 
     870    member_semantic_started = true; 
     871    } 
     872 
     873    int failed = 0; 
     874 
     875    // last defer exception that was caught. stored for the error message inside 
     876    DeferStatus<void> lastdefer; 
     877 
     878    // if we deferred an order dependent member, save it here 
     879    // we will then skip all order dependent members until this is reached again 
     880    Dsymbol *deferredOrderDependent = NULL; 
     881 
     882    while (!remaining_semantic.empty() && failed != remaining_semantic.size()) 
     883    {   Dsymbol *s; 
     884    s = remaining_semantic[0]; 
     885    remaining_semantic.pop_front(); 
     886 
     887    // if we deferred something order dependent, skip other 
     888    // order dependent ones for one iteration 
     889    if (deferredOrderDependent == s) 
     890        deferredOrderDependent = NULL; 
     891    if (deferredOrderDependent && !isMemberReorderable(s)) { 
     892        ++failed; 
     893        remaining_semantic.push_back(s); 
     894        continue; 
     895    } 
     896 
     897    DeferStatus<void> res = s->semantic(sc); 
     898    if (res.defer()) { 
     899        lastdefer = res; 
     900        ++failed; 
     901        remaining_semantic.push_back(s); 
     902        if (!isMemberReorderable(s)) 
     903        deferredOrderDependent = s; 
     904        continue; 
     905    } 
     906 
     907    failed = 0; 
     908    postMemberSemantic(sc); 
     909    } 
     910 
     911    if (!remaining_semantic.empty()) 
     912    { 
     913    assert(lastdefer.defer()); 
     914 
     915    // reorder members into a valid state if necessary 
     916    if (deferredOrderDependent) 
     917        while (remaining_semantic[0] != deferredOrderDependent) { 
     918        Dsymbol* s = remaining_semantic[0]; 
     919        remaining_semantic.pop_front(); 
     920        remaining_semantic.push_back(s); 
     921        } 
     922    return lastdefer; 
     923    } 
     924     
     925    lastdefer.handled = true; 
     926    return nodefer(); 
     927} 
     928 
    852929 
    853930/******************************************* 
    854931 * Look for member of the form: 
     
    895972    this->withstate = withstate; 
    896973} 
    897974 
    898 Dsymbol *WithScopeSymbol::search(Loc loc, Identifier *ident, int flags) 
     975DeferStatus<Dsymbol*> WithScopeSymbol::search(Loc loc, Identifier *ident, int flags) 
    899976{ 
    900977    // Acts as proxy to the with class declaration 
    901978    return withstate->exp->type->toDsymbol(NULL)->search(loc, ident, 0); 
     
    9281005    td = s; 
    9291006} 
    9301007 
    931 Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags) 
     1008DeferStatus<Dsymbol*> ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags) 
    9321009{ 
    9331010    //printf("ArrayScopeSymbol::search('%s', flags = %d)\n", ident->toChars(), flags); 
    9341011    if (ident == Id::length || ident == Id::dollar) 
     
    10161093    return NULL; 
    10171094} 
    10181095 
    1019  
    10201096/****************************** DsymbolTable ******************************/ 
    10211097 
    10221098DsymbolTable::DsymbolTable() 
  • a/dmd/dsymbol.h

    old new  
    2020 
    2121#include "mars.h" 
    2222#include "arraytypes.h" 
     23#include <deque> 
    2324 
    2425// llvm 
    2526#include "../ir/irdsymbol.h" 
     
    139140    virtual const char *kind(); 
    140141    virtual Dsymbol *toAlias();         // resolve real symbol 
    141142    virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum); 
    142     virtual void semantic(Scope *sc); 
    143     virtual void semantic2(Scope *sc); 
    144     virtual void semantic3(Scope *sc); 
     143    virtual DeferStatus<void> semantic(Scope *sc); 
     144    virtual DeferStatus<void> semantic2(Scope *sc); 
     145    virtual DeferStatus<void> semantic3(Scope *sc); 
    145146    virtual void inlineScan(); 
    146     virtual Dsymbol *search(Loc loc, Identifier *ident, int flags); 
    147     Dsymbol *searchX(Loc loc, Scope *sc, Identifier *id); 
     147    virtual DeferStatus<Dsymbol*> search(Loc loc, Identifier *ident, int flags); 
     148    DeferStatus<Dsymbol*> searchX(Loc loc, Scope *sc, Identifier *id); 
    148149    virtual int overloadInsert(Dsymbol *s); 
    149150#ifdef _DH 
    150151    char *toHChars(); 
     
    255256    ScopeDsymbol(); 
    256257    ScopeDsymbol(Identifier *id); 
    257258    Dsymbol *syntaxCopy(Dsymbol *s); 
    258     Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     259    DeferStatus<Dsymbol*> search(Loc loc, Identifier *ident, int flags); 
    259260    void importScope(ScopeDsymbol *s, enum PROT protection); 
    260261    int isforwardRef(); 
    261262    void defineRef(Dsymbol *s); 
     
    266267    void emitMemberComments(Scope *sc); 
    267268 
    268269    ScopeDsymbol *isScopeDsymbol() { return this; } 
     270 
     271    // LDC 
     272    std::deque<Dsymbol*> remaining_semantic; // Dsymbols where semantic remains to be called 
     273    bool member_semantic_started; 
     274    DeferStatus<void> callSemanticOnMembers(Scope* sc); 
     275    virtual void postMemberSemantic(Scope* sc) {} 
     276    virtual bool isMemberReorderable(Dsymbol* sym) { return true; } 
    269277}; 
    270278 
    271279// With statement scope 
     
    275283    WithStatement *withstate; 
    276284 
    277285    WithScopeSymbol(WithStatement *withstate); 
    278     Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     286    DeferStatus<Dsymbol*> search(Loc loc, Identifier *ident, int flags); 
    279287 
    280288    WithScopeSymbol *isWithScopeSymbol() { return this; } 
    281289}; 
     
    291299    ArrayScopeSymbol(Expression *e); 
    292300    ArrayScopeSymbol(TypeTuple *t); 
    293301    ArrayScopeSymbol(TupleDeclaration *td); 
    294     Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     302    DeferStatus<Dsymbol*> search(Loc loc, Identifier *ident, int flags); 
    295303 
    296304    ArrayScopeSymbol *isArrayScopeSymbol() { return this; } 
    297305}; 
  • a/dmd/enum.c

    old new  
    2424    this->loc = loc; 
    2525    type = new TypeEnum(this); 
    2626    this->memtype = memtype; 
     27    if (!this->memtype) 
     28    this->memtype = Type::tint32; 
    2729    maxval = 0; 
    2830    minval = 0; 
    2931    defaultval = 0; 
     
    5052    return ed; 
    5153} 
    5254 
    53 void EnumDeclaration::semantic(Scope *sc) 
     55DeferStatus<void> EnumDeclaration::semantic(Scope *sc) 
    5456{   int i; 
    5557    uinteger_t number; 
    5658    Type *t; 
     
    5860 
    5961    //printf("EnumDeclaration::semantic(sd = %p, '%s')\n", sc->scopesym, sc->scopesym->toChars()); 
    6062    if (symtab)         // if already done 
    61     return; 
    62     if (!memtype) 
    63     memtype = Type::tint32; 
     63    return nodefer(); 
    6464    if (sc->stc & STCdeprecated) 
    6565    isdeprecated = 1; 
    6666 
     
    8989    sce->parent = this; 
    9090    number = 0; 
    9191    if (!members)       // enum ident; 
    92     return
     92    return nodefer()
    9393    if (members->dim == 0) 
    9494    error("enum %s must have at least one member", toChars()); 
    9595    int first = 1; 
     
    222222 
    223223    sce->pop(); 
    224224    //members->print(); 
     225    return nodefer(); 
    225226} 
    226227 
    227228int EnumDeclaration::oneMember(Dsymbol **ps) 
  • a/dmd/enum.h

    old new  
    4646 
    4747    EnumDeclaration(Loc loc, Identifier *id, Type *memtype); 
    4848    Dsymbol *syntaxCopy(Dsymbol *s); 
    49     void semantic(Scope *sc); 
     49    DeferStatus<void> semantic(Scope *sc); 
    5050    int oneMember(Dsymbol **ps); 
    5151    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    5252    Type *getType(); 
  • a/dmd/expression.c

    old new  
    342342 * Pull out any properties. 
    343343 */ 
    344344 
    345 Expression *resolveProperties(Scope *sc, Expression *e) 
     345DeferStatus<Expression*> resolveProperties(Scope *sc, Expression *e) 
    346346{ 
    347347    //printf("resolveProperties(%s)\n", e->toChars()); 
    348348    if (e->type) 
    349349    { 
    350     Type *t = e->type->toBasetype(); 
     350    DeferStatus<Type*> t = e->type->toBasetype(); 
     351    if (t.defer()) return t; 
    351352 
    352353    if (t->ty == Tfunction /*|| e->op == TOKoverloadset*/) 
    353354    { 
     
    914915 * Determine types, fold constants, etc. 
    915916 */ 
    916917 
    917 Expression *Expression::semantic(Scope *sc) 
     918DeferStatus<Expression*> Expression::semantic(Scope *sc) 
    918919{ 
    919920#if LOGSEMANTIC 
    920921    printf("Expression::semantic() %s\n", toChars()); 
     
    14071408    return result ? value != 0 : value == 0; 
    14081409} 
    14091410 
    1410 Expression *IntegerExp::semantic(Scope *sc) 
     1411DeferStatus<Expression*> IntegerExp::semantic(Scope *sc) 
    14111412{ 
    14121413    if (!type) 
    14131414    { 
     
    16681669    return 0; 
    16691670} 
    16701671 
    1671 Expression *RealExp::semantic(Scope *sc) 
     1672DeferStatus<Expression*> RealExp::semantic(Scope *sc) 
    16721673{ 
    16731674    if (!type) 
    16741675    type = Type::tfloat64; 
     
    18701871    return 0; 
    18711872} 
    18721873 
    1873 Expression *ComplexExp::semantic(Scope *sc) 
     1874DeferStatus<Expression*> ComplexExp::semantic(Scope *sc) 
    18741875{ 
    18751876    if (!type) 
    18761877    type = Type::tcomplex80; 
     
    19251926    this->ident = ident; 
    19261927} 
    19271928 
    1928 Expression *IdentifierExp::semantic(Scope *sc) 
     1929DeferStatus<Expression*> IdentifierExp::semantic(Scope *sc) 
    19291930{ 
    19301931    Dsymbol *s; 
    19311932    Dsymbol *scopesym; 
     
    20432044    this->s = s; 
    20442045} 
    20452046 
    2046 Expression *DsymbolExp::semantic(Scope *sc) 
     2047DeferStatus<Expression*> DsymbolExp::semantic(Scope *sc) 
    20472048{ 
    20482049#if LOGSEMANTIC 
    20492050    printf("DsymbolExp::semantic('%s')\n", s->toChars()); 
     
    22702271    var = NULL; 
    22712272} 
    22722273 
    2273 Expression *ThisExp::semantic(Scope *sc) 
     2274DeferStatus<Expression*> ThisExp::semantic(Scope *sc) 
    22742275{   FuncDeclaration *fd; 
    22752276    FuncDeclaration *fdthis; 
    22762277    int nested = 0; 
     
    23722373    op = TOKsuper; 
    23732374} 
    23742375 
    2375 Expression *SuperExp::semantic(Scope *sc) 
     2376DeferStatus<Expression*> SuperExp::semantic(Scope *sc) 
    23762377{   FuncDeclaration *fd; 
    23772378    FuncDeclaration *fdthis; 
    23782379    ClassDeclaration *cd; 
     
    24742475    committed = 0; 
    24752476} 
    24762477 
    2477 Expression *NullExp::semantic(Scope *sc) 
     2478DeferStatus<Expression*> NullExp::semantic(Scope *sc) 
    24782479{ 
    24792480#if LOGSEMANTIC 
    24802481    printf("NullExp::semantic('%s')\n", toChars()); 
     
    25682569    return p; 
    25692570} 
    25702571 
    2571 Expression *StringExp::semantic(Scope *sc) 
     2572DeferStatus<Expression*> StringExp::semantic(Scope *sc) 
    25722573{ 
    25732574#if LOGSEMANTIC 
    25742575    printf("StringExp::semantic() %s\n", toChars()); 
     
    28452846    return new ArrayLiteralExp(loc, arraySyntaxCopy(elements)); 
    28462847} 
    28472848 
    2848 Expression *ArrayLiteralExp::semantic(Scope *sc) 
     2849DeferStatus<Expression*> ArrayLiteralExp::semantic(Scope *sc) 
    28492850{   Expression *e; 
    28502851    Type *t0 = NULL; 
    28512852 
     
    29602961    arraySyntaxCopy(keys), arraySyntaxCopy(values)); 
    29612962} 
    29622963 
    2963 Expression *AssocArrayLiteralExp::semantic(Scope *sc) 
     2964DeferStatus<Expression*> AssocArrayLiteralExp::semantic(Scope *sc) 
    29642965{   Expression *e; 
    29652966    Type *tkey = NULL; 
    29662967    Type *tvalue = NULL; 
     
    30993100    return new StructLiteralExp(loc, sd, arraySyntaxCopy(elements)); 
    31003101} 
    31013102 
    3102 Expression *StructLiteralExp::semantic(Scope *sc) 
     3103DeferStatus<Expression*> StructLiteralExp::semantic(Scope *sc) 
    31033104{   Expression *e; 
    31043105 
    31053106#if LOGSEMANTIC 
     
    33263327    return new TypeExp(loc, type->syntaxCopy()); 
    33273328} 
    33283329 
    3329 Expression *TypeExp::semantic(Scope *sc) 
     3330DeferStatus<Expression*> TypeExp::semantic(Scope *sc) 
    33303331{ 
    33313332    //printf("TypeExp::semantic(%s)\n", type->toChars()); 
    33323333    type = type->semantic(loc, sc); 
     
    33563357    return se; 
    33573358} 
    33583359 
    3359 Expression *ScopeExp::semantic(Scope *sc) 
     3360DeferStatus<Expression*> ScopeExp::semantic(Scope *sc) 
    33603361{ 
    33613362    TemplateInstance *ti; 
    33623363    ScopeDsymbol *sds2; 
     
    33693370    if (ti && !global.errors) 
    33703371    {   Dsymbol *s; 
    33713372    if (!ti->semanticdone) 
    3372         ti->semantic(sc); 
     3373    { 
     3374        DeferStatus<void> ret = ti->semantic(sc); 
     3375        if (ret.defer()) 
     3376        return ret; 
     3377    } 
    33733378    s = ti->inst->toAlias(); 
    33743379    sds2 = s->isScopeDsymbol(); 
    33753380    if (!sds2) 
     
    34673472} 
    34683473 
    34693474 
    3470 Expression *NewExp::semantic(Scope *sc) 
     3475DeferStatus<Expression*> NewExp::semantic(Scope *sc) 
    34713476{   int i; 
    34723477    Type *tb; 
    34733478    ClassDeclaration *cdthis = NULL; 
     
    37813786} 
    37823787 
    37833788 
    3784 Expression *NewAnonClassExp::semantic(Scope *sc) 
     3789DeferStatus<Expression*> NewAnonClassExp::semantic(Scope *sc) 
    37853790{ 
    37863791#if LOGSEMANTIC 
    37873792    printf("NewAnonClassExp::semantic() %s\n", toChars()); 
     
    38643869    error("need 'this' for address of %s", v->toChars()); 
    38653870} 
    38663871 
    3867 Expression *SymOffExp::semantic(Scope *sc) 
     3872DeferStatus<Expression*> SymOffExp::semantic(Scope *sc) 
    38683873{ 
    38693874#if LOGSEMANTIC 
    38703875    printf("SymOffExp::semantic('%s')\n", toChars()); 
     
    39233928    return 0; 
    39243929} 
    39253930 
    3926 Expression *VarExp::semantic(Scope *sc) 
     3931DeferStatus<Expression*> VarExp::semantic(Scope *sc) 
    39273932{   FuncLiteralDeclaration *fd; 
    39283933 
    39293934#if LOGSEMANTIC 
     
    41774182    return new TupleExp(loc, arraySyntaxCopy(exps)); 
    41784183} 
    41794184 
    4180 Expression *TupleExp::semantic(Scope *sc) 
     4185DeferStatus<Expression*> TupleExp::semantic(Scope *sc) 
    41814186{ 
    41824187#if LOGSEMANTIC 
    41834188    printf("+TupleExp::semantic(%s)\n", toChars()); 
     
    42554260    return new FuncExp(loc, (FuncLiteralDeclaration *)fd->syntaxCopy(NULL)); 
    42564261} 
    42574262 
    4258 Expression *FuncExp::semantic(Scope *sc) 
     4263DeferStatus<Expression*> FuncExp::semantic(Scope *sc) 
    42594264{ 
    42604265#if LOGSEMANTIC 
    42614266    printf("FuncExp::semantic(%s)\n", toChars()); 
     
    43204325    return new DeclarationExp(loc, declaration->syntaxCopy(NULL)); 
    43214326} 
    43224327 
    4323 Expression *DeclarationExp::semantic(Scope *sc) 
     4328DeferStatus<Expression*> DeclarationExp::semantic(Scope *sc) 
    43244329{ 
    43254330    if (type) 
    43264331    return this; 
     
    44414446} 
    44424447 
    44434448 
    4444 Expression *TypeidExp::semantic(Scope *sc) 
     4449DeferStatus<Expression*> TypeidExp::semantic(Scope *sc) 
    44454450{   Expression *e; 
    44464451 
    44474452#if LOGSEMANTIC 
     
    45054510{ 
    45064511} 
    45074512 
    4508 Expression *HaltExp::semantic(Scope *sc) 
     4513DeferStatus<Expression*> HaltExp::semantic(Scope *sc) 
    45094514{ 
    45104515#if LOGSEMANTIC 
    45114516    printf("HaltExp::semantic()\n"); 
     
    45474552    tok2); 
    45484553} 
    45494554 
    4550 Expression *IsExp::semantic(Scope *sc) 
     4555DeferStatus<Expression*> IsExp::semantic(Scope *sc) 
    45514556{   Type *tded; 
    45524557 
    45534558    /* is(targ id tok tspec) 
     
    48154820    return e; 
    48164821} 
    48174822 
    4818 Expression *UnaExp::semantic(Scope *sc) 
     4823DeferStatus<Expression*> UnaExp::semantic(Scope *sc) 
    48194824{ 
    48204825#if LOGSEMANTIC 
    48214826    printf("UnaExp::semantic('%s')\n", toChars()); 
    48224827#endif 
    4823     e1 = e1->semantic(sc); 
     4828    DeferStatus<Expression*> ret = e1->semantic(sc); 
     4829    if (ret.defer()) 
     4830    return ret; 
     4831    e1 = ret; 
    48244832//    if (!e1->type) 
    48254833//  error("%s has no value", e1->toChars()); 
    48264834    return this; 
     
    48584866    return e; 
    48594867} 
    48604868 
    4861 Expression *BinExp::semantic(Scope *sc) 
     4869DeferStatus<Expression*> BinExp::semantic(Scope *sc) 
    48624870{ 
    48634871#if LOGSEMANTIC 
    48644872    printf("BinExp::semantic('%s')\n", toChars()); 
    48654873#endif 
    4866     e1 = e1->semantic(sc); 
     4874    DeferStatus<Expression*> ret = e1->semantic(sc); 
     4875    if (ret.defer()) return ret; 
     4876    e1 = ret; 
    48674877    if (!e1->type && 
    48684878    !(op == TOKassign && e1->op == TOKdottd))   // a.template = e2 
    48694879    { 
     
    48794889    return this; 
    48804890} 
    48814891 
    4882 Expression *BinExp::semanticp(Scope *sc) 
    4883 
    4884     BinExp::semantic(sc); 
     4892DeferStatus<Expression*> BinExp::semanticp(Scope *sc) 
     4893
     4894    DeferStatus<Expression*> ret = BinExp::semantic(sc); 
     4895    if (ret.defer()) return ret; 
    48854896    e1 = resolveProperties(sc, e1); 
    48864897    e2 = resolveProperties(sc, e2); 
    48874898    return this; 
     
    50235034{ 
    50245035} 
    50255036 
    5026 Expression *CompileExp::semantic(Scope *sc) 
     5037DeferStatus<Expression*> CompileExp::semantic(Scope *sc) 
    50275038{ 
    50285039#if LOGSEMANTIC 
    50295040    printf("CompileExp::semantic('%s')\n", toChars()); 
     
    50625073{ 
    50635074} 
    50645075 
    5065 Expression *FileExp::semantic(Scope *sc) 
     5076DeferStatus<Expression*> FileExp::semantic(Scope *sc) 
    50665077{   char *name; 
    50675078    StringExp *se; 
    50685079 
     
    51405151    return ae; 
    51415152} 
    51425153 
    5143 Expression *AssertExp::semantic(Scope *sc) 
     5154DeferStatus<Expression*> AssertExp::semantic(Scope *sc) 
    51445155{ 
    51455156#if LOGSEMANTIC 
    51465157    printf("AssertExp::semantic('%s')\n", toChars()); 
     
    52045215    this->ident = ident; 
    52055216} 
    52065217 
    5207 Expression *DotIdExp::semantic(Scope *sc) 
     5218DeferStatus<Expression*> DotIdExp::semantic(Scope *sc) 
    52085219{   Expression *e; 
    52095220    Expression *eleft; 
    52105221    Expression *eright; 
     
    52695280    } 
    52705281    } 
    52715282 
    5272     UnaExp::semantic(sc); 
     5283    DeferStatus<Expression*> ret = UnaExp::semantic(sc); 
     5284    if (ret.defer()) 
     5285    return ret; 
    52735286 
    52745287    if (e1->op == TOKdotexp) 
    52755288    { 
     
    52795292    } 
    52805293    else 
    52815294    { 
    5282     e1 = resolveProperties(sc, e1); 
     5295    DeferStatus<Expression*> ret2 = resolveProperties(sc, e1); 
     5296    if (ret2.defer()) return ret2; 
     5297    e1 = ret2; 
    52835298    eleft = NULL; 
    52845299    eright = e1; 
    52855300    } 
     
    55125527#endif 
    55135528    else 
    55145529    { 
    5515     e = e1->type->dotExp(sc, e1, ident); 
    5516     e = e->semantic(sc); 
    5517     return e; 
     5530    DeferStatus<Expression*> ret = e1->type->dotExp(sc, e1, ident); 
     5531    if (ret.defer()) return ret; 
     5532    ret = ret->semantic(sc); 
     5533    if (ret.defer()) return ret; 
     5534    return ret; 
    55185535    } 
    55195536} 
    55205537 
     
    55545571    this->var = v; 
    55555572} 
    55565573 
    5557 Expression *DotVarExp::semantic(Scope *sc) 
     5574DeferStatus<Expression*> DotVarExp::semantic(Scope *sc) 
    55585575{ 
    55595576#if LOGSEMANTIC 
    55605577    printf("DotVarExp::semantic('%s')\n", toChars()); 
     
    57305747    return de; 
    57315748} 
    57325749 
    5733 Expression *DotTemplateInstanceExp::semantic(Scope *sc) 
     5750DeferStatus<Expression*> DotTemplateInstanceExp::semantic(Scope *sc) 
    57345751{   Dsymbol *s; 
    57355752    Dsymbol *s2; 
    57365753    TemplateDeclaration *td; 
     
    58655882    m = NULL; 
    58665883} 
    58675884 
    5868 Expression *DelegateExp::semantic(Scope *sc) 
     5885DeferStatus<Expression*> DelegateExp::semantic(Scope *sc) 
    58695886{ 
    58705887#if LOGSEMANTIC 
    58715888    printf("DelegateExp::semantic('%s')\n", toChars()); 
     
    59045921    this->type = s->getType(); 
    59055922} 
    59065923 
    5907 Expression *DotTypeExp::semantic(Scope *sc) 
     5924DeferStatus<Expression*> DotTypeExp::semantic(Scope *sc) 
    59085925{ 
    59095926#if LOGSEMANTIC 
    59105927    printf("DotTypeExp::semantic('%s')\n", toChars()); 
     
    59615978} 
    59625979 
    59635980 
    5964 Expression *CallExp::semantic(Scope *sc) 
     5981DeferStatus<Expression*> CallExp::semantic(Scope *sc) 
    59655982{ 
    59665983    TypeFunction *tf; 
    59675984    FuncDeclaration *f; 
     
    65906607    m = NULL; 
    65916608} 
    65926609 
    6593 Expression *AddrExp::semantic(Scope *sc) 
     6610DeferStatus<Expression*> AddrExp::semantic(Scope *sc) 
    65946611{ 
    65956612#if LOGSEMANTIC 
    65966613    printf("AddrExp::semantic('%s')\n", toChars()); 
     
    66666683    type = t; 
    66676684} 
    66686685 
    6669 Expression *PtrExp::semantic(Scope *sc) 
     6686DeferStatus<Expression*> PtrExp::semantic(Scope *sc) 
    66706687{   Type *tb; 
    66716688 
    66726689#if LOGSEMANTIC 
     
    67546771{ 
    67556772} 
    67566773 
    6757 Expression *NegExp::semantic(Scope *sc) 
     6774DeferStatus<Expression*> NegExp::semantic(Scope *sc) 
    67586775{   Expression *e; 
    67596776 
    67606777#if LOGSEMANTIC 
     
    67836800{ 
    67846801} 
    67856802 
    6786 Expression *UAddExp::semantic(Scope *sc) 
     6803DeferStatus<Expression*> UAddExp::semantic(Scope *sc) 
    67876804{   Expression *e; 
    67886805 
    67896806#if LOGSEMANTIC 
     
    68076824{ 
    68086825} 
    68096826 
    6810 Expression *ComExp::semantic(Scope *sc) 
     6827DeferStatus<Expression*> ComExp::semantic(Scope *sc) 
    68116828{   Expression *e; 
    68126829 
    68136830    if (!type) 
     
    68336850{ 
    68346851} 
    68356852 
    6836 Expression *NotExp::semantic(Scope *sc) 
     6853DeferStatus<Expression*> NotExp::semantic(Scope *sc) 
    68376854{ 
    68386855    UnaExp::semantic(sc); 
    68396856    e1 = resolveProperties(sc, e1); 
     
    68576874    type = t; 
    68586875} 
    68596876 
    6860 Expression *BoolExp::semantic(Scope *sc) 
     6877DeferStatus<Expression*> BoolExp::semantic(Scope *sc) 
    68616878{ 
    68626879    UnaExp::semantic(sc); 
    68636880    e1 = resolveProperties(sc, e1); 
     
    68786895{ 
    68796896} 
    68806897 
    6881 Expression *DeleteExp::semantic(Scope *sc) 
     6898DeferStatus<Expression*> DeleteExp::semantic(Scope *sc) 
    68826899{ 
    68836900    Type *tb; 
    68846901 
     
    69907007} 
    69917008 
    69927009 
    6993 Expression *CastExp::semantic(Scope *sc) 
     7010DeferStatus<Expression*> CastExp::semantic(Scope *sc) 
    69947011{   Expression *e; 
    69957012    BinExp *b; 
    69967013    UnaExp *u; 
     
    71257142    return new SliceExp(loc, e1->syntaxCopy(), lwr, upr); 
    71267143} 
    71277144 
    7128 Expression *SliceExp::semantic(Scope *sc) 
     7145DeferStatus<Expression*> SliceExp::semantic(Scope *sc) 
    71297146{   Expression *e; 
    71307147    AggregateDeclaration *ad; 
    71317148    //FuncDeclaration *fd; 
     
    73377354{ 
    73387355} 
    73397356 
    7340 Expression *ArrayLengthExp::semantic(Scope *sc) 
     7357DeferStatus<Expression*> ArrayLengthExp::semantic(Scope *sc) 
    73417358{   Expression *e; 
    73427359 
    73437360#if LOGSEMANTIC 
     
    73747391    return new ArrayExp(loc, e1->syntaxCopy(), arraySyntaxCopy(arguments)); 
    73757392} 
    73767393 
    7377 Expression *ArrayExp::semantic(Scope *sc) 
     7394DeferStatus<Expression*> ArrayExp::semantic(Scope *sc) 
    73787395{   Expression *e; 
    73797396    Type *t1; 
    73807397 
     
    74477464{ 
    74487465} 
    74497466 
    7450 Expression *DotExp::semantic(Scope *sc) 
     7467DeferStatus<Expression*> DotExp::semantic(Scope *sc) 
    74517468{ 
    74527469#if LOGSEMANTIC 
    74537470    printf("DotExp::semantic('%s')\n", toChars()); 
     
    74787495{ 
    74797496} 
    74807497 
    7481 Expression *CommaExp::semantic(Scope *sc) 
     7498DeferStatus<Expression*> CommaExp::semantic(Scope *sc) 
    74827499{ 
    74837500    if (!type) 
    74847501    {   BinExp::semanticp(sc); 
     
    75397556    modifiable = 0; // assume it is an rvalue 
    75407557} 
    75417558 
    7542 Expression *IndexExp::semantic(Scope *sc) 
     7559DeferStatus<Expression*> IndexExp::semantic(Scope *sc) 
    75437560{   Expression *e; 
    75447561    BinExp *b; 
    75457562    UnaExp *u; 
     
    77077724{ 
    77087725} 
    77097726 
    7710 Expression *PostExp::semantic(Scope *sc) 
     7727DeferStatus<Expression*> PostExp::semantic(Scope *sc) 
    77117728{   Expression *e = this; 
    77127729 
    77137730    if (!type) 
     
    77487765    ismemset = 0; 
    77497766} 
    77507767 
    7751 Expression *AssignExp::semantic(Scope *sc) 
     7768DeferStatus<Expression*> AssignExp::semantic(Scope *sc) 
    77527769{   Type *t1; 
    77537770    Expression *e1old = e1; 
    77547771 
     
    79777994{ 
    79787995} 
    79797996 
    7980 Expression *AddAssignExp::semantic(Scope *sc) 
     7997DeferStatus<Expression*> AddAssignExp::semantic(Scope *sc) 
    79817998{   Expression *e; 
    79827999 
    79838000    if (type) 
     
    80858102{ 
    80868103} 
    80878104 
    8088 Expression *MinAssignExp::semantic(Scope *sc) 
     8105DeferStatus<Expression*> MinAssignExp::semantic(Scope *sc) 
    80898106{   Expression *e; 
    80908107 
    80918108    if (type) 
     
    81368153{ 
    81378154} 
    81388155 
    8139 Expression *CatAssignExp::semantic(Scope *sc) 
     8156DeferStatus<Expression*> CatAssignExp::semantic(Scope *sc) 
    81408157{   Expression *e; 
    81418158 
    81428159    BinExp::semantic(sc); 
     
    81948211{ 
    81958212} 
    81968213 
    8197 Expression *MulAssignExp::semantic(Scope *sc) 
     8214DeferStatus<Expression*> MulAssignExp::semantic(Scope *sc) 
    81988215{   Expression *e; 
    81998216 
    82008217    BinExp::semantic(sc); 
     
    82608277{ 
    82618278} 
    82628279 
    8263 Expression *DivAssignExp::semantic(Scope *sc) 
     8280DeferStatus<Expression*> DivAssignExp::semantic(Scope *sc) 
    82648281{   Expression *e; 
    82658282 
    82668283    BinExp::semantic(sc); 
     
    83298346{ 
    83308347} 
    83318348 
    8332 Expression *ModAssignExp::semantic(Scope *sc) 
     8349DeferStatus<Expression*> ModAssignExp::semantic(Scope *sc) 
    83338350{ 
    83348351    return commonSemanticAssign(sc); 
    83358352} 
     
    83418358{ 
    83428359} 
    83438360 
    8344 Expression *ShlAssignExp::semantic(Scope *sc) 
     8361DeferStatus<Expression*> ShlAssignExp::semantic(Scope *sc) 
    83458362{   Expression *e; 
    83468363 
    83478364    //printf("ShlAssignExp::semantic()\n"); 
     
    83718388{ 
    83728389} 
    83738390 
    8374 Expression *ShrAssignExp::semantic(Scope *sc) 
     8391DeferStatus<Expression*> ShrAssignExp::semantic(Scope *sc) 
    83758392{   Expression *e; 
    83768393 
    83778394    BinExp::semantic(sc); 
     
    84008417{ 
    84018418} 
    84028419 
    8403 Expression *UshrAssignExp::semantic(Scope *sc) 
     8420DeferStatus<Expression*> UshrAssignExp::semantic(Scope *sc) 
    84048421{   Expression *e; 
    84058422 
    84068423    BinExp::semantic(sc); 
     
    84298446{ 
    84308447} 
    84318448 
    8432 Expression *AndAssignExp::semantic(Scope *sc) 
     8449DeferStatus<Expression*> AndAssignExp::semantic(Scope *sc) 
    84338450{ 
    84348451    return commonSemanticAssignIntegral(sc); 
    84358452} 
     
    84418458{ 
    84428459} 
    84438460 
    8444 Expression *OrAssignExp::semantic(Scope *sc) 
     8461DeferStatus<Expression*> OrAssignExp::semantic(Scope *sc) 
    84458462{ 
    84468463    return commonSemanticAssignIntegral(sc); 
    84478464} 
     
    84538470{ 
    84548471} 
    84558472 
    8456 Expression *XorAssignExp::semantic(Scope *sc) 
     8473DeferStatus<Expression*> XorAssignExp::semantic(Scope *sc) 
    84578474{ 
    84588475    return commonSemanticAssignIntegral(sc); 
    84598476} 
     
    84658482{ 
    84668483} 
    84678484 
    8468 Expression *AddExp::semantic(Scope *sc) 
     8485DeferStatus<Expression*> AddExp::semantic(Scope *sc) 
    84698486{   Expression *e; 
    84708487 
    84718488#if LOGSEMANTIC 
     
    84738490#endif 
    84748491    if (!type) 
    84758492    { 
    8476     BinExp::semanticp(sc); 
     8493    DeferStatus<Expression*> ret = BinExp::semanticp(sc); 
     8494    if (ret.defer()) return ret; 
    84778495 
    84788496    e = op_overload(sc); 
    84798497    if (e) 
     
    85408558{ 
    85418559} 
    85428560 
    8543 Expression *MinExp::semantic(Scope *sc) 
     8561DeferStatus<Expression*> MinExp::semantic(Scope *sc) 
    85448562{   Expression *e; 
    85458563    Type *t1; 
    85468564    Type *t2; 
     
    86358653{ 
    86368654} 
    86378655 
    8638 Expression *CatExp::semantic(Scope *sc) 
     8656DeferStatus<Expression*> CatExp::semantic(Scope *sc) 
    86398657{   Expression *e; 
    86408658 
    86418659    //printf("CatExp::semantic() %s\n", toChars()); 
     
    87228740{ 
    87238741} 
    87248742 
    8725 Expression *MulExp::semantic(Scope *sc) 
     8743DeferStatus<Expression*> MulExp::semantic(Scope *sc) 
    87268744{   Expression *e; 
    87278745 
    87288746#if 0 
     
    87938811{ 
    87948812} 
    87958813 
    8796 Expression *DivExp::semantic(Scope *sc) 
     8814DeferStatus<Expression*> DivExp::semantic(Scope *sc) 
    87978815{   Expression *e; 
    87988816 
    87998817    if (type) 
     
    88608878{ 
    88618879} 
    88628880 
    8863 Expression *ModExp::semantic(Scope *sc) 
     8881DeferStatus<Expression*> ModExp::semantic(Scope *sc) 
    88648882{   Expression *e; 
    88658883 
    88668884    if (type) 
     
    88938911{ 
    88948912} 
    88958913 
    8896 Expression *ShlExp::semantic(Scope *sc) 
     8914DeferStatus<Expression*> ShlExp::semantic(Scope *sc) 
    88978915{   Expression *e; 
    88988916 
    88998917    //printf("ShlExp::semantic(), type = %p\n", type); 
     
    89198937{ 
    89208938} 
    89218939 
    8922 Expression *ShrExp::semantic(Scope *sc) 
     8940DeferStatus<Expression*> ShrExp::semantic(Scope *sc) 
    89238941{   Expression *e; 
    89248942 
    89258943    if (!type) 
     
    89448962{ 
    89458963} 
    89468964 
    8947 Expression *UshrExp::semantic(Scope *sc) 
     8965DeferStatus<Expression*> UshrExp::semantic(Scope *sc) 
    89488966{   Expression *e; 
    89498967 
    89508968    if (!type) 
     
    89698987{ 
    89708988} 
    89718989 
    8972 Expression *AndExp::semantic(Scope *sc) 
     8990DeferStatus<Expression*> AndExp::semantic(Scope *sc) 
    89738991{   Expression *e; 
    89748992 
    89758993    if (!type) 
     
    90029020{ 
    90039021} 
    90049022 
    9005 Expression *OrExp::semantic(Scope *sc) 
     9023DeferStatus<Expression*> OrExp::semantic(Scope *sc) 
    90069024{   Expression *e; 
    90079025 
    90089026    if (!type) 
     
    90359053{ 
    90369054} 
    90379055 
    9038 Expression *XorExp::semantic(Scope *sc) 
     9056DeferStatus<Expression*> XorExp::semantic(Scope *sc) 
    90399057{   Expression *e; 
    90409058 
    90419059    if (!type) 
     
    90699087{ 
    90709088} 
    90719089 
    9072 Expression *OrOrExp::semantic(Scope *sc) 
     9090DeferStatus<Expression*> OrOrExp::semantic(Scope *sc) 
    90739091{ 
    90749092    unsigned cs1; 
    90759093 
     
    91349152{ 
    91359153} 
    91369154 
    9137 Expression *AndAndExp::semantic(Scope *sc) 
     9155DeferStatus<Expression*> AndAndExp::semantic(Scope *sc) 
    91389156{ 
    91399157    unsigned cs1; 
    91409158 
     
    92009218{ 
    92019219} 
    92029220 
    9203 Expression *InExp::semantic(Scope *sc) 
     9221DeferStatus<Expression*> InExp::semantic(Scope *sc) 
    92049222{   Expression *e; 
    92059223 
    92069224    if (type) 
     
    92559273{ 
    92569274} 
    92579275 
    9258 Expression *CmpExp::semantic(Scope *sc) 
     9276DeferStatus<Expression*> CmpExp::semantic(Scope *sc) 
    92599277{   Expression *e; 
    92609278    Type *t1; 
    92619279    Type *t2; 
     
    93389356    assert(op == TOKequal || op == TOKnotequal); 
    93399357} 
    93409358 
    9341 Expression *EqualExp::semantic(Scope *sc) 
     9359DeferStatus<Expression*> EqualExp::semantic(Scope *sc) 
    93429360{   Expression *e; 
    93439361    Type *t1; 
    93449362    Type *t2; 
     
    94309448{ 
    94319449} 
    94329450 
    9433 Expression *IdentityExp::semantic(Scope *sc) 
     9451DeferStatus<Expression*> IdentityExp::semantic(Scope *sc) 
    94349452{ 
    94359453    if (type) 
    94369454    return this; 
     
    94679485} 
    94689486 
    94699487 
    9470 Expression *CondExp::semantic(Scope *sc) 
     9488DeferStatus<Expression*> CondExp::semantic(Scope *sc) 
    94719489{   Type *t1; 
    94729490    Type *t2; 
    94739491    unsigned cs0; 
  • a/dmd/expression.h

    old new  
    7070 
    7171void initPrecedence(); 
    7272 
    73 Expression *resolveProperties(Scope *sc, Expression *e); 
     73DeferStatus<Expression*> resolveProperties(Scope *sc, Expression *e); 
    7474void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d); 
    7575Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid); 
    7676void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Module* from); 
     
    9191    Expression(Loc loc, enum TOK op, int size); 
    9292    Expression *copy(); 
    9393    virtual Expression *syntaxCopy(); 
    94     virtual Expression *semantic(Scope *sc); 
     94    virtual DeferStatus<Expression*> semantic(Scope *sc); 
    9595 
    9696    int dyncast() { return DYNCAST_EXPRESSION; }    // kludge for template.isExpression() 
    9797 
     
    180180    IntegerExp(Loc loc, dinteger_t value, Type *type); 
    181181    IntegerExp(dinteger_t value); 
    182182    int equals(Object *o); 
    183     Expression *semantic(Scope *sc); 
     183    DeferStatus<Expression*> semantic(Scope *sc); 
    184184    Expression *interpret(InterState *istate); 
    185185    char *toChars(); 
    186186    void dump(int indent); 
     
    216216 
    217217    RealExp(Loc loc, real_t value, Type *type); 
    218218    int equals(Object *o); 
    219     Expression *semantic(Scope *sc); 
     219    DeferStatus<Expression*> semantic(Scope *sc); 
    220220    Expression *interpret(InterState *istate); 
    221221    char *toChars(); 
    222222    dinteger_t toInteger(); 
     
    244244 
    245245    ComplexExp(Loc loc, complex_t value, Type *type); 
    246246    int equals(Object *o); 
    247     Expression *semantic(Scope *sc); 
     247    DeferStatus<Expression*> semantic(Scope *sc); 
    248248    Expression *interpret(InterState *istate); 
    249249    char *toChars(); 
    250250    dinteger_t toInteger(); 
     
    276276 
    277277    IdentifierExp(Loc loc, Identifier *ident); 
    278278    IdentifierExp(Loc loc, Declaration *var); 
    279     Expression *semantic(Scope *sc); 
     279    DeferStatus<Expression*> semantic(Scope *sc); 
    280280    char *toChars(); 
    281281    void dump(int indent); 
    282282    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    293293    Dsymbol *s; 
    294294 
    295295    DsymbolExp(Loc loc, Dsymbol *s); 
    296     Expression *semantic(Scope *sc); 
     296    DeferStatus<Expression*> semantic(Scope *sc); 
    297297    char *toChars(); 
    298298    void dump(int indent); 
    299299    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    305305    Declaration *var; 
    306306 
    307307    ThisExp(Loc loc); 
    308     Expression *semantic(Scope *sc); 
     308    DeferStatus<Expression*> semantic(Scope *sc); 
    309309    int isBool(int result); 
    310310    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    311311    Expression *toLvalue(Scope *sc, Expression *e); 
     
    327327struct SuperExp : ThisExp 
    328328{ 
    329329    SuperExp(Loc loc); 
    330     Expression *semantic(Scope *sc); 
     330    DeferStatus<Expression*> semantic(Scope *sc); 
    331331    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    332332    void scanForNestedRef(Scope *sc); 
    333333 
     
    341341    unsigned char committed;    // !=0 if type is committed 
    342342 
    343343    NullExp(Loc loc); 
    344     Expression *semantic(Scope *sc); 
     344    DeferStatus<Expression*> semantic(Scope *sc); 
    345345    int isBool(int result); 
    346346    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    347347    void toMangleBuffer(OutBuffer *buf); 
     
    371371    //Expression *syntaxCopy(); 
    372372    int equals(Object *o); 
    373373    char *toChars(); 
    374     Expression *semantic(Scope *sc); 
     374    DeferStatus<Expression*> semantic(Scope *sc); 
    375375    Expression *interpret(InterState *istate); 
    376376    StringExp *toUTF8(Scope *sc); 
    377377    MATCH implicitConvTo(Type *t); 
     
    400400    TupleExp(Loc loc, TupleDeclaration *tup); 
    401401    Expression *syntaxCopy(); 
    402402    int equals(Object *o); 
    403     Expression *semantic(Scope *sc); 
     403    DeferStatus<Expression*> semantic(Scope *sc); 
    404404    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    405405    void scanForNestedRef(Scope *sc); 
    406406    void checkEscape(); 
     
    429429    ArrayLiteralExp(Loc loc, Expression *e); 
    430430 
    431431    Expression *syntaxCopy(); 
    432     Expression *semantic(Scope *sc); 
     432    DeferStatus<Expression*> semantic(Scope *sc); 
    433433    int isBool(int result); 
    434434    int checkSideEffect(int flag); 
    435435    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    461461    AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values); 
    462462 
    463463    Expression *syntaxCopy(); 
    464     Expression *semantic(Scope *sc); 
     464    DeferStatus<Expression*> semantic(Scope *sc); 
    465465    int isBool(int result); 
    466466#if IN_DMD 
    467467    elem *toElem(IRState *irs); 
     
    500500    StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements); 
    501501 
    502502    Expression *syntaxCopy(); 
    503     Expression *semantic(Scope *sc); 
     503    DeferStatus<Expression*> semantic(Scope *sc); 
    504504    Expression *getField(Type *type, unsigned offset); 
    505505    int getFieldIndex(Type *type, unsigned offset); 
    506506    int checkSideEffect(int flag); 
     
    538538{ 
    539539    TypeExp(Loc loc, Type *type); 
    540540    Expression *syntaxCopy(); 
    541     Expression *semantic(Scope *sc); 
     541    DeferStatus<Expression*> semantic(Scope *sc); 
    542542    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    543543    Expression *optimize(int result); 
    544544#if IN_DMD 
     
    556556 
    557557    ScopeExp(Loc loc, ScopeDsymbol *sds); 
    558558    Expression *syntaxCopy(); 
    559     Expression *semantic(Scope *sc); 
     559    DeferStatus<Expression*> semantic(Scope *sc); 
    560560#if IN_DMD 
    561561    elem *toElem(IRState *irs); 
    562562#endif 
     
    592592    NewExp(Loc loc, Expression *thisexp, Expressions *newargs, 
    593593    Type *newtype, Expressions *arguments); 
    594594    Expression *syntaxCopy(); 
    595     Expression *semantic(Scope *sc); 
     595    DeferStatus<Expression*> semantic(Scope *sc); 
    596596#if IN_DMD 
    597597    elem *toElem(IRState *irs); 
    598598#endif 
     
    621621    NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs, 
    622622    ClassDeclaration *cd, Expressions *arguments); 
    623623    Expression *syntaxCopy(); 
    624     Expression *semantic(Scope *sc); 
     624    DeferStatus<Expression*> semantic(Scope *sc); 
    625625    int checkSideEffect(int flag); 
    626626    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    627627}; 
     
    635635    Module* m;  // starting point for overload resolution 
    636636 
    637637    SymOffExp(Loc loc, Declaration *var, unsigned offset); 
    638     Expression *semantic(Scope *sc); 
     638    DeferStatus<Expression*> semantic(Scope *sc); 
    639639    void checkEscape(); 
    640640    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    641641    int isConst(); 
     
    663663 
    664664    VarExp(Loc loc, Declaration *var); 
    665665    int equals(Object *o); 
    666     Expression *semantic(Scope *sc); 
     666    DeferStatus<Expression*> semantic(Scope *sc); 
    667667    Expression *optimize(int result); 
    668668    Expression *interpret(InterState *istate); 
    669669    void dump(int indent); 
     
    710710 
    711711    FuncExp(Loc loc, FuncLiteralDeclaration *fd); 
    712712    Expression *syntaxCopy(); 
    713     Expression *semantic(Scope *sc); 
     713    DeferStatus<Expression*> semantic(Scope *sc); 
    714714    void scanForNestedRef(Scope *sc); 
    715715    char *toChars(); 
    716716    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    736736 
    737737    DeclarationExp(Loc loc, Dsymbol *declaration); 
    738738    Expression *syntaxCopy(); 
    739     Expression *semantic(Scope *sc); 
     739    DeferStatus<Expression*> semantic(Scope *sc); 
    740740    Expression *interpret(InterState *istate); 
    741741    int checkSideEffect(int flag); 
    742742    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    760760 
    761761    TypeidExp(Loc loc, Type *typeidType); 
    762762    Expression *syntaxCopy(); 
    763     Expression *semantic(Scope *sc); 
     763    DeferStatus<Expression*> semantic(Scope *sc); 
    764764    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    765765}; 
    766766 
     
    772772 
    773773    TraitsExp(Loc loc, Identifier *ident, Objects *args); 
    774774    Expression *syntaxCopy(); 
    775     Expression *semantic(Scope *sc); 
     775    DeferStatus<Expression*> semantic(Scope *sc); 
    776776    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    777777}; 
    778778#endif 
     
    780780struct HaltExp : Expression 
    781781{ 
    782782    HaltExp(Loc loc); 
    783     Expression *semantic(Scope *sc); 
     783    DeferStatus<Expression*> semantic(Scope *sc); 
    784784    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    785785    int checkSideEffect(int flag); 
    786786 
     
    806806 
    807807    IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2); 
    808808    Expression *syntaxCopy(); 
    809     Expression *semantic(Scope *sc); 
     809    DeferStatus<Expression*> semantic(Scope *sc); 
    810810    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    811811}; 
    812812 
     
    818818 
    819819    UnaExp(Loc loc, enum TOK op, int size, Expression *e1); 
    820820    Expression *syntaxCopy(); 
    821     Expression *semantic(Scope *sc); 
     821    DeferStatus<Expression*> semantic(Scope *sc); 
    822822    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    823823    Expression *optimize(int result); 
    824824    void dump(int indent); 
     
    839839 
    840840    BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2); 
    841841    Expression *syntaxCopy(); 
    842     Expression *semantic(Scope *sc); 
    843     Expression *semanticp(Scope *sc); 
     842    DeferStatus<Expression*> semantic(Scope *sc); 
     843    DeferStatus<Expression*> semanticp(Scope *sc); 
    844844    Expression *commonSemanticAssign(Scope *sc); 
    845845    Expression *commonSemanticAssignIntegral(Scope *sc); 
    846846    int checkSideEffect(int flag); 
     
    879879struct CompileExp : UnaExp 
    880880{ 
    881881    CompileExp(Loc loc, Expression *e); 
    882     Expression *semantic(Scope *sc); 
     882    DeferStatus<Expression*> semantic(Scope *sc); 
    883883    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    884884}; 
    885885 
    886886struct FileExp : UnaExp 
    887887{ 
    888888    FileExp(Loc loc, Expression *e); 
    889     Expression *semantic(Scope *sc); 
     889    DeferStatus<Expression*> semantic(Scope *sc); 
    890890    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    891891}; 
    892892 
     
    896896 
    897897    AssertExp(Loc loc, Expression *e, Expression *msg = NULL); 
    898898    Expression *syntaxCopy(); 
    899     Expression *semantic(Scope *sc); 
     899    DeferStatus<Expression*> semantic(Scope *sc); 
    900900    Expression *interpret(InterState *istate); 
    901901    int checkSideEffect(int flag); 
    902902    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    919919    Identifier *ident; 
    920920 
    921921    DotIdExp(Loc loc, Expression *e, Identifier *ident); 
    922     Expression *semantic(Scope *sc); 
     922    DeferStatus<Expression*> semantic(Scope *sc); 
    923923    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    924924    void dump(int i); 
    925925}; 
     
    937937    Declaration *var; 
    938938 
    939939    DotVarExp(Loc loc, Expression *e, Declaration *var); 
    940     Expression *semantic(Scope *sc); 
     940    DeferStatus<Expression*> semantic(Scope *sc); 
    941941    Expression *toLvalue(Scope *sc, Expression *e); 
    942942    Expression *modifiableLvalue(Scope *sc, Expression *e); 
    943943    Expression *optimize(int result); 
     
    960960 
    961961    DotTemplateInstanceExp(Loc loc, Expression *e, TemplateInstance *ti); 
    962962    Expression *syntaxCopy(); 
    963     Expression *semantic(Scope *sc); 
     963    DeferStatus<Expression*> semantic(Scope *sc); 
    964964    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    965965    void dump(int indent); 
    966966}; 
     
    971971    Module* m;  // starting point for overload resolution 
    972972 
    973973    DelegateExp(Loc loc, Expression *e, FuncDeclaration *func); 
    974     Expression *semantic(Scope *sc); 
     974    DeferStatus<Expression*> semantic(Scope *sc); 
    975975    MATCH implicitConvTo(Type *t); 
    976976    Expression *castTo(Scope *sc, Type *t); 
    977977    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    992992    Dsymbol *sym;       // symbol that represents a type 
    993993 
    994994    DotTypeExp(Loc loc, Expression *e, Dsymbol *sym); 
    995     Expression *semantic(Scope *sc); 
     995    DeferStatus<Expression*> semantic(Scope *sc); 
    996996    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    997997#if IN_DMD 
    998998    elem *toElem(IRState *irs); 
     
    10131013    CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2); 
    10141014 
    10151015    Expression *syntaxCopy(); 
    1016     Expression *semantic(Scope *sc); 
     1016    DeferStatus<Expression*> semantic(Scope *sc); 
    10171017    Expression *optimize(int result); 
    10181018    Expression *interpret(InterState *istate); 
    10191019    int checkSideEffect(int flag); 
     
    10391039    Module* m;  // starting point for overload resolution 
    10401040 
    10411041    AddrExp(Loc loc, Expression *e); 
    1042     Expression *semantic(Scope *sc); 
     1042    DeferStatus<Expression*> semantic(Scope *sc); 
    10431043#if IN_DMD 
    10441044    elem *toElem(IRState *irs); 
    10451045#endif 
     
    10571057{ 
    10581058    PtrExp(Loc loc, Expression *e); 
    10591059    PtrExp(Loc loc, Expression *e, Type *t); 
    1060     Expression *semantic(Scope *sc); 
     1060    DeferStatus<Expression*> semantic(Scope *sc); 
    10611061    Expression *toLvalue(Scope *sc, Expression *e); 
    10621062    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    10631063#if IN_DMD 
     
    10751075struct NegExp : UnaExp 
    10761076{ 
    10771077    NegExp(Loc loc, Expression *e); 
    1078     Expression *semantic(Scope *sc); 
     1078    DeferStatus<Expression*> semantic(Scope *sc); 
    10791079    Expression *optimize(int result); 
    10801080    Expression *interpret(InterState *istate); 
    10811081    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    10961096struct UAddExp : UnaExp 
    10971097{ 
    10981098    UAddExp(Loc loc, Expression *e); 
    1099     Expression *semantic(Scope *sc); 
     1099    DeferStatus<Expression*> semantic(Scope *sc); 
    11001100 
    11011101    // For operator overloading 
    11021102    Identifier *opId(); 
     
    11051105struct ComExp : UnaExp 
    11061106{ 
    11071107    ComExp(Loc loc, Expression *e); 
    1108     Expression *semantic(Scope *sc); 
     1108    DeferStatus<Expression*> semantic(Scope *sc); 
    11091109    Expression *optimize(int result); 
    11101110    Expression *interpret(InterState *istate); 
    11111111    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    11261126struct NotExp : UnaExp 
    11271127{ 
    11281128    NotExp(Loc loc, Expression *e); 
    1129     Expression *semantic(Scope *sc); 
     1129    DeferStatus<Expression*> semantic(Scope *sc); 
    11301130    Expression *optimize(int result); 
    11311131    Expression *interpret(InterState *istate); 
    11321132    int isBit(); 
     
    11421142struct BoolExp : UnaExp 
    11431143{ 
    11441144    BoolExp(Loc loc, Expression *e, Type *type); 
    1145     Expression *semantic(Scope *sc); 
     1145    DeferStatus<Expression*> semantic(Scope *sc); 
    11461146    Expression *optimize(int result); 
    11471147    Expression *interpret(InterState *istate); 
    11481148    int isBit(); 
     
    11581158struct DeleteExp : UnaExp 
    11591159{ 
    11601160    DeleteExp(Loc loc, Expression *e); 
    1161     Expression *semantic(Scope *sc); 
     1161    DeferStatus<Expression*> semantic(Scope *sc); 
    11621162    Expression *checkToBoolean(); 
    11631163    int checkSideEffect(int flag); 
    11641164    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    11781178 
    11791179    CastExp(Loc loc, Expression *e, Type *t); 
    11801180    Expression *syntaxCopy(); 
    1181     Expression *semantic(Scope *sc); 
     1181    DeferStatus<Expression*> semantic(Scope *sc); 
    11821182    Expression *optimize(int result); 
    11831183    Expression *interpret(InterState *istate); 
    11841184    int checkSideEffect(int flag); 
     
    12061206 
    12071207    SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr); 
    12081208    Expression *syntaxCopy(); 
    1209     Expression *semantic(Scope *sc); 
     1209    DeferStatus<Expression*> semantic(Scope *sc); 
    12101210    void checkEscape(); 
    12111211    Expression *toLvalue(Scope *sc, Expression *e); 
    12121212    Expression *modifiableLvalue(Scope *sc, Expression *e); 
     
    12341234struct ArrayLengthExp : UnaExp 
    12351235{ 
    12361236    ArrayLengthExp(Loc loc, Expression *e1); 
    1237     Expression *semantic(Scope *sc); 
     1237    DeferStatus<Expression*> semantic(Scope *sc); 
    12381238    Expression *optimize(int result); 
    12391239    Expression *interpret(InterState *istate); 
    12401240    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    12551255 
    12561256    ArrayExp(Loc loc, Expression *e1, Expressions *arguments); 
    12571257    Expression *syntaxCopy(); 
    1258     Expression *semantic(Scope *sc); 
     1258    DeferStatus<Expression*> semantic(Scope *sc); 
    12591259    Expression *toLvalue(Scope *sc, Expression *e); 
    12601260    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    12611261    void scanForNestedRef(Scope *sc); 
     
    12731273struct DotExp : BinExp 
    12741274{ 
    12751275    DotExp(Loc loc, Expression *e1, Expression *e2); 
    1276     Expression *semantic(Scope *sc); 
     1276    DeferStatus<Expression*> semantic(Scope *sc); 
    12771277}; 
    12781278 
    12791279struct CommaExp : BinExp 
    12801280{ 
    12811281    CommaExp(Loc loc, Expression *e1, Expression *e2); 
    1282     Expression *semantic(Scope *sc); 
     1282    DeferStatus<Expression*> semantic(Scope *sc); 
    12831283    void checkEscape(); 
    12841284    Expression *toLvalue(Scope *sc, Expression *e); 
    12851285    Expression *modifiableLvalue(Scope *sc, Expression *e); 
     
    13021302    int modifiable; 
    13031303 
    13041304    IndexExp(Loc loc, Expression *e1, Expression *e2); 
    1305     Expression *semantic(Scope *sc); 
     1305    DeferStatus<Expression*> semantic(Scope *sc); 
    13061306    Expression *toLvalue(Scope *sc, Expression *e); 
    13071307    Expression *modifiableLvalue(Scope *sc, Expression *e); 
    13081308    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    13251325struct PostExp : BinExp 
    13261326{ 
    13271327    PostExp(enum TOK op, Loc loc, Expression *e); 
    1328     Expression *semantic(Scope *sc); 
     1328    DeferStatus<Expression*> semantic(Scope *sc); 
    13291329    Expression *interpret(InterState *istate); 
    13301330    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    13311331    Identifier *opId();    // For operator overloading 
     
    13421342{   int ismemset;   // !=0 if setting the contents of an array 
    13431343 
    13441344    AssignExp(Loc loc, Expression *e1, Expression *e2); 
    1345     Expression *semantic(Scope *sc); 
     1345    DeferStatus<Expression*> semantic(Scope *sc); 
    13461346    Expression *checkToBoolean(); 
    13471347    Expression *interpret(InterState *istate); 
    13481348    Identifier *opId();    // For operator overloading 
     
    13691369struct op##AssignExp : BinExp                   \ 
    13701370{                               \ 
    13711371    op##AssignExp(Loc loc, Expression *e1, Expression *e2); \ 
    1372     Expression *semantic(Scope *sc);              \ 
     1372    DeferStatus<Expression*> semantic(Scope *sc);             \ 
    13731373    Expression *interpret(InterState *istate);          \ 
    13741374    X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \ 
    13751375    X(Expression *buildArrayLoop(Arguments *fparams);)      \ 
     
    14041404struct AddExp : BinExp 
    14051405{ 
    14061406    AddExp(Loc loc, Expression *e1, Expression *e2); 
    1407     Expression *semantic(Scope *sc); 
     1407    DeferStatus<Expression*> semantic(Scope *sc); 
    14081408    Expression *optimize(int result); 
    14091409    Expression *interpret(InterState *istate); 
    14101410    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    14271427struct MinExp : BinExp 
    14281428{ 
    14291429    MinExp(Loc loc, Expression *e1, Expression *e2); 
    1430     Expression *semantic(Scope *sc); 
     1430    DeferStatus<Expression*> semantic(Scope *sc); 
    14311431    Expression *optimize(int result); 
    14321432    Expression *interpret(InterState *istate); 
    14331433    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    14491449struct CatExp : BinExp 
    14501450{ 
    14511451    CatExp(Loc loc, Expression *e1, Expression *e2); 
    1452     Expression *semantic(Scope *sc); 
     1452    DeferStatus<Expression*> semantic(Scope *sc); 
    14531453    Expression *optimize(int result); 
    14541454    Expression *interpret(InterState *istate); 
    14551455 
     
    14691469struct MulExp : BinExp 
    14701470{ 
    14711471    MulExp(Loc loc, Expression *e1, Expression *e2); 
    1472     Expression *semantic(Scope *sc); 
     1472    DeferStatus<Expression*> semantic(Scope *sc); 
    14731473    Expression *optimize(int result); 
    14741474    Expression *interpret(InterState *istate); 
    14751475    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    14921492struct DivExp : BinExp 
    14931493{ 
    14941494    DivExp(Loc loc, Expression *e1, Expression *e2); 
    1495     Expression *semantic(Scope *sc); 
     1495    DeferStatus<Expression*> semantic(Scope *sc); 
    14961496    Expression *optimize(int result); 
    14971497    Expression *interpret(InterState *istate); 
    14981498    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    15141514struct ModExp : BinExp 
    15151515{ 
    15161516    ModExp(Loc loc, Expression *e1, Expression *e2); 
    1517     Expression *semantic(Scope *sc); 
     1517    DeferStatus<Expression*> semantic(Scope *sc); 
    15181518    Expression *optimize(int result); 
    15191519    Expression *interpret(InterState *istate); 
    15201520    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    15361536struct ShlExp : BinExp 
    15371537{ 
    15381538    ShlExp(Loc loc, Expression *e1, Expression *e2); 
    1539     Expression *semantic(Scope *sc); 
     1539    DeferStatus<Expression*> semantic(Scope *sc); 
    15401540    Expression *optimize(int result); 
    15411541    Expression *interpret(InterState *istate); 
    15421542 
     
    15561556struct ShrExp : BinExp 
    15571557{ 
    15581558    ShrExp(Loc loc, Expression *e1, Expression *e2); 
    1559     Expression *semantic(Scope *sc); 
     1559    DeferStatus<Expression*> semantic(Scope *sc); 
    15601560    Expression *optimize(int result); 
    15611561    Expression *interpret(InterState *istate); 
    15621562 
     
    15761576struct UshrExp : BinExp 
    15771577{ 
    15781578    UshrExp(Loc loc, Expression *e1, Expression *e2); 
    1579     Expression *semantic(Scope *sc); 
     1579    DeferStatus<Expression*> semantic(Scope *sc); 
    15801580    Expression *optimize(int result); 
    15811581    Expression *interpret(InterState *istate); 
    15821582 
     
    15961596struct AndExp : BinExp 
    15971597{ 
    15981598    AndExp(Loc loc, Expression *e1, Expression *e2); 
    1599     Expression *semantic(Scope *sc); 
     1599    DeferStatus<Expression*> semantic(Scope *sc); 
    16001600    Expression *optimize(int result); 
    16011601    Expression *interpret(InterState *istate); 
    16021602    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    16191619struct OrExp : BinExp 
    16201620{ 
    16211621    OrExp(Loc loc, Expression *e1, Expression *e2); 
    1622     Expression *semantic(Scope *sc); 
     1622    DeferStatus<Expression*> semantic(Scope *sc); 
    16231623    Expression *optimize(int result); 
    16241624    Expression *interpret(InterState *istate); 
    16251625    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    16421642struct XorExp : BinExp 
    16431643{ 
    16441644    XorExp(Loc loc, Expression *e1, Expression *e2); 
    1645     Expression *semantic(Scope *sc); 
     1645    DeferStatus<Expression*> semantic(Scope *sc); 
    16461646    Expression *optimize(int result); 
    16471647    Expression *interpret(InterState *istate); 
    16481648    void buildArrayIdent(OutBuffer *buf, Expressions *arguments); 
     
    16651665struct OrOrExp : BinExp 
    16661666{ 
    16671667    OrOrExp(Loc loc, Expression *e1, Expression *e2); 
    1668     Expression *semantic(Scope *sc); 
     1668    DeferStatus<Expression*> semantic(Scope *sc); 
    16691669    Expression *checkToBoolean(); 
    16701670    int isBit(); 
    16711671    Expression *optimize(int result); 
     
    16831683struct AndAndExp : BinExp 
    16841684{ 
    16851685    AndAndExp(Loc loc, Expression *e1, Expression *e2); 
    1686     Expression *semantic(Scope *sc); 
     1686    DeferStatus<Expression*> semantic(Scope *sc); 
    16871687    Expression *checkToBoolean(); 
    16881688    int isBit(); 
    16891689    Expression *optimize(int result); 
     
    17011701struct CmpExp : BinExp 
    17021702{ 
    17031703    CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); 
    1704     Expression *semantic(Scope *sc); 
     1704    DeferStatus<Expression*> semantic(Scope *sc); 
    17051705    Expression *optimize(int result); 
    17061706    Expression *interpret(InterState *istate); 
    17071707    int isBit(); 
     
    17221722struct InExp : BinExp 
    17231723{ 
    17241724    InExp(Loc loc, Expression *e1, Expression *e2); 
    1725     Expression *semantic(Scope *sc); 
     1725    DeferStatus<Expression*> semantic(Scope *sc); 
    17261726    int isBit(); 
    17271727 
    17281728    // For operator overloading 
     
    17551755struct EqualExp : BinExp 
    17561756{ 
    17571757    EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); 
    1758     Expression *semantic(Scope *sc); 
     1758    DeferStatus<Expression*> semantic(Scope *sc); 
    17591759    Expression *optimize(int result); 
    17601760    Expression *interpret(InterState *istate); 
    17611761    int isBit(); 
     
    17781778struct IdentityExp : BinExp 
    17791779{ 
    17801780    IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2); 
    1781     Expression *semantic(Scope *sc); 
     1781    DeferStatus<Expression*> semantic(Scope *sc); 
    17821782    int isBit(); 
    17831783    Expression *optimize(int result); 
    17841784    Expression *interpret(InterState *istate); 
     
    17991799 
    18001800    CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2); 
    18011801    Expression *syntaxCopy(); 
    1802     Expression *semantic(Scope *sc); 
     1802    DeferStatus<Expression*> semantic(Scope *sc); 
    18031803    Expression *optimize(int result); 
    18041804    Expression *interpret(InterState *istate); 
    18051805    void checkEscape(); 
     
    18401840struct FileInitExp : DefaultInitExp 
    18411841{ 
    18421842    FileInitExp(Loc loc); 
    1843     Expression *semantic(Scope *sc); 
     1843    DeferStatus<Expression*> semantic(Scope *sc); 
    18441844    Expression *resolve(Loc loc, Scope *sc); 
    18451845}; 
    18461846 
    18471847struct LineInitExp : DefaultInitExp 
    18481848{ 
    18491849    LineInitExp(Loc loc); 
    1850     Expression *semantic(Scope *sc); 
     1850    DeferStatus<Expression*> semantic(Scope *sc); 
    18511851    Expression *resolve(Loc loc, Scope *sc); 
    18521852}; 
    18531853#endif 
  • a/dmd/func.c

    old new  
    129129 
    130130// Do the semantic analysis on the external interface to the function. 
    131131 
    132 void FuncDeclaration::semantic(Scope *sc) 
     132DeferStatus<void> FuncDeclaration::semantic(Scope *sc) 
    133133{   TypeFunction *f; 
    134134    StructDeclaration *sd; 
    135135    ClassDeclaration *cd; 
     
    151151     * once on them. 
    152152     * See test\interface2.d, test20 
    153153     */ 
    154     return
     154    return nodefer()
    155155    } 
    156156    assert(semanticRun <= 1); 
    157157    semanticRun = 1; 
    158158 
    159159    if (type->nextOf()) 
    160     type = type->semantic(loc, sc); 
     160    { 
     161    DeferStatus<Type*> ret = type->semantic(loc, sc); 
     162    if (ret.defer()) { 
     163        semanticRun = 0; 
     164        return ret; 
     165    } 
     166    type = ret; 
     167    } 
    161168    //type->print(); 
    162169    if (type->ty != Tfunction) 
    163170    { 
    164171    error("%s must be a function", toChars()); 
    165     return
     172    return nodefer()
    166173    } 
    167174    f = (TypeFunction *)(type); 
    168175    size_t nparams = Argument::dim(f->parameters); 
     
    279286//      ctor = (CtorDeclaration *)this; 
    280287//      if (!cd->ctor) 
    281288//      cd->ctor = ctor; 
    282         return
     289        return nodefer()
    283290    } 
    284291 
    285292#if 0 
     
    361368        break; 
    362369 
    363370        case -2:    // can't determine because of fwd refs 
    364         cd->sizeok = 2; // can't finish due to forward reference 
    365         return; 
     371        return defer<void>(loc, "cannot determine vtbl index of %s because of forward references", toChars()); 
    366372 
    367373        default: 
    368374        {   FuncDeclaration *fdv = (FuncDeclaration *)cd->vtbl.data[vi]; 
     
    435441            break; 
    436442 
    437443        case -2: 
    438             cd->sizeok = 2; // can't finish due to forward reference 
    439             return; 
     444            return defer<void>(loc, "cannot determine vtbl index of %s because of forward references", toChars()); 
    440445 
    441446        default: 
    442447        {   FuncDeclaration *fdv = (FuncDeclaration *)b->base->vtbl.data[vi]; 
     
    531536            } 
    532537            if (cov == 3) 
    533538            { 
    534             cd->sizeok = 2; // can't finish due to forward reference 
    535             return; 
     539            return defer<void>(loc, "cannot finish due to forward reference"); 
    536540            } 
    537541        } 
    538542        } 
     
    639643     */ 
    640644    scope = new Scope(*sc); 
    641645    scope->setNoFree(); 
    642     return
     646    return nodefer()
    643647 
    644648Lassignerr: 
    645649    error("identity assignment operator overload is illegal"); 
     650    return nodefer(); 
    646651} 
    647652 
    648 void FuncDeclaration::semantic2(Scope *sc) 
     653DeferStatus<void> FuncDeclaration::semantic2(Scope *sc) 
    649654{ 
     655    return nodefer(); 
    650656} 
    651657 
    652658// Do the semantic analysis on the internals of the function. 
    653659 
    654 void FuncDeclaration::semantic3(Scope *sc) 
     660DeferStatus<void> FuncDeclaration::semantic3(Scope *sc) 
    655661{   TypeFunction *f; 
    656662    AggregateDeclaration *ad; 
    657663    VarDeclaration *argptr = NULL; 
     
    660666    if (!parent) 
    661667    { 
    662668    if (global.errors) 
    663         return
     669        return nodefer()
    664670    //printf("FuncDeclaration::semantic3(%s '%s', sc = %p)\n", kind(), toChars(), sc); 
    665671    assert(0); 
    666672    } 
     
    671677 
    672678    //printf(" sc->incontract = %d\n", sc->incontract); 
    673679    if (semanticRun >= 3) 
    674     return
     680    return nodefer()
    675681    semanticRun = 3; 
    676682 
    677683    if (!type || type->ty != Tfunction) 
    678     return
     684    return nodefer()
    679685    f = (TypeFunction *)(type); 
    680686    size_t nparams = Argument::dim(f->parameters); 
    681687 
     
    728734        if (isFuncLiteralDeclaration() && isNested()) 
    729735        { 
    730736        error("literals cannot be class members"); 
    731         return
     737        return nodefer()
    732738        } 
    733739        else 
    734740        { 
     
    13641370    sc2->pop(); 
    13651371    } 
    13661372    semanticRun = 4; 
     1373     
     1374    return nodefer(); 
    13671375} 
    13681376 
    13691377void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
     
    23692377} 
    23702378 
    23712379 
    2372 void CtorDeclaration::semantic(Scope *sc) 
     2380DeferStatus<void> CtorDeclaration::semantic(Scope *sc) 
    23732381{ 
    23742382    ClassDeclaration *cd; 
    23752383    Type *tret; 
    23762384 
    23772385    //printf("CtorDeclaration::semantic()\n"); 
    23782386    if (type) 
    2379     return
     2387    return nodefer()
    23802388 
    23812389    sc = sc->push(); 
    23822390    sc->stc &= ~STCstatic;      // not a static constructor 
     
    24122420    fbody = new CompoundStatement(0, fbody, s); 
    24132421    } 
    24142422 
    2415     FuncDeclaration::semantic(sc); 
     2423    DeferStatus<void> ret = FuncDeclaration::semantic(sc); 
    24162424 
    24172425    sc->pop(); 
    24182426 
    24192427    // See if it's the default constructor 
    24202428    if (cd && varargs == 0 && Argument::dim(arguments) == 0) 
    24212429    cd->defaultCtor = this; 
     2430 
     2431    return ret; 
    24222432} 
    24232433 
    24242434const char *CtorDeclaration::kind() 
     
    24742484} 
    24752485 
    24762486 
    2477 void DtorDeclaration::semantic(Scope *sc) 
     2487DeferStatus<void> DtorDeclaration::semantic(Scope *sc) 
    24782488{ 
    24792489    ClassDeclaration *cd; 
    24802490 
     
    24942504    sc->stc &= ~STCstatic;      // not a static destructor 
    24952505    sc->linkage = LINKd; 
    24962506 
    2497     FuncDeclaration::semantic(sc); 
     2507    DeferStatus<void> ret = FuncDeclaration::semantic(sc); 
    24982508 
    24992509    sc->pop(); 
     2510    return ret; 
    25002511} 
    25012512 
    25022513int DtorDeclaration::overloadInsert(Dsymbol *s) 
     
    25522563} 
    25532564 
    25542565 
    2555 void StaticCtorDeclaration::semantic(Scope *sc) 
     2566DeferStatus<void> StaticCtorDeclaration::semantic(Scope *sc) 
    25562567{ 
    25572568    //printf("StaticCtorDeclaration::semantic()\n"); 
    25582569 
     
    25862597    fbody = new CompoundStatement(0, sa); 
    25872598    } 
    25882599 
    2589     FuncDeclaration::semantic(sc); 
     2600    DeferStatus<void> ret = FuncDeclaration::semantic(sc); 
    25902601 
    25912602    // We're going to need ModuleInfo 
    25922603    Module *m = getModule(); 
     
    25982609    m->strictlyneedmoduleinfo = 1; 
    25992610#endif 
    26002611    } 
     2612     
     2613    return ret; 
    26012614} 
    26022615 
    26032616AggregateDeclaration *StaticCtorDeclaration::isThis() 
     
    26542667} 
    26552668 
    26562669 
    2657 void StaticDtorDeclaration::semantic(Scope *sc) 
     2670DeferStatus<void> StaticDtorDeclaration::semantic(Scope *sc) 
    26582671{ 
    26592672    ClassDeclaration *cd; 
    26602673    Type *tret; 
     
    26952708    vgate = v; 
    26962709    } 
    26972710 
    2698     FuncDeclaration::semantic(sc); 
     2711    DeferStatus<void> ret = FuncDeclaration::semantic(sc); 
    26992712 
    27002713    // We're going to need ModuleInfo 
    27012714    Module *m = getModule(); 
     
    27072720    m->strictlyneedmoduleinfo = 1; 
    27082721#endif 
    27092722    } 
     2723     
     2724    return ret; 
    27102725} 
    27112726 
    27122727AggregateDeclaration *StaticDtorDeclaration::isThis() 
     
    27602775} 
    27612776 
    27622777 
    2763 void InvariantDeclaration::semantic(Scope *sc) 
     2778DeferStatus<void> InvariantDeclaration::semantic(Scope *sc) 
    27642779{ 
    27652780    AggregateDeclaration *ad; 
    27662781    Type *tret; 
     
    27712786    if (!ad) 
    27722787    { 
    27732788    error("invariants are only for struct/union/class definitions"); 
    2774     return
     2789    return nodefer()
    27752790    } 
    27762791    else if (ad->inv && ad->inv != this) 
    27772792    { 
     
    27852800    sc->incontract++; 
    27862801    sc->linkage = LINKd; 
    27872802 
    2788     FuncDeclaration::semantic(sc); 
     2803    DeferStatus<void> ret = FuncDeclaration::semantic(sc); 
    27892804 
    27902805    sc->pop(); 
     2806    return ret; 
    27912807} 
    27922808 
    27932809int InvariantDeclaration::isVirtual() 
     
    28412857} 
    28422858 
    28432859 
    2844 void UnitTestDeclaration::semantic(Scope *sc) 
     2860DeferStatus<void> UnitTestDeclaration::semantic(Scope *sc) 
    28452861{ 
    28462862    if (global.params.useUnitTests) 
    28472863    { 
     
    28602876    m = sc->module; 
    28612877    if (m) 
    28622878    m->needmoduleinfo = 1; 
     2879     
     2880    return nodefer(); 
    28632881} 
    28642882 
    28652883AggregateDeclaration *UnitTestDeclaration::isThis() 
     
    29132931} 
    29142932 
    29152933 
    2916 void NewDeclaration::semantic(Scope *sc) 
     2934DeferStatus<void> NewDeclaration::semantic(Scope *sc) 
    29172935{ 
    29182936    ClassDeclaration *cd; 
    29192937    Type *tret; 
     
    29462964        error("first argument must be type size_t, not %s", a->type->toChars()); 
    29472965    } 
    29482966 
    2949     FuncDeclaration::semantic(sc); 
     2967    return FuncDeclaration::semantic(sc); 
    29502968} 
    29512969 
    29522970const char *NewDeclaration::kind() 
     
    29993017} 
    30003018 
    30013019 
    3002 void DeleteDeclaration::semantic(Scope *sc) 
     3020DeferStatus<void> DeleteDeclaration::semantic(Scope *sc) 
    30033021{ 
    30043022    ClassDeclaration *cd; 
    30053023 
     
    30303048        error("one argument of type void* expected, not %s", a->type->toChars()); 
    30313049    } 
    30323050 
    3033     FuncDeclaration::semantic(sc); 
     3051    return FuncDeclaration::semantic(sc); 
    30343052} 
    30353053 
    30363054const char *DeleteDeclaration::kind() 
  • a/dmd/import.c

    old new  
    8282    return si; 
    8383} 
    8484 
    85 void Import::load(Scope *sc) 
     85DeferStatus<void> Import::load(Scope *sc) 
    8686{ 
    8787    DsymbolTable *dst; 
    8888    Dsymbol *s; 
     
    114114    pkg = mod; 
    115115 
    116116    //printf("-Import::load('%s'), pkg = %p\n", toChars(), pkg); 
     117    return nodefer(); 
    117118} 
    118119 
    119120char* escapePath(char* fname, char* buffer, int bufLen) { 
     
    136137    return buffer; 
    137138} 
    138139 
    139 void Import::semantic(Scope *sc) 
     140DeferStatus<void> Import::semantic(Scope *sc) 
    140141{ 
    141142    //printf("Import::semantic('%s')\n", toChars()); 
    142143 
    143     load(sc); 
     144    DeferStatus<void> defer = load(sc); 
    144145 
    145146    if (mod) 
    146147    { 
     
    154155    } 
    155156#endif 
    156157 
     158    DeferStatus<void> ret = mod->semantic(); 
     159    if (ret.defer()) return ret; 
     160 
    157161    // Modules need a list of each imported module 
    158162    //printf("%s imports %s\n", sc->module->toChars(), mod->toChars()); 
    159     sc->module->aimports.push(mod); 
    160  
    161     mod->semantic(); 
     163    bool in_aimports = false; 
     164    for (int i = 0; i < sc->module->aimports.dim; ++i) 
     165        if (sc->module->aimports.data[i] == mod) 
     166        in_aimports = true; 
     167    if (!in_aimports) 
     168        sc->module->aimports.push(mod); 
    162169 
    163170    /* Default to private importing 
    164171     */ 
     
    187194    } 
    188195    sc = sc->pop(); 
    189196    } 
     197 
    190198    //printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg); 
    191199 
    192200 
     
    250258 
    251259    ob->writenl(); 
    252260    } 
     261 
     262    return defer; 
    253263} 
    254264 
    255 void Import::semantic2(Scope *sc) 
     265DeferStatus<void> Import::semantic2(Scope *sc) 
    256266{ 
    257267    //printf("Import::semantic2('%s')\n", toChars()); 
    258268    mod->semantic2(); 
    259269    if (mod->needmoduleinfo) 
    260270    sc->module->needmoduleinfo = 1; 
     271    return nodefer(); 
    261272} 
    262273 
    263274Dsymbol *Import::toAlias() 
     
    302313    return result; 
    303314} 
    304315 
    305 Dsymbol *Import::search(Loc loc, Identifier *ident, int flags) 
     316DeferStatus<Dsymbol*> Import::search(Loc loc, Identifier *ident, int flags) 
    306317{ 
    307318    //printf("%s.Import::search(ident = '%s', flags = x%x)\n", toChars(), ident->toChars(), flags); 
    308319 
  • a/dmd/import.h

    old new  
    5252    const char *kind(); 
    5353    enum PROT prot(); 
    5454    Dsymbol *syntaxCopy(Dsymbol *s);    // copy only syntax trees 
    55     void load(Scope *sc); 
    56     void semantic(Scope *sc); 
    57     void semantic2(Scope *sc); 
     55    DeferStatus<void> load(Scope *sc); 
     56    DeferStatus<void> semantic(Scope *sc); 
     57    DeferStatus<void> semantic2(Scope *sc); 
    5858    Dsymbol *toAlias(); 
    5959    int addMember(Scope *sc, ScopeDsymbol *s, int memnum); 
    60     Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     60    DeferStatus<Dsymbol*> search(Loc loc, Identifier *ident, int flags); 
    6161    int overloadInsert(Dsymbol *s); 
    6262    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    6363 
  • a/dmd/init.c

    old new  
    3939    return this; 
    4040} 
    4141 
    42 Type *Initializer::inferType(Scope *sc) 
     42DeferStatus<Type*> Initializer::inferType(Scope *sc) 
    4343{ 
    4444    error(loc, "cannot infer type from initializer"); 
    4545    return Type::terror; 
     
    464464} 
    465465 
    466466 
    467 Type *ArrayInitializer::inferType(Scope *sc) 
     467DeferStatus<Type*> ArrayInitializer::inferType(Scope *sc) 
    468468{ 
    469469    for (size_t i = 0; i < value.dim; i++) 
    470470    { 
     
    563563    return this; 
    564564} 
    565565 
    566 Type *ExpInitializer::inferType(Scope *sc) 
     566DeferStatus<Type*> ExpInitializer::inferType(Scope *sc) 
    567567{ 
    568568    //printf("ExpInitializer::inferType() %s\n", toChars()); 
    569     exp = exp->semantic(sc); 
     569    DeferStatus<Expression*> ret = exp->semantic(sc); 
     570    if (ret.defer()) 
     571    return ret; 
     572    exp = ret; 
    570573    exp = resolveProperties(sc, exp); 
    571574 
    572575#if DMDV2 
  • a/dmd/init.h

    old new  
    3737    Initializer(Loc loc); 
    3838    virtual Initializer *syntaxCopy(); 
    3939    virtual Initializer *semantic(Scope *sc, Type *t); 
    40     virtual Type *inferType(Scope *sc); 
     40    virtual DeferStatus<Type*> inferType(Scope *sc); 
    4141    virtual Expression *toExpression() = 0; 
    4242    virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0; 
    4343    char *toChars(); 
     
    105105    Initializer *syntaxCopy(); 
    106106    void addInit(Expression *index, Initializer *value); 
    107107    Initializer *semantic(Scope *sc, Type *t); 
    108     Type *inferType(Scope *sc); 
     108    DeferStatus<Type*> inferType(Scope *sc); 
    109109    Expression *toExpression(); 
    110110    Initializer *toAssocArrayInitializer(); 
    111111    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
     
    125125    ExpInitializer(Loc loc, Expression *exp); 
    126126    Initializer *syntaxCopy(); 
    127127    Initializer *semantic(Scope *sc, Type *t); 
    128     Type *inferType(Scope *sc); 
     128    DeferStatus<Type*> inferType(Scope *sc); 
    129129    Expression *toExpression(); 
    130130    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
    131131 
  • a/dmd/module.c

    old new  
    6363DsymbolTable *Module::modules; 
    6464Array Module::amodules; 
    6565 
    66 Array Module::deferred;   // deferred Dsymbol's needing semantic() run on them 
     66std::deque<DeferredDsymbol> Module::deferred; // deferred Dsymbol's needing semantic() run on them 
    6767unsigned Module::dprogress; 
    6868 
    6969void Module::init() 
     
    148148    llvmForceLogging = false; 
    149149    this->doDocComment = doDocComment; 
    150150    this->doHdrGen = doHdrGen; 
     151    sc = NULL; 
    151152} 
    152153 
    153154File* Module::buildFilePath(const char* forcename, const char* path, const char* ext) 
     
    635636    } 
    636637} 
    637638 
    638 void Module::semantic(Scope* unused_sc) 
     639DeferStatus<void> Module::semantic(Scope* unused_sc) 
    639640{   int i; 
    640641 
    641     if (semanticstarted) 
    642     return; 
     642    // if already done or circular, bail out 
     643    if (semanticdone || semanticstarted == 1) 
     644    return nodefer(); 
    643645 
    644     //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); 
    645     semanticstarted = 1; 
     646    if (semanticstarted == 0) 
     647    { 
     648    //printf("+Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); 
     649    semanticstarted = 1; 
    646650 
    647     // Note that modules get their own scope, from scratch. 
    648     // This is so regardless of where in the syntax a module 
    649     // gets imported, it is unaffected by context. 
    650     Scope *sc = Scope::createGlobal(this);    // create root scope 
     651   // Note that modules get their own scope, from scratch. 
     652   // This is so regardless of where in the syntax a module 
     653   // gets imported, it is unaffected by context. 
     654   sc = Scope::createGlobal(this);    // create root scope 
    651655 
    652     //printf("Module = %p, linkage = %d\n", sc->scopesym, sc->linkage); 
     656   //printf("Module = %p, linkage = %d\n", sc->scopesym, sc->linkage); 
    653657 
    654     // Add import of "object" if this module isn't "object" 
    655     if (ident != Id::object) 
    656    
    657     Import *im = new Import(0, NULL, Id::object, NULL, 0); 
    658     members->shift(im); 
    659    
     658   // Add import of "object" if this module isn't "object" 
     659   if (ident != Id::object) 
     660   
     661        Import *im = new Import(0, NULL, Id::object, NULL, 0); 
     662        members->shift(im); 
     663   
    660664 
    661     // Add all symbols into module's symbol table 
    662     symtab = new DsymbolTable(); 
    663     for (i = 0; i < members->dim; i++) 
    664     { Dsymbol *s; 
     665   // Add all symbols into module's symbol table 
     666   symtab = new DsymbolTable(); 
     667   for (i = 0; i < members->dim; i++) 
     668   {  Dsymbol *s; 
    665669 
    666     s = (Dsymbol *)members->data[i]; 
    667     s->addMember(NULL, sc->scopesym, 1); 
     670        s = (Dsymbol *)members->data[i]; 
     671        s->addMember(NULL, sc->scopesym, 1); 
     672    } 
    668673    } 
    669674 
    670675    // Pass 1 semantic routines: do public side of the definition 
    671     for (i = 0; i < members->dim; i++) 
    672     {   Dsymbol *s; 
    673  
    674     s = (Dsymbol *)members->data[i]; 
    675     //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); 
    676     s->semantic(sc); 
    677     runDeferredSemantic(); 
     676    DeferStatus<void> res = callSemanticOnMembers(sc); 
     677    if (res.defer()) { 
     678        semanticstarted = -1; 
     679        return res; 
    678680    } 
    679681 
    680682    sc = sc->pop(); 
    681683    sc->pop(); 
    682     semanticdone = semanticstarted; 
     684    semanticstarted = 1; 
     685    semanticdone = 1; 
    683686    //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); 
     687    return nodefer(); 
    684688} 
    685689 
    686 void Module::semantic2(Scope* unused_sc) 
     690DeferStatus<void> Module::semantic2(Scope* unused_sc) 
    687691{   int i; 
    688692 
    689     if (deferred.dim
     693    if (!deferred.empty()
    690694    { 
    691     for (int i = 0; i < deferred.dim; i++) 
     695    for (int i = 0; i < deferred.size(); i++) 
    692696    { 
    693         Dsymbol *sd = (Dsymbol *)deferred.data[i]
     697        Dsymbol *sd = deferred[i].sym
    694698 
    695699        sd->error("unable to resolve forward reference in definition"); 
    696700    } 
    697     return
     701    return nodefer()
    698702    } 
    699703    //printf("Module::semantic2('%s'): parent = %p\n", toChars(), parent); 
    700704    if (semanticstarted >= 2) 
    701     return
     705    return nodefer()
    702706    assert(semanticstarted == 1); 
    703707    semanticstarted = 2; 
    704708 
     
    720724    sc->pop(); 
    721725    semanticdone = semanticstarted; 
    722726    //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent); 
     727    return nodefer(); 
    723728} 
    724729 
    725 void Module::semantic3(Scope* unused_sc) 
     730DeferStatus<void> Module::semantic3(Scope* unused_sc) 
    726731{   int i; 
    727732 
    728733    //printf("Module::semantic3('%s'): parent = %p\n", toChars(), parent); 
    729734    if (semanticstarted >= 3) 
    730     return
     735    return nodefer()
    731736    assert(semanticstarted == 2); 
    732737    semanticstarted = 3; 
    733738 
     
    749754    sc = sc->pop(); 
    750755    sc->pop(); 
    751756    semanticdone = semanticstarted; 
     757    return nodefer(); 
    752758} 
    753759 
    754760void Module::inlineScan() 
     
    814820    return needmoduleinfo; 
    815821} 
    816822 
    817 Dsymbol *Module::search(Loc loc, Identifier *ident, int flags) 
     823DeferStatus<Dsymbol*> Module::search(Loc loc, Identifier *ident, int flags) 
    818824{ 
    819825    /* Since modules can be circularly referenced, 
    820826     * need to stop infinite recursive searches. 
     
    832838    s = ScopeDsymbol::search(loc, ident, flags); 
    833839    insearch = 0; 
    834840 
     841    if (!s && semanticstarted == -1) 
     842        error("Forward reference!"); 
     843 
    835844    searchCacheIdent = ident; 
    836845    searchCacheSymbol = s; 
    837846    searchCacheFlags = flags; 
     
    843852 * Can't run semantic on s now, try again later. 
    844853 */ 
    845854 
    846 void Module::addDeferredSemantic(Dsymbol *s
     855void Module::addDeferredSemantic(Dsymbol *sym, Scope *scope
    847856{ 
    848857    // Don't add it if it is already there 
    849     for (int i = 0; i < deferred.dim; i++) 
     858    for (int i = 0; i < deferred.size(); i++) 
    850859    { 
    851     Dsymbol *sd = (Dsymbol *)deferred.data[i]
     860    Dsymbol *sd = (Dsymbol *)deferred[i].sym
    852861 
    853     if (sd == s
     862    if (sd == sym
    854863        return; 
    855864    } 
    856865 
     866    // copy scope 
     867    Scope* scx = new Scope(*scope); 
     868    scx->setNoFree(); 
     869 
    857870    //printf("Module::addDeferredSemantic('%s')\n", s->toChars()); 
    858     deferred.push(s); 
     871    deferred.push_back(DeferredDsymbol(sym, scx)); 
    859872} 
    860873 
    861874 
     
    865878 
    866879void Module::runDeferredSemantic() 
    867880{ 
    868     size_t len
     881    //if (deferred.dim) printf("+Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim)
    869882 
    870883    static int nested; 
    871884    if (nested) 
    872885    return; 
    873     //if (deferred.dim) printf("+Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); 
    874886    nested++; 
    875887 
    876     do 
    877     { 
    878     dprogress = 0; 
    879     len = deferred.dim; 
    880     if (!len) 
    881         break; 
     888    int failed = 0; 
    882889 
    883     Dsymbol **todo; 
    884     Dsymbol *tmp; 
    885     if (len == 1) 
     890    // last defer exception that was caught. stored for the error message inside 
     891    DeferStatus<void> lastdefer; 
     892 
     893    // if we deferred an order dependent member, save it here 
     894    // we will then skip all order dependent members until this is reached again 
     895    Dsymbol *deferredOrderDependent = NULL; 
     896 
     897    while (!deferred.empty() && failed != deferred.size()) 
     898    {   Dsymbol *s; 
     899    Scope *sc; 
     900    s = deferred[0].sym; 
     901    sc = deferred[0].scope; 
     902    deferred.pop_front(); 
     903 
     904    // if we deferred something order dependent, skip other 
     905    // order dependent ones for one iteration 
     906    if (deferredOrderDependent == s) 
     907        deferredOrderDependent = NULL; 
     908    if (deferredOrderDependent && !isMemberReorderable(s)) { 
     909        ++failed; 
     910        deferred.push_back(DeferredDsymbol(s, sc)); 
     911        continue; 
     912    } 
     913 
     914    DeferStatus<void> res = s->semantic(sc); 
     915    if (!res.defer()) 
    886916    { 
    887         todo = &tmp; 
     917        if (!deferred.empty() && deferred.rbegin()->sym == s) 
     918        ++failed; 
     919        else 
     920        failed = 0; 
    888921    } 
    889     else 
     922    else  
    890923    { 
    891         todo = (Dsymbol **)alloca(len * sizeof(Dsymbol *)); 
    892         assert(todo); 
     924        lastdefer = res; 
     925        ++failed; 
     926        deferred.push_back(DeferredDsymbol(s, sc)); 
     927        if (!isMemberReorderable(s)) 
     928        deferredOrderDependent = s; 
     929        continue; 
    893930    } 
    894     memcpy(todo, deferred.data, len * sizeof(Dsymbol *)); 
    895     deferred.setDim(0); 
     931    } 
    896932 
    897     for (int i = 0; i < len; i++) 
    898     { 
    899         Dsymbol *s = todo[i]; 
    900  
    901         s->semantic(NULL); 
    902         //printf("deferred: %s, parent = %s\n", s->toChars(), s->parent->toChars()); 
    903     } 
    904     //printf("\tdeferred.dim = %d, len = %d, dprogress = %d\n", deferred.dim, len, dprogress); 
    905     } while (deferred.dim < len || dprogress);  // while making progress 
    906933    nested--; 
    907934    //printf("-Module::runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); 
    908935} 
  • a/dmd/module.h

    old new  
    1717 
    1818#include "root.h" 
    1919#include "dsymbol.h" 
     20#include <deque> 
    2021 
    2122struct ModuleInfoDeclaration; 
    2223struct ClassDeclaration; 
     
    4142#endif 
    4243#endif 
    4344 
     45// The global list of out-of-order deferred Dsymbols 
     46// contains elements of this type. In addition to the 
     47// Dsymbol, they hold the scope that's to be used for 
     48// the deferred semantic call. 
     49struct DeferredDsymbol 
     50{ 
     51    DeferredDsymbol(Dsymbol* sym_, Scope* scope_) 
     52    : sym(sym_), scope(scope_) {} 
     53 
     54    Dsymbol* sym; 
     55    Scope* scope; 
     56}; 
     57 
    4458struct Package : ScopeDsymbol 
    4559{ 
    4660    Package(Identifier *ident); 
     
    5064 
    5165    Package *isPackage() { return this; } 
    5266 
    53     virtual void semantic(Scope *sc) {
     67    virtual DeferStatus<void> semantic(Scope *sc) { return nodefer();
    5468}; 
    5569 
    5670struct Module : Package 
     
    5872    static Module *rootModule; 
    5973    static DsymbolTable *modules;   // symbol table of all modules 
    6074    static Array amodules;      // array of all modules 
    61     static Array deferred;    // deferred Dsymbol's needing semantic() run on them 
     75    static std::deque<DeferredDsymbol> deferred;  // deferred Dsymbol's needing semantic() run on them 
    6276    static unsigned dprogress;  // progress resolving the deferred list 
    6377    static void init(); 
    6478 
     
    132146#else 
    133147    void parse();   // syntactic parse 
    134148#endif 
    135     void semantic(Scope* unused_sc = NULL);   // semantic analysis 
    136     void semantic2(Scope* unused_sc = NULL);  // pass 2 semantic analysis 
    137     void semantic3(Scope* unused_sc = NULL);  // pass 3 semantic analysis 
     149    DeferStatus<void> semantic(Scope* unused_sc = NULL);  // semantic analysis 
     150    DeferStatus<void> semantic2(Scope* unused_sc = NULL); // pass 2 semantic analysis 
     151    DeferStatus<void> semantic3(Scope* unused_sc = NULL); // pass 3 semantic analysis 
    138152    void inlineScan();  // scan for functions to inline 
    139153#ifdef _DH 
    140154    void genhdrfile();  // generate D import file 
     
    142156//    void gensymfile(); 
    143157    void gendocfile(); 
    144158    int needModuleInfo(); 
    145     Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     159    DeferStatus<Dsymbol*> search(Loc loc, Identifier *ident, int flags); 
    146160    void deleteObjFile(); 
    147     void addDeferredSemantic(Dsymbol *s); 
     161    void addDeferredSemantic(Dsymbol *sym, Scope* scope); 
    148162    void runDeferredSemantic(); 
    149163    int imports(Module *m); 
    150164 
     
    188202    // array ops emitted in this module already 
    189203    StringTable arrayfuncs; 
    190204#endif 
     205 
     206    // LDC 
     207    virtual void postMemberSemantic(Scope* sc) { runDeferredSemantic(); } 
     208    Scope* sc; 
    191209}; 
    192210 
    193211 
  • a/dmd/mtype.c

    old new  
    307307    return size(0); 
    308308} 
    309309 
    310 Type *Type::semantic(Loc loc, Scope *sc) 
     310DeferStatus<Type*> Type::semantic(Loc loc, Scope *sc) 
    311311{ 
    312312    if (next) 
    313313    next = next->semantic(loc,sc); 
     
    676676    return e; 
    677677} 
    678678 
    679 Expression *Type::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     679DeferStatus<Expression*> Type::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    680680{   VarDeclaration *v = NULL; 
    681681 
    682682#if LOGDOTEXP 
     
    820820} 
    821821 
    822822 
    823 void Type::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
     823DeferStatus<void> Type::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
    824824{ 
    825825    //printf("Type::resolve() %s, %d\n", toChars(), ty); 
    826826    Type *t = semantic(loc, sc); 
    827827    *pt = t; 
    828828    *pe = NULL; 
    829829    *ps = NULL; 
     830    return nodefer(); 
    830831} 
    831832 
    832833/******************************* 
     
    13391340    return e; 
    13401341} 
    13411342 
    1342 Expression *TypeBasic::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     1343DeferStatus<Expression*> TypeBasic::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    13431344{ 
    13441345#if LOGDOTEXP 
    13451346    printf("TypeBasic::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
     
    15851586{ 
    15861587} 
    15871588 
    1588 Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     1589DeferStatus<Expression*> TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    15891590{ 
    15901591    Type *n = this->next->toBasetype();     // uncover any typedef's 
    15911592 
     
    18041805 * This evaluates exp while setting length to be the number 
    18051806 * of elements in the tuple t. 
    18061807 */ 
    1807 Expression *semanticLength(Scope *sc, Type *t, Expression *exp) 
    1808 
     1808DeferStatus<Expression*> semanticLength(Scope *sc, Type *t, Expression *exp) 
     1809
     1810    DeferStatus<Expression*> ret; 
    18091811    if (t->ty == Ttuple) 
    18101812    {   ScopeDsymbol *sym = new ArrayScopeSymbol((TypeTuple *)t); 
    18111813    sym->parent = sc->scopesym; 
    18121814    sc = sc->push(sym); 
    18131815 
    1814     exp = exp->semantic(sc); 
     1816    ret = exp->semantic(sc); 
    18151817 
    18161818    sc->pop(); 
    18171819    } 
    18181820    else 
    1819     exp = exp->semantic(sc); 
    1820     return exp
    1821 } 
    1822  
    1823 Expression *semanticLength(Scope *sc, TupleDeclaration *s, Expression *exp) 
     1821    ret = exp->semantic(sc); 
     1822    return ret
     1823} 
     1824 
     1825DeferStatus<Expression*> semanticLength(Scope *sc, TupleDeclaration *s, Expression *exp) 
    18241826{ 
    18251827    ScopeDsymbol *sym = new ArrayScopeSymbol(s); 
    18261828    sym->parent = sc->scopesym; 
    18271829    sc = sc->push(sym); 
    18281830 
    1829     exp = exp->semantic(sc); 
     1831    DeferStatus<Expression*> ret = exp->semantic(sc); 
    18301832 
    18311833    sc->pop(); 
    1832     return exp
    1833 } 
    1834  
    1835 void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
     1834    return ret
     1835} 
     1836 
     1837DeferStatus<void> TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
    18361838{ 
    18371839    //printf("TypeSArray::resolve() %s\n", toChars()); 
    18381840    next->resolve(loc, sc, pe, pt, ps); 
     
    18661868        if (o->dyncast() == DYNCAST_DSYMBOL) 
    18671869        { 
    18681870        *ps = (Dsymbol *)o; 
    1869         return
     1871        return nodefer()
    18701872        } 
    18711873        if (o->dyncast() == DYNCAST_EXPRESSION) 
    18721874        { 
    18731875        *ps = NULL; 
    18741876        *pe = (Expression *)o; 
    1875         return
     1877        return nodefer()
    18761878        } 
    18771879 
    18781880        /* Create a new TupleDeclaration which 
     
    18931895    else 
    18941896    { 
    18951897     Ldefault: 
    1896     Type::resolve(loc, sc, pe, pt, ps); 
    1897     } 
    1898 
    1899  
    1900 Type *TypeSArray::semantic(Loc loc, Scope *sc) 
     1898    return Type::resolve(loc, sc, pe, pt, ps); 
     1899    } 
     1900    return nodefer(); 
     1901
     1902 
     1903DeferStatus<Type*> TypeSArray::semantic(Loc loc, Scope *sc) 
    19011904{ 
    19021905    //printf("TypeSArray::semantic() %s\n", toChars()); 
    19031906 
     
    19081911    if (dim && s && s->isTupleDeclaration()) 
    19091912    {   TupleDeclaration *sd = s->isTupleDeclaration(); 
    19101913 
    1911     dim = semanticLength(sc, sd, dim); 
    1912     dim = dim->optimize(WANTvalue | WANTinterpret); 
     1914    DeferStatus<Expression*> ret = semanticLength(sc, sd, dim); 
     1915    if (ret.defer()) return ret; 
     1916    dim = ret->optimize(WANTvalue | WANTinterpret); 
    19131917    uinteger_t d = dim->toUInteger(); 
    19141918 
    19151919    if (d >= sd->objects->dim) 
     
    19311935    if (dim) 
    19321936    {   dinteger_t n, n2; 
    19331937 
    1934     dim = semanticLength(sc, tbn, dim); 
    1935  
    1936     dim = dim->optimize(WANTvalue | WANTinterpret); 
     1938    DeferStatus<Expression*> ret = semanticLength(sc, tbn, dim); 
     1939    if (ret.defer()) return ret; 
     1940    dim = ret->optimize(WANTvalue | WANTinterpret); 
    19371941    if (sc && sc->parameterSpecialization && dim->op == TOKvar && 
    19381942        ((VarExp *)dim)->var->storage_class & STCtemplateparameter) 
    19391943    { 
     
    20202024    buf->printf("[%s]", dim->toChars()); 
    20212025} 
    20222026 
    2023 Expression *TypeSArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     2027DeferStatus<Expression*> TypeSArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    20242028{ 
    20252029#if LOGDOTEXP 
    20262030    printf("TypeSArray::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
     
    21452149    return PTRSIZE; 
    21462150} 
    21472151 
    2148 Type *TypeDArray::semantic(Loc loc, Scope *sc) 
     2152DeferStatus<Type*> TypeDArray::semantic(Loc loc, Scope *sc) 
    21492153{   Type *tn = next; 
    21502154 
    21512155    tn = next->semantic(loc,sc); 
     
    21842188    buf->writestring("[]"); 
    21852189} 
    21862190 
    2187 Expression *TypeDArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     2191DeferStatus<Expression*> TypeDArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    21882192{ 
    21892193#if LOGDOTEXP 
    21902194    printf("TypeDArray::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
     
    22922296} 
    22932297 
    22942298 
    2295 Type *TypeAArray::semantic(Loc loc, Scope *sc) 
     2299DeferStatus<Type*> TypeAArray::semantic(Loc loc, Scope *sc) 
    22962300{ 
    22972301    //printf("TypeAArray::semantic() %s index->ty = %d\n", toChars(), index->ty); 
    22982302 
     
    23642368    return merge(); 
    23652369} 
    23662370 
    2367 void TypeAArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
     2371DeferStatus<void> TypeAArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
    23682372{ 
    23692373    //printf("TypeAArray::resolve() %s\n", toChars()); 
    23702374 
     
    23892393    else 
    23902394        index->error(loc, "index is not a type or an expression"); 
    23912395    } 
    2392     Type::resolve(loc, sc, pe, pt, ps); 
    2393 } 
    2394  
    2395  
    2396 Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     2396    return Type::resolve(loc, sc, pe, pt, ps); 
     2397} 
     2398 
     2399 
     2400DeferStatus<Expression*> TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    23972401{ 
    23982402#if LOGDOTEXP 
    23992403    printf("TypeAArray::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
     
    25552559    return t; 
    25562560} 
    25572561 
    2558 Type *TypePointer::semantic(Loc loc, Scope *sc) 
     2562DeferStatus<Type*> TypePointer::semantic(Loc loc, Scope *sc) 
    25592563{ 
    25602564    //printf("TypePointer::semantic()\n"); 
    25612565    Type *n = next->semantic(loc, sc); 
     
    26822686    buf->writeByte('&'); 
    26832687} 
    26842688 
    2685 Expression *TypeReference::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     2689DeferStatus<Expression*> TypeReference::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    26862690{ 
    26872691#if LOGDOTEXP 
    26882692    printf("TypeReference::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
     
    29562960    inuse--; 
    29572961} 
    29582962 
    2959 Type *TypeFunction::semantic(Loc loc, Scope *sc) 
     2963DeferStatus<Type*> TypeFunction::semantic(Loc loc, Scope *sc) 
    29602964{ 
    29612965    if (deco)           // if semantic() already run 
    29622966    { 
     
    30073011        Type *t; 
    30083012 
    30093013        tf->inuse++; 
    3010         arg->type = arg->type->semantic(loc,sc); 
     3014        DeferStatus<Type*> ret = arg->type->semantic(loc,sc); 
     3015        if (ret.defer()) return ret; 
     3016        arg->type = ret; 
    30113017        if (tf->inuse == 1) tf->inuse--; 
    30123018 
    30133019        // each function needs its own copy of a tuple arg, since 
     
    32173223    return t; 
    32183224} 
    32193225 
    3220 Type *TypeDelegate::semantic(Loc loc, Scope *sc) 
     3226DeferStatus<Type*> TypeDelegate::semantic(Loc loc, Scope *sc) 
    32213227{ 
    32223228    if (deco)           // if semantic() already run 
    32233229    { 
     
    32753281    return TRUE; 
    32763282} 
    32773283 
    3278 Expression *TypeDelegate::dotExp(Scope *sc, Expression *e, Identifier *ident) 
     3284DeferStatus<Expression*> TypeDelegate::dotExp(Scope *sc, Expression *e, Identifier *ident) 
    32793285{ 
    32803286#if LOGDOTEXP 
    32813287    printf("TypeDelegate::dotExp(e = '%s', ident = '%s')\n", e->toChars(), ident->toChars()); 
     
    33713377 *  if type, *pt is set 
    33723378 */ 
    33733379 
    3374 void TypeQualified::resolveHelper(Loc loc, Scope *sc, 
     3380DeferStatus<void> TypeQualified::resolveHelper(Loc loc, Scope *sc, 
    33753381    Dsymbol *s, Dsymbol *scopesym, 
    33763382    Expression **pe, Type **pt, Dsymbol **ps) 
    33773383{ 
     
    34013407    {   Dsymbol *sm; 
    34023408 
    34033409