Set parent scope rather than prototype for temporary global prototype.

This should solve the problems described in bug 390 where global functions
were called on the temporary prototype in some cases.
This commit is contained in:
hns 2004-12-20 13:14:39 +00:00
parent 35791bf5fb
commit da007f9506

View file

@ -886,8 +886,11 @@ public final class RhinoCore {
public void prepareCompilation() { public void prepareCompilation() {
if ("global".equals(frameworkProto.getLowerCaseName())) { if ("global".equals(frameworkProto.getLowerCaseName())) {
tmpObjProto = new GlobalObject(RhinoCore.this, app); tmpObjProto = new GlobalObject(RhinoCore.this, app);
tmpObjProto.setPrototype(global); // setting the prototype to global does not seem to be the right
tmpObjProto.setParentScope(null); // thing to do. that and not using a GlobalObject instance
// as temporary object proto resulted in bug 390.
tmpObjProto.setPrototype(null);
tmpObjProto.setParentScope(global);
} else { } else {
tmpObjProto = new HopObject(frameworkProto.getName()); tmpObjProto = new HopObject(frameworkProto.getName());
tmpObjProto.setPrototype(objProto); tmpObjProto.setPrototype(objProto);