mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Removal of scope argument of runtime functions to access|modify object members. The only reason for the argument was the need to call toObject to convert target object to Scriptable, but since now there is topCallScope available, that one can always be used instead.
This commit is contained in:
parent
aea4e1b0c0
commit
141e7d2365
@ -2717,14 +2717,13 @@ switch (op) {
|
||||
--stackTop;
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop] = ScriptRuntime.delete(cx, frame.scope, lhs, rhs);
|
||||
stack[stackTop] = ScriptRuntime.delete(lhs, rhs, cx);
|
||||
continue Loop;
|
||||
}
|
||||
case Token.GETPROP : {
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg,
|
||||
cx, frame.scope);
|
||||
stack[stackTop] = ScriptRuntime.getObjectProp(lhs, stringReg, cx);
|
||||
continue Loop;
|
||||
}
|
||||
case Token.SETPROP : {
|
||||
@ -2734,15 +2733,14 @@ switch (op) {
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop] = ScriptRuntime.setObjectProp(lhs, stringReg, rhs,
|
||||
cx, frame.scope);
|
||||
cx);
|
||||
continue Loop;
|
||||
}
|
||||
case Icode_PROP_INC_DEC : {
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop] = ScriptRuntime.propIncrDecr(lhs, stringReg,
|
||||
frame.scope,
|
||||
iCode[frame.pc]);
|
||||
cx, iCode[frame.pc]);
|
||||
++frame.pc;
|
||||
continue Loop;
|
||||
}
|
||||
@ -2755,10 +2753,10 @@ switch (op) {
|
||||
Object value;
|
||||
Object id = stack[stackTop + 1];
|
||||
if (id != DBL_MRK) {
|
||||
value = ScriptRuntime.getObjectElem(lhs, id, cx, frame.scope);
|
||||
value = ScriptRuntime.getObjectElem(lhs, id, cx);
|
||||
} else {
|
||||
double d = sDbl[stackTop + 1];
|
||||
value = ScriptRuntime.getObjectIndex(lhs, d, cx, frame.scope);
|
||||
value = ScriptRuntime.getObjectIndex(lhs, d, cx);
|
||||
}
|
||||
stack[stackTop] = value;
|
||||
continue Loop;
|
||||
@ -2776,10 +2774,10 @@ switch (op) {
|
||||
Object value;
|
||||
Object id = stack[stackTop + 1];
|
||||
if (id != DBL_MRK) {
|
||||
value = ScriptRuntime.setObjectElem(lhs, id, rhs, cx, frame.scope);
|
||||
value = ScriptRuntime.setObjectElem(lhs, id, rhs, cx);
|
||||
} else {
|
||||
double d = sDbl[stackTop + 1];
|
||||
value = ScriptRuntime.setObjectIndex(lhs, d, rhs, cx, frame.scope);
|
||||
value = ScriptRuntime.setObjectIndex(lhs, d, rhs, cx);
|
||||
}
|
||||
stack[stackTop] = value;
|
||||
continue Loop;
|
||||
@ -2790,7 +2788,7 @@ switch (op) {
|
||||
--stackTop;
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop] = ScriptRuntime.elemIncrDecr(lhs, rhs, cx, frame.scope,
|
||||
stack[stackTop] = ScriptRuntime.elemIncrDecr(lhs, rhs, cx,
|
||||
iCode[frame.pc]);
|
||||
++frame.pc;
|
||||
continue Loop;
|
||||
@ -2843,7 +2841,7 @@ switch (op) {
|
||||
if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
// stringReg: property
|
||||
stack[stackTop] = ScriptRuntime.getPropFunctionAndThis(obj, stringReg,
|
||||
cx, frame.scope);
|
||||
cx);
|
||||
++stackTop;
|
||||
stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx);
|
||||
continue Loop;
|
||||
@ -2853,9 +2851,7 @@ switch (op) {
|
||||
if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop - 1]);
|
||||
Object id = stack[stackTop];
|
||||
if (id == DBL_MRK) id = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop - 1] = ScriptRuntime.getElemFunctionAndThis(obj, id,
|
||||
cx,
|
||||
frame.scope);
|
||||
stack[stackTop - 1] = ScriptRuntime.getElemFunctionAndThis(obj, id, cx);
|
||||
stack[stackTop] = ScriptRuntime.lastStoredScriptable(cx);
|
||||
continue Loop;
|
||||
}
|
||||
@ -3169,7 +3165,7 @@ switch (op) {
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
--stackTop;
|
||||
frame.scope = ScriptRuntime.enterWith(lhs, frame.scope);
|
||||
frame.scope = ScriptRuntime.enterWith(lhs, cx, frame.scope);
|
||||
continue Loop;
|
||||
}
|
||||
case Token.LEAVEWITH :
|
||||
@ -3196,20 +3192,14 @@ switch (op) {
|
||||
++frame.pc;
|
||||
continue Loop;
|
||||
}
|
||||
case Token.ENUM_INIT_KEYS : {
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
--stackTop;
|
||||
indexReg += frame.localShift;
|
||||
stack[indexReg] = ScriptRuntime.enumInit(lhs, frame.scope);
|
||||
continue Loop;
|
||||
}
|
||||
case Token.ENUM_INIT_KEYS :
|
||||
case Token.ENUM_INIT_VALUES : {
|
||||
Object lhs = stack[stackTop];
|
||||
if (lhs == DBL_MRK) lhs = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
--stackTop;
|
||||
indexReg += frame.localShift;
|
||||
stack[indexReg] = ScriptRuntime.enumValuesInit(lhs, frame.scope);
|
||||
stack[indexReg] = ScriptRuntime.enumInit(
|
||||
lhs, cx, (op == Token.ENUM_INIT_VALUES));
|
||||
continue Loop;
|
||||
}
|
||||
case Token.ENUM_NEXT :
|
||||
@ -3226,8 +3216,7 @@ switch (op) {
|
||||
//stringReg: name of special property
|
||||
Object obj = stack[stackTop];
|
||||
if (obj == DBL_MRK) obj = ScriptRuntime.wrapNumber(sDbl[stackTop]);
|
||||
stack[stackTop] = ScriptRuntime.specialRef(obj, stringReg,
|
||||
cx, frame.scope);
|
||||
stack[stackTop] = ScriptRuntime.specialRef(obj, stringReg, cx);
|
||||
continue Loop;
|
||||
}
|
||||
case Token.REF_MEMBER: {
|
||||
|
@ -548,7 +548,7 @@ public class NativeArray extends IdScriptableObject
|
||||
Function fun;
|
||||
Scriptable funThis;
|
||||
fun = ScriptRuntime.getPropFunctionAndThis(
|
||||
elem, "toLocaleString", cx, scope);
|
||||
elem, "toLocaleString", cx);
|
||||
funThis = ScriptRuntime.lastStoredScriptable(cx);
|
||||
elem = fun.call(cx, scope, funThis,
|
||||
ScriptRuntime.emptyArgs);
|
||||
|
@ -852,7 +852,10 @@ public class ScriptRuntime {
|
||||
public static Scriptable toObject(Scriptable scope, Object val,
|
||||
Class staticClass)
|
||||
{
|
||||
return toObject(scope, val);
|
||||
if (val instanceof Scriptable && val != Undefined.instance) {
|
||||
return (Scriptable)val;
|
||||
}
|
||||
return toObject(Context.getContext(), scope, val);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1276,18 +1279,12 @@ public class ScriptRuntime {
|
||||
/**
|
||||
* Call obj.[[Get]](id)
|
||||
*/
|
||||
public static Object getObjectElem(Object obj, Object elem,
|
||||
Context cx, Scriptable scope)
|
||||
public static Object getObjectElem(Object obj, Object elem, Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefReadError(obj, elem);
|
||||
}
|
||||
Scriptable sobj;
|
||||
if (obj instanceof Scriptable) {
|
||||
sobj = (Scriptable)obj;
|
||||
} else {
|
||||
sobj = toObject(cx, obj);
|
||||
}
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
return getObjectElem(sobj, elem, cx);
|
||||
}
|
||||
|
||||
@ -1320,17 +1317,12 @@ public class ScriptRuntime {
|
||||
* Version of getObjectElem when elem is a valid JS identifier name.
|
||||
*/
|
||||
public static Object getObjectProp(Object obj, String property,
|
||||
Context cx, Scriptable scope)
|
||||
Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefReadError(obj, property);
|
||||
}
|
||||
Scriptable sobj;
|
||||
if (obj instanceof Scriptable) {
|
||||
sobj = (Scriptable)obj;
|
||||
} else {
|
||||
sobj = toObject(cx, obj);
|
||||
}
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
return getObjectProp(sobj, property, cx);
|
||||
}
|
||||
|
||||
@ -1355,17 +1347,12 @@ public class ScriptRuntime {
|
||||
* types.
|
||||
*/
|
||||
public static Object getObjectIndex(Object obj, double dblIndex,
|
||||
Context cx, Scriptable scope)
|
||||
Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefReadError(obj, toString(dblIndex));
|
||||
}
|
||||
Scriptable sobj;
|
||||
if (obj instanceof Scriptable) {
|
||||
sobj = (Scriptable)obj;
|
||||
} else {
|
||||
sobj = toObject(cx, obj);
|
||||
}
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
|
||||
int index = (int)dblIndex;
|
||||
if ((double)index == dblIndex) {
|
||||
@ -1396,17 +1383,12 @@ public class ScriptRuntime {
|
||||
* Call obj.[[Put]](id, value)
|
||||
*/
|
||||
public static Object setObjectElem(Object obj, Object elem, Object value,
|
||||
Context cx, Scriptable scope)
|
||||
Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefWriteError(obj, elem, value);
|
||||
}
|
||||
Scriptable sobj;
|
||||
if (obj instanceof Scriptable) {
|
||||
sobj = (Scriptable)obj;
|
||||
} else {
|
||||
sobj = toObject(cx, obj);
|
||||
}
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
return setObjectElem(sobj, elem, value, cx);
|
||||
}
|
||||
|
||||
@ -1434,18 +1416,12 @@ public class ScriptRuntime {
|
||||
* Version of setObjectElem when elem is a valid JS identifier name.
|
||||
*/
|
||||
public static Object setObjectProp(Object obj, String property,
|
||||
Object value,
|
||||
Context cx, Scriptable scope)
|
||||
Object value, Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefWriteError(obj, property, value);
|
||||
}
|
||||
Scriptable sobj;
|
||||
if (obj instanceof Scriptable) {
|
||||
sobj = (Scriptable)obj;
|
||||
} else {
|
||||
sobj = toObject(cx, obj);
|
||||
}
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
return setObjectProp(sobj, property, value, cx);
|
||||
}
|
||||
|
||||
@ -1466,18 +1442,12 @@ public class ScriptRuntime {
|
||||
* types.
|
||||
*/
|
||||
public static Object setObjectIndex(Object obj, double dblIndex,
|
||||
Object value,
|
||||
Context cx, Scriptable scope)
|
||||
Object value, Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefWriteError(obj, String.valueOf(dblIndex), value);
|
||||
}
|
||||
Scriptable sobj;
|
||||
if (obj instanceof Scriptable) {
|
||||
sobj = (Scriptable)obj;
|
||||
} else {
|
||||
sobj = toObject(cx, obj);
|
||||
}
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
|
||||
int index = (int)dblIndex;
|
||||
if ((double)index == dblIndex) {
|
||||
@ -1561,9 +1531,9 @@ public class ScriptRuntime {
|
||||
}
|
||||
|
||||
public static Reference specialRef(Object obj, String specialProperty,
|
||||
Context cx, Scriptable scope)
|
||||
Context cx)
|
||||
{
|
||||
return SpecialRef.createSpecial(cx, scope, obj, specialProperty);
|
||||
return SpecialRef.createSpecial(cx, obj, specialProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1577,8 +1547,7 @@ public class ScriptRuntime {
|
||||
* define a return value. Here we assume that the [[Delete]]
|
||||
* method doesn't return a value.
|
||||
*/
|
||||
public static Object delete(Context cx, Scriptable scope,
|
||||
Object obj, Object id)
|
||||
public static Object delete(Object obj, Object id, Context cx)
|
||||
{
|
||||
Scriptable sobj = toObject(cx, obj);
|
||||
boolean result = deleteObjectElem(sobj, id, cx);
|
||||
@ -1809,22 +1778,12 @@ public class ScriptRuntime {
|
||||
boolean enumValues;
|
||||
}
|
||||
|
||||
public static Object enumValuesInit(Object value, Scriptable scope)
|
||||
public static Object enumInit(Object value, Context cx, boolean enumValues)
|
||||
{
|
||||
IdEnumeration x = new IdEnumeration();
|
||||
if (!(value == null || value == Undefined.instance)) {
|
||||
x.obj = toObject(scope, value);
|
||||
x.enumValues = true;
|
||||
enumChangeObject(x);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static Object enumInit(Object value, Scriptable scope)
|
||||
{
|
||||
IdEnumeration x = new IdEnumeration();
|
||||
if (!(value == null || value == Undefined.instance)) {
|
||||
x.obj = toObject(scope, value);
|
||||
x.obj = toObject(cx, value);
|
||||
x.enumValues = enumValues;
|
||||
// enumInit should read all initial ids before returning
|
||||
// or "for (a.i in a)" would wrongly enumerate i in a as well
|
||||
enumChangeObject(x);
|
||||
@ -1950,12 +1909,11 @@ public class ScriptRuntime {
|
||||
*/
|
||||
public static Function getElemFunctionAndThis(Object obj,
|
||||
Object elem,
|
||||
Context cx,
|
||||
Scriptable scope)
|
||||
Context cx)
|
||||
{
|
||||
String s = toStringIdOrIndex(cx, elem);
|
||||
if (s != null) {
|
||||
return getPropFunctionAndThis(obj, s, cx, scope);
|
||||
return getPropFunctionAndThis(obj, s, cx);
|
||||
}
|
||||
int index = lastIndexResult(cx);
|
||||
|
||||
@ -1998,8 +1956,7 @@ public class ScriptRuntime {
|
||||
*/
|
||||
public static Function getPropFunctionAndThis(Object obj,
|
||||
String property,
|
||||
Context cx,
|
||||
Scriptable scope)
|
||||
Context cx)
|
||||
{
|
||||
if (obj == null || obj == Undefined.instance) {
|
||||
throw undefReadError(obj, property);
|
||||
@ -2358,9 +2315,9 @@ public class ScriptRuntime {
|
||||
}
|
||||
|
||||
public static Object propIncrDecr(Object obj, String id,
|
||||
Scriptable scope, int incrDecrMask)
|
||||
Context cx, int incrDecrMask)
|
||||
{
|
||||
Scriptable start = toObject(scope, obj);
|
||||
Scriptable start = toObject(cx, obj);
|
||||
Scriptable target = start;
|
||||
Object value;
|
||||
search: {
|
||||
@ -2410,10 +2367,9 @@ public class ScriptRuntime {
|
||||
}
|
||||
|
||||
public static Object elemIncrDecr(Object obj, Object index,
|
||||
Context cx, Scriptable scope,
|
||||
int incrDecrMask)
|
||||
Context cx, int incrDecrMask)
|
||||
{
|
||||
Object value = getObjectElem(obj, index, cx, scope);
|
||||
Object value = getObjectElem(obj, index, cx);
|
||||
boolean post = ((incrDecrMask & Node.POST_FLAG) != 0);
|
||||
double number;
|
||||
if (value instanceof Number) {
|
||||
@ -2431,7 +2387,7 @@ public class ScriptRuntime {
|
||||
--number;
|
||||
}
|
||||
Number result = wrapNumber(number);
|
||||
setObjectElem(obj, index, result, cx, scope);
|
||||
setObjectElem(obj, index, result, cx);
|
||||
if (post) {
|
||||
return value;
|
||||
} else {
|
||||
@ -3003,13 +2959,14 @@ public class ScriptRuntime {
|
||||
return catchScopeObject;
|
||||
}
|
||||
|
||||
public static Scriptable enterWith(Object value, Scriptable scope)
|
||||
public static Scriptable enterWith(Object value, Context cx,
|
||||
Scriptable scope)
|
||||
{
|
||||
if (value instanceof XMLObject) {
|
||||
XMLObject object = (XMLObject)value;
|
||||
return object.enterWith(scope);
|
||||
}
|
||||
return new NativeWith(scope, toObject(scope, value));
|
||||
return new NativeWith(scope, toObject(cx, value));
|
||||
}
|
||||
|
||||
public static Scriptable leaveWith(Scriptable scope)
|
||||
|
@ -42,23 +42,19 @@ class SpecialRef extends Reference
|
||||
private static final int SPECIAL_PARENT = 2;
|
||||
|
||||
private int type;
|
||||
private Scriptable scope;
|
||||
private Scriptable target;
|
||||
private String name;
|
||||
|
||||
private SpecialRef(int type, Scriptable scope, Scriptable target,
|
||||
String name)
|
||||
private SpecialRef(int type, Scriptable target, String name)
|
||||
{
|
||||
this.type = type;
|
||||
this.scope = scope;
|
||||
this.target = target;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
static Reference createSpecial(Context cx, Scriptable scope, Object object,
|
||||
String name)
|
||||
static Reference createSpecial(Context cx, Object object, String name)
|
||||
{
|
||||
Scriptable target = ScriptRuntime.toObject(scope, object);
|
||||
Scriptable target = ScriptRuntime.toObject(cx, object);
|
||||
|
||||
int type;
|
||||
if (name.equals("__proto__")) {
|
||||
@ -74,7 +70,7 @@ class SpecialRef extends Reference
|
||||
type = SPECIAL_NONE;
|
||||
}
|
||||
|
||||
return new SpecialRef(type, scope, target, name);
|
||||
return new SpecialRef(type, target, name);
|
||||
}
|
||||
|
||||
public Object get(Context cx)
|
||||
@ -103,7 +99,7 @@ class SpecialRef extends Reference
|
||||
if (value == null) {
|
||||
obj = null;
|
||||
} else {
|
||||
obj = ScriptRuntime.toObject(scope, value);
|
||||
obj = ScriptRuntime.toObject(cx, value);
|
||||
// Check that obj does not contain on its prototype/scope
|
||||
// chain to prevent cycles
|
||||
Scriptable search = obj;
|
||||
|
@ -1544,10 +1544,12 @@ class BodyCodegen
|
||||
|
||||
case Token.ENTERWITH:
|
||||
generateExpression(child, node);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"enterWith",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Lorg/mozilla/javascript/Scriptable;");
|
||||
cfw.addAStore(variableObjectLocal);
|
||||
@ -1565,11 +1567,12 @@ class BodyCodegen
|
||||
case Token.ENUM_INIT_KEYS:
|
||||
case Token.ENUM_INIT_VALUES:
|
||||
generateExpression(child, node);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke((type == Token.ENUM_INIT_KEYS)
|
||||
? "enumInit" : "enumValuesInit",
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addPush(type == Token.ENUM_INIT_VALUES);
|
||||
addScriptRuntimeInvoke("enumInit",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Z"
|
||||
+")Ljava/lang/Object;");
|
||||
cfw.addAStore(getLocalBlockRegister(node));
|
||||
break;
|
||||
@ -2000,13 +2003,11 @@ class BodyCodegen
|
||||
generateExpression(child, node); // object
|
||||
generateExpression(child.getNext(), node); // id
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
if (node.getIntProp(Node.ISNUMBER_PROP, -1) != -1) {
|
||||
addScriptRuntimeInvoke(
|
||||
"getObjectIndex",
|
||||
"(Ljava/lang/Object;D"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
else {
|
||||
@ -2015,7 +2016,6 @@ class BodyCodegen
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
break;
|
||||
@ -2087,16 +2087,14 @@ class BodyCodegen
|
||||
break;
|
||||
|
||||
case Token.DELPROP:
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
generateExpression(child, node);
|
||||
child = child.getNext();
|
||||
generateExpression(child, node);
|
||||
cfw.addALoad(contextLocal);
|
||||
addScriptRuntimeInvoke("delete",
|
||||
"(Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+"Ljava/lang/Object;"
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+")Ljava/lang/Object;");
|
||||
break;
|
||||
|
||||
@ -2129,13 +2127,11 @@ class BodyCodegen
|
||||
generateExpression(child, node);
|
||||
cfw.addPush(special);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"specialRef",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/String;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Lorg/mozilla/javascript/Reference;");
|
||||
}
|
||||
break;
|
||||
@ -2825,13 +2821,11 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
String property = id.getString();
|
||||
cfw.addPush(property);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"getPropFunctionAndThis",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/String;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Lorg/mozilla/javascript/Function;");
|
||||
} else {
|
||||
// Optimizer do not optimize this case for now
|
||||
@ -2839,13 +2833,11 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
throw Codegen.badTree();
|
||||
generateExpression(id, node); // id
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"getElemFunctionAndThis",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Lorg/mozilla/javascript/Function;");
|
||||
}
|
||||
break;
|
||||
@ -3147,12 +3139,12 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
Node getPropChild = child.getFirstChild();
|
||||
generateExpression(getPropChild, node);
|
||||
generateExpression(getPropChild.getNext(), node);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addPush(incrDecrMask);
|
||||
addScriptRuntimeInvoke("propIncrDecr",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/String;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"I)Ljava/lang/Object;");
|
||||
break;
|
||||
}
|
||||
@ -3161,14 +3153,13 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
generateExpression(elemChild, node);
|
||||
generateExpression(elemChild.getNext(), node);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
cfw.addPush(incrDecrMask);
|
||||
addScriptRuntimeInvoke("elemIncrDecr",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+"I)Ljava/lang/Object;");
|
||||
+"I"
|
||||
+")Ljava/lang/Object;");
|
||||
break;
|
||||
}
|
||||
case Token.GET_REF: {
|
||||
@ -3655,13 +3646,11 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
+")Ljava/lang/Object;");
|
||||
} else {
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"getObjectProp",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/String;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
}
|
||||
@ -3694,26 +3683,22 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
+")Ljava/lang/Object;");
|
||||
} else {
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"getObjectProp",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/String;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
}
|
||||
generateExpression(child, node);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"setObjectProp",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/String;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
|
||||
@ -3733,31 +3718,26 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
// -> ... object number object number
|
||||
cfw.add(ByteCode.DUP2_X1);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addOptRuntimeInvoke(
|
||||
"getObjectIndex",
|
||||
"(Ljava/lang/Object;D"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
} else {
|
||||
// stack: ... object object indexObject
|
||||
// -> ... object indexObject object indexObject
|
||||
cfw.add(ByteCode.DUP_X1);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
addScriptRuntimeInvoke(
|
||||
"getObjectElem",
|
||||
"(Ljava/lang/Object;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
}
|
||||
generateExpression(child, node);
|
||||
cfw.addALoad(contextLocal);
|
||||
cfw.addALoad(variableObjectLocal);
|
||||
if (indexIsNumber) {
|
||||
addScriptRuntimeInvoke(
|
||||
"setObjectIndex",
|
||||
@ -3765,7 +3745,6 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
+"D"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
} else {
|
||||
addScriptRuntimeInvoke(
|
||||
@ -3774,7 +3753,6 @@ Else pass the JS object in the aReg and 0.0 in the dReg.
|
||||
+"Ljava/lang/Object;"
|
||||
+"Ljava/lang/Object;"
|
||||
+"Lorg/mozilla/javascript/Context;"
|
||||
+"Lorg/mozilla/javascript/Scriptable;"
|
||||
+")Ljava/lang/Object;");
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public final class OptRuntime extends ScriptRuntime
|
||||
public static Object callProp0(Object value, String property,
|
||||
Context cx, Scriptable scope)
|
||||
{
|
||||
Function f = getPropFunctionAndThis(value, property, cx, scope);
|
||||
Function f = getPropFunctionAndThis(value, property, cx);
|
||||
Scriptable thisObj = lastStoredScriptable(cx);
|
||||
return f.call(cx, scope, thisObj, ScriptRuntime.emptyArgs);
|
||||
}
|
||||
|
@ -637,39 +637,4 @@ public final class XMLLibImpl extends XMLLib
|
||||
return constructNamespace(cx, uriValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method exists in order to handle the difference between a XML element property
|
||||
* and a method on an XML Object that might have the same name.
|
||||
*
|
||||
* @param obj
|
||||
* @param id
|
||||
* @param scope
|
||||
* @param thisObj
|
||||
* @return
|
||||
*/
|
||||
static Object getXmlMethod(Object obj, String id, Scriptable scope,
|
||||
Scriptable thisObj)
|
||||
{
|
||||
Scriptable start;
|
||||
|
||||
if (obj instanceof Scriptable) {
|
||||
start = (Scriptable) obj;
|
||||
} else {
|
||||
start = ScriptRuntime.toObject(scope, obj);
|
||||
}
|
||||
|
||||
Scriptable m = start;
|
||||
do {
|
||||
if (m instanceof XMLObjectImpl) {
|
||||
XMLObjectImpl xmlObject = (XMLObjectImpl) m;
|
||||
Object result = xmlObject.getMethod(id);
|
||||
if (result != Scriptable.NOT_FOUND) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
m = m.getPrototype();
|
||||
} while (m != null);
|
||||
|
||||
return Undefined.instance;
|
||||
}
|
||||
}
|
||||
|
@ -1563,8 +1563,7 @@ class XMLList extends XMLObjectImpl implements Function
|
||||
// This XMLList is being called as a Function.
|
||||
// Let's find the real Function object.
|
||||
if(targetProperty == null)
|
||||
throw ScriptRuntime.typeError1("msg.isnt.function",
|
||||
ScriptRuntime.toString(this));
|
||||
throw ScriptRuntime.notFunctionError(this);
|
||||
|
||||
String methodName = targetProperty.getLocalPart();
|
||||
|
||||
@ -1572,22 +1571,12 @@ class XMLList extends XMLObjectImpl implements Function
|
||||
if(isApply || methodName.equals("call"))
|
||||
return applyOrCall(isApply, cx, scope, thisObj, args);
|
||||
|
||||
Object methodObj = XMLLibImpl.getXmlMethod(targetObject, methodName, scope, targetObject);
|
||||
|
||||
if(!(methodObj instanceof Function))
|
||||
{
|
||||
if(thisObj instanceof XMLObjectImpl &&
|
||||
((XMLObjectImpl)thisObj).hasSimpleContent())
|
||||
{
|
||||
thisObj = ScriptRuntime.toObject(cx, scope, thisObj.toString());
|
||||
methodObj = ScriptableObject.getProperty(thisObj, methodName);
|
||||
}
|
||||
}
|
||||
|
||||
if(!(methodObj instanceof Function))
|
||||
throw ScriptRuntime.typeError1("msg.isnt.function", methodName);
|
||||
|
||||
Function method = (Function)methodObj;
|
||||
Function method = ScriptRuntime.getElemFunctionAndThis(
|
||||
this, methodName, cx);
|
||||
// Call lastStoredScriptable to clear stored thisObj
|
||||
// but ignore the result as the method should use the supplied
|
||||
// thisObj, not one from redirected call
|
||||
ScriptRuntime.lastStoredScriptable(cx);
|
||||
return method.call(cx, scope, thisObj, args);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user