Skip to content

Commit

Permalink
Add static member function DsymbolExp.resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Sep 23, 2015
1 parent 0284ca0 commit be961e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -3673,10 +3673,15 @@ public:
}

override Expression semantic(Scope* sc)
{
return resolve(loc ,sc, s, hasOverloads);
}

static Expression resolve(Loc loc, Scope *sc, Dsymbol s, bool hasOverloads)
{
static if (LOGSEMANTIC)
{
printf("DsymbolExp::semantic(%s %s)\n", s.kind(), s.toChars());
printf("DsymbolExp::resolve(%s %s)\n", s.kind(), s.toChars());
}
Lagain:
Expression e;
Expand All @@ -3691,11 +3696,11 @@ public:
else
{
if (!s.isFuncDeclaration()) // functions are checked after overloading
checkDeprecated(sc, s);
s.checkDeprecated(loc, sc);
s = s.toAlias();
//printf("s = '%s', s->kind = '%s', s->needThis() = %p\n", s->toChars(), s->kind(), s->needThis());
if (s != olds && !s.isFuncDeclaration())
checkDeprecated(sc, s);
s.checkDeprecated(loc, sc);
}
if (VarDeclaration v = s.isVarDeclaration())
{
Expand Down Expand Up @@ -3729,22 +3734,18 @@ public:
if (VarDeclaration v = s.isVarDeclaration())
{
//printf("Identifier '%s' is a variable, type '%s'\n", toChars(), v->type->toChars());
if (!type)
if (!v.type)
{
type = v.type;
if (!v.type)
{
error("forward reference of %s %s", s.kind(), s.toChars());
return new ErrorExp();
}
.error(loc, "forward reference of %s %s", s.kind(), s.toChars());
return new ErrorExp();
}
if ((v.storage_class & STCmanifest) && v._init)
{
// Detect recursive initializers.
// BUG: The check for speculative gagging is not correct
if (v.inuse && !global.gag)
{
error("circular initialization of %s", v.toChars());
.error(loc, "circular initialization of %s", v.toChars());
return new ErrorExp();
}
if (v._scope)
Expand All @@ -3757,7 +3758,7 @@ public:
e = v._init.toExpression(v.type);
if (!e)
{
error("cannot make expression out of initializer for %s", v.toChars());
.error(loc, "cannot make expression out of initializer for %s", v.toChars());
return new ErrorExp();
}
e = e.copy();
Expand All @@ -3766,7 +3767,7 @@ public:
return e;
}
e = new VarExp(loc, v);
e.type = type;
e.type = v.type;
e = e.semantic(sc);
return e.deref();
}
Expand All @@ -3784,7 +3785,7 @@ public:
if (!f.type.deco)
{
const(char)* trailMsg = f.inferRetType ? "inferred return type of function call " : "";
error("forward reference to %s'%s'", trailMsg, toChars());
.error(loc, "forward reference to %s'%s'", trailMsg, f.toChars());
return new ErrorExp();
}
FuncDeclaration fd = s.isFuncDeclaration();
Expand All @@ -3806,7 +3807,7 @@ public:
{
if (!imp.pkg)
{
error("forward reference of import %s", imp.toChars());
.error(loc, "forward reference of import %s", imp.toChars());
return new ErrorExp();
}
auto ie = new ScopeExp(loc, imp.pkg);
Expand Down Expand Up @@ -3864,7 +3865,7 @@ public:
e = e.semantic(sc);
return e;
}
error("%s '%s' is not a variable", s.kind(), s.toChars());
.error(loc, "%s '%s' is not a variable", s.kind(), s.toChars());
return new ErrorExp();
}

Expand Down
1 change: 1 addition & 0 deletions src/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class DsymbolExp : public Expression

DsymbolExp(Loc loc, Dsymbol *s, bool hasOverloads = false);
Expression *semantic(Scope *sc);
static Expression resolve(Loc loc, Scope *sc, Dsymbol *s, bool hasOverloads);
bool isLvalue();
Expression *toLvalue(Scope *sc, Expression *e);
void accept(Visitor *v) { v->visit(this); }
Expand Down

0 comments on commit be961e7

Please sign in to comment.