X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FInterpreter.java;h=2b4e8887fb0f31ccef244f8cb3eaf549529ec4e9;hp=26521fa0ac4c22a8268e6a225c7b32fe22327302;hb=HEAD;hpb=45e832a060620ef5efe6f855808d273e3aa8fdd5 diff --git a/src/org/ibex/js/Interpreter.java b/src/org/ibex/js/Interpreter.java index 26521fa..2b4e888 100644 --- a/src/org/ibex/js/Interpreter.java +++ b/src/org/ibex/js/Interpreter.java @@ -159,7 +159,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable { case BREAK: case CONTINUE: while(!stack.empty()) { - JS o = (JS)stack.pop(); + Object o = stack.pop(); if (o instanceof CallMarker) je("break or continue not within a loop"); if (o instanceof TryMarker) { if(((TryMarker)o).finallyLoc < 0) continue; // no finally block, keep going @@ -468,14 +468,21 @@ class Interpreter implements ByteCodes, Tokens, Pausable { case RSH: stack.push(JSU.N(JSU.toLong(left) >> JSU.toLong(right))); break; case URSH: stack.push(JSU.N(JSU.toLong(left) >>> JSU.toLong(right))); break; - //#repeat />= LT/LE/GT/GE - case LT: { + case LT: case LE: case GT: case GE: { + int cmp = 0; if(left instanceof JSString && right instanceof JSString) - stack.push(JSU.B(JSU.toString(left).compareTo(JSU.toString(right)) < 0)); + cmp = JSU.toString(left).compareTo(JSU.toString(right)); else - stack.push(JSU.B(JSU.toDouble(left) < JSU.toDouble(right))); + cmp = (int)(100 * (JSU.toDouble(left) - JSU.toDouble(right))); + switch(op) { + case LE: stack.push(JSU.B(cmp <= 0)); break; + case LT: stack.push(JSU.B(cmp < 0)); break; + case GE: stack.push(JSU.B(cmp >= 0)); break; + case GT: stack.push(JSU.B(cmp > 0)); break; + default: throw new RuntimeException("impossible"); + } + break; } - //#end case EQ: case NE: {