X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSU.java;h=805224b7749f23dc7e74d2f42f86243bda107f45;hb=f3ad8b6cba43f3c5364dc2cd9f1d050c1f48f167;hp=a20d075767f1142e0c1ce159a2cb5a0a8b98a6d7;hpb=d6af365692904fafa588dd8fe95a7babcbccf57f;p=org.ibex.js.git diff --git a/src/org/ibex/js/JSU.java b/src/org/ibex/js/JSU.java index a20d075..805224b 100644 --- a/src/org/ibex/js/JSU.java +++ b/src/org/ibex/js/JSU.java @@ -2,12 +2,19 @@ package org.ibex.js; import java.io.Reader; import java.io.IOException; +import java.io.InputStream; import org.ibex.util.*; public class JSU { public static final JS[] emptyArgs = new JS[] { }; + 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. */ public static Pausable pause() throws Pausable.NotPausableException { @@ -115,13 +122,8 @@ public class JSU { 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) { - 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); }