- if (target instanceof JSScope && key.equals("cascade")) {
- Trap.TrapScope ts = null;
- JSScope p = (JSScope)target; // search the scope-path for the trap
- if (target instanceof Trap.TrapScope) {
- ts = (Trap.TrapScope)target;
- }
- else {
- while (ts == null && p.getParentScope() != null) {
- p = p.getParentScope();
- if (p instanceof Trap.TrapScope) {
- ts = (Trap.TrapScope)p;
- }
- }
- }
- t = ts.t.next;
- ts.cascadeHappened = true;
- while (t != null && t.f.numFormalArgs == 0) t = t.next;
- if (t == null) { target = ts.t.trapee; key = ts.t.name; }
-
- } else if (target instanceof Trap.TrapScope && key.equals(((Trap.TrapScope)target).t.name)) {
- throw je("tried to put to " + key + " inside a trap it owns; use cascade instead");
-
- } else if (target instanceof JS) {
- if (target instanceof JSScope) {
- JSScope p = (JSScope)target; // search the scope-path for the trap
- t = p.getTrap(key);
- while (t == null && p.getParentScope() != null) { p = p.getParentScope(); t = p.getTrap(key); }
- } else {
- t = ((JS)target).getTrap(key);
+ TrapMarker tm = null;
+ if(target instanceof JSScope && key.equals("cascade")) {
+ Object o=null;
+ int i;
+ for(i=stack.size()-1;i>=0;i--) if((o = stack.elementAt(i)) instanceof CallMarker) break;
+ if(i==0) throw new Error("didn't find a call marker while doing cascade");
+ if(o instanceof TrapMarker) {
+ tm = (TrapMarker) o;
+ target = tm.trapee;
+ key = tm.key;
+ tm.cascadeHappened = true;
+ t = tm.t;
+ if(t.readTrap()) throw new JSExn("can't put to cascade in a read trap");
+ t = t.next;
+ while(t != null && t.readTrap()) t = t.next;