X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FCompiledFunctionImpl.java;fp=src%2Forg%2Fxwt%2Fjs%2FCompiledFunctionImpl.java;h=721b0a4bf189fb11dc25be5fbfa6fc16db0bb584;hb=bbf5ef35ca37016d19d92deffc0c992428c3bf6d;hp=8f063b26c2bb66aa52313f035b9b46332ec9c5ff;hpb=e8442c40f5b8c03a4e6993cbcc9ce64dddab6a90;p=org.ibex.core.git diff --git a/src/org/xwt/js/CompiledFunctionImpl.java b/src/org/xwt/js/CompiledFunctionImpl.java index 8f063b2..721b0a4 100644 --- a/src/org/xwt/js/CompiledFunctionImpl.java +++ b/src/org/xwt/js/CompiledFunctionImpl.java @@ -353,26 +353,51 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { t.push(isPrefix ? val : num); 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))); + break; + } + 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