function evaluateForStatement({ node, environment, evaluate, reporting, statementTraversalStack, typescript }) {
    // Prepare a lexical environment for the ForStatement
    const forEnvironment = cloneLexicalEnvironment(environment);
    // Evaluate the initializer if it is given
    if (node.initializer !== undefined) {
        if (typescript.isVariableDeclarationList(node.initializer)) {
            for (const declaration of node.initializer.declarations) {
                evaluate.declaration(declaration, forEnvironment, statementTraversalStack);
            }
        }
        else {
            evaluate.expression(node.initializer, forEnvironment, statementTraversalStack);
        }
    }
    while (true) {
        // Prepare a lexical environment for the current iteration
        const iterationEnvironment = cloneLexicalEnvironment(forEnvironment);
        // Define a new binding for a break symbol within the environment
        setInLexicalEnvironment({ env: iterationEnvironment, path: BREAK_SYMBOL, value: false, newBinding: true, reporting, node });
        // Define a new binding for a continue symbol within the environment
        setInLexicalEnvironment({ env: iterationEnvironment, path: CONTINUE_SYMBOL, value: false, newBinding: true, reporting, node });
        // Evaluate the condition. It may be truthy always
        const conditionResult = node.condition == null ? true : evaluate.expression(node.condition, forEnvironment, statementTraversalStack);
        // If the condition doesn't hold, return immediately
        if (!conditionResult)
            return;
        // Execute the Statement
        evaluate.statement(node.statement, iterationEnvironment);
        // Check if a 'break' statement has been encountered and break if so
        if (pathInLexicalEnvironmentEquals(node, iterationEnvironment, true, BREAK_SYMBOL)) {
            break;
        }
        else if (pathInLexicalEnvironmentEquals(node, iterationEnvironment, true, RETURN_SYMBOL)) {
            return;
        }
        // Run the incrementor
        if (node.incrementor != null) {
            evaluate.expression(node.incrementor, forEnvironment, statementTraversalStack);
        }
        // Always run the incrementor before continuing
        else if (pathInLexicalEnvironmentEquals(node, iterationEnvironment, true, CONTINUE_SYMBOL)) {
            // noinspection UnnecessaryContinueJS
            continue;
        }
    }
}
/**
 * Evaluates, or attempts to evaluate, a ForStatement
 */
Evaluates, or attempts to evaluate, a ForStatement
Evaluates or attempts to evaluate a ForStatement
function evaluateForStatement({ node, environment, evaluate, reporting, statementTraversalStack, typescript }) {
    const forEnvironment = cloneLexicalEnvironment(environment);
    if (node.initializer !== undefined) {
        if (typescript.isVariableDeclarationList(node.initializer)) {
            for (const declaration of node.initializer.declarations) {
                evaluate.declaration(declaration, forEnvironment, statementTraversalStack);
            }
        }
        else {
            evaluate.expression(node.initializer, forEnvironment, statementTraversalStack);
        }
    }
    while (true) {
        const iterationEnvironment = cloneLexicalEnvironment(forEnvironment);
        setInLexicalEnvironment({ env: iterationEnvironment, path: BREAK_SYMBOL, value: false, newBinding: true, reporting, node });
        setInLexicalEnvironment({ env: iterationEnvironment, path: CONTINUE_SYMBOL, value: false, newBinding: true, reporting, node });
        const conditionResult = node.condition == null ? true : evaluate.expression(node.condition, forEnvironment, statementTraversalStack);
        if (!conditionResult)
            return;
        evaluate.statement(node.statement, iterationEnvironment);
        if (pathInLexicalEnvironmentEquals(node, iterationEnvironment, true, BREAK_SYMBOL)) {
            break;
        }
        else if (pathInLexicalEnvironmentEquals(node, iterationEnvironment, true, RETURN_SYMBOL)) {
            return;
        }
        if (node.incrementor != null) {
            evaluate.expression(node.incrementor, forEnvironment, statementTraversalStack);
        }
        else if (pathInLexicalEnvironmentEquals(node, iterationEnvironment, true, CONTINUE_SYMBOL)) {
            continue;
        }
    }
}
function evaluateForStatement ( { node , environment , evaluate , reporting , statementTraversalStack , typescript } ) { const forEnvironment = cloneLexicalEnvironment ( environment ) ; if ( node . initializer !== undefined ) { if ( typescript . isVariableDeclarationList ( node . initializer ) ) { for ( const declaration of node . initializer . declarations ) { evaluate . declaration ( declaration , forEnvironment , statementTraversalStack ) ; } } else { evaluate . expression ( node . initializer , forEnvironment , statementTraversalStack ) ; } } while ( true ) { const iterationEnvironment = cloneLexicalEnvironment ( forEnvironment ) ; setInLexicalEnvironment ( { env : iterationEnvironment , path : BREAK_SYMBOL , value : false , newBinding : true , reporting , node } ) ; setInLexicalEnvironment ( { env : iterationEnvironment , path : CONTINUE_SYMBOL , value : false , newBinding : true , reporting , node } ) ; const conditionResult = node . condition == null ? true : evaluate . expression ( node . condition , forEnvironment , statementTraversalStack ) ; if ( ! conditionResult ) return ; evaluate . statement ( node . statement , iterationEnvironment ) ; if ( pathInLexicalEnvironmentEquals ( node , iterationEnvironment , true , BREAK_SYMBOL ) ) { break ; } else if ( pathInLexicalEnvironmentEquals ( node , iterationEnvironment , true , RETURN_SYMBOL ) ) { return ; } if ( node . incrementor != null ) { evaluate . expression ( node . incrementor , forEnvironment , statementTraversalStack ) ; } else if ( pathInLexicalEnvironmentEquals ( node , iterationEnvironment , true , CONTINUE_SYMBOL ) ) { continue ; } } }
Evaluates, or attempts to evaluate, a ForStatement
Evaluates or attempts to evaluate a ForStatement
// Prepare a lexical environment for the ForStatement // Evaluate the initializer if it is given // Prepare a lexical environment for the current iteration // Define a new binding for a break symbol within the environment // Define a new binding for a continue symbol within the environment // Evaluate the condition. It may be truthy always // If the condition doesn't hold, return immediately // Execute the Statement // Check if a 'break' statement has been encountered and break if so // Run the incrementor // Always run the incrementor before continuing // noinspection UnnecessaryContinueJS