/** * Conditionals, Loops, and Blocks * * Handles control flow constructs: * - Conditionals (if-else) * - While loops * - Do-while loops * - Block expressions * - Body evaluation * * Interface requirements (from spec): * - evaluateConditional(node) -> Promise * - evaluateWhileLoop(node) -> Promise * - evaluateDoWhileLoop(node) -> Promise * - evaluateBody(node) -> Promise * - evaluateBodyExpression(node) -> Promise * * Error Handling: * - Non-boolean conditions throw RuntimeError(RUNTIME_TYPE_ERROR) * - BreakSignal/ReturnSignal are caught and handled appropriately * - Body evaluation errors propagate correctly * * @internal */ import type { ConditionalNode, WhileLoopNode, DoWhileLoopNode, BodyNode, AssertNode, ErrorNode } from '../../../../types.js'; import type { RillValue } from '../../types/structures.js'; import type { EvalState } from '../state.js'; /** * Evaluate conditional expression (ternary if-else). * * Syntax: * cond ? then ! else - explicit condition * $ -> ? then ! else - piped conditional ($ is condition) * * Condition must evaluate to boolean. Branches create child scopes. * ReturnSignal propagates up (not caught here). */ export declare function evaluateConditional(s: EvalState, node: ConditionalNode): Promise; /** * Evaluate while loop: (cond) @ body * * Condition must evaluate to boolean. Re-evaluated each iteration. * Each iteration creates a child scope (reads parent, writes local only). * Loop body result becomes the accumulator ($) for next iteration. * * BreakSignal exits loop and returns break value. * ReturnSignal propagates up to containing block. */ export declare function evaluateWhileLoop(s: EvalState, node: WhileLoopNode): Promise; /** * Evaluate do-while loop: `do { body } while (cond)` * * Body executes at least once, then condition is checked. * Condition must evaluate to boolean. * Each iteration creates a child scope (reads parent, writes local only). * Loop body result becomes the accumulator ($) for next iteration. * * BreakSignal exits loop and returns break value. * ReturnSignal propagates up to containing block. */ export declare function evaluateDoWhileLoop(s: EvalState, node: DoWhileLoopNode): Promise; /** * Evaluate assert statement. * * Evaluates condition expression, halts with RuntimeError if false. * Returns piped value unchanged on success. * * @param s - Evaluator state * @param node - AssertNode to evaluate * @param input - Input value (for pipe targets) or undefined (for statements) * @returns Original pipe value on successful assertion * @throws RuntimeError with RUNTIME_ASSERTION_FAILED on false condition * @throws RuntimeError with RUNTIME_TYPE_ERROR on non-boolean condition */ export declare function evaluateAssert(s: EvalState, node: AssertNode, input?: RillValue): Promise; /** * Evaluate error statement. * * Evaluates message string literal and halts execution with RuntimeError. * Never returns normally (always throws). * * Forms: * - Direct: error "message" - Uses literal message * - Piped: "message" -> error - Uses piped input as message * * @param s - Evaluator state * @param node - ErrorNode to evaluate * @param input - Input value (for pipe targets) or undefined (for statements) * @returns Never returns (always throws) * @throws RuntimeError with RUNTIME_ERROR_RAISED using evaluated message * @throws RuntimeError with RUNTIME_TYPE_ERROR if message is not string */ export declare function evaluateError(s: EvalState, node: ErrorNode, input?: RillValue): Promise; /** * Evaluate a body node (Block, GroupedExpr, PostfixExpr, or PipeChain). * Used by conditionals and loops. * * Does NOT catch ReturnSignal - it propagates up. * BreakSignal should be caught by the loop that called this. * * Hot path: called from 11 external call sites. Signature is stable — * do not reorder or rename parameters. */ export declare function evaluateBody(s: EvalState, node: BodyNode): Promise; /** * Evaluate a body node as an expression (catches ReturnSignal). * * Used when a body needs to be treated as an expression whose * ReturnSignal should resolve to a value rather than propagate * (see other call sites of this function for current usages). * * Catches ReturnSignal and returns its value. * Other signals (BreakSignal) and errors propagate up. */ export declare function evaluateBodyExpression(s: EvalState, node: BodyNode): Promise;