FIXME triage and formatting cleanups
[org.ibex.js.git] / src / org / ibex / js / JSU.java
index 9fa3630..805224b 100644 (file)
@@ -9,8 +9,11 @@ public class JSU {
 
     public static final JS[] emptyArgs = new JS[] { };
 
 
     public static final JS[] emptyArgs = new JS[] { };
 
-    // FIXME
-    public static InputStream getInputStream(JS j) { return null; }
+    public static InputStream getInputStream(JS j) throws IOException {
+        while(j != null && j instanceof JS.Cloneable) j = j.unclone();
+        if (j != null && j instanceof Fountain) return ((Fountain)j).getInputStream();
+        return null;
+    }
 
     /** returns a Pausable which will restart the context;
      *  expects a value to be pushed onto the stack when unpaused. */
 
     /** returns a Pausable which will restart the context;
      *  expects a value to be pushed onto the stack when unpaused. */
@@ -119,13 +122,8 @@ public class JSU {
     public static JS fromReader(String sourceName, int firstLine, Reader source) throws IOException {
         return Parser.fromReader(sourceName, firstLine, source); }
 
     public static JS fromReader(String sourceName, int firstLine, Reader source) throws IOException {
         return Parser.fromReader(sourceName, firstLine, source); }
 
-    // FIXME
     public static JS cloneWithNewGlobalScope(JS js, JS s) {
     public static JS cloneWithNewGlobalScope(JS js, JS s) {
-        if(js instanceof JSFunction)
-            return ((JSFunction)js)._cloneWithNewParentScope(new JSScope.Top(s));
-        else
-            return js;
-    }
+        return js instanceof JSFunction ?  ((JSFunction)js)._cloneWithNewParentScope(new JSScope.Top(s)) : js; }
 
     /** log a message with the current JavaScript sourceName/line */
     public static void log(Object message) { info(message); }
 
     /** log a message with the current JavaScript sourceName/line */
     public static void log(Object message) { info(message); }