2003/06/09 01:46:11
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:00:55 +0000 (07:00 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:00:55 +0000 (07:00 +0000)
darcs-hash:20040130070055-2ba56-4696f9c661c42594dac3cf0d8a0de74ae746fade.gz

src/org/xwt/js/ByteCodeBlock.java

index 5813274..057a3ca 100644 (file)
@@ -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; }
     }