moved ProxyAutoConfig.java from org.ibex.net.HTTP to this package
[org.ibex.js.git] / src / org / ibex / js / JSArray.java
index dd2aecd..e8529c6 100644 (file)
@@ -12,10 +12,10 @@ public 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 JSArray() { }
+    public JSArray(int size) { super(size); }
+    public JSArray(JS[] args) { super(args.length); addAll(args); }
+    public JSArray(JS arg) { super(1); add(arg); }
 
     public JS unclone() { return this; }
     public JS.Enumeration keys() throws JSExn {
@@ -51,12 +51,13 @@ public class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
             "arrays only support positive integer keys, can not use: "+JSU.str(key));
         int i = ((JSNumber.I)key).toInt();
         if (i < 0) throw new JSExn("arrays can not use negative integer keys "+i);
-        size(i + 1); while (size() < i) add(null);
+        if (size() < i+1) size(i + 1);
+       //while (size() < i) add(null);
         set(i, val);
     }
 
     public String[] getFormalArgs() { return empty; }
-    public String coerceToString() { return "array"; } // FIXME
+    public String coerceToString() throws JSExn { throw new JSExn("cannot coerce a "+getClass().getName()+" to a string"); }
 
     public JS call(JS method, JS[] args) throws JSExn {
         //#switch(JSU.str(method))
@@ -85,9 +86,9 @@ public class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
 
     public void addTrap(JS k, JS f) throws JSExn { throw new JSExn("arrays do not support traps"); }
     public void delTrap(JS k, JS f) throws JSExn { throw new JSExn("arrays do not support traps"); }
-    public JS.Trap getTrap(JS k) throws JSExn { throw new JSExn("arrays do not support traps"); }
+    public JS.Trap getTrap(JS k) throws JSExn { return null; }
 
-    /** FIXME: move to specialised ArrayStore superclass. */
+    /** FEATURE: move to specialised ArrayStore superclass. */
     public void addAll(JS[] entries) { for (int i=0; i < entries.length; i++) add(entries[i]); }
 
     public void setSize(int newSize) {
@@ -122,7 +123,7 @@ public class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
         if(start > length) start = length;
         if(end > length) end = length;
         JSArray a = new JSArray(end-start);
-        for(int i=0;i<end-start;i++) // FIXME: with ArrayStore do System.arraycopy()
+        for(int i=0;i<end-start;i++) // FEATURE: with ArrayStore do System.arraycopy()
             a.set(i, get(start+i));
         return a;
     }
@@ -141,7 +142,7 @@ public class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
         int newLength = oldLength - deleteCount + newCount;
         int lengthChange = newLength - oldLength;
         JSArray ret = new JSArray(deleteCount);
-        for(int i=0;i<deleteCount;i++) // FIXME: ArrayStore System.arraycopy()
+        for(int i=0;i<deleteCount;i++) // FEATURE: ArrayStore System.arraycopy()
             ret.set(i, get(start+i));
         if(lengthChange > 0) {
             setSize(newLength);