2003/06/08 23:48:03
[org.ibex.core.git] / src / org / xwt / js / ByteCodeBlock.java
index fb2d1f5..a0e675c 100644 (file)
@@ -4,24 +4,28 @@ package org.xwt.js;
 import org.xwt.util.*;
 import java.io.*;
 
-/**
- *  A block of JavaScript bytecode.
- *
- *  The JavaScript ByteCode runs on a very simple stack machine.
- */
+/** A block of JavaScript bytecode run on a very simple stack machine. */
 class ByteCodeBlock implements ByteCodes, Tokens {
 
-    int line;
-    String sourceName;
-    int[] op = new int[10];
-    Object[] arg = new Object[10];
-    int size = 0;
+    // FIXME: this should be line-by-line
+    private int line;
+    private String sourceName;
+
+    /** the instructions */
+    private int[] op = new int[10];
+
+    /** the arguments to the instructions */
+    private Object[] arg = new Object[10];
+
+    /** the number of instruction/argument pairs */
+    private int size = 0;
 
     public ByteCodeBlock(int line, String sourceName) { this.line = line; this.sourceName = sourceName; }
-    public ByteCodeBlock(int line, String sourceName, int op_, Object arg_) { this(line, sourceName); add(op_, arg_); }
+    public String getSourceName() { return sourceName; }
 
     public int size() { return size; }
     public void set(int pos, int op_, Object arg_) { op[pos] = op_; arg[pos] = arg_; }
+    public void set(int pos, Object arg_) { arg[pos] = arg_; }
     public void paste(ByteCodeBlock other) { for(int i=0; i<other.size; i++) add(other.op[i], other.arg[i]); }
     public ByteCodeBlock add(int op_) { return add(op_, null); }
     public ByteCodeBlock add(int op_, Object arg_) {
@@ -55,12 +59,11 @@ class ByteCodeBlock implements ByteCodes, Tokens {
             case RETURN: throw new ReturnException(t.pop());
             case THROW: throw new JS.Exn(t.pop());
             case TRY: break;
-            case INSTANCEOF: break;
             case TYPEOF: break;
-            case BITNOT: t.push(new Long(~JS.toLong(t.pop()))); break;
-            case BANG: t.push(new Boolean(!JS.toBoolean(t.pop()))); break;
             case BREAK: return Boolean.FALSE;
             case CONTINUE: return Boolean.TRUE;
+            case BITNOT: t.push(new Long(~JS.toLong(t.pop()))); break;
+            case BANG: t.push(new Boolean(!JS.toBoolean(t.pop()))); break;
 
             case PUSHKEYS: {
                 Object o = t.peek();