mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-06 09:05:45 +00:00
41 lines
1.0 KiB
Java
41 lines
1.0 KiB
Java
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);
|
|
}
|
|
|
|
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"));
|
|
}
|
|
|
|
JSIdentifier id;
|
|
int scope;
|
|
|
|
} |