if(i > oldSize) setSize(i);
insertElementAt(val,i);
}
+ return;
}
if(isString(key)) {
if (JS.toString(key).equals("length")) {
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++);
}
};
}
a.setElementAt(elementAt(start+i),i);
return a;
}
-
+
private static final Vec.CompareFunc defaultSort = new Vec.CompareFunc() {
public int compare(Object a, Object b) {
try {
return JS.toString((JS)a).compareTo(JS.toString((JS)b));
- } catch(JSExn e) {
- // FIXME: See emca about this
- throw new RuntimeException(e.toString());
- }
+ } catch(JSExn e) { throw new JSExn.Wrapper(e); }
}
};
private JS sort(JS tmp) throws JSExn {
Vec vec = toVec();
- if(tmp instanceof JS) {
- final JS jsFunc = (JS) tmp;
- vec.sort(new Vec.CompareFunc() {
- public int compare(Object a, Object b) {
- try {
- return JS.toInt(jsFunc.call((JS)a, (JS)b, null, null, 2));
- } catch (JSExn e) {
- // FIXME: Check ecma to see what we should do here
- throw new RuntimeException(e.toString());
+ try {
+ if(tmp instanceof JS) {
+ final JS jsFunc = (JS) tmp;
+ vec.sort(new Vec.CompareFunc() {
+ public int compare(Object a, Object b) {
+ try {
+ return JS.toInt(jsFunc.call((JS)a, (JS)b, null, null, 2));
+ } catch(JSExn e) { throw new JSExn.Wrapper(e); }
}
- }
- });
- } else {
- vec.sort(defaultSort);
+ });
+ } else {
+ vec.sort(defaultSort);
+ }
+ } catch(JSExn.Wrapper e) {
+ throw e.refill();
}
setFromVec(vec);
return this;