Mercurial > projects > ldc
diff dmd2/module.c @ 1526:54b3c1394d62
Merged dmdfe 2.031.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 07 Jul 2009 02:26:11 +0100 |
parents | 638d16625da2 |
children |
line wrap: on
line diff
--- a/dmd2/module.c Mon Jul 06 23:57:27 2009 +0100 +++ b/dmd2/module.c Tue Jul 07 02:26:11 2009 +0100 @@ -99,7 +99,7 @@ searchCacheSymbol = NULL; searchCacheFlags = 0; semanticstarted = 0; - semanticdone = 0; + semanticRun = 0; decldefs = NULL; vmoduleinfo = NULL; #if IN_DMD @@ -770,25 +770,32 @@ // Add all symbols into module's symbol table symtab = new DsymbolTable(); for (i = 0; i < members->dim; i++) - { Dsymbol *s; + { Dsymbol *s = (Dsymbol *)members->data[i]; + s->addMember(NULL, sc->scopesym, 1); + } - s = (Dsymbol *)members->data[i]; - s->addMember(NULL, sc->scopesym, 1); + /* Set scope for the symbols so that if we forward reference + * a symbol, it can possibly be resolved on the spot. + * If this works out well, it can be extended to all modules + * before any semantic() on any of them. + */ + for (i = 0; i < members->dim; i++) + { Dsymbol *s = (Dsymbol *)members->data[i]; + s->setScope(sc); } // Pass 1 semantic routines: do public side of the definition for (i = 0; i < members->dim; i++) - { Dsymbol *s; + { Dsymbol *s = (Dsymbol *)members->data[i]; - s = (Dsymbol *)members->data[i]; //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); s->semantic(sc); runDeferredSemantic(); } sc = sc->pop(); - sc->pop(); - semanticdone = semanticstarted; + sc->pop(); // 2 pops because Scope::createGlobal() created 2 + semanticRun = semanticstarted; //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); } @@ -827,7 +834,7 @@ sc = sc->pop(); sc->pop(); - semanticdone = semanticstarted; + semanticRun = semanticstarted; //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent); } @@ -857,7 +864,7 @@ sc = sc->pop(); sc->pop(); - semanticdone = semanticstarted; + semanticRun = semanticstarted; } void Module::inlineScan() @@ -882,7 +889,7 @@ s->inlineScan(); } - semanticdone = semanticstarted; + semanticRun = semanticstarted; } /**************************************************** @@ -1143,11 +1150,14 @@ else { assert(p->isPackage()); +#if TARGET_NET //dot net needs modules and packages with same name +#else if (p->isModule()) { p->error("module and package have the same name"); fatal(); break; } +#endif } parent = p; dst = ((Package *)p)->symtab;