2003/06/09 03:13:18
[org.ibex.core.git] / src / org / xwt / js / ByteCodeBlock.java
index 057a3ca..2da760d 100644 (file)
@@ -40,7 +40,9 @@ public class ByteCodeBlock implements ByteCodes, Tokens {
     }
         
     public Object eval(final JS.Scope s, Vec t) throws ControlTransferException {
-        for(int i=0; i<size; i++) switch(op[i]) {
+
+        for(int i=0; i<size; i++) {
+           switch(op[i]) {
             case LABEL: break;
             case LITERAL: t.push(arg[i]); break;
             case OBJECT: t.push(new JS.Obj()); break;
@@ -107,7 +109,7 @@ public class ByteCodeBlock implements ByteCodes, Tokens {
                 Object key = t.pop();
                 JS target = (JS)t.peek();
                 if (target == null)
-                   throw new EvaluatorException(line, sourceName, "tried to put a value to the " + key + " property on the null value");
+                   throw new JS.Exn("tried to put a value to the " + key + " property on the null value");
                 target.put(key, val);
                 t.push(val);
                 break;
@@ -134,7 +136,7 @@ public class ByteCodeBlock implements ByteCodes, Tokens {
                 arguments.setSize(numArgs);
                 for(int j=numArgs - 1; j >= 0; j--) arguments.setElementAt(t.pop(), j);
                 JS.Function f = (JS.Function)t.pop();
-                if (f == null) throw new JS.Exn(new EvaluatorException(line, sourceName, "attempted to call null"));
+                if (f == null) throw new JS.Exn("attempted to call null");
                 t.push(f.call(arguments));
                 break;
             }
@@ -205,14 +207,14 @@ public class ByteCodeBlock implements ByteCodes, Tokens {
                 default: throw new Error("unknown opcode " + op[i]);
                 } }
             }
-       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();
     }
 
     public Object doGet(final Object o, final Object v) {
         if (o == null)
-            throw new EvaluatorException(line, sourceName, "tried to get property \"" + v + "\" from the null value");
+            throw new JS.Exn("tried to get property \"" + v + "\" from the null value");
         if (o instanceof String) {
             if (v.equals("length")) return new Integer(((String)o).length());
             else if (v.equals("substring")) return new JS.Function() {