From 4a68f95ea155c9da270df2483df4ed9eb15fdcfb Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:00:55 +0000 Subject: [PATCH] 2003/06/09 01:46:11 darcs-hash:20040130070055-2ba56-4696f9c661c42594dac3cf0d8a0de74ae746fade.gz --- src/org/xwt/js/ByteCodeBlock.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/org/xwt/js/ByteCodeBlock.java b/src/org/xwt/js/ByteCodeBlock.java index 5813274..057a3ca 100644 --- a/src/org/xwt/js/ByteCodeBlock.java +++ b/src/org/xwt/js/ByteCodeBlock.java @@ -5,7 +5,7 @@ import org.xwt.util.*; import java.io.*; /** A block of JavaScript bytecode run on a very simple stack machine. */ -class ByteCodeBlock implements ByteCodes, Tokens { +public class ByteCodeBlock implements ByteCodes, Tokens { // FIXME: this should be line-by-line private int line; @@ -155,10 +155,6 @@ class ByteCodeBlock implements ByteCodes, Tokens { Object left = t.pop(); switch(op[i]) { - case BITOR: t.push(new Long(JS.toLong(left) | JS.toLong(right))); break; - case BITXOR: t.push(new Long(JS.toLong(left) ^ JS.toLong(right))); break; - case BITAND: t.push(new Long(JS.toLong(left) & JS.toLong(right))); break; - case ADD: { Object l = left; Object r = right; @@ -174,6 +170,10 @@ class ByteCodeBlock implements ByteCodes, Tokens { t.push(new Double(JS.toDouble(l) + JS.toDouble(r))); break; } + case BITOR: t.push(new Long(JS.toLong(left) | JS.toLong(right))); break; + case BITXOR: t.push(new Long(JS.toLong(left) ^ JS.toLong(right))); break; + case BITAND: t.push(new Long(JS.toLong(left) & JS.toLong(right))); break; + case SUB: t.push(new Double(JS.toDouble(left) - JS.toDouble(right))); break; case MUL: t.push(new Double(JS.toDouble(left) * JS.toDouble(right))); break; case DIV: t.push(new Double(JS.toDouble(left) / JS.toDouble(right))); break; @@ -205,9 +205,8 @@ class ByteCodeBlock implements ByteCodes, Tokens { default: throw new Error("unknown opcode " + op[i]); } } } - if (t.size() != 1) - throw new EvaluatorException(line, sourceName, "eval() terminated with " + t.size() + - " elements on the stack; one expected"); + System.out.println("returning"); + if (t.size() != 1) throw new Error("eval() terminated with " + t.size() + " elements on the stack; one expected"); return t.pop(); } @@ -274,7 +273,7 @@ class ByteCodeBlock implements ByteCodes, Tokens { public String label; ContinueException(String label) { this.label = label; } } - static class ReturnException extends ControlTransferException { + public static class ReturnException extends ControlTransferException { public Object retval; ReturnException(Object retval) { this.retval = retval; } } -- 1.7.10.4