X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJS.java;h=65ba3f63c420e5ba0bd6055d4effe080c7478fb2;hp=c13d2a0eb89b1bc45a877ac58d223b4538c7c3df;hb=85c8f402be33df8440511492fb597fba9c2eb45f;hpb=b1c3851aa91d7da83b62c267596ecacb6ac73868 diff --git a/src/org/ibex/js/JS.java b/src/org/ibex/js/JS.java index c13d2a0..65ba3f6 100644 --- a/src/org/ibex/js/JS.java +++ b/src/org/ibex/js/JS.java @@ -74,13 +74,7 @@ public abstract class JS { public final void replaceNode(int index, Object o) { bt().replaceNode(index,o); } public final int indexNode(Object o) { return bt().indexNode(o); } } - - // FEATURE: JS.StringKeys - /* public static StringKeys extends JS { - public JS get(JS key) { return JS.isString(key) ? get(JS.toString(key) : null; } - ... - */ - + JS _unclone() { return this; } public interface Cloneable { } @@ -120,7 +114,7 @@ public abstract class JS { public final JS nextElement() throws JSExn { return !done ? _nextElement() : parent != null ? parent.nextElement() : null; } public JS get(JS key) throws JSExn { - //#switch(JS.toString(key)) + //#jswitch(key) case "hasMoreElements": return B(hasMoreElements()); case "nextElement": return nextElement(); //#end @@ -300,17 +294,21 @@ public abstract class JS { /** performs a put, triggering traps if present; traps are run in an unpauseable interpreter */ public void putAndTriggerTraps(JS key, JS value) throws JSExn { Trap t = getTrap(key); - throw new Error("FIXME"); - /*if (t != null) t.invoke(value); - elese put(key, value);*/ + if(t == null || (t = t.writeTrap()) == null) put(key,value); + else new Interpreter(t,value,false).resume(); } /** performs a get, triggering traps if present; traps are run in an unpauseable interpreter */ public JS getAndTriggerTraps(JS key) throws JSExn { Trap t = getTrap(key); - throw new Error("FIXME"); - /*if (t != null) return t.invoke(); - else return get(key);*/ + if (t == null || (t = t.readTrap()) == null) return get(key); + else return new Interpreter(t,null,false).resume(); + } + + public JS justTriggerTraps(JS key, JS value) throws JSExn { + Trap t = getTrap(key); + if(t == null || (t = t.writeTrap()) == null) return value; + else return new Interpreter(t,value,true).resume(); } /** adds a trap, avoiding duplicates */