2004/01/03 04:27:27
[org.ibex.core.git] / src / org / xwt / js / JS.java
index de0c5fc..c6d5dd6 100644 (file)
@@ -11,6 +11,10 @@ public class JS extends org.xwt.util.BalancedTree {
 
     // Static Interpreter Control Methods ///////////////////////////////////////////////////////////////
 
+    /** log a message with the current JavaScript sourceName/line */
+    public static void log(Object o, Object message) { log(message); }
+    public static void log(Object message) { Log.echo(JS.getSourceName() + ":" + JS.getLine(), message); }
+
     public static int getLine() {
         Interpreter c = Interpreter.current();
         return c == null || c.f == null || c.pc < 0 || c.pc >= c.f.size ? -1 : c.f.line[c.pc];
@@ -21,15 +25,6 @@ public class JS extends org.xwt.util.BalancedTree {
         return c == null || c.f == null ? null : c.f.sourceName;
     } 
 
-    public static class PausedException extends Exception { PausedException() { } }
-
-    public static void invokePauseable(JSFunction function) throws JS.PausedException, JSExn {
-        Interpreter i = new Interpreter(function, true, new JSArray());
-        int oldpausecount = i.pausecount;
-        i.resume();
-        if (i.pausecount > oldpausecount) throw new PausedException();
-    }
-
     public static class NotPauseableException extends Exception { NotPauseableException() { } }
 
     /** returns a callback which will restart the context; expects a value to be pushed onto the stack when unpaused */
@@ -40,9 +35,10 @@ public class JS extends org.xwt.util.BalancedTree {
         return new JS.UnpauseCallback(i);
     }
 
-    public static class UnpauseCallback {
+    public static class UnpauseCallback implements Scheduler.Task {
         Interpreter i;
         UnpauseCallback(Interpreter i) { this.i = i; }
+        public void perform() throws JSExn { unpause(null); }
         public void unpause(Object o) throws JSExn {
             // FIXME: if o instanceof JSExn, throw it into the JSworld
             i.stack.push(o);