package org.ibex.js;
class JSPrimitive extends JS {
- public JS callMethod(JS method_, JS arg0, JS arg1, JS arg2, JS[] rest, int alength) throws JSExn {
- if(!JS.isString(method_)) return super.callMethod(method_,arg0,arg1,arg2,rest,alength);
- String method = JS.toString(method_);
-
- //#switch(method)
+ public JS callMethod(JS method, JS arg0, JS arg1, JS arg2, JS[] rest, int alength) throws JSExn {
+ //#jswitch(method)
case "toFixed": throw new JSExn("toFixed() not implemented");
case "toExponential": throw new JSExn("toExponential() not implemented");
case "toPrecision": throw new JSExn("toPrecision() not implemented");
String s = coerceToString();
int slength = s.length();
- //#switch(method)
+ //#jswitch(method)
case "substring": {
int a = alength >= 1 ? JS.toInt(arg0) : 0;
int b = alength >= 2 ? JS.toInt(arg1) : slength;
return JS.S(s.substring(a,b));
}
//#end
- return super.callMethod(method_,arg0,arg1,arg2,rest,alength);
+ return super.callMethod(method,arg0,arg1,arg2,rest,alength);
}
- public JS get(JS key_) throws JSExn {
- if(!JS.isString(key_)) return super.get(key_);
- String key = JS.toString(key_);
- //#switch(key)
+ public JS get(JS key) throws JSExn {
+ //#jswitch(key)
case "length": return JS.N(JS.toString(this).length());
case "substring": return METHOD;
case "charAt": return METHOD;
case "toExponential": return METHOD;
case "toFixed": return METHOD;
//#end
- return super.get(key_);
+ return super.get(key);
}
}