X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FInterpreter.java;h=b0eb602e0eed47c8f5cb7b8429f4d3fc502e9a10;hp=80de88d1ac23ef30ae2a51d5fbba48f8f235c839;hb=b7d7d6f7dc1ddac7889d8334c194a96f344524e7;hpb=5a5f5ef235158d513c1f2879dc916b115a4fa9d0 diff --git a/src/org/ibex/js/Interpreter.java b/src/org/ibex/js/Interpreter.java index 80de88d..b0eb602 100644 --- a/src/org/ibex/js/Interpreter.java +++ b/src/org/ibex/js/Interpreter.java @@ -338,7 +338,13 @@ class Interpreter implements ByteCodes, Tokens, Pausable { } case CALL: case CALLMETHOD: { - JS[] jsargs = (JS[])arg; + // FIXME: can a lot of simple cases in Parser be + // reduced so creating a new JS[] is not necessary? + JS[] jsargs; + if (arg instanceof JSNumber.I) { + jsargs = new JS[((JSNumber.I)arg).toInt()]; + for (int i=0; i < jsargs.length; i++) jsargs[i] = (JS)stack.pop(); + } else jsargs = (JS[])arg; JS method = null; JS ret = null; @@ -406,7 +412,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable { JS key = (JS)stack.pop(); JS js = (JS)stack.peek(); // A trap addition/removal - if(!(val instanceof JSFunction)) throw new JSExn("tried to add/remove a non-function trap"); + if(!(val instanceof JSFunction)) throw new JSExn("tried to add/remove a non-function trap"); // FIXME if(op == ADD_TRAP) js.addTrap(key, val); else js.delTrap(key, val); break; @@ -515,7 +521,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable { */ void catchException(JSExn e) throws JSExn { while(!stack.empty()) { - JS o = (JS)stack.pop(); + Object o = stack.pop(); if (o instanceof CatchMarker || o instanceof TryMarker) { boolean inCatch = o instanceof CatchMarker; if(inCatch) {