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();
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();
}
};
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 //////////////////////////////////////////////////////////////////////////////
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);
// 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"; }