X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FTrap.java;fp=src%2Forg%2Fxwt%2Fjs%2FTrap.java;h=0000000000000000000000000000000000000000;hb=3591b88b94a6bb378af3d4abe6eb5233ce583104;hp=041e012d8837e03f0f626dca9d1b33198d919f5b;hpb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;p=org.ibex.core.git diff --git a/src/org/xwt/js/Trap.java b/src/org/xwt/js/Trap.java deleted file mode 100644 index 041e012..0000000 --- a/src/org/xwt/js/Trap.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] -package org.xwt.js; - -import java.util.*; -import org.xwt.util.*; -import java.io.*; - -/** - * This class encapsulates a single trap placed on a given node. The - * traps for a given property name on a given box are maintained as a - * linked list stack, with the most recently placed trap at the head - * of the list. - */ -class Trap { - - JS trapee = null; ///< the box on which this trap was placed - Object name = null; ///< the property that the trap was placed on - - 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; - } - - 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(2, Tokens.RETURN, null); - getInvoker.add(1, ByteCodes.GET, null); - getInvoker.add(2, Tokens.RETURN, null); - } - - void invoke(Object value) throws JSExn { - Interpreter i = new Interpreter(putInvoker, false, null); - i.stack.push(trapee); - i.stack.push(name); - i.stack.push(value); - i.resume(); - } - - Object invoke() throws JSExn { - Interpreter i = new Interpreter(getInvoker, false, null); - i.stack.push(trapee); - i.stack.push(name); - return i.resume(); - } - - // FIXME: review; is necessary? - static class TrapScope extends JSScope { - Trap t; - 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) 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); - } - } -} -