X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJS.java;h=9bd8abcf4a5acd34c03f9bc98db52ea906aad99d;hb=a6fb49b55117ea4cf330b412d2a2fff403fcd053;hp=e47785d76c9f376d0d7ed35939be559e54943465;hpb=8309adefd009d469f3bfecfe94888d188052b5b9;p=org.ibex.js.git diff --git a/src/org/ibex/js/JS.java b/src/org/ibex/js/JS.java index e47785d..9bd8abc 100644 --- a/src/org/ibex/js/JS.java +++ b/src/org/ibex/js/JS.java @@ -55,7 +55,7 @@ public interface JS { public void delTrap(JS key, JS function) throws JSExn; public Trap getTrap(JS key) throws JSExn; - // FIXME: consider renaming/removing these + // FEATURE: consider renaming/removing these public JS unclone(); public String coerceToString() throws JSExn; @@ -81,9 +81,9 @@ public interface JS { public String[] getFormalArgs() { return emptystr; } public String coerceToString() throws JSExn { throw new JSExn("cannot coerce a "+getClass().getName()+" to a string"); } - public JS putAndTriggerTraps(JS key, JS val) throws JSExn { throw new JSExn( - "'" + key + "' is trap read only on class ["+ getClass().getName() +"]"); } - public JS getAndTriggerTraps(JS key) throws JSExn { return null; } // FIXME throw errors? + public JS putAndTriggerTraps(JS key, JS val) throws JSExn { + throw new JSExn("'" + key + "' is trap read only on class ["+ getClass().getName() +"]"); } + public JS getAndTriggerTraps(JS key) throws JSExn { return null; } public JS justTriggerTraps(JS key, JS value) throws JSExn { return null; } public void addTrap(JS key, JS function) throws JSExn { Log.warn(this, "'" + JSU.str(key) + "' is not trappable on class ["+ getClass().getName() +"]"); } @@ -116,7 +116,7 @@ public interface JS { public String coerceToString() throws JSExn { return clonee.coerceToString(); } } - public static class Obj extends Basket.HashMap implements JS { + public static class Obj extends Basket.Hash implements JS { private static final String[] emptystr = new String[0]; private static final Placeholder holder = new Placeholder(); @@ -151,7 +151,7 @@ public interface JS { } public JS getAndTriggerTraps(JS key) throws JSExn { Trap t = (Trap)super.get(key, 1); - return t == null ? (JS)super.get(key) : (JS)new Interpreter(t, null, false).run(null); + return t == null ? (JS)get(key) : (JS)new Interpreter(t, null, false).run(null); } public JS justTriggerTraps(JS key, JS val) throws JSExn { Trap t = (Trap)super.get(key, 1); @@ -207,8 +207,7 @@ public interface JS { public Trap next(); public Trap nextRead(); public Trap nextWrite(); - - public Trap read(); // FIXME reconsider these function names + public Trap read(); // FEATURE reconsider these function names public Trap write(); } @@ -222,6 +221,7 @@ public interface JS { private final Enumeration parent; + public Enumeration() { this(null); } public Enumeration(Enumeration parent) { this.parent = parent; } protected abstract boolean _hasNext(); @@ -248,13 +248,20 @@ public interface JS { protected JS _next() { throw new NoSuchElementException(); } } - public static final class JavaIterator extends Enumeration { - private final Iterator i; + public static class JavaIterator extends Enumeration { + protected final Iterator i; public JavaIterator(Enumeration parent, Iterator i) { super(parent); this.i = i; } protected boolean _hasNext() { return i.hasNext(); } protected JS _next() { return (JS)i.next(); } } + public static class JavaStringEnumeration extends Enumeration { + protected final java.util.Enumeration e; + public JavaStringEnumeration(java.util.Enumeration e) { this.e = e; } + protected boolean _hasNext() { return e.hasMoreElements(); } + protected JS _next() { return JSU.S(e.nextElement().toString()); } + } + public static final class RandomAccessList extends Enumeration { private final List l; private int pos = 0, size;