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,15 +884,16 @@ public final class RhinoCore {
|
||||||
* code against.
|
* code against.
|
||||||
*/
|
*/
|
||||||
public void prepareCompilation() {
|
public void prepareCompilation() {
|
||||||
tmpObjProto = new ScriptableObject() {
|
if ("global".equals(frameworkProto.getLowerCaseName())) {
|
||||||
public String getClassName() {
|
tmpObjProto = new GlobalObject(RhinoCore.this, app);
|
||||||
return frameworkProto.getName();
|
tmpObjProto.setPrototype(global);
|
||||||
}
|
tmpObjProto.setParentScope(null);
|
||||||
};
|
} else {
|
||||||
|
tmpObjProto = new HopObject(frameworkProto.getName());
|
||||||
tmpObjProto.setPrototype(objProto);
|
tmpObjProto.setPrototype(objProto);
|
||||||
if (!"global".equals(frameworkProto.getLowerCaseName()))
|
|
||||||
tmpObjProto.setParentScope(global);
|
tmpObjProto.setParentScope(global);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compilation has been completed successfully - switch over to code
|
* Compilation has been completed successfully - switch over to code
|
||||||
|
@ -923,6 +924,13 @@ public final class RhinoCore {
|
||||||
// copy them over to the actual prototype object
|
// copy them over to the actual prototype object
|
||||||
int attributes = tmpObjProto.getAttributes(key);
|
int attributes = tmpObjProto.getAttributes(key);
|
||||||
Object value = tmpObjProto.get(key, tmpObjProto);
|
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);
|
objProto.defineProperty(key, value, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue