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 final JS target; ///< the box on which this trap was placed
13 final JS key; ///< the property that the trap was placed on
15 final JSFunction f; ///< the function for this trap
16 Trap next; ///< the next trap down the trap stack
18 Trap(JS b, JS n, JSFunction f, Trap nx) {
19 target = b; key = n; this.f = f; this.next = nx;
22 boolean isReadTrap() { return f.numFormalArgs == 0; }
23 boolean isWriteTrap() { return f.numFormalArgs != 0; }
24 Trap readTrap() { Trap t = this; while(t!=null && t.isWriteTrap()) t = t.next; return t; }
25 Trap writeTrap() { Trap t = this; while(t!=null && t.isReadTrap()) t = t.next; return t; }
26 Trap nextReadTrap() { return next == null ? null : next.readTrap(); }
27 Trap nextWriteTrap() { return next == null ? null : next.writeTrap(); }