// Static Data //////////////////////////////////////////////////////////////
+ /** the arguments.cascade() function */
+ public static final JS.Callable cascadeFunction = new JS.Callable() {
+ public Object call(JS.Array args) {
+ Trap currentTrap = TrapContext.get().currentTrap;
+ 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);
+ }
+ };
+
/** a vector of weak references to all instances of Trap; used for retheming */
private static Hashtable allTraps = new Hashtable(1000);
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.Callable {
- CascadeFunction() { setSeal(true); }
- public Object call(JS.Array args) { return call(args, JS.Thread.fromJavaThread(java.lang.Thread.currentThread()).getCurrentCompiledFunction()); }
- public Object call(JS.Array args, JS.CompiledFunction currentFunction) {
- Trap currentTrap = TrapContext.get().currentTrap;
- 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);
- }
- };
-
/** called by Rhino's arguments.trapee hack */
public static Object currentTrapee() {
Trap current = TrapContext.get().currentTrap;
// invoke the trap function
try {
- if (!isreadtrap && args.length() == 0) return cascadeFunction.call(args, f);
+ if (!isreadtrap && args.length() == 0) return cascadeFunction.call(args);
if (f == null) {
if (Log.verbose) Log.log(this, "debug: reclaimed a dangling trap on property " + name);
- Object ret = cascadeFunction.call(args, f);
+ Object ret = cascadeFunction.call(args);
delete();
return ret;
}
Object ret = f.call(args);
// autocascade if required
- if (args.length() > 0 && !isreadtrap && !tc.putCascadeHappened) cascadeFunction.call(args, f);
+ if (args.length() > 0 && !isreadtrap && !tc.putCascadeHappened) cascadeFunction.call(args);
return ret;