* Use the same class for temporary compile time prototypes as for live protos
* Switch over parent scope when moving properties to live prototype. This
  does not fix any problems because the functions causing the problems in
  AntvilleLib are nested properties, but it seems like the right thing to do.
This commit is contained in:
hns 2004-12-20 12:15:35 +00:00
parent 9b9028df72
commit 35791bf5fb

View file

@ -884,14 +884,15 @@ public final class RhinoCore {
* code against.
*/
public void prepareCompilation() {
tmpObjProto = new ScriptableObject() {
public String getClassName() {
return frameworkProto.getName();
}
};
tmpObjProto.setPrototype(objProto);
if (!"global".equals(frameworkProto.getLowerCaseName()))
if ("global".equals(frameworkProto.getLowerCaseName())) {
tmpObjProto = new GlobalObject(RhinoCore.this, app);
tmpObjProto.setPrototype(global);
tmpObjProto.setParentScope(null);
} else {
tmpObjProto = new HopObject(frameworkProto.getName());
tmpObjProto.setPrototype(objProto);
tmpObjProto.setParentScope(global);
}
}
/**
@ -923,6 +924,13 @@ public final class RhinoCore {
// copy them over to the actual prototype object
int attributes = tmpObjProto.getAttributes(key);
Object value = tmpObjProto.get(key, tmpObjProto);
if (value instanceof ScriptableObject) {
// switch parent scope to actual prototype
ScriptableObject obj = (ScriptableObject) value;
if (obj.getParentScope() == tmpObjProto) {
obj.setParentScope(objProto);
}
}
objProto.defineProperty(key, value, attributes);
}