better enumeration, no need for SWAP(n>1)
[org.ibex.core.git] / src / org / ibex / js / JSArray.java
index 305a5de..2171e4d 100644 (file)
@@ -95,6 +95,7 @@ public class JSArray extends JS.BT {
                 if(i > oldSize) setSize(i);
                 insertElementAt(val,i);
             }
+            return;
         }
         if(isString(key)) {
             if (JS.toString(key).equals("length")) {
@@ -105,14 +106,12 @@ public class JSArray extends JS.BT {
         super.put(key,val);
     }
 
-    // FIXME: Needs to include super's keys
-    public Enumeration keys() {
-        return new Enumeration() {
-                private int n = size();
-                public boolean hasMoreElements() { return n > 0; }
-                public Object nextElement() {
-                    if(n == 0) throw new NoSuchElementException();
-                    return new Integer(--n);
+    public Enumeration keys() throws JSExn {
+        return new Enumeration(super.keys()) {
+                private int n = 0;
+                public boolean _hasMoreElements() { return n < size(); }
+                public JS _nextElement() {
+                    return n >= size() ? null : JS.N(n++);
                 }
             };
     }