Changeset 205

Show
Ignore:
Timestamp:
10/13/09 09:49:25 (2 years ago)
Author:
walter
Message:

fix QtD hang problem, fold in Rainer Schuetze's Bugzilla 1170 patch

Files:

Legend:

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

    r203 r205  
    477477    if (!isAnonymous())     // no name, so can't add it to symbol table 
    478478    { 
    479     if (!sd->symtab->insert(this))    // if name is already defined 
     479    if (!sd->symtabInsert(this))  // if name is already defined 
    480480    { 
    481481        Dsymbol *s2; 
     
    870870} 
    871871 
     872Dsymbol *ScopeDsymbol::symtabInsert(Dsymbol *s) 
     873{ 
     874    return symtab->insert(s); 
     875} 
     876 
     877/*************************************** 
     878 * Determine number of Dsymbols, folding in AttribDeclaration members. 
     879 */ 
     880 
     881#if DMDV2 
     882size_t ScopeDsymbol::dim(Array *members) 
     883{ 
     884    size_t n = 0; 
     885    if (members) 
     886    { 
     887    for (size_t i = 0; i < members->dim; i++) 
     888    {   Dsymbol *s = (Dsymbol *)members->data[i]; 
     889        AttribDeclaration *a = s->isAttribDeclaration(); 
     890 
     891        if (a) 
     892        { 
     893        n += dim(a->decl); 
     894        } 
     895        else 
     896        n++; 
     897    } 
     898    } 
     899    return n; 
     900} 
     901#endif 
     902 
     903/*************************************** 
     904 * Get nth Dsymbol, folding in AttribDeclaration members. 
     905 * Returns: 
     906 *  Dsymbol*    nth Dsymbol 
     907 *  NULL        not found, *pn gets incremented by the number 
     908 *          of Dsymbols 
     909 */ 
     910 
     911#if DMDV2 
     912Dsymbol *ScopeDsymbol::getNth(Array *members, size_t nth, size_t *pn) 
     913{ 
     914    if (!members) 
     915    return NULL; 
     916 
     917    size_t n = 0; 
     918    for (size_t i = 0; i < members->dim; i++) 
     919    {   Dsymbol *s = (Dsymbol *)members->data[i]; 
     920    AttribDeclaration *a = s->isAttribDeclaration(); 
     921 
     922    if (a) 
     923    { 
     924        s = getNth(a->decl, nth - n, &n); 
     925        if (s) 
     926        return s; 
     927    } 
     928    else if (n == nth) 
     929        return s; 
     930    else 
     931        n++; 
     932    } 
     933 
     934    if (pn) 
     935    *pn += n; 
     936    return NULL; 
     937} 
     938#endif 
    872939 
    873940/******************************************* 
  • branches/dmd-1.x/src/dsymbol.h

    r204 r205  
    250250    const char *kind(); 
    251251    FuncDeclaration *findGetMembers(); 
     252    virtual Dsymbol *symtabInsert(Dsymbol *s); 
    252253 
    253254    void emitMemberComments(Scope *sc); 
  • branches/dmd-1.x/src/mars.c

    r204 r205  
    8181#endif 
    8282    ; 
    83     version = "v1.049"; 
     83    version = "v1.050"; 
    8484    global.structalign = 8; 
    8585 
  • branches/dmd-1.x/src/module.c

    r203 r205  
    110110    macrotable = NULL; 
    111111    escapetable = NULL; 
     112    safe = FALSE; 
    112113    doppelganger = 0; 
    113114    cov = NULL; 
     
    810811 
    811812void Module::inlineScan() 
    812 {   int i; 
    813  
     813
    814814    if (semanticstarted >= 4) 
    815815    return; 
     
    822822    //printf("Module = %p\n", sc.scopesym); 
    823823 
    824     for (i = 0; i < members->dim; i++) 
    825     {   Dsymbol *s; 
    826  
    827     s = (Dsymbol *)members->data[i]; 
     824    for (int i = 0; i < members->dim; i++) 
     825    {   Dsymbol *s = (Dsymbol *)members->data[i]; 
    828826    //if (global.params.verbose) 
    829827        //printf("inline scan symbol %s\n", s->toChars()); 
     
    874872    /* Since modules can be circularly referenced, 
    875873     * need to stop infinite recursive searches. 
     874     * This is done with the cache. 
    876875     */ 
    877876 
     
    880879    if (insearch) 
    881880    s = NULL; 
    882     else if (searchCacheIdent == ident && searchCacheFlags == flags && searchCacheSymbol
     881    else if (searchCacheIdent == ident && searchCacheFlags == flags
    883882    { 
    884883    s = searchCacheSymbol; 
     
    897896    return s; 
    898897} 
     898 
     899Dsymbol *Module::symtabInsert(Dsymbol *s) 
     900{ 
     901    searchCacheIdent = 0;   // symbol is inserted, so invalidate cache 
     902    return Package::symtabInsert(s); 
     903} 
     904 
    899905 
    900906/******************************************* 
  • branches/dmd-1.x/src/module.h

    r204 r205  
    107107    Macro *macrotable;      // document comment macros 
    108108    Escape *escapetable;    // document comment escapes 
     109    bool safe;          // TRUE if module is marked as 'safe' 
    109110 
    110111    Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); 
     
    137138    int needModuleInfo(); 
    138139    Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     140    Dsymbol *symtabInsert(Dsymbol *s); 
    139141    void deleteObjFile(); 
    140142    void addDeferredSemantic(Dsymbol *s); 
     
    177179    Identifier *id; 
    178180    Array *packages;        // array of Identifier's representing packages 
     181    bool safe; 
    179182 
    180183    ModuleDeclaration(Array *packages, Identifier *id); 
  • branches/dmd-1.x/src/scope.c

    r190 r205  
    283283        if (!sc->scopesym->symtab) 
    284284        sc->scopesym->symtab = new DsymbolTable(); 
    285         return sc->scopesym->symtab->insert(s); 
     285        return sc->scopesym->symtabInsert(s); 
    286286    } 
    287287    } 
  • branches/dmd-1.x/src/typinf.c

    r196 r205  
    428428    TypeDelegate *tc = (TypeDelegate *)tinfo; 
    429429 
    430     tc->next->next->getTypeInfo(NULL); 
    431     dtxoff(pdt, tc->next->next->vtinfo->toSymbol(), 0, TYnptr); // TypeInfo for delegate return value 
     430    tc->next->nextOf()->getTypeInfo(NULL); 
     431    dtxoff(pdt, tc->next->nextOf()->vtinfo->toSymbol(), 0, TYnptr); // TypeInfo for delegate return value 
    432432} 
    433433 
     
    847847    v = new VarDeclaration(0, t, id, ai); 
    848848    m->members->push(v); 
    849     m->symtab->insert(v); 
     849    m->symtabInsert(v); 
    850850    sc = sc->push(); 
    851851    sc->linkage = LINKc; 
  • trunk/src/dsymbol.c

    r203 r205  
    477477    if (!isAnonymous())     // no name, so can't add it to symbol table 
    478478    { 
    479     if (!sd->symtab->insert(this))    // if name is already defined 
     479    if (!sd->symtabInsert(this))  // if name is already defined 
    480480    { 
    481481        Dsymbol *s2; 
     
    908908} 
    909909 
     910Dsymbol *ScopeDsymbol::symtabInsert(Dsymbol *s) 
     911{ 
     912    return symtab->insert(s); 
     913} 
    910914 
    911915/*************************************** 
     
    913917 */ 
    914918 
     919#if DMDV2 
    915920size_t ScopeDsymbol::dim(Array *members) 
    916921{ 
     
    932937    return n; 
    933938} 
     939#endif 
    934940 
    935941/*************************************** 
     
    941947 */ 
    942948 
     949#if DMDV2 
    943950Dsymbol *ScopeDsymbol::getNth(Array *members, size_t nth, size_t *pn) 
    944951{ 
     
    967974    return NULL; 
    968975} 
     976#endif 
    969977 
    970978/******************************************* 
  • trunk/src/dsymbol.h

    r204 r205  
    250250    const char *kind(); 
    251251    FuncDeclaration *findGetMembers(); 
     252    virtual Dsymbol *symtabInsert(Dsymbol *s); 
    252253 
    253254    void emitMemberComments(Scope *sc); 
  • trunk/src/mars.c

    r204 r205  
    8181#endif 
    8282    ; 
    83     version = "v2.035"; 
     83    version = "v2.036"; 
    8484    global.structalign = 8; 
    8585 
  • trunk/src/module.c

    r204 r205  
    876876    /* Since modules can be circularly referenced, 
    877877     * need to stop infinite recursive searches. 
     878     * This is done with the cache. 
    878879     */ 
    879880 
     
    882883    if (insearch) 
    883884    s = NULL; 
    884     else if (searchCacheIdent == ident && searchCacheFlags == flags && searchCacheSymbol
     885    else if (searchCacheIdent == ident && searchCacheFlags == flags
    885886    { 
    886887    s = searchCacheSymbol; 
     
    899900    return s; 
    900901} 
     902 
     903Dsymbol *Module::symtabInsert(Dsymbol *s) 
     904{ 
     905    searchCacheIdent = 0;   // symbol is inserted, so invalidate cache 
     906    return Package::symtabInsert(s); 
     907} 
     908 
    901909 
    902910/******************************************* 
  • trunk/src/module.h

    r204 r205  
    138138    int needModuleInfo(); 
    139139    Dsymbol *search(Loc loc, Identifier *ident, int flags); 
     140    Dsymbol *symtabInsert(Dsymbol *s); 
    140141    void deleteObjFile(); 
    141142    void addDeferredSemantic(Dsymbol *s); 
  • trunk/src/scope.c

    r192 r205  
    283283        if (!sc->scopesym->symtab) 
    284284        sc->scopesym->symtab = new DsymbolTable(); 
    285         return sc->scopesym->symtab->insert(s); 
     285        return sc->scopesym->symtabInsert(s); 
    286286    } 
    287287    } 
  • trunk/src/typinf.c

    r195 r205  
    880880    v = new VarDeclaration(0, t, id, ai); 
    881881    m->members->push(v); 
    882     m->symtab->insert(v); 
     882    m->symtabInsert(v); 
    883883    sc = sc->push(); 
    884884    sc->linkage = LINKc;