(In Rhino) Why Context.newObject() looking for constructors only in TopLevelScope?

K

k0t1k

This is "newObject" method from org.mozilla.javascript.Context class.

....
01 : public final Scriptable newObject(Scriptable scope, String
constructorName, Object[] args)
02 : {
03 : scope = ScriptableObject.getTopLevelScope(scope);
04 : Function ctor = ScriptRuntime.getExistingCtor(this, scope,
05 :
constructorName);
06 : if (args == null) { args = ScriptRuntime.emptyArgs; }
07 : return ctor.construct(this, scope, args);
08 : }
....

Why scope gets reset to point to TopLevelScope (line 03)?
 
R

Richard Cornford

k0t1k said:
This is "newObject" method from org.mozilla.javascript.Context class.
<snip>

Generally the point of ECMAScript is that the author does not need to
know anything about how implementations of the language work. And doing
cross-browser work makes the specific implementations less significant
as they are not the same in different browsers. So long as the resulting
behaviour corresponds with ECMA 262 the internal details are not
important.

A good group for asking questions related to the Spidermonkey and/or
Rhino implementations is - netscape.public.mozilla.jseng -, as there
they may get the attention of the authors of those implementations.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top