2003/11/29 03:06:09
[org.ibex.core.git] / src / org / xwt / js / JS.java
index 28622a3..5da9e76 100644 (file)
@@ -23,7 +23,7 @@ public class JS extends org.xwt.util.BalancedTree {
 
     public static class PausedException extends Exception { PausedException() { } }
 
-    public static void invokePauseable(JSFunction function) throws JS.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();
@@ -43,7 +43,7 @@ public class JS extends org.xwt.util.BalancedTree {
     public static class UnpauseCallback {
         Interpreter i;
         UnpauseCallback(Interpreter i) { this.i = i; }
-        public void unpause(Object o) throws PausedException {
+        public void unpause(Object o) throws PausedException, JSExn {
             i.stack.push(o);
             i.resume();
         }
@@ -140,9 +140,14 @@ public class JS extends org.xwt.util.BalancedTree {
         };
     
     private Hash entries = null;
-    public Enumeration keys() { return entries == null ? emptyEnumeration : entries.keys(); }
-    public Object get(Object key) { return entries == null ? null : entries.get(key, null); }
-    public void put(Object key, Object val) { if (entries == null) entries = new Hash(); entries.put(key, null, val); }
+    public Enumeration keys() throws JSExn {
+        return entries == null ? emptyEnumeration : entries.keys();
+    }
+    public Object get(Object key) throws JSExn { return entries == null ? null : entries.get(key, null); }
+    public void put(Object key, Object val) throws JSExn {
+        if (entries == null) entries = new Hash();
+        entries.put(key, null, val);
+    }
 
 
     // Trap support //////////////////////////////////////////////////////////////////////////////
@@ -151,14 +156,14 @@ public class JS extends org.xwt.util.BalancedTree {
     protected boolean isTrappable() { return false; }
 
     /** performs a put, triggering traps if present; traps are run in an unpauseable interpreter */
-    public final void putAndTriggerTraps(Object key, Object value) {
+    public void putAndTriggerTraps(Object key, Object value) throws JSExn {
         Trap t = getTrap(key);
         if (t != null) t.invoke(key, value);
         else put(key, value);
     }
 
     /** performs a get, triggering traps if present; traps are run in an unpauseable interpreter */
-    public final Object getAndTriggerTraps(Object key) {
+    public Object getAndTriggerTraps(Object key) throws JSExn {
         Trap t = getTrap(key);
         if (t != null) return t.invoke(key);
         else return get(key);
@@ -195,19 +200,19 @@ public class JS extends org.xwt.util.BalancedTree {
 
     // return this from get() if the key was actually a method.
     public static final Object METHOD = new Object();
-    public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) {
+    public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
         throw new JSExn("attempted to call the null value (method "+method+")");
     }    
-    public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) {
+    public Object call(Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
         throw new JSExn("you cannot call this object (class=" + this.getClass().getName() +")");
     }
 
 
     // Typing Support //////////////////////////////////////////////////////////////////////////////
 
-    public Number coerceToNumber() { throw new JSExn("tried to coerce a JavaScript object to a Number"); }
-    public String coerceToString() { throw new JSExn("tried to coerce a JavaScript object to a String"); }
-    public boolean coerceToBoolean() { throw new JSExn("tried to coerce a JavaScript object to a Boolean"); }
+    public Number coerceToNumber() { throw new JSRuntimeExn("tried to coerce a JavaScript object to a Number"); }
+    public String coerceToString() { throw new JSRuntimeExn("tried to coerce a JavaScript object to a String"); }
+    public boolean coerceToBoolean() { throw new JSRuntimeExn("tried to coerce a JavaScript object to a Boolean"); }
 
     public String typeName() { return "object"; }