From bbf5ef35ca37016d19d92deffc0c992428c3bf6d Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 30 Jan 2004 07:03:35 +0000 Subject: [PATCH] 2003/07/07 04:44:17 darcs-hash:20040130070335-aa32f-c3daf9621be8fcf436e6e2228c6f6bc64953cf05.gz --- src/org/xwt/js/CompiledFunctionImpl.java | 55 ++++++++++++++++++++++-------- src/org/xwt/js/JS.java | 20 +++++++++-- src/org/xwt/js/Parser.java | 26 ++++++++------ 3 files changed, 73 insertions(+), 28 deletions(-) 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