- return null;
- }
-
- /** Called by Rhino's arguments.cascade. Note: cx will be null if this was invoked from perform() rather than from a script. */
- public static final CascadeFunction cascadeFunction = new CascadeFunction();
- private static class CascadeFunction extends JS.Function {
- CascadeFunction() { setSeal(true); }
- public Object _call(JS.Array args) { return _call(args, JS.getCurrentFunction()); }
- public Object _call(JS.Array args, Function currentFunction) {
- Trap currentTrap = TrapContext.get().currentTrap;
- /*
- if (currentTrap == null || (currentFunction != currentTrap.f)) {
- if (Log.on) Log.log(this, "attempt to cascade() by a function that was not invoked as a trap at " +
- currentFunction.getSourceName());
- if (Log.on) Log.log(this, "currentfunction == " + currentFunction);
- if (Log.on) Log.log(this, "currentTrap.f == " + currentTrap.f);
- return null;
- }
- */
- if (args.length() != 0) TrapContext.get().putCascadeHappened = true;
- Trap t = currentTrap.next;
- // if we've hit the end of the trap stack, just do a put(,,,true)
- if (t == null) {
- if (args.length() == 0) return currentTrap.trapee.get(currentTrap.name, true);
- currentTrap.trapee.put(currentTrap.name, args.elementAt(0), true);
- return null;
- }
- return t.perform(args);
+ /**
+ * deletes a trap.
+ * @param trapee the box to remove the trap from
+ * @param name the name of the property to trap on
+ * @param f the function to remove
+ */
+ static void delTrap(Box trapee, Object name, JS.CompiledFunction f) {
+ Trap t = (Trap)trapee.get(name, Trap.class);
+ if (t.f == f) {
+ trapee.put(name, Trap.class, t.next);
+ return;