Changing order of parameters in ScriptRuntime.instanceOf to match order in ScriptRuntime.in to use simpler code in optimizer.

This commit is contained in:
igor%mir2.org 2003-08-18 08:00:55 +00:00
Родитель c3d4e19b03
Коммит 5ccaea2003
4 изменённых файлов: 9 добавлений и 30 удалений

Просмотреть файл

@ -1924,7 +1924,7 @@ public class Interpreter
--stackTop;
Object lhs = stack[stackTop];
if (lhs == DBL_MRK) lhs = doubleWrap(sDbl[stackTop]);
boolean valBln = ScriptRuntime.instanceOf(scope, lhs, rhs);
boolean valBln = ScriptRuntime.instanceOf(lhs, rhs, scope);
stack[stackTop] = valBln ? Boolean.TRUE : Boolean.FALSE;
break;
}

Просмотреть файл

@ -1023,7 +1023,7 @@ public class NativeArray extends IdScriptable {
/* Put the target in the result array; only add it as an array
* if it looks like one.
*/
if (ScriptRuntime.instanceOf(scope, thisObj, ctor)) {
if (ScriptRuntime.instanceOf(thisObj, ctor, scope)) {
length = getLengthProperty(thisObj);
// Copy from the target object into the result
@ -1040,7 +1040,7 @@ public class NativeArray extends IdScriptable {
* elements separately; otherwise, just copy the argument.
*/
for (int i = 0; i < args.length; i++) {
if (ScriptRuntime.instanceOf(scope, args[i], ctor)) {
if (ScriptRuntime.instanceOf(args[i], ctor, scope)) {
// ScriptRuntime.instanceOf => instanceof Scriptable
Scriptable arg = (Scriptable)args[i];
length = getLengthProperty(arg);

Просмотреть файл

@ -1638,7 +1638,8 @@ public class ScriptRuntime {
*
* @return a instanceof b
*/
public static boolean instanceOf(Scriptable scope, Object a, Object b) {
public static boolean instanceOf(Object a, Object b, Scriptable scope)
{
// Check RHS is an object
if (! (b instanceof Scriptable)) {
throw NativeGlobal.typeError0("msg.instanceof.not.object", scope);

Просмотреть файл

@ -2552,24 +2552,12 @@ public class Codegen extends Interpreter {
generateCodeFromNode(child.getNext(), node);
genSimpleCompare(op, trueGOTO, falseGOTO);
} else {
if (op == Token.INSTANCEOF) {
aload(variableObjectLocal);
generateCodeFromNode(child, node);
generateCodeFromNode(child.getNext(), node);
addScriptRuntimeInvoke(
"instanceOf",
"(Lorg/mozilla/javascript/Scriptable;"
+"Ljava/lang/Object;"
+"Ljava/lang/Object;"
+")Z");
addByteCode(ByteCode.IFNE, trueGOTO);
addByteCode(ByteCode.GOTO, falseGOTO);
} else if (op == Token.IN) {
if (op == Token.INSTANCEOF || op == Token.IN) {
generateCodeFromNode(child, node);
generateCodeFromNode(child.getNext(), node);
aload(variableObjectLocal);
addScriptRuntimeInvoke(
"in",
(op == Token.INSTANCEOF) ? "instanceOf" : "in",
"(Ljava/lang/Object;"
+"Ljava/lang/Object;"
+"Lorg/mozilla/javascript/Scriptable;"
@ -2699,24 +2687,14 @@ public class Codegen extends Interpreter {
|| op == Token.INSTANCEOF
|| op == Token.IN)
{
if (op == Token.INSTANCEOF)
aload(variableObjectLocal);
generateCodeFromNode(child, node);
generateCodeFromNode(child.getNext(), node);
int trueGOTO = acquireLabel();
int skip = acquireLabel();
if (op == Token.INSTANCEOF) {
addScriptRuntimeInvoke(
"instanceOf",
"(Lorg/mozilla/javascript/Scriptable;"
+"Ljava/lang/Object;"
+"Ljava/lang/Object;"
+")Z");
addByteCode(ByteCode.IFNE, trueGOTO);
} else if (op == Token.IN) {
if (op == Token.INSTANCEOF || op == Token.IN) {
aload(variableObjectLocal);
addScriptRuntimeInvoke(
"in",
(op == Token.INSTANCEOF) ? "instanceOf" : "in",
"(Ljava/lang/Object;"
+"Ljava/lang/Object;"
+"Lorg/mozilla/javascript/Scriptable;"