Refine search
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { String stack = args[0].toString(); return new NativeArray(resultParser.decodeStack(stack)); } };
final Context context = Context.getCurrentContext(); final Window window = (Window) ScriptRuntime.getTopCallScope(context); if (window.getBrowserVersion().hasFeature(JS_WEAKMAP_CONSTRUCTOR_IGNORE_ARGUMENT)) { for (int i = 0; i < array.getLength(); i++) { final Object entryObject = array.get(i); if (entryObject instanceof NativeArray) { final Object[] entry = toArray((NativeArray) entryObject); throw Context.reportRuntimeError("TypeError: object is not iterable (" + entryObject.getClass().getName() + ")"); if (Iterator.iterate(Context.getCurrentContext(), this, scriptable, value -> { if (Undefined.instance != value && value instanceof NativeArray) {
if (filename == null) { ps.println(cx.getImplementationVersion()); cx.setOptimizationLevel(-1); if (cx.stringIsCompilableUnit(source)) break; ps.print(prompts[1]); h.put((int)h.getLength(), h, source);
for (int i = 0; i < array.getLength(); i++) { final Object value = ScriptableObject.getProperty(array, i); if (Undefined.instance != value if (Iterator.iterate(Context.getCurrentContext(), this, scriptable, value -> { if (Undefined.instance != value throw Context.reportRuntimeError("TypeError: object is not iterable (" + iterable.getClass().getName() + ")");
Locale locale = new Locale("en", "US"); if (locales instanceof NativeArray) { if (((NativeArray) locales).getLength() != 0) { locale = new Locale(((NativeArray) locales).get(0).toString()); throw Context.throwAsScriptRuntimeEx(new Exception("Unknown type " + locales.getClass().getName()));
/** * 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); } } }
private static Promise all(final boolean race, final Scriptable thisObj, final Object[] args) { final Window window = getWindow(thisObj); final Promise returnPromise = new Promise(window); if (args.length == 0) { returnPromise.all_ = new Promise[0]; } else if (args[0] instanceof NativeArray) { final NativeArray array = (NativeArray) args[0]; final int length = (int) array.getLength(); returnPromise.all_ = new Promise[length]; for (int i = 0; i < length; i++) { final Object o = array.get(i); if (o instanceof Promise) { returnPromise.all_[i] = (Promise) o; if (returnPromise.all_[i].dependentPromises_ == null) { returnPromise.all_[i].dependentPromises_ = new ArrayList<Promise>(2); } returnPromise.all_[i].dependentPromises_.add(returnPromise); } else { returnPromise.all_[i] = create(thisObj, new Object[] {o}, PromiseState.FULFILLED); } } } // TODO handle the other cases returnPromise.race_ = race; returnPromise.settleAll(window); return returnPromise; }
if (subtree_ || target == node_.getDomNodeOrDie()) { final String attributeName = event.getName(); if (attributeFilter_ == null || attributeFilter_.contains(attributeName)) { final MutationRecord mutationRecord = new MutationRecord(); final Scriptable scope = getParentScope(); @Override public void execute() throws Exception { final NativeArray array = new NativeArray(new Object[] {mutationRecord}); ScriptRuntime.setBuiltinProtoAndParent(array, scope, TopLevel.Builtins.Array); jsEngine.callFunction(owningPage, function_, scope,
static void init(Scriptable scope, boolean sealed) { NativeArray obj = new NativeArray(0); obj.exportAsJSClass(MAX_PROTOTYPE_ID, scope, sealed); }
/** @deprecated Use {@link #getLength()} instead. */ public long jsGet_length() { return getLength(); }
long length = array.getLength(); Class<?> arrayType = type.getComponentType(); Object Result = Array.newInstance(arrayType, (int)length); try { Array.set(Result, i, coerceType(arrayType, array.get(i, array))); Context cx = Context.getContext(); Object glue = InterfaceAdapter.create(cx, type, (Callable)value);
private static void appendNativeArray(final NativeArray a, final StringBuilder sb, final int level) { sb.append("["); if (level < 3) { for (int i = 0; i < a.size(); i++) { if (i > 0) { sb.append(", "); } final Object val = a.get(i); if (val != null) { appendValue(val, sb, level + 1); } } } sb.append("]"); }
long longVal = ScriptRuntime.toUint32(d); if (longVal != d) throw Context.reportRuntimeError0("msg.arraylength.bad"); } else if (longVal < MAX_PRE_GROW_SIZE && longVal < (length * GROW_FACTOR) && ensureCapacity((int)longVal)) Object[] e = getIds(); // will only find in object itself for (int i=0; i < e.length; i++) { Object id = e[i]; long index = toArrayIndex(strId); if (index >= longVal) delete(strId); } else { int index = ((Integer)id).intValue(); if (index >= longVal) delete(index); deleteElem(this, i);
@Override public Object item(int index) { return array.get(index); } };
addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_join, "join", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_reverse, "reverse", 1); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_sort, "sort", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_push, "push", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_pop, "pop", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_shift, "shift", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_unshift, "unshift", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_splice, "splice", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_concat, "concat", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_slice, "slice", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_indexOf, "indexOf", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_lastIndexOf, "lastIndexOf", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_every, "every", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_filter, "filter", 2); addIdFunctionProperty(ctor, ARRAY_TAG, ConstructorId_forEach,
final Context context = Context.getCurrentContext(); final Window window = (Window) ScriptRuntime.getTopCallScope(context); if (window.getBrowserVersion().hasFeature(JS_MAP_CONSTRUCTOR_IGNORE_ARGUMENT)) { for (int i = 0; i < array.getLength(); i++) { final Object entryObject = array.get(i); if (entryObject instanceof NativeArray) { final Object[] entry = toArray((NativeArray) entryObject); throw Context.reportRuntimeError("TypeError: object is not iterable (" + entryObject.getClass().getName() + ")"); if (Iterator.iterate(Context.getCurrentContext(), this, scriptable, value -> { if (Undefined.instance != value && value instanceof NativeArray) {
final Window window = (Window) ScriptRuntime.getTopCallScope(Context.getCurrentContext()); if (window.getBrowserVersion().hasFeature(JS_SET_CONSTRUCTOR_IGNORE_ARGUMENT)) { return; for (int i = 0; i < array.getLength(); i++) { add(ScriptableObject.getProperty(array, i)); if (Iterator.iterate(Context.getCurrentContext(), this, scriptable, value -> { if (value != Undefined.instance) { throw Context.reportRuntimeError("TypeError: object is not iterable (" + iterable.getClass().getName() + ")");
Locale locale = new Locale("en", "US"); if (locales instanceof NativeArray) { if (((NativeArray) locales).getLength() != 0) { locale = new Locale(((NativeArray) locales).get(0).toString()); throw Context.throwAsScriptRuntimeEx(new Exception("Unknown type " + locales.getClass().getName()));