for(int i=0; i<s.length(); i++) if (s.charAt(i) < '0' || s.charAt(i) > '9') return Integer.MIN_VALUE;
return Integer.parseInt(s);
}
- public Object get(Object key) throws JS.Exn {
+ // 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("trapname")) return org.xwt.Trap.currentTrapname();
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 {
return null;
}
}
- public void put(Object key, Object val) {
+ // we use _put instead of put solely to work around a GCJ bug
+ 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);