X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FTrap.java;h=1e299e5f19308f67ad8966f28898e1b00954d826;hb=6261c41b2ac9d182d8c3541e8e0e5fd00062fa43;hp=29860798a40d65b32622b69b7021cfae2a10bf1f;hpb=47f708e9d75f65e097c5968653139859047ec5a0;p=org.ibex.core.git diff --git a/src/org/xwt/js/Trap.java b/src/org/xwt/js/Trap.java index 2986079..1e299e5 100644 --- a/src/org/xwt/js/Trap.java +++ b/src/org/xwt/js/Trap.java @@ -19,29 +19,33 @@ 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); + getInvoker.add(-1, Tokens.RETURN, null); } - void invoke(Object key, Object value) { + void invoke(Object value) throws JSExn { Interpreter i = new Interpreter(putInvoker, false, null); - i.stack.push(this); - i.stack.push(key); + i.stack.push(trapee); + i.stack.push(name); i.stack.push(value); i.resume(); } - Object invoke(Object key) { + Object invoke() throws JSExn { Interpreter i = new Interpreter(getInvoker, false, null); - i.stack.push(this); - i.stack.push(key); - i.resume(); - return i.stack.pop(); + i.stack.push(trapee); + i.stack.push(name); + return i.resume(); } // FIXME: review; is necessary? @@ -50,8 +54,9 @@ class Trap { Object val = null; boolean cascadeHappened = false; public TrapScope(JSScope parent, Trap t, Object val) { super(parent); this.t = t; this.val = val; } - public Object get(Object key) { + 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); }