Skip to content

Commit

Permalink
remove unused memnum/return value of ::addMember
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed May 14, 2015
1 parent 4982d13 commit 904c411
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 77 deletions.
35 changes: 8 additions & 27 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ Scope *AttribDeclaration::newScope(Scope *sc)
return sc;
}

int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sds)
{
int m = 0;
Dsymbols *d = include(sc, sds);

if (d)
Expand All @@ -113,13 +112,12 @@ int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
{
Dsymbol *s = (*d)[i];
//printf("\taddMember %s to %s\n", s->toChars(), sds->toChars());
m |= s->addMember(sc2, sds, m | memnum);
s->addMember(sc2, sds);
}

if (sc2 != sc)
sc2->pop();
}
return m;
}

void AttribDeclaration::setScope(Scope *sc)
Expand Down Expand Up @@ -585,7 +583,7 @@ Scope *ProtDeclaration::newScope(Scope *sc)
return createNewScope(sc, sc->stc, sc->linkage, this->protection, 1, sc->structalign);
}

int ProtDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void ProtDeclaration::addMember(Scope *sc, ScopeDsymbol *sds)
{
if (pkg_identifiers)
{
Expand All @@ -604,7 +602,7 @@ int ProtDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
m->toPrettyChars(true));
}

return AttribDeclaration::addMember(sc, sds, memnum);
return AttribDeclaration::addMember(sc, sds);
}

const char *ProtDeclaration::kind()
Expand Down Expand Up @@ -1199,7 +1197,7 @@ Dsymbols *StaticIfDeclaration::include(Scope *sc, ScopeDsymbol *sds)
for (size_t i = 0; i < d->dim; i++)
{
Dsymbol *s = (*d)[i];
s->addMember(scope, scopesym, 1);
s->addMember(scope, scopesym);
}

// Set the member scopes lazily.
Expand All @@ -1219,7 +1217,7 @@ Dsymbols *StaticIfDeclaration::include(Scope *sc, ScopeDsymbol *sds)
}
}

int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sds)
{
//printf("StaticIfDeclaration::addMember() '%s'\n", toChars());
/* This is deferred until the condition evaluated later (by the include() call),
Expand All @@ -1234,8 +1232,6 @@ int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
* }
*/
this->scopesym = sds;

return 0;
}

void StaticIfDeclaration::importAll(Scope *sc)
Expand Down Expand Up @@ -1281,25 +1277,10 @@ Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s)
return new CompileDeclaration(loc, exp->syntaxCopy());
}

int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sds)
{
//printf("CompileDeclaration::addMember(sc = %p, sds = %p, memnum = %d)\n", sc, sds, memnum);
#if 0
if (compiled)
return 1;
#endif
this->scopesym = sds;
#if 0
if (memnum == 0)
{
/* No members yet, so parse the mixin now
*/
compileIt(sc);
memnum |= AttribDeclaration::addMember(sc, sds, memnum);
compiled = 1;
}
#endif
return memnum;
}

void CompileDeclaration::setScope(Scope *sc)
Expand Down Expand Up @@ -1347,7 +1328,7 @@ void CompileDeclaration::semantic(Scope *sc)
if (!compiled)
{
compileIt(sc);
AttribDeclaration::addMember(sc, scopesym, 0);
AttribDeclaration::addMember(sc, scopesym);
compiled = 1;

if (scope && decl)
Expand Down
8 changes: 4 additions & 4 deletions src/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AttribDeclaration : public Dsymbol
StorageClass newstc, LINK linkage, Prot protection, int explictProtection,
structalign_t structalign);
virtual Scope *newScope(Scope *sc);
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
void setScope(Scope *sc);
void importAll(Scope *sc);
void semantic(Scope *sc);
Expand Down Expand Up @@ -107,7 +107,7 @@ class ProtDeclaration : public AttribDeclaration

Dsymbol *syntaxCopy(Dsymbol *s);
Scope *newScope(Scope *sc);
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
const char *kind();
const char *toPrettyChars(bool unused);
void accept(Visitor *v) { v->visit(this); }
Expand Down Expand Up @@ -176,7 +176,7 @@ class StaticIfDeclaration : public ConditionalDeclaration
StaticIfDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl);
Dsymbol *syntaxCopy(Dsymbol *s);
Dsymbols *include(Scope *sc, ScopeDsymbol *sds);
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
void semantic(Scope *sc);
void importAll(Scope *sc);
void setScope(Scope *sc);
Expand All @@ -196,7 +196,7 @@ class CompileDeclaration : public AttribDeclaration

CompileDeclaration(Loc loc, Expression *exp);
Dsymbol *syntaxCopy(Dsymbol *s);
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
void setScope(Scope *sc);
void compileIt(Scope *sc);
void semantic(Scope *sc);
Expand Down
6 changes: 3 additions & 3 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void ClassDeclaration::semantic(Scope *sc)
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(sc, this, 1);
s->addMember(sc, this);
}

Scope *sc2 = sc->push(this);
Expand Down Expand Up @@ -782,7 +782,7 @@ void ClassDeclaration::semantic(Scope *sc)
CtorDeclaration *ctor = new CtorDeclaration(loc, Loc(), 0, tf);
ctor->fbody = new CompoundStatement(Loc(), new Statements());
members->push(ctor);
ctor->addMember(sc, this, 1);
ctor->addMember(sc, this);
ctor->semantic(sc2);
this->ctor = ctor;
defaultCtor = ctor;
Expand Down Expand Up @@ -1540,7 +1540,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(sc, this, 1);
s->addMember(sc, this);
}

Scope *sc2 = sc->push(this);
Expand Down
2 changes: 1 addition & 1 deletion src/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ FuncDeclaration *buildOpAssign(StructDeclaration *sd, Scope *sc)
}

sd->members->push(fop);
fop->addMember(sc, sd, 1);
fop->addMember(sc, sd);
sd->hasIdentityAssign = true; // temporary mark identity assignable

unsigned errors = global.startGagging(); // Do not report errors, even if the
Expand Down
4 changes: 1 addition & 3 deletions src/dsymbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ int Dsymbol::apply(Dsymbol_apply_ft_t fp, void *param)
return (*fp)(this, param);
}

int Dsymbol::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void Dsymbol::addMember(Scope *sc, ScopeDsymbol *sds)
{
//printf("Dsymbol::addMember('%s')\n", toChars());
//printf("Dsymbol::addMember(this = %p, '%s' scopesym = '%s')\n", this, toChars(), sds->toChars());
Expand All @@ -701,9 +701,7 @@ int Dsymbol::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
if (ident == Id::__sizeof || ident == Id::__xalignof || ident == Id::mangleof)
error(".%s property cannot be redefined", ident->toChars());
}
return 1;
}
return 0;
}

void Dsymbol::error(const char *format, ...)
Expand Down
2 changes: 1 addition & 1 deletion src/dsymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class Dsymbol : public RootObject
virtual const char *kind();
virtual Dsymbol *toAlias(); // resolve real symbol
virtual int apply(Dsymbol_apply_ft_t fp, void *param);
virtual int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
virtual void addMember(Scope *sc, ScopeDsymbol *sds);
virtual void setScope(Scope *sc);
virtual void importAll(Scope *sc);
virtual void semantic(Scope *sc);
Expand Down
9 changes: 4 additions & 5 deletions src/enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void EnumDeclaration::setScope(Scope *sc)
ScopeDsymbol::setScope(sc);
}

int EnumDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void EnumDeclaration::addMember(Scope *sc, ScopeDsymbol *sds)
{
#if 0
printf("EnumDeclaration::addMember() %s\n", toChars());
Expand All @@ -74,7 +74,7 @@ int EnumDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)

if (!isAnonymous())
{
ScopeDsymbol::addMember(sc, sds, memnum);
ScopeDsymbol::addMember(sc, sds);

if (!symtab)
symtab = new DsymbolTable();
Expand All @@ -87,11 +87,10 @@ int EnumDeclaration::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
EnumMember *em = (*members)[i]->isEnumMember();
em->ed = this;
//printf("add %s to scope %s\n", em->toChars(), scopesym->toChars());
em->addMember(sc, scopesym, 1);
em->addMember(sc, scopesym);
}
}
added = true;
return 1;
}


Expand Down Expand Up @@ -258,7 +257,7 @@ void EnumDeclaration::semantic(Scope *sc)
if (em)
{
em->ed = this;
em->addMember(sc, scopesym, 1);
em->addMember(sc, scopesym);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class EnumDeclaration : public ScopeDsymbol

EnumDeclaration(Loc loc, Identifier *id, Type *memtype);
Dsymbol *syntaxCopy(Dsymbol *s);
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
void setScope(Scope *sc);
void semantic(Scope *sc);
bool oneMember(Dsymbol **ps, Identifier *ident);
Expand Down
4 changes: 2 additions & 2 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -6454,7 +6454,7 @@ Expression *IsExp::semantic(Scope *sc)
goto Lno;
s->semantic(sc);
if (sc->sds)
s->addMember(sc, sc->sds, 1);
s->addMember(sc, sc->sds);
else if (!sc->insert(s))
error("declaration %s is already defined", s->toChars());

Expand Down Expand Up @@ -6488,7 +6488,7 @@ Expression *IsExp::semantic(Scope *sc)
if (!tup && !sc->insert(s))
error("declaration %s is already defined", s->toChars());
if (sc->sds)
s->addMember(sc, sc->sds, 1);
s->addMember(sc, sc->sds);

unSpeculative(sc, s);
}
Expand Down
12 changes: 4 additions & 8 deletions src/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,13 @@ Dsymbol *Import::toAlias()
* Add import to sd's symbol table.
*/

int Import::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
void Import::addMember(Scope *sc, ScopeDsymbol *sd)
{
int result = 0;

if (names.dim == 0)
return Dsymbol::addMember(sc, sd, memnum);
return Dsymbol::addMember(sc, sd);

if (aliasId)
result = Dsymbol::addMember(sc, sd, memnum);
Dsymbol::addMember(sc, sd);

/* Instead of adding the import to sd's symbol table,
* add each of the alias=name pairs
Expand All @@ -420,12 +418,10 @@ int Import::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
TypeIdentifier *tname = new TypeIdentifier(loc, name);
AliasDeclaration *ad = new AliasDeclaration(loc, alias, tname);
ad->import = this;
result |= ad->addMember(sc, sd, memnum);
ad->addMember(sc, sd);

aliasdecls.push(ad);
}

return result;
}

Dsymbol *Import::search(Loc loc, Identifier *ident, int flags)
Expand Down
2 changes: 1 addition & 1 deletion src/import.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Import : public Dsymbol
void semantic(Scope *sc);
void semantic2(Scope *sc);
Dsymbol *toAlias();
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
Dsymbol *search(Loc loc, Identifier *ident, int flags = IgnoreNone);
bool overloadInsert(Dsymbol *s);

Expand Down
4 changes: 1 addition & 3 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void Module::importAll(Scope *prevsc)
for (size_t i = 0; i < members->dim; i++)
{
Dsymbol *s = (*members)[i];
s->addMember(sc, sc->scopesym, 1);
s->addMember(sc, sc->scopesym);
}
}
// anything else should be run after addMember, so version/debug symbols are defined
Expand Down Expand Up @@ -1258,5 +1258,3 @@ const char *lookForSourceFile(const char *filename)
}
return NULL;
}


2 changes: 1 addition & 1 deletion src/nspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Nspace::semantic(Scope *sc)
{
Dsymbol *s = (*members)[i];
//printf("add %s to scope %s\n", s->toChars(), toChars());
s->addMember(sc, this, 1);
s->addMember(sc, this);
}

for (size_t i = 0; i < members->dim; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Scope *Scope::createGlobal(Module *module)
Dsymbol *m = module;
while (m->parent)
m = m->parent;
m->addMember(NULL, sc->scopesym, 1);
m->addMember(NULL, sc->scopesym);
m->parent = NULL; // got changed by addMember()

// Create the module scope underneath the global scope
Expand Down
4 changes: 2 additions & 2 deletions src/staticassert.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Dsymbol *StaticAssert::syntaxCopy(Dsymbol *s)
return new StaticAssert(loc, exp->syntaxCopy(), msg ? msg->syntaxCopy() : NULL);
}

int StaticAssert::addMember(Scope *sc, ScopeDsymbol *sds, int memnum)
void StaticAssert::addMember(Scope *sc, ScopeDsymbol *sds)
{
return 0; // we didn't add anything
// we didn't add anything
}

void StaticAssert::semantic(Scope *sc)
Expand Down
2 changes: 1 addition & 1 deletion src/staticassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StaticAssert : public Dsymbol
StaticAssert(Loc loc, Expression *exp, Expression *msg);

Dsymbol *syntaxCopy(Dsymbol *s);
int addMember(Scope *sc, ScopeDsymbol *sds, int memnum);
void addMember(Scope *sc, ScopeDsymbol *sds);
void semantic(Scope *sc);
void semantic2(Scope *sc);
bool oneMember(Dsymbol **ps, Identifier *ident);
Expand Down
4 changes: 1 addition & 3 deletions src/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ void StructDeclaration::semantic(Scope *sc)
{
Dsymbol *s = (*members)[i];
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
s->addMember(sc, this, 1);
s->addMember(sc, this);
}
}

Expand Down Expand Up @@ -1332,5 +1332,3 @@ const char *UnionDeclaration::kind()
{
return "union";
}


Loading

0 comments on commit 904c411

Please sign in to comment.