Skip to content

Commit

Permalink
Refactor ScopeExp::semantic()
Browse files Browse the repository at this point in the history
Remove goto statement, and reduce indent level.
  • Loading branch information
9rnsr committed Sep 28, 2015
1 parent dadfbab commit 5a36f77
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions src/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -5195,9 +5195,10 @@ public:
}
//if (type == Type::tvoid)
// return this;
Lagain:
TemplateInstance ti = sds.isTemplateInstance();
if (ti)

ScopeDsymbol sds2 = sds;
TemplateInstance ti = sds2.isTemplateInstance();
while (ti)
{
WithScopeSymbol withsym;
if (!ti.findTempDecl(sc, &withsym) || !ti.semanticTiargs(sc))
Expand Down Expand Up @@ -5238,42 +5239,36 @@ public:
ti.semantic(sc);
if (!ti.inst || ti.errors)
return new ErrorExp();

Dsymbol s = ti.toAlias();
if (s == ti)
{
Dsymbol s = ti.toAlias();
ScopeDsymbol sds2 = s.isScopeDsymbol();
if (!sds2)
{
Expression e;
//printf("s = %s, '%s'\n", s->kind(), s->toChars());
if (withsym && withsym.withstate.wthis)
{
// Same as wthis.s
e = new VarExp(loc, withsym.withstate.wthis);
e = new DotVarExp(loc, e, s.isDeclaration());
e = e.semantic(sc);
}
else
e = DsymbolExp.resolve(loc, sc, s, s.hasOverloads());
//printf("-1ScopeExp::semantic()\n");
return e;
}
if (sds2 != sds)
{
sds = sds2;
goto Lagain;
}
//printf("sds = %s, '%s'\n", sds->kind(), sds->toChars());
sds = ti;
type = Type.tvoid;
return this;
}
sds2 = s.isScopeDsymbol();
if (sds2)
{
ti = sds2.isTemplateInstance();
//printf("+ sds2 = %s, '%s'\n", sds2.kind(), sds2.toChars());
continue;
}

//printf("s = %s, '%s'\n", s.kind(), s.toChars());
auto e = DsymbolExp.resolve(loc, sc, s, s.hasOverloads());
//printf("-1ScopeExp::semantic()\n");
return e;
}
else
{
//printf("sds = %s, '%s'\n", sds->kind(), sds->toChars());
//printf("\tparent = '%s'\n", sds->parent->toChars());
sds.semantic(sc);
AggregateDeclaration ad = sds.isAggregateDeclaration();
if (ad)
return (new TypeExp(loc, ad.type)).semantic(sc);
}

//printf("sds2 = %s, '%s'\n", sds2.kind(), sds2.toChars());
//printf("\tparent = '%s'\n", sds2.parent.toChars());
sds2.semantic(sc);

if (auto ad = sds2.isAggregateDeclaration())
return (new TypeExp(loc, ad.type)).semantic(sc);

sds = sds2;
type = Type.tvoid;
//printf("-2ScopeExp::semantic() %s\n", toChars());
return this;
Expand Down

0 comments on commit 5a36f77

Please sign in to comment.