use of com.github.anba.es6draft.runtime.internal.ScriptRuntime.CheckCallable in project es6draft by anba.
the class Interpreter method EvaluateCall.
/**
* 12.3.4.2 Runtime Semantics: EvaluateCall( ref, arguments, tailPosition )<br>
* 12.3.4.3 Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments, tailPosition )
*
* @param ref
* the call base reference
* @param arguments
* the function call arguments
* @param directEval
* the direct eval flag
* @param cx
* the execution context
* @return the return value after applying the call operation
*/
private Object EvaluateCall(Object ref, List<Expression> arguments, boolean directEval, ExecutionContext cx) {
/* steps 1-2 (EvaluateCall) */
Object func = GetValue(ref, cx);
/* steps 3-4 (EvaluateCall) */
Object thisValue = UNDEFINED;
if (ref instanceof Reference) {
Reference<?, ?> rref = (Reference<?, ?>) ref;
if (rref.isPropertyReference()) {
thisValue = rref.getThisValue();
} else if (!(rref instanceof Reference.BindingReference)) {
assert rref instanceof Reference.IdentifierReference;
Reference.IdentifierReference<?> idref = (Reference.IdentifierReference<?>) rref;
ScriptObject newThisValue = idref.getBase().withBaseObject();
if (newThisValue != null) {
thisValue = newThisValue;
}
}
}
/* steps 1-2 (EvaluateDirectCall) */
Object[] argList = ArgumentListEvaluation(arguments, cx);
/* steps 3-4 (EvaluateDirectCall) */
Callable f = CheckCallable(func, cx);
/* [12.3.4.1 Runtime Semantics: Evaluation - step 3] */
if (directEval && IsBuiltinEval(ref, f, cx)) {
int evalFlags = EvalFlags.Direct.getValue();
if (strict) {
evalFlags |= EvalFlags.Strict.getValue();
}
evalFlags |= EvalFlags.toFlags(parserOptions);
return Eval.directEval(argList, cx, evalFlags);
}
if (directEval && ScriptRuntime.directEvalFallbackHook(cx) != null) {
argList = ScriptRuntime.directEvalFallbackArguments(f, cx, thisValue, argList);
thisValue = ScriptRuntime.directEvalFallbackThisArgument(cx);
f = ScriptRuntime.directEvalFallbackHook(cx);
}
/* steps 6, 9 (EvaluateDirectCall) */
return f.call(cx, thisValue, argList);
}
Aggregations