Fixes for bug 390 <http://www.helma.org/bugs/show_bug.cgi?id=390>
* 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:
parent
9b9028df72
commit
35791bf5fb
1 changed files with 15 additions and 7 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue