1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
8 * This class encapsulates a single trap placed on a given node. The
9 * traps for a given property name on a given box are maintained as a
10 * linked list stack, with the most recently placed trap at the head
15 final JS target; ///< the box on which this trap was placed
16 final JS key; ///< the property that the trap was placed on
18 final JSFunction f; ///< the function for this trap
19 Trap next; ///< the next trap down the trap stack
21 Trap(JS b, JS n, JSFunction f, Trap nx) {
22 target = b; key = n; this.f = f; this.next = nx;
25 boolean isReadTrap() { return f.numFormalArgs == 0; }
26 boolean isWriteTrap() { return f.numFormalArgs != 0; }
27 Trap readTrap() { Trap t = this; while(t!=null && t.isWriteTrap()) t = t.next; return t; }
28 Trap writeTrap() { Trap t = this; while(t!=null && t.isReadTrap()) t = t.next; return t; }
29 Trap nextReadTrap() { return next == null ? null : next.readTrap(); }
30 Trap nextWriteTrap() { return next == null ? null : next.writeTrap(); }