-public class JSArray extends JS {
-
- private static final Object NULL = new Object();
- private Vec vec = new Vec();
-
- public JSArray() { }
- public JSArray(int size) { setSize(size); }
-
- private static int intVal(Object o) {
- if (o instanceof Number) {
- int intVal = ((Number)o).intValue();
- if (intVal == ((Number)o).doubleValue()) return intVal;
- return Integer.MIN_VALUE;
+class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
+ private static final JS.Method METHOD = new JS.Method();
+ private static final String[] empty = new String[0];
+
+ JSArray() { }
+ JSArray(int size) { super(size); }
+ JSArray(JS[] args) { super(args.length); addAll(args); }
+ JSArray(JS arg) { super(1); add(arg); }
+
+ public JS unclone() { return this; }
+ public JS.Enumeration keys() throws JSExn {
+ return new Enumeration(null) {
+ private int n = 0;
+ public boolean _hasNext() { return n < size(); }
+ public JS _next() { return JSU.N(n++); }
+ };
+ }
+ public JS get(JS key) throws JSExn {
+ if (key == null || !(key instanceof JSNumber.I)) {
+ //#switch(JSU.str(key))
+ case "pop": return METHOD;
+ case "reverse": return METHOD;
+ case "toString": return METHOD;
+ case "shift": return METHOD;
+ case "join": return METHOD;
+ case "sort": return METHOD;
+ case "slice": return METHOD;
+ case "push": return METHOD;
+ case "unshift": return METHOD;
+ case "splice": return METHOD;
+ case "length": return JSU.N(size());
+ //#end
+ throw new JSExn("arrays only support positive integer keys, can not use: "+JSU.str(key));