Object ret = cx.stack.pop();
if (cx.stack.size() > size)
// this should never happen
- throw new Error("ERROR: stack grew by " + (cx.stack.size() - size) + " elements during call at " + sourceName + ":" + firstLine);
+ throw new Error("ERROR: stack grew by " + (cx.stack.size() - size) +
+ " elements during call at " + sourceName + ":" + firstLine);
return ret;
} catch(Error e) {
// Unwind the stack
Object old = t.pop();
Object key = t.pop();
Object obj = t.peek();
- if (obj instanceof org.xwt.Box && val instanceof CompiledFunction) {
- if (curOP == ASSIGN_ADD) {
- ((org.xwt.Box)obj).addTrap(key, val);
- } else {
- ((org.xwt.Box)obj).delTrap(key, val);
+ if (val instanceof CompiledFunction) {
+ if (obj instanceof JS.Scope) {
+ JS.Scope parent = (JS.Scope)obj;
+ while(parent.getParentScope() != null) parent = parent.getParentScope();
+ if (parent instanceof org.xwt.Box) {
+ if (curOP == ASSIGN_ADD) {
+ ((org.xwt.Box)parent).addTrap(key, val);
+ } else {
+ ((org.xwt.Box)parent).delTrap(key, val);
+ }
+ // skip over the "normal" implementation of +=/-=
+ pc += ((Integer)arg[pc]).intValue() - 1;
+ break;
+ }
}
- // skip over the "normal" implementation of +=/-=
- pc += ((Integer)arg[pc]).intValue() - 1;
- } else {
- // use the "normal" implementation
- t.push(key);
- t.push(old);
- t.push(arg);
}
+ // use the "normal" implementation
+ t.push(key);
+ t.push(old);
+ t.push(arg);
break;
}