jswitch
[org.ibex.core.git] / src / org / ibex / js / JSPrimitive.java
index 1b574ea..904a587 100644 (file)
@@ -1,11 +1,8 @@
 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");
@@ -15,7 +12,7 @@ class JSPrimitive extends JS {
         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;
@@ -82,13 +79,11 @@ class JSPrimitive extends JS {
             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;
@@ -109,6 +104,6 @@ class JSPrimitive extends JS {
         case "toExponential": return METHOD;
         case "toFixed": return METHOD;
         //#end
-        return super.get(key_);
+        return super.get(key);
     }
 }