more optimal jsfunction calls
[org.ibex.core.git] / src / org / ibex / js / JS.java
index 04d7edd..5d1b58d 100644 (file)
@@ -18,12 +18,16 @@ public abstract class JS {
     public Enumeration keys() throws JSExn { throw new JSExn("you can't enumerate the keys of this object (class=" + getClass().getName() +")"); }
     public JS get(JS key) throws JSExn { return null; }
     public void put(JS key, JS val) throws JSExn { throw new JSExn("" + key + " is read only (class=" + getClass().getName() +")"); }
+    
+    public InputStream getInputStream() throws IOException {
+        throw new IOException("this object doesn't have a stream associated with it " + getClass().getName() + ")");
+    }
         
     public final boolean hasTrap(JS key) { return getTrap(key) != null; }
     
     public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
         throw new JSExn("method not found (" + JS.debugToString(method) + ")");
-    }    
+    }
     
     // FIXME: JSArgs objects, pointers into stack frame
     public JS call(JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
@@ -87,7 +91,7 @@ public abstract class JS {
         JS _unclone() { return clonee.unclone(); }
         public JS getClonee() { return clonee; }
         public Clone(JS clonee) throws JSExn {
-            if(!(clonee instanceof Cloneable)) throw new JSExn("" + getClass().getName() + " isn't cloneable");
+            if(!(clonee instanceof Cloneable)) throw new JSExn("" + clonee.getClass().getName() + " isn't cloneable");
             this.clonee = clonee;
         }
         public boolean jsequals(JS o) { return unclone().jsequals(o.unclone()); }
@@ -100,6 +104,7 @@ public abstract class JS {
         public JS call(JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
             return clonee.call(a0, a1, a2, rest, nargs);
         }
+        public InputStream getInputStream() throws IOException { return clonee.getInputStream(); }
     }
     
     // Static Interpreter Control Methods ///////////////////////////////////////////////////////////////
@@ -120,7 +125,7 @@ public abstract class JS {
         boolean get;
         switch(i.f.op[i.pc]) {
             case Tokens.RETURN: case ByteCodes.PUT: get = false; break;
-            case ByteCodes.GET: get = true; break;
+            case ByteCodes.GET: case ByteCodes.CALL: get = true; break;
             default: throw new Error("should never happen");
         }
         i.pausecount++;