private final static Double NaN = new Double(Double.NaN);
private final static Double POSITIVE_INFINITY = new Double(Double.POSITIVE_INFINITY);
- public Global(JSScope parent) {
- super(parent);
- }
- public Object get(Object key) {
- if(key.equals("NaN")) return NaN;
- if(key.equals("Infinity")) return POSITIVE_INFINITY;
- if(key.equals("undefined")) return null;
- return super.get(key);
- }
-
- public Object call(Object method, JSArray args) {
- if (method.equals("stringFromCharCode")) return stringFromCharCode(args);
- return super.call(method, args);
- }
+ public Global(JSScope parent) { super(parent); }
- public Object call1(Object method, Object arg0) {
- //#switch(method)
- case "parseInt": return parseInt(arg0, N(0));
- case "isNaN": { double d = toDouble(arg0); return d == d ? F : T; }
- case "isFinite": { double d = toDouble(arg0); return (d == d && !Double.isInfinite(d)) ? T : F; }
- case "decodeURI": throw new JS.Exn("unimplemented");
- case "decodeURIComponent": throw new JS.Exn("unimplemented");
- case "encodeURI": throw new JS.Exn("unimplemented");
- case "encodeURIComponent": throw new JS.Exn("unimplemented");
- case "escape": throw new JS.Exn("unimplemented");
- case "unescape": throw new JS.Exn("unimplemented");
+ public Object get(Object key) {
+ //#switch(key)
+ case "NaN": return NaN;
+ case "Infinity": return POSITIVE_INFINITY;
+ case "undefined": return null;
+ case "stringFromCharCode": return METHOD;
+ case "parseInt": return METHOD;
+ case "isNaN": return METHOD;
+ case "isFinite": return METHOD;
+ case "decodeURI": return METHOD;
+ case "decodeURIComponent": return METHOD;
+ case "encodeURI": return METHOD;
+ case "encodeURIComponent": return METHOD;
+ case "escape": return METHOD;
+ case "unescape": return METHOD;
+ case "parseInt": return METHOD;
//#end
- return super.call1(method, arg0);
+ return super.get(key);
}
- public Object call2(Object method, Object arg1, Object arg2) {
- if (method.equals("parseInt")) return parseInt(arg1, arg2);
- return super.call2(method, arg1, arg2);
+ public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) {
+ switch(nargs) {
+ case 0: {
+ //#switch(method)
+ case "stringFromCharCode":
+ JSArray args = new JSArray();
+ for(int i=0; i<nargs; i++) args.addElement(i==0?a0:i==1?a1:i==2?a2:rest[i-3]);
+ return stringFromCharCode(args);
+ default: break;
+ //#end
+ }
+ case 1: {
+ //#switch(method)
+ case "parseInt": return parseInt(a0, N(0));
+ case "isNaN": { double d = toDouble(a0); return d == d ? F : T; }
+ case "isFinite": { double d = toDouble(a0); return (d == d && !Double.isInfinite(d)) ? T : F; }
+ case "decodeURI": throw new JS.Exn("unimplemented");
+ case "decodeURIComponent": throw new JS.Exn("unimplemented");
+ case "encodeURI": throw new JS.Exn("unimplemented");
+ case "encodeURIComponent": throw new JS.Exn("unimplemented");
+ case "escape": throw new JS.Exn("unimplemented");
+ case "unescape": throw new JS.Exn("unimplemented");
+ default: break;
+ //#end
+ }
+ case 2: {
+ //#switch(method)
+ case "parseInt": return parseInt(a0, a1);
+ default: break;
+ //#end
+ }
+ }
+ return super.callMethod(method, a0, a1, a2, rest, nargs);
}
private Object stringFromCharCode(JSArray args) {