- /** 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 Function cascadeFunction = new CascadeFunction();
- private static class CascadeFunction extends JSObject implements Function {
- CascadeFunction() { setSeal(true); }
- public Scriptable construct(Context cx, Scriptable scope, java.lang.Object[] args) { return null; }
- public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] args) {
- Trap currentTrap = TrapContext.get().currentTrap;
- if (currentTrap == null || (cx != null && Context.getCurrentContext().currentFunction != currentTrap.f)) {
- if (Log.on) Log.log(this, "attempt to cascade() by a function that was not invoked as a trap at " +
- cx.interpreterSourceFile + ":" + cx.interpreterLine);
- 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, currentTrap.trapee, true);
- currentTrap.trapee.put(currentTrap.name, currentTrap.trapee, args[0], true);
- return null;
- }
- return t.perform(args);
- }
- };
-