fixed bugs 495 and 499
[org.ibex.core.git] / src / org / ibex / js / Interpreter.java
index 6cbaf23..92b29a4 100644 (file)
@@ -245,6 +245,11 @@ class Interpreter implements ByteCodes, Tokens {
                     }
                 }
                 if (t != null) {
+                    stack.pop();
+                    stack.push(new CallMarker(this));
+                    stack.push(target);
+                    JSArray args = new JSArray();
+                    args.addElement(val);
                     f = t.f;
                     scope = new Trap.TrapScope(f.parentScope, t, val);
                     pc = -1;
@@ -289,15 +294,12 @@ class Interpreter implements ByteCodes, Tokens {
                         } else {
                             t = ((JS)o).getTrap(v);
                         }
-
                         while (t != null && t.f.numFormalArgs != 0) t = t.next; // get first read trap
-                        if (t != null) {
-                            stack.push(new CallMarker(this));
-                            JSArray args = new JSArray();
-                            stack.push(args);
-                        }
                     }
                     if (t != null) {
+                        stack.push(new CallMarker(this));
+                        JSArray args = new JSArray();
+                        stack.push(args);
                         f = t.f;
                         scope = new Trap.TrapScope(f.parentScope, t, null);
                         ((Trap.TrapScope)scope).cascadeHappened = true;