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

41 строка
1.0 KiB
Java
Исходник Обычный вид История

1999-06-09 07:10:30 +04: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 07:10:30 +04: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 07:10:30 +04:00
}
JSIdentifier id;
int scope;
}