2003/11/29 03:06:09
[org.ibex.core.git] / src / org / xwt / js / JSArray.java
index 56d37e2..2f5f04d 100644 (file)
@@ -22,7 +22,7 @@ public class JSArray extends JS {
         return Integer.parseInt(s);
     }
     
-    public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) {
+    public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn {
         //#switch(method)
         case "pop": return vec.pop();
         case "reverse": return reverse();
@@ -80,7 +80,7 @@ public class JSArray extends JS {
         return super.get(key);
     }
 
-    public void put(Object key, Object val) {
+    public void put(Object key, Object val) throws JSExn {
         if (key.equals("length")) vec.setSize(toNumber(val).intValue());
         int i = intVal(key);
         if (i == Integer.MIN_VALUE) super.put(key, val);
@@ -151,15 +151,20 @@ public class JSArray extends JS {
             return JS.toString(a).compareTo(JS.toString(b));
         }
     };
-    private Object sort(Object tmp) {
+    private Object sort(Object tmp) throws JSExn {
         if(tmp instanceof JS) {
             final JSArray funcArgs = new JSArray(2);
             final JS jsFunc = (JS) tmp;
             vec.sort(new Vec.CompareFunc() {
                 public int compare(Object a, Object b) {
-                    funcArgs.setElementAt(a,0);
-                    funcArgs.setElementAt(b,1);
-                    return JS.toInt(jsFunc.call(a, b, null, null, 2));
+                    try {
+                        funcArgs.setElementAt(a,0);
+                        funcArgs.setElementAt(b,1);
+                        return JS.toInt(jsFunc.call(a, b, null, null, 2));
+                    } catch (Exception e) {
+                        // FIXME
+                        throw new JSRuntimeExn(e.toString());
+                    }
                 }
             });
         } else {