bug fixes
[org.ibex.js.git] / src / org / ibex / js / Interpreter.java
index 80de88d..b0eb602 100644 (file)
@@ -338,7 +338,13 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             }
             
             case CALL: case CALLMETHOD: {
             }
             
             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;
 
                 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
                 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;
                 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()) {
     */
     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) {
             if (o instanceof CatchMarker || o instanceof TryMarker) {
                 boolean inCatch = o instanceof CatchMarker;
                 if(inCatch) {