1 // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
5 * This class encapsulates a single trap placed on a given node. The
6 * traps for a given property name on a given box are maintained as a
7 * linked list stack, with the most recently placed trap at the head
12 JS trapee = null; ///< the box on which this trap was placed
13 JS name = null; ///< the property that the trap was placed on
15 JSFunction f = null; ///< the function for this trap
16 Trap next = null; ///< the next trap down the trap stack
18 Trap(JS b, JS n, JSFunction f, Trap nx) {
19 trapee = b; name = n; this.f = f; this.next = nx;
22 static final JSFunction putInvoker = new JSFunction("putInvoker", 0, null);
23 static final JSFunction getInvoker = new JSFunction("getInvoker", 0, null);
26 putInvoker.add(1, ByteCodes.PUT, null);
27 putInvoker.add(2, Tokens.RETURN, null);
28 getInvoker.add(1, ByteCodes.GET, null);
29 getInvoker.add(2, Tokens.RETURN, null);
32 boolean readTrap() { return f.numFormalArgs == 0; }
33 boolean writeTrap() { return f.numFormalArgs != 0; }
35 void invoke(JS value) throws JSExn {
36 Interpreter i = new Interpreter(putInvoker, false, null);
43 JS invoke() throws JSExn {
44 Interpreter i = new Interpreter(getInvoker, false, null);