- boolean readTrap() { return f.numFormalArgs == 0; }
- boolean writeTrap() { return f.numFormalArgs != 0; }
-
- void invoke(Object value) throws JSExn {
- Interpreter i = new Interpreter(putInvoker, false, null);
- i.stack.push(trapee);
- i.stack.push(name);
- i.stack.push(value);
- i.resume();
- }
-
- Object invoke() throws JSExn {
- Interpreter i = new Interpreter(getInvoker, false, null);
- i.stack.push(trapee);
- i.stack.push(name);
- return i.resume();
- }
-
- // FIXME: review; is necessary?
- /*static class TrapScope extends JSScope {
- Trap t;
- Object val = null;
- boolean cascadeHappened = false;
- public TrapScope(JSScope parent, Trap t, Object val) { super(parent); this.t = t; this.val = val; }
- public Object get(Object key) throws JSExn {
- if (key.equals("trapee")) return t.trapee;
- if (key.equals("callee")) return t.f;
- if (key.equals("trapname")) return t.name;
- return super.get(key);
- }
- }*/
+ boolean isReadTrap() { return f.numFormalArgs == 0; }
+ boolean isWriteTrap() { return f.numFormalArgs != 0; }
+ Trap readTrap() { Trap t = this; while(t!=null && t.isWriteTrap()) t = t.next; return t; }
+ Trap writeTrap() { Trap t = this; while(t!=null && t.isReadTrap()) t = t.next; return t; }
+ Trap nextReadTrap() { return next == null ? null : next.readTrap(); }
+ Trap nextWriteTrap() { return next == null ? null : next.writeTrap(); }