function evaluateCallExpression({ node, environment, evaluate, statementTraversalStack, typescript, logger }) {
    const evaluatedArgs = [];
    for (let i = 0; i < node.arguments.length; i++) {
        evaluatedArgs[i] = evaluate.expression(node.arguments[i], environment, statementTraversalStack);
    }
    // Evaluate the expression
    const expressionResult = evaluate.expression(node.expression, environment, statementTraversalStack);
    if (isLazyCall(expressionResult)) {
        const currentThisBinding = expressionContainsSuperKeyword(node.expression, typescript) ? getFromLexicalEnvironment(node, environment, THIS_SYMBOL) : undefined;
        const value = expressionResult.invoke(currentThisBinding != null ? currentThisBinding.literal : undefined, ...evaluatedArgs);
        logger.logResult(value, "CallExpression");
        return value;
    }
    // Otherwise, assume that the expression still needs calling
    else {
        // Unless optional chaining is being used, throw a NotCallableError
        if (node.questionDotToken == null && typeof expressionResult !== "function") {
            throw new NotCallableError({ value: expressionResult, node: node.expression });
        }
        const value = typeof expressionResult !== "function" ? undefined : expressionResult(...evaluatedArgs);
        logger.logResult(value, "CallExpression");
        return value;
    }
}
/**
 * Evaluates, or attempts to evaluate, a CallExpression
 */
Evaluates, or attempts to evaluate, a CallExpression
Evaluates or attempts to evaluate a CallExpression
function evaluateCallExpression({ node, environment, evaluate, statementTraversalStack, typescript, logger }) {
    const evaluatedArgs = [];
    for (let i = 0; i < node.arguments.length; i++) {
        evaluatedArgs[i] = evaluate.expression(node.arguments[i], environment, statementTraversalStack);
    }
    const expressionResult = evaluate.expression(node.expression, environment, statementTraversalStack);
    if (isLazyCall(expressionResult)) {
        const currentThisBinding = expressionContainsSuperKeyword(node.expression, typescript) ? getFromLexicalEnvironment(node, environment, THIS_SYMBOL) : undefined;
        const value = expressionResult.invoke(currentThisBinding != null ? currentThisBinding.literal : undefined, ...evaluatedArgs);
        logger.logResult(value, "CallExpression");
        return value;
    }
    else {
        if (node.questionDotToken == null && typeof expressionResult !== "function") {
            throw new NotCallableError({ value: expressionResult, node: node.expression });
        }
        const value = typeof expressionResult !== "function" ? undefined : expressionResult(...evaluatedArgs);
        logger.logResult(value, "CallExpression");
        return value;
    }
}
function evaluateCallExpression ( { node , environment , evaluate , statementTraversalStack , typescript , logger } ) { const evaluatedArgs = [ ] ; for ( let i = 0 ; i < node . arguments . length ; i ++ ) { evaluatedArgs [ i ] = evaluate . expression ( node . arguments [ i ] , environment , statementTraversalStack ) ; } const expressionResult = evaluate . expression ( node . expression , environment , statementTraversalStack ) ; if ( isLazyCall ( expressionResult ) ) { const currentThisBinding = expressionContainsSuperKeyword ( node . expression , typescript ) ? getFromLexicalEnvironment ( node , environment , THIS_SYMBOL ) : undefined ; const value = expressionResult . invoke ( currentThisBinding != null ? currentThisBinding . literal : undefined , ... evaluatedArgs ) ; logger . logResult ( value , "CallExpression" ) ; return value ; } else { if ( node . questionDotToken == null && typeof expressionResult !== "function" ) { throw new NotCallableError ( { value : expressionResult , node : node . expression } ) ; } const value = typeof expressionResult !== "function" ? undefined : expressionResult ( ... evaluatedArgs ) ; logger . logResult ( value , "CallExpression" ) ; return value ; } }
Evaluates, or attempts to evaluate, a CallExpression
Evaluates or attempts to evaluate a CallExpression
// Evaluate the expression // Otherwise, assume that the expression still needs calling // Unless optional chaining is being used, throw a NotCallableError