X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSMath.java;h=816c3e8ee1c9c377f49aa70123a215682716acce;hp=835eefa2c90952933deec0cdc56b24a26e2425e1;hb=85c8f402be33df8440511492fb597fba9c2eb45f;hpb=0e9197be8053d1e3bc8699a8f527d34850024cd7 diff --git a/src/org/ibex/js/JSMath.java b/src/org/ibex/js/JSMath.java index 835eefa..816c3e8 100644 --- a/src/org/ibex/js/JSMath.java +++ b/src/org/ibex/js/JSMath.java @@ -16,18 +16,16 @@ public class JSMath extends JS { private static final JS SQRT1_2 = JS.N(1/java.lang.Math.sqrt(2)); private static final JS SQRT2 = JS.N(java.lang.Math.sqrt(2)); - public JS callMethod(JS method_, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn { - if(!JS.isString(method_)) return super.callMethod(method_,a0,a1,a2,rest,nargs); - String method = JS.toString(method_); + public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn { switch(nargs) { case 0: { - //#switch(method) + //#jswitch(method) case "random": return JS.N(java.lang.Math.random()); //#end break; } case 1: { - //#switch(method) + //#jswitch(method) case "ceil": return JS.N((long)java.lang.Math.ceil(toDouble(a0))); case "floor": return JS.N((long)java.lang.Math.floor(toDouble(a0))); case "round": return JS.N((long)java.lang.Math.round(toDouble(a0))); @@ -45,7 +43,7 @@ public class JSMath extends JS { break; } case 2: { - //#switch(method) + //#jswitch(method) case "min": return JS.N(java.lang.Math.min(toDouble(a0), toDouble(a1))); case "max": return JS.N(java.lang.Math.max(toDouble(a0), toDouble(a1))); case "pow": return JS.N(java.lang.Math.pow(toDouble(a0), toDouble(a1))); @@ -54,13 +52,11 @@ public class JSMath extends JS { break; } } - return super.callMethod(method_, a0, a1, a2, rest, nargs); + return super.callMethod(method, a0, a1, a2, rest, nargs); } - 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 "E": return E; case "LN10": return LN10; case "LN2": return LN2; @@ -88,6 +84,6 @@ public class JSMath extends JS { case "log": return METHOD; case "random": return METHOD; //#end - return super.get(key_); + return super.get(key); } }