- /** The publicly-visible face of JavaScript Array objects */
- public static class Array extends ArrayImpl {
- public Array() { }
- public Array(int size) { super(size); }
- public void setSize(int i) { super.setSize(i); }
- public int length() { return super.length(); }
- public Object elementAt(int i) { return super.elementAt(i); }
- public void addElement(Object o) { super.addElement(o); }
- public void setElementAt(Object o, int i) { super.setElementAt(o, i); }
- public Object get(Object key) { return super._get(key); }
- public void put(Object key, Object val) { super._put(key, val); }
- }
-
- /** Any object which becomes part of the scope chain must support this interface */
- public static class Scope extends ScopeImpl {
- public Scope(Scope parentScope) { this(parentScope, false); }
- public Scope(Scope parentScope, boolean sealed) { super(parentScope, sealed); }
- /** transparent scopes are not returned by THIS */
- public boolean isTransparent() { return super.isTransparent(); }
- public boolean has(Object key) { return super.has(key); }
- public Object get(Object key) { return super._get(key); }
- public void put(Object key, Object val) { super._put(key, val); }
- public void declare(String s) { super.declare(s); }
- }
-
- /** anything that is callable with the () operator */
- public static abstract class Callable extends JS.Obj {
- public abstract Object call(JS.Array args) throws JS.Exn;
- }
-
- /** a Callable which was compiled from JavaScript code */
- public static class CompiledFunction extends CompiledFunctionImpl {
- CompiledFunction(String sourceName, int firstLine, Reader sourceCode, Scope scope) throws IOException {
- super(sourceName, firstLine, sourceCode, scope);
+ /** the result of a graft */
+ // FIXME: uber-broken
+ public static class Graft extends JSCallable {
+ private JS graftee;
+ private Object replaced_key;
+ private Object replaced_val;
+ public Graft(Object graftee, Object key, Object val) {
+ if (graftee instanceof JSArray) throw new JS.Exn("can't graft onto JSArrays (yet)");
+ if (graftee instanceof JSCallable) throw new JS.Exn("can't graft onto JSCallables (yet)");
+ if (graftee instanceof JSScope) throw new JS.Exn("can't graft onto JSScopes (yet)");
+ this.graftee = (JS)graftee;
+ replaced_key = key;
+ replaced_val = val;