X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJS.java;h=6b40fe8774405e208ee72a536f4be79479484128;hp=6d17d316797ce5e1cd69f67378da8daad74ef3fb;hb=7113d47d1ef227732b610026bee8c22b9ada3525;hpb=361d18aff8f32e60fb8b6c5c52744a9f1e9890be diff --git a/src/org/ibex/js/JS.java b/src/org/ibex/js/JS.java index 6d17d31..6b40fe8 100644 --- a/src/org/ibex/js/JS.java +++ b/src/org/ibex/js/JS.java @@ -251,15 +251,13 @@ public interface JS extends Pausable { return (JS)new Interpreter(t, val, true).run(null); } - /** returns a callback which will restart the context; expects a value to be pushed onto the stack when unpaused */ - public static UnpauseCallback pause() throws NotPauseableException { - Interpreter i = Interpreter.current(); - if (i.pausecount == -1) throw new NotPauseableException(); - boolean get; - switch(i.f.op[i.pc]) { - case Tokens.RETURN: case ByteCodes.PUT: get = false; break; - case ByteCodes.GET: case ByteCodes.CALL: get = true; break; - default: throw new Error("should never happen"); + public void addTrap(JS key, JS f) throws JSExn { + if (f.getFormalArgs() == null || f.getFormalArgs().length > 1) throw new JSExn( + "traps must take either one argument (write) or no arguments (read)"); + int i = indexOf(key); if (i < 0) i = put(i, key); + for (Trap t = (Trap)entries[i + 2]; t != null; t = t.next()) + if (t.function().equals(f)) return; + entries[i + 2] = new TrapHolder(this, key, f, (Trap)entries[i + 2]); } public void delTrap(JS key, JS f) throws JSExn {