private static long toArrayIndex(double d) { if (d == d) { long index = ScriptRuntime.toUint32(d); if (index == d && index != 4294967295L) { return index; } } return -1; }
private static long toArrayIndex(double d) { if (d == d) { long index = ScriptRuntime.toUint32(d); if (index == d && index != 4294967295L) { return index; } } return -1; }
private static long toArrayIndex(double d) { if (d == d) { long index = ScriptRuntime.toUint32(d); if (index == d && index != 4294967295L) { return index; } } return -1; }
private static long toArrayIndex(double d) { if (d == d) { long index = ScriptRuntime.toUint32(d); if (index == d && index != 4294967295L) { return index; } } return -1; }
public static long toUint32(Object val) { return toUint32(toNumber(val)); }
public static long toUint32(Object val) { return toUint32(toNumber(val)); }
public static long toUint32(Object val) { return toUint32(toNumber(val)); }
public static long toUint32(Object val) { return toUint32(toNumber(val)); }
private static long toArrayIndex(String id) { double d = ScriptRuntime.toNumber(id); if (d == d) { long index = ScriptRuntime.toUint32(d); if (index == d && index != 4294967295L) { // Assume that ScriptRuntime.toString(index) is the same // as java.lang.Long.toString(index) for long if (Long.toString(index).equals(id)) { return index; } } } return -1; }
public static long toUint32(Object val) { return toUint32(toNumber(val)); }
public static long toUint32(Object val) { return toUint32(toNumber(val)); }
private static long toArrayIndex(String id) { double d = ScriptRuntime.toNumber(id); if (d == d) { long index = ScriptRuntime.toUint32(d); if (index == d && index != 4294967295L) { // Assume that ScriptRuntime.toString(index) is the same // as java.lang.Long.toString(index) for long if (Long.toString(index).equals(id)) { return index; } } } return -1; }
private ModuleSource loadFromPathArray(String moduleId, Scriptable paths, Object validator) throws IOException { final long llength = ScriptRuntime.toUint32( ScriptableObject.getProperty(paths, "length")); // Yeah, I'll ignore entries beyond Integer.MAX_VALUE; so sue me. int ilength = llength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)llength; for(int i = 0; i < ilength; ++i) { final String path = ensureTrailingSlash( ScriptableObject.getTypedProperty(paths, i, String.class)); try { URI uri = new URI(path); if (!uri.isAbsolute()) { uri = new File(path).toURI().resolve(""); } final ModuleSource moduleSource = loadFromUri( uri.resolve(moduleId), uri, validator); if(moduleSource != null) { return moduleSource; } } catch(URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } } return null; }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } return ScriptRuntime.toUint32( ScriptRuntime.getObjectProp(obj, "length", cx)); }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } return ScriptRuntime.toUint32( ScriptRuntime.getObjectProp(obj, "length", cx)); }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } return ScriptRuntime.toUint32( ScriptRuntime.getObjectProp(obj, "length", cx)); }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } Object len = ScriptableObject.getProperty(obj, "length"); if (len == Scriptable.NOT_FOUND) { // toUint32(undefined) == 0 return 0; } return ScriptRuntime.toUint32(len); }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } return ScriptRuntime.toUint32( ScriptRuntime.getObjectProp(obj, "length", cx)); }
static long getLengthProperty(Context cx, Scriptable obj) { // These will both give numeric lengths within Uint32 range. if (obj instanceof NativeString) { return ((NativeString)obj).getLength(); } else if (obj instanceof NativeArray) { return ((NativeArray)obj).getLength(); } Object len = ScriptableObject.getProperty(obj, "length"); if (len == Scriptable.NOT_FOUND) { // toUint32(undefined) == 0 return 0; } return ScriptRuntime.toUint32(len); }
/** * See ECMA 15.4.1,2 */ private static Object jsConstructor(Context cx, Scriptable scope, Object[] args) { if (args.length == 0) return new NativeArray(0); // Only use 1 arg as first element for version 1.2; for // any other version (including 1.3) follow ECMA and use it as // a length. if (cx.getLanguageVersion() == Context.VERSION_1_2) { return new NativeArray(args); } else { Object arg0 = args[0]; if (args.length > 1 || !(arg0 instanceof Number)) { return new NativeArray(args); } else { long len = ScriptRuntime.toUint32(arg0); if (len != ((Number)arg0).doubleValue()) throw Context.reportRuntimeError0("msg.arraylength.bad"); return new NativeArray(len); } } }