X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FInterpreter.java;h=80de88d1ac23ef30ae2a51d5fbba48f8f235c839;hp=9899a14fe4072d374699196ac1c7c73cd6d35fd2;hb=7113d47d1ef227732b610026bee8c22b9ada3525;hpb=361d18aff8f32e60fb8b6c5c52744a9f1e9890be;ds=sidebyside diff --git a/src/org/ibex/js/Interpreter.java b/src/org/ibex/js/Interpreter.java index 9899a14..80de88d 100644 --- a/src/org/ibex/js/Interpreter.java +++ b/src/org/ibex/js/Interpreter.java @@ -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 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; @@ -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 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; @@ -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; - 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; } @@ -237,7 +237,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable { 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; @@ -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; - else ret = left.jsequals(right); + else ret = left.equals(right); 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) - s += " (trap on " + Script.str(((Interpreter.TrapMarker)cm).t.key) + ")"; + s += " (trap on " + Script.str(((Interpreter.TrapMarker)cm).t.key()) + ")"; e.addBacktrace(s); } }