2003/07/05 02:38:15
[org.ibex.core.git] / src / org / xwt / js / ArrayImpl.java
index c4e4bf6..13f7d80 100644 (file)
@@ -25,10 +25,20 @@ class ArrayImpl extends JS.Obj {
     }
     // we use _get instead of get solely to work around a GCJ bug
     public Object _get(Object key) throws JS.Exn {
-        // FIXME: HACK!
-        if (key.equals("cascade")) return org.xwt.Trap.cascadeFunction;
-        if (key.equals("trapee")) return org.xwt.Trap.currentTrapee();
         if (key.equals("length")) return new Long(vec.size());
+        if (key.equals("push")) return new JS.Callable() {
+            public Object call(JS.Array args) {
+                for(int i=0;i<args.length();i++)
+                    vec.push(args.elementAt(i));
+                return new Long(vec.size());
+            }
+        };
+        if (key.equals("pop")) return new JS.Callable() {
+            public Object call(JS.Array args) {
+                return vec.pop(); // this'll return null on size()==0 
+            }
+        };
+                
         int i = intVal(key);
         if (i == Integer.MIN_VALUE) return super.get(key);
         try {
@@ -38,7 +48,7 @@ class ArrayImpl extends JS.Obj {
         }
     }
     // we use _put instead of put solely to work around a GCJ bug
-    public void put(Object key, Object val) {
+    public void _put(Object key, Object val) {
         if (key.equals("length")) vec.setSize(toNumber(val).intValue());
         int i = intVal(key);
         if (i == Integer.MIN_VALUE) super.put(key, val);
@@ -60,5 +70,7 @@ class ArrayImpl extends JS.Obj {
     public Object elementAt(int i) { return vec.elementAt(i); }
     public void addElement(Object o) { vec.addElement(o); }
     public void setElementAt(Object o, int i) { vec.setElementAt(o, i); }
+    
+    public String typeName() { return "array"; }
 }