2003/12/07 08:45:04
[org.ibex.core.git] / src / org / xwt / js / Trap.java
index e92bad7..60c34c6 100644 (file)
@@ -19,29 +19,32 @@ class Trap {
     JSFunction f = null;       ///< the function for this trap
     Trap next = null;          ///< the next trap down the trap stack
 
-    Trap(JS b, String n, JSFunction f, Trap nx) { trapee = b; name = n; this.f = f; this.next = nx; }
+    Trap(JS b, String n, JSFunction f, Trap nx) {
+        trapee = b; name = n; this.f = f; this.next = nx;
+    }
 
     private static final JSFunction putInvoker = new JSFunction("putInvoker", 0, null);
     private static final JSFunction getInvoker = new JSFunction("getInvoker", 0, null);
+
     static {
         putInvoker.add(-1, ByteCodes.PUT, null);
         putInvoker.add(-1, Tokens.RETURN, null);
         getInvoker.add(-1, ByteCodes.GET, null);
-        putInvoker.add(-1, Tokens.RETURN, null);
+        getInvoker.add(-1, Tokens.RETURN, null);
     }
     
-    void invoke(Object key, Object value) throws JSExn {
+    void invoke(Object value) throws JSExn {
         Interpreter i = new Interpreter(putInvoker, false, null);
         i.stack.push(trapee);
-        i.stack.push(key);
+        i.stack.push(name);
         i.stack.push(value);
         i.resume();
     }
 
-    Object invoke(Object key) throws JSExn {
+    Object invoke() throws JSExn {
         Interpreter i = new Interpreter(getInvoker, false, null);
         i.stack.push(this);
-        i.stack.push(key);
+        i.stack.push(name);
         i.resume();
         return i.stack.pop();
     }
@@ -54,6 +57,7 @@ class Trap {
         public TrapScope(JSScope parent, Trap t, Object val) { super(parent); this.t = t; this.val = val; }
         public Object get(Object key) throws JSExn {
             if (key.equals("trapee")) return t.trapee;
+            if (key.equals("callee")) return t.f;
             if (key.equals("trapname")) return t.name;
             return super.get(key);
         }