2003/06/09 01:45:29
[org.ibex.core.git] / src / org / xwt / Trap.java
index 8d9404e..770ad51 100644 (file)
@@ -123,15 +123,6 @@ public class Trap {
         public Object _call(JS.Array args) { return _call(args, JS.getCurrentFunction()); }
         public Object _call(JS.Array args, Function currentFunction) {
             Trap currentTrap = TrapContext.get().currentTrap;
-           /*
-            if (currentTrap == null || (currentFunction != currentTrap.f)) {
-                if (Log.on) Log.log(this, "attempt to cascade() by a function that was not invoked as a trap at " +
-                                   currentFunction.getSourceName());
-                if (Log.on) Log.log(this, "currentfunction == " + currentFunction);
-                if (Log.on) Log.log(this, "currentTrap.f == " + currentTrap.f);
-                return null;
-            }
-           */
             if (args.length() != 0) TrapContext.get().putCascadeHappened = true;
             Trap t = currentTrap.next;
             // if we've hit the end of the trap stack, just do a put(,,,true)
@@ -186,8 +177,14 @@ public class Trap {
                 return ret;
             }
             
-            Object ret = f._call(args);
-            
+           System.out.println("calling trap on " + name);
+           Object ret = null;
+           try {
+               ret = f._call(args);
+           } catch (org.xwt.js.ByteCodeBlock.ReturnException re) {
+               ret = re.retval;
+           }
+           
             // autocascade if required
             if (args.length() > 0 && !isreadtrap && !tc.putCascadeHappened) cascadeFunction._call(args, f);