gecko-dev/js/js2/java/JSName.java

41 lines
1.0 KiB
Java
Raw Normal View History

1999-06-09 03:10:30 +00:00
class JSName extends ExpressionNode {
JSName(JSIdentifier anID, int aScope)
{
id = anID;
scope = aScope; // this is the scope that the name was used in
}
String print(String indent)
{
return indent + "JSName : " + id.s + ", scope : " + scope + "\n";
}
JSReference evalLHS(Environment theEnv)
{
JSScope scope = theEnv.scope;
while (scope != null) {
if (scope.hasProp(theEnv, id))
return new JSReference(scope, id);
else
scope = scope.parent;
}
return new JSReference(theEnv.globalScope, id);
1999-06-09 03:10:30 +00:00
}
JSValue eval(Environment theEnv)
{
JSScope scope = theEnv.scope;
while (scope != null) {
if (scope.hasProp(theEnv, id))
return scope.getProp(theEnv, id);
else
scope = scope.parent;
}
throw new JSException(new JSString(id.s + " undefined"));
1999-06-09 03:10:30 +00:00
}
JSIdentifier id;
int scope;
}