Use toObject() in ScriptRuntime.delete to convert non-Scriptable delete target to Object which required to pass Context and scope to the method and update Interpreter and optimizer/Codegen accordingly.


git-svn-id: svn://10.0.0.236/trunk@141165 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
igor%mir2.org
2003-04-15 07:33:17 +00:00
parent ec82356eda
commit 1e56b29a4a
3 changed files with 15 additions and 7 deletions

View File

@@ -2016,7 +2016,7 @@ public class Interpreter {
--stackTop;
Object lhs = stack[stackTop];
if (lhs == DBL_MRK) lhs = doubleWrap(sDbl[stackTop]);
stack[stackTop] = ScriptRuntime.delete(lhs, rhs);
stack[stackTop] = ScriptRuntime.delete(cx, scope, lhs, rhs);
break;
}
case TokenStream.GETPROP : {

View File

@@ -1059,11 +1059,15 @@ public class ScriptRuntime {
* define a return value. Here we assume that the [[Delete]]
* method doesn't return a value.
*/
public static Object delete(Object obj, Object id) {
public static Object delete(Context cx, Scriptable scope,
Object obj, Object id)
{
Scriptable sobj = (obj instanceof Scriptable)
? (Scriptable)obj : toObject(cx, scope, obj);
String s = getStringId(id);
boolean result = s != null
? ScriptableObject.deleteProperty((Scriptable) obj, s)
: ScriptableObject.deleteProperty((Scriptable) obj, getIntId(id));
boolean result = (s != null)
? ScriptableObject.deleteProperty(sobj, s)
: ScriptableObject.deleteProperty(sobj, getIntId(id));
return result ? Boolean.TRUE : Boolean.FALSE;
}

View File

@@ -191,7 +191,7 @@ public class Codegen extends Interpreter {
Exception e = null;
Class result = null;
ClassLoader parentLoader = cx.getClass().getClassLoader();
ClassLoader parentLoader = cx.getApplicationClassLoader();
GeneratedClassLoader loader;
if (securityController == null) {
loader = cx.createClassLoader(parentLoader);
@@ -1421,12 +1421,16 @@ public class Codegen extends Interpreter {
break;
case TokenStream.DELPROP:
aload(contextLocal);
aload(variableObjectLocal);
while (child != null) {
generateCodeFromNode(child, node, trueLabel, falseLabel);
child = child.getNext();
}
addScriptRuntimeInvoke("delete",
"(Ljava/lang/Object;"
"(Lorg/mozilla/javascript/Context;"
+"Lorg/mozilla/javascript/Scriptable;"
+"Ljava/lang/Object;"
+"Ljava/lang/Object;"
+")Ljava/lang/Object;");
break;