-
- /** per-thread storage for Traps */
- private static class TrapContext {
-
- private static Hash trapContextByThread = new Hash();
- private TrapContext() { }
-
- private boolean putCascadeHappened = false;
- private Trap currentTrap = null;
- private int trapDepth = 0;
-
- /** returns the TrapContext for the current thread */
- static TrapContext get() {
- TrapContext ret = (TrapContext)trapContextByThread.get(java.lang.Thread.currentThread());
- if (ret == null) {
- ret = new TrapContext();
- trapContextByThread.put(Thread.currentThread(), ret);
- }
- return ret;
+
+ private static class TrapArgs extends JS.Array {
+ public boolean cascadeHappened;
+ private Trap t;
+ public TrapArgs(Trap t,JS.Array args) {
+ int size = args.length();
+ setSize(size);
+ for(int i=0;i<args.length();i++) setElementAt(args.elementAt(i),i);
+ cascadeHappened = false;
+ this.t = t;
+ }
+
+ public Object get(Object key) {
+ // common case
+ if(!(key instanceof String)) return super.get(key);
+
+ if(key.equals("trapee")) return t.trapee;
+ if(key.equals("trapname")) return t.name;
+ // FIXME: GETCALL when its available
+ if(key.equals("cascade")) return new JS.Callable() {
+ public Object call(JS.Array args) {
+ if(args.length() != 0) cascadeHappened = true;
+ return t.cascade(args);
+ }
+ };
+ return super.get(key);