Skip to content

Commit

Permalink
Supply scope for addMember call
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Apr 30, 2014
1 parent 1672505 commit 15caf0c
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions src/module.c
Expand Up @@ -193,16 +193,14 @@ const char *Module::kind()
}

Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident)
{ Module *m;
char *filename;

{
//printf("Module::load(ident = '%s')\n", ident->toChars());

// Build module filename by turning:
// foo.bar.baz
// into:
// foo\bar\baz
filename = ident->toChars();
char *filename = ident->toChars();
if (packages && packages->dim)
{
OutBuffer buf;
Expand All @@ -222,7 +220,7 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident)
filename = (char *)buf.extractData();
}

m = new Module(filename, ident, 0, 0);
Module *m = new Module(filename, ident, 0, 0);
m->loc = loc;

/* Look for the source file
Expand All @@ -237,7 +235,8 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident)
if (packages)
{
for (size_t i = 0; i < packages->dim; i++)
{ Identifier *pid = (*packages)[i];
{
Identifier *pid = (*packages)[i];
fprintf(global.stdmsg, "%s.", pid->toChars());
}
}
Expand Down Expand Up @@ -663,7 +662,7 @@ void Module::importAll(Scope *prevsc)
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(NULL, sc->scopesym, 1);
s->addMember(sc, sc->scopesym, 1);
}
}
// anything else should be run after addMember, so version/debug symbols are defined
Expand Down Expand Up @@ -709,34 +708,6 @@ void Module::semantic()

//printf("Module = %p, linkage = %d\n", sc->scopesym, sc->linkage);

#if 0
// Add import of "object" if this module isn't "object"
if (ident != Id::object)
{
Import *im = new Import(0, NULL, Id::object, NULL, 0);
members->shift(im);
}

// Add all symbols into module's symbol table
symtab = new DsymbolTable();
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *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 (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (Dsymbol *)members->data[i];
s->setScope(sc);
}
#endif

// Pass 1 semantic routines: do public side of the definition
for (size_t i = 0; i < members->dim; i++)
{
Expand Down

0 comments on commit 15caf0c

Please sign in to comment.