src/jdk/nashorn/internal/runtime/arrays/IteratorAction.java
Print this page
*** 25,34 ****
--- 25,35 ----
package jdk.nashorn.internal.runtime.arrays;
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
+ import jdk.nashorn.api.scripting.ScriptObjectMirror;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptRuntime;
/**
*** 94,109 ****
/**
* Apply action main loop.
* @return result of apply
*/
public final T apply() {
! if (!(callbackfn instanceof ScriptFunction)) {
throw typeError("not.a.function", ScriptRuntime.safeToString(callbackfn));
}
! final ScriptFunction func = ((ScriptFunction)callbackfn);
// for non-strict callback, need to translate undefined thisArg to be global object
! thisArg = (thisArg == ScriptRuntime.UNDEFINED && !func.isStrict()) ? Context.getGlobal() : thisArg;
applyLoopBegin(iter);
final boolean reverse = iter.isReverse();
while (iter.hasNext()) {
--- 95,116 ----
/**
* Apply action main loop.
* @return result of apply
*/
public final T apply() {
! final boolean strict;
! if (callbackfn instanceof ScriptFunction) {
! strict = ((ScriptFunction)callbackfn).isStrict();
! } else if (callbackfn instanceof ScriptObjectMirror &&
! ((ScriptObjectMirror)callbackfn).isFunction()) {
! strict = ((ScriptObjectMirror)callbackfn).isStrictFunction();
! } else {
throw typeError("not.a.function", ScriptRuntime.safeToString(callbackfn));
}
!
// for non-strict callback, need to translate undefined thisArg to be global object
! thisArg = (thisArg == ScriptRuntime.UNDEFINED && !strict)? Context.getGlobal() : thisArg;
applyLoopBegin(iter);
final boolean reverse = iter.isReverse();
while (iter.hasNext()) {