X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSPrimitive.java;h=be81749b66af10641bc6077c0ed1a1f15d8aa460;hp=71155f3503e16bf2bf7eaaa6eb341e0886bb0053;hb=7113d47d1ef227732b610026bee8c22b9ada3525;hpb=361d18aff8f32e60fb8b6c5c52744a9f1e9890be diff --git a/src/org/ibex/js/JSPrimitive.java b/src/org/ibex/js/JSPrimitive.java index 71155f3..be81749 100644 --- a/src/org/ibex/js/JSPrimitive.java +++ b/src/org/ibex/js/JSPrimitive.java @@ -20,8 +20,8 @@ class JSPrimitive extends JS.Immutable { //#switch(Script.toString(method)) case "substring": { - int a = alength >= 1 ? Script.toInt(arg0) : 0; - int b = alength >= 2 ? Script.toInt(arg1) : slength; + int a = args.length >= 1 ? Script.toInt(args[0]) : 0; + int b = args.length >= 2 ? Script.toInt(args[1]) : slength; if (a > slength) a = slength; if (b > slength) b = slength; if (a < 0) a = 0; @@ -30,8 +30,8 @@ class JSPrimitive extends JS.Immutable { return Script.S(s.substring(a,b)); } case "substr": { - int start = alength >= 1 ? Script.toInt(arg0) : 0; - int len = alength >= 2 ? Script.toInt(arg1) : Integer.MAX_VALUE; + int start = args.length >= 1 ? Script.toInt(args[0]) : 0; + int len = args.length >= 2 ? Script.toInt(args[1]) : Integer.MAX_VALUE; if (start < 0) start = slength + start; if (start < 0) start = 0; if (len < 0) len = 0; @@ -40,12 +40,12 @@ class JSPrimitive extends JS.Immutable { return Script.S(s.substring(start,start+len)); } case "charAt": { - int p = alength >= 1 ? Script.toInt(arg0) : 0; + int p = args.length >= 1 ? Script.toInt(args[0]) : 0; if (p < 0 || p >= slength) return Script.S(""); return Script.S(s.substring(p,p+1)); } case "charCodeAt": { - int p = alength >= 1 ? Script.toInt(arg0) : 0; + int p = args.length >= 1 ? Script.toInt(args[0]) : 0; if (p < 0 || p >= slength) return Script.N(Double.NaN); return Script.N(s.charAt(p)); } @@ -55,26 +55,26 @@ class JSPrimitive extends JS.Immutable { return Script.S(sb.toString()); } case "indexOf": { - String search = alength >= 1 ? Script.toString(arg0) : "null"; - int start = alength >= 2 ? Script.toInt(arg1) : 0; + String search = args.length >= 1 ? Script.toString(args[0]) : "null"; + int start = args.length >= 2 ? Script.toInt(args[1]) : 0; // Java's indexOf handles an out of bounds start index, it'll return -1 return Script.N(s.indexOf(search,start)); } case "lastIndexOf": { - String search = alength >= 1 ? Script.toString(arg0) : "null"; - int start = alength >= 2 ? Script.toInt(arg1) : 0; + String search = args.length >= 1 ? Script.toString(args[0]) : "null"; + int start = args.length >= 2 ? Script.toInt(args[1]) : 0; // Java's indexOf handles an out of bounds start index, it'll return -1 return Script.N(s.lastIndexOf(search,start)); } - case "match": return JSRegexp.stringMatch(this,arg0); - case "replace": return JSRegexp.stringReplace(this,arg0,arg1); - case "search": return JSRegexp.stringSearch(this,arg0); - case "split": return JSRegexp.stringSplit(this,arg0,arg1,alength); + case "match": return JSRegexp.stringMatch(this,args[0]); + case "replace": return JSRegexp.stringReplace(this,args[0],args[1]); + case "search": return JSRegexp.stringSearch(this,args[0]); + case "split": return JSRegexp.stringSplit(this,args[0],args[1],args.length); case "toLowerCase": return Script.S(s.toLowerCase()); case "toUpperCase": return Script.S(s.toUpperCase()); case "slice": { - int a = alength >= 1 ? Script.toInt(arg0) : 0; - int b = alength >= 2 ? Script.toInt(arg1) : slength; + int a = args.length >= 1 ? Script.toInt(args[0]) : 0; + int b = args.length >= 2 ? Script.toInt(args[1]) : slength; if (a < 0) a = slength + a; if (b < 0) b = slength + b; if (a < 0) a = 0;