+
+ case ASSIGN_SUB: case ASSIGN_ADD: {
+ Object val = t.pop();
+ Object old = t.pop();
+ Object key = t.pop();
+ Object obj = t.peek();
+ 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;
+ }
+ }
+ }
+ // use the "normal" implementation
+ t.push(key);
+ t.push(old);
+ t.push(arg);
+ break;
+ }
+
+ case ADD: {
+ int count = ((Number)arg[pc]).intValue();
+ if(count < 2) throw new Error("this should never happen");
+ if(count == 2) {
+ // common case
+ Object right = t.pop();
+ Object left = t.pop();
+ if(left instanceof String || right instanceof String) t.push(JS.toString(left).concat(JS.toString(right)));
+ else t.push(new Double(JS.toDouble(left) + JS.toDouble(right)));
+ } else {
+ Object[] args = new Object[count];
+ while(--count >= 0) args[count] = t.pop();
+ if(args[0] instanceof String) {
+ StringBuffer sb = new StringBuffer(64);
+ for(int i=0;i<args.length;i++) sb.append(JS.toString(args[i]));
+ t.push(sb.toString());
+ } else {
+ int numStrings = 0;
+ for(int i=0;i<args.length;i++) if(args[i] instanceof String) numStrings++;
+ if(numStrings == 0) {
+ double d = 0.0;
+ for(int i=0;i<args.length;i++) d += JS.toDouble(args[i]);
+ t.push(new Double(d));
+ } else {
+ double d=0.0;
+ int i=0;
+ do {
+ d += JS.toDouble(args[i++]);
+ } while(!(args[i] instanceof String));
+ StringBuffer sb = new StringBuffer(64);
+ sb.append(JS.toString(new Double(d)));
+ while(i < args.length) sb.append(JS.toString(args[i++]));
+ t.push(sb.toString());
+ }
+ }
+ }
+ break;
+ }