minor bug fixes from moving interfaces
[org.ibex.js.git] / src / org / ibex / js / Interpreter.java
index 9899a14..80de88d 100644 (file)
@@ -109,8 +109,8 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             case OBJECT: stack.push(new JS.Obj()); break;
             case ARRAY: stack.push(new JSArray(Script.toInt((JS)arg))); break;
             //case DECLARE: scope.declare((JS)(arg==null ? stack.peek() : arg)); if(arg != null) stack.push((JS)arg); break;
             case OBJECT: stack.push(new JS.Obj()); break;
             case ARRAY: stack.push(new JSArray(Script.toInt((JS)arg))); break;
             //case DECLARE: scope.declare((JS)(arg==null ? stack.peek() : arg)); if(arg != null) stack.push((JS)arg); break;
-            case JT: if (Script.toBoolean(stack.pop())) pc += Script.toInt((JS)arg) - 1; break;
-            case JF: if (!Script.toBoolean(stack.pop())) pc += Script.toInt((JS)arg) - 1; break;
+            case JT: if (Script.toBoolean((JS)stack.pop())) pc += Script.toInt((JS)arg) - 1; break;
+            case JF: if (!Script.toBoolean((JS)stack.pop())) pc += Script.toInt((JS)arg) - 1; break;
             case JMP: pc += Script.toInt((JS)arg) - 1; break;
             case POP: stack.pop(); break;
             case SWAP: stack.swap(); break;
             case JMP: pc += Script.toInt((JS)arg) - 1; break;
             case POP: stack.pop(); break;
             case SWAP: stack.swap(); break;
@@ -123,10 +123,10 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             case OLDSCOPE: scope = scope.parent; break;
             case GLOBALSCOPE: stack.push(scope.getGlobal()); break;
             case SCOPEGET: stack.push(scope.get((JS)arg)); break;
             case OLDSCOPE: scope = scope.parent; break;
             case GLOBALSCOPE: stack.push(scope.getGlobal()); break;
             case SCOPEGET: stack.push(scope.get((JS)arg)); break;
-            case SCOPEPUT: scope.put((JS)arg,stack.peek()); break;
-            case ASSERT: if (!Script.toBoolean(stack.pop())) throw je("ibex.assertion.failed"); break;
-            case BITNOT: stack.push(Script.N(~Script.toLong(stack.pop()))); break;
-            case BANG: stack.push(Script.B(!Script.toBoolean(stack.pop()))); break;
+            case SCOPEPUT: scope.put((JS)arg, (JS)stack.peek()); break;
+            case ASSERT: if (!Script.toBoolean((JS)stack.pop())) throw je("ibex.assertion.failed"); break;
+            case BITNOT: stack.push(Script.N(~Script.toLong((JS)stack.pop()))); break;
+            case BANG: stack.push(Script.B(!Script.toBoolean((JS)stack.pop()))); break;
             case NEWFUNCTION: stack.push(((JSFunction)arg)._cloneWithNewParentScope(scope)); break;
             case LABEL: break;
 
             case NEWFUNCTION: stack.push(((JSFunction)arg)._cloneWithNewParentScope(scope)); break;
             case LABEL: break;
 
@@ -168,7 +168,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                             int loopInstructionLocation = ((LoopMarker)o).location;
                             int endOfLoop = Script.toInt((JS)f.arg[loopInstructionLocation]) + loopInstructionLocation;
                             scope = ((LoopMarker)o).scope;
                             int loopInstructionLocation = ((LoopMarker)o).location;
                             int endOfLoop = Script.toInt((JS)f.arg[loopInstructionLocation]) + loopInstructionLocation;
                             scope = ((LoopMarker)o).scope;
-                            if (op == CONTINUE) { stack.push(o); stack.push(JS.F); }
+                            if (op == CONTINUE) { stack.push(o); stack.push(Script.F); }
                             pc = op == BREAK ? endOfLoop - 1 : loopInstructionLocation;
                             continue OUTER;
                         }
                             pc = op == BREAK ? endOfLoop - 1 : loopInstructionLocation;
                             continue OUTER;
                         }
@@ -237,7 +237,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                 
             case CASCADE: {
                 boolean write = Script.toBoolean((JS)arg);
                 
             case CASCADE: {
                 boolean write = Script.toBoolean((JS)arg);
-                JS val = write ? stack.pop() : null;
+                JS val = write ? (JS)stack.pop() : null;
                 CallMarker o = stack.findCall();
                 if(!(o instanceof TrapMarker)) throw new JSExn("tried to CASCADE while not in a trap");
                 TrapMarker tm = (TrapMarker) o;
                 CallMarker o = stack.findCall();
                 if(!(o instanceof TrapMarker)) throw new JSExn("tried to CASCADE while not in a trap");
                 TrapMarker tm = (TrapMarker) o;
@@ -494,7 +494,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     boolean ret;
                     if(left == null && right == null) ret = true;
                     else if(left == null || right == null) ret = false;
                     boolean ret;
                     if(left == null && right == null) ret = true;
                     else if(left == null || right == null) ret = false;
-                    else ret = left.jsequals(right);
+                    else ret = left.equals(right);
                     stack.push(Script.B(op == EQ ? ret : !ret)); break;
                 }
 
                     stack.push(Script.B(op == EQ ? ret : !ret)); break;
                 }
 
@@ -671,7 +671,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     if(cm.f == null) break;
                     String s = cm.f.sourceName + ":" + cm.f.line[cm.pc-1];
                     if(cm instanceof Interpreter.TrapMarker) 
                     if(cm.f == null) break;
                     String s = cm.f.sourceName + ":" + cm.f.line[cm.pc-1];
                     if(cm instanceof Interpreter.TrapMarker) 
-                        s += " (trap on " + Script.str(((Interpreter.TrapMarker)cm).t.key) + ")";
+                        s += " (trap on " + Script.str(((Interpreter.TrapMarker)cm).t.key()) + ")";
                     e.addBacktrace(s);
                 }
             }
                     e.addBacktrace(s);
                 }
             }