@rcrsr/rill 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +187 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +69 -0
- package/dist/cli.js.map +1 -0
- package/dist/demo.d.ts +6 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/demo.js +121 -0
- package/dist/demo.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/errors.d.ts +9 -0
- package/dist/lexer/errors.d.ts.map +1 -0
- package/dist/lexer/errors.js +12 -0
- package/dist/lexer/errors.js.map +1 -0
- package/dist/lexer/helpers.d.ts +14 -0
- package/dist/lexer/helpers.d.ts.map +1 -0
- package/dist/lexer/helpers.js +30 -0
- package/dist/lexer/helpers.js.map +1 -0
- package/dist/lexer/index.d.ts +8 -0
- package/dist/lexer/index.d.ts.map +1 -0
- package/dist/lexer/index.js +8 -0
- package/dist/lexer/index.js.map +1 -0
- package/dist/lexer/operators.d.ts +11 -0
- package/dist/lexer/operators.d.ts.map +1 -0
- package/dist/lexer/operators.js +58 -0
- package/dist/lexer/operators.js.map +1 -0
- package/dist/lexer/readers.d.ts +12 -0
- package/dist/lexer/readers.d.ts.map +1 -0
- package/dist/lexer/readers.js +144 -0
- package/dist/lexer/readers.js.map +1 -0
- package/dist/lexer/state.d.ts +18 -0
- package/dist/lexer/state.d.ts.map +1 -0
- package/dist/lexer/state.js +37 -0
- package/dist/lexer/state.js.map +1 -0
- package/dist/lexer/tokenizer.d.ts +9 -0
- package/dist/lexer/tokenizer.d.ts.map +1 -0
- package/dist/lexer/tokenizer.js +100 -0
- package/dist/lexer/tokenizer.js.map +1 -0
- package/dist/lexer.d.ts +19 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +344 -0
- package/dist/lexer.js.map +1 -0
- package/dist/parser/arithmetic.d.ts +16 -0
- package/dist/parser/arithmetic.d.ts.map +1 -0
- package/dist/parser/arithmetic.js +128 -0
- package/dist/parser/arithmetic.js.map +1 -0
- package/dist/parser/boolean.d.ts +15 -0
- package/dist/parser/boolean.d.ts.map +1 -0
- package/dist/parser/boolean.js +20 -0
- package/dist/parser/boolean.js.map +1 -0
- package/dist/parser/control-flow.d.ts +56 -0
- package/dist/parser/control-flow.d.ts.map +1 -0
- package/dist/parser/control-flow.js +167 -0
- package/dist/parser/control-flow.js.map +1 -0
- package/dist/parser/expressions.d.ts +23 -0
- package/dist/parser/expressions.d.ts.map +1 -0
- package/dist/parser/expressions.js +950 -0
- package/dist/parser/expressions.js.map +1 -0
- package/dist/parser/extraction.d.ts +48 -0
- package/dist/parser/extraction.d.ts.map +1 -0
- package/dist/parser/extraction.js +279 -0
- package/dist/parser/extraction.js.map +1 -0
- package/dist/parser/functions.d.ts +20 -0
- package/dist/parser/functions.d.ts.map +1 -0
- package/dist/parser/functions.js +96 -0
- package/dist/parser/functions.js.map +1 -0
- package/dist/parser/helpers.d.ts +94 -0
- package/dist/parser/helpers.d.ts.map +1 -0
- package/dist/parser/helpers.js +225 -0
- package/dist/parser/helpers.js.map +1 -0
- package/dist/parser/index.d.ts +49 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +73 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/literals.d.ts +37 -0
- package/dist/parser/literals.d.ts.map +1 -0
- package/dist/parser/literals.js +373 -0
- package/dist/parser/literals.js.map +1 -0
- package/dist/parser/parser-collect.d.ts +16 -0
- package/dist/parser/parser-collect.d.ts.map +1 -0
- package/dist/parser/parser-collect.js +125 -0
- package/dist/parser/parser-collect.js.map +1 -0
- package/dist/parser/parser-control.d.ts +20 -0
- package/dist/parser/parser-control.d.ts.map +1 -0
- package/dist/parser/parser-control.js +120 -0
- package/dist/parser/parser-control.js.map +1 -0
- package/dist/parser/parser-expr.d.ts +37 -0
- package/dist/parser/parser-expr.d.ts.map +1 -0
- package/dist/parser/parser-expr.js +639 -0
- package/dist/parser/parser-expr.js.map +1 -0
- package/dist/parser/parser-extract.d.ts +17 -0
- package/dist/parser/parser-extract.d.ts.map +1 -0
- package/dist/parser/parser-extract.js +222 -0
- package/dist/parser/parser-extract.js.map +1 -0
- package/dist/parser/parser-functions.d.ts +21 -0
- package/dist/parser/parser-functions.d.ts.map +1 -0
- package/dist/parser/parser-functions.js +155 -0
- package/dist/parser/parser-functions.js.map +1 -0
- package/dist/parser/parser-literals.d.ts +22 -0
- package/dist/parser/parser-literals.d.ts.map +1 -0
- package/dist/parser/parser-literals.js +288 -0
- package/dist/parser/parser-literals.js.map +1 -0
- package/dist/parser/parser-script.d.ts +21 -0
- package/dist/parser/parser-script.d.ts.map +1 -0
- package/dist/parser/parser-script.js +174 -0
- package/dist/parser/parser-script.js.map +1 -0
- package/dist/parser/parser-variables.d.ts +20 -0
- package/dist/parser/parser-variables.d.ts.map +1 -0
- package/dist/parser/parser-variables.js +146 -0
- package/dist/parser/parser-variables.js.map +1 -0
- package/dist/parser/parser.d.ts +49 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +54 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/script.d.ts +14 -0
- package/dist/parser/script.d.ts.map +1 -0
- package/dist/parser/script.js +196 -0
- package/dist/parser/script.js.map +1 -0
- package/dist/parser/state.d.ts +40 -0
- package/dist/parser/state.d.ts.map +1 -0
- package/dist/parser/state.js +129 -0
- package/dist/parser/state.js.map +1 -0
- package/dist/parser/variables.d.ts +10 -0
- package/dist/parser/variables.d.ts.map +1 -0
- package/dist/parser/variables.js +215 -0
- package/dist/parser/variables.js.map +1 -0
- package/dist/runtime/ast-equals.d.ts +13 -0
- package/dist/runtime/ast-equals.d.ts.map +1 -0
- package/dist/runtime/ast-equals.js +447 -0
- package/dist/runtime/ast-equals.js.map +1 -0
- package/dist/runtime/builtins.d.ts +13 -0
- package/dist/runtime/builtins.d.ts.map +1 -0
- package/dist/runtime/builtins.js +180 -0
- package/dist/runtime/builtins.js.map +1 -0
- package/dist/runtime/callable.d.ts +88 -0
- package/dist/runtime/callable.d.ts.map +1 -0
- package/dist/runtime/callable.js +98 -0
- package/dist/runtime/callable.js.map +1 -0
- package/dist/runtime/context.d.ts +13 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +73 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/core/callable.d.ts +171 -0
- package/dist/runtime/core/callable.d.ts.map +1 -0
- package/dist/runtime/core/callable.js +246 -0
- package/dist/runtime/core/callable.js.map +1 -0
- package/dist/runtime/core/context.d.ts +29 -0
- package/dist/runtime/core/context.d.ts.map +1 -0
- package/dist/runtime/core/context.js +154 -0
- package/dist/runtime/core/context.js.map +1 -0
- package/dist/runtime/core/equals.d.ts +9 -0
- package/dist/runtime/core/equals.d.ts.map +1 -0
- package/dist/runtime/core/equals.js +381 -0
- package/dist/runtime/core/equals.js.map +1 -0
- package/dist/runtime/core/eval/base.d.ts +65 -0
- package/dist/runtime/core/eval/base.d.ts.map +1 -0
- package/dist/runtime/core/eval/base.js +112 -0
- package/dist/runtime/core/eval/base.js.map +1 -0
- package/dist/runtime/core/eval/evaluator.d.ts +47 -0
- package/dist/runtime/core/eval/evaluator.d.ts.map +1 -0
- package/dist/runtime/core/eval/evaluator.js +73 -0
- package/dist/runtime/core/eval/evaluator.js.map +1 -0
- package/dist/runtime/core/eval/index.d.ts +57 -0
- package/dist/runtime/core/eval/index.d.ts.map +1 -0
- package/dist/runtime/core/eval/index.js +95 -0
- package/dist/runtime/core/eval/index.js.map +1 -0
- package/dist/runtime/core/eval/mixins/annotations.d.ts +19 -0
- package/dist/runtime/core/eval/mixins/annotations.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/annotations.js +146 -0
- package/dist/runtime/core/eval/mixins/annotations.js.map +1 -0
- package/dist/runtime/core/eval/mixins/closures.d.ts +49 -0
- package/dist/runtime/core/eval/mixins/closures.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/closures.js +479 -0
- package/dist/runtime/core/eval/mixins/closures.js.map +1 -0
- package/dist/runtime/core/eval/mixins/collections.d.ts +24 -0
- package/dist/runtime/core/eval/mixins/collections.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/collections.js +466 -0
- package/dist/runtime/core/eval/mixins/collections.js.map +1 -0
- package/dist/runtime/core/eval/mixins/control-flow.d.ts +27 -0
- package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/control-flow.js +369 -0
- package/dist/runtime/core/eval/mixins/control-flow.js.map +1 -0
- package/dist/runtime/core/eval/mixins/core.d.ts +24 -0
- package/dist/runtime/core/eval/mixins/core.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/core.js +335 -0
- package/dist/runtime/core/eval/mixins/core.js.map +1 -0
- package/dist/runtime/core/eval/mixins/expressions.d.ts +19 -0
- package/dist/runtime/core/eval/mixins/expressions.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/expressions.js +202 -0
- package/dist/runtime/core/eval/mixins/expressions.js.map +1 -0
- package/dist/runtime/core/eval/mixins/extraction.d.ts +10 -0
- package/dist/runtime/core/eval/mixins/extraction.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/extraction.js +250 -0
- package/dist/runtime/core/eval/mixins/extraction.js.map +1 -0
- package/dist/runtime/core/eval/mixins/literals.d.ts +23 -0
- package/dist/runtime/core/eval/mixins/literals.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/literals.js +180 -0
- package/dist/runtime/core/eval/mixins/literals.js.map +1 -0
- package/dist/runtime/core/eval/mixins/types.d.ts +20 -0
- package/dist/runtime/core/eval/mixins/types.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/types.js +109 -0
- package/dist/runtime/core/eval/mixins/types.js.map +1 -0
- package/dist/runtime/core/eval/mixins/variables.d.ts +34 -0
- package/dist/runtime/core/eval/mixins/variables.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/variables.js +247 -0
- package/dist/runtime/core/eval/mixins/variables.js.map +1 -0
- package/dist/runtime/core/eval/types.d.ts +41 -0
- package/dist/runtime/core/eval/types.d.ts.map +1 -0
- package/dist/runtime/core/eval/types.js +10 -0
- package/dist/runtime/core/eval/types.js.map +1 -0
- package/dist/runtime/core/evaluate.d.ts +42 -0
- package/dist/runtime/core/evaluate.d.ts.map +1 -0
- package/dist/runtime/core/evaluate.debug.js +1251 -0
- package/dist/runtime/core/evaluate.js +1913 -0
- package/dist/runtime/core/evaluate.js.map +1 -0
- package/dist/runtime/core/execute.d.ts +26 -0
- package/dist/runtime/core/execute.d.ts.map +1 -0
- package/dist/runtime/core/execute.js +177 -0
- package/dist/runtime/core/execute.js.map +1 -0
- package/dist/runtime/core/signals.d.ts +19 -0
- package/dist/runtime/core/signals.d.ts.map +1 -0
- package/dist/runtime/core/signals.js +26 -0
- package/dist/runtime/core/signals.js.map +1 -0
- package/dist/runtime/core/types.d.ts +177 -0
- package/dist/runtime/core/types.d.ts.map +1 -0
- package/dist/runtime/core/types.js +50 -0
- package/dist/runtime/core/types.js.map +1 -0
- package/dist/runtime/core/values.d.ts +66 -0
- package/dist/runtime/core/values.d.ts.map +1 -0
- package/dist/runtime/core/values.js +240 -0
- package/dist/runtime/core/values.js.map +1 -0
- package/dist/runtime/evaluate.d.ts +32 -0
- package/dist/runtime/evaluate.d.ts.map +1 -0
- package/dist/runtime/evaluate.js +1111 -0
- package/dist/runtime/evaluate.js.map +1 -0
- package/dist/runtime/execute.d.ts +26 -0
- package/dist/runtime/execute.d.ts.map +1 -0
- package/dist/runtime/execute.js +121 -0
- package/dist/runtime/execute.js.map +1 -0
- package/dist/runtime/ext/builtins.d.ts +16 -0
- package/dist/runtime/ext/builtins.d.ts.map +1 -0
- package/dist/runtime/ext/builtins.js +528 -0
- package/dist/runtime/ext/builtins.js.map +1 -0
- package/dist/runtime/ext/content-parser.d.ts +83 -0
- package/dist/runtime/ext/content-parser.d.ts.map +1 -0
- package/dist/runtime/ext/content-parser.js +536 -0
- package/dist/runtime/ext/content-parser.js.map +1 -0
- package/dist/runtime/index.d.ts +28 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +34 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/signals.d.ts +19 -0
- package/dist/runtime/signals.d.ts.map +1 -0
- package/dist/runtime/signals.js +26 -0
- package/dist/runtime/signals.js.map +1 -0
- package/dist/runtime/types.d.ts +169 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +50 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/values.d.ts +50 -0
- package/dist/runtime/values.d.ts.map +1 -0
- package/dist/runtime/values.js +209 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/runtime.d.ts +254 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2014 -0
- package/dist/runtime.js.map +1 -0
- package/dist/types.d.ts +752 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +189 -0
- package/dist/types.js.map +1 -0
- package/docs/00_INDEX.md +65 -0
- package/docs/01_guide.md +390 -0
- package/docs/02_types.md +399 -0
- package/docs/03_variables.md +314 -0
- package/docs/04_operators.md +551 -0
- package/docs/05_control-flow.md +350 -0
- package/docs/06_closures.md +353 -0
- package/docs/07_collections.md +686 -0
- package/docs/08_iterators.md +330 -0
- package/docs/09_strings.md +205 -0
- package/docs/10_parsing.md +366 -0
- package/docs/11_reference.md +350 -0
- package/docs/12_examples.md +771 -0
- package/docs/13_modules.md +519 -0
- package/docs/14_host-integration.md +826 -0
- package/docs/15_grammar.ebnf +693 -0
- package/docs/16_conventions.md +696 -0
- package/docs/99_llm-reference.txt +300 -0
- package/docs/assets/logo.png +0 -0
- package/package.json +70 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ControlFlowMixin: Conditionals, Loops, and Blocks
|
|
3
|
+
*
|
|
4
|
+
* Handles control flow constructs:
|
|
5
|
+
* - Conditionals (if-else)
|
|
6
|
+
* - While loops
|
|
7
|
+
* - Do-while loops
|
|
8
|
+
* - Block expressions
|
|
9
|
+
* - Body evaluation
|
|
10
|
+
*
|
|
11
|
+
* Interface requirements (from spec):
|
|
12
|
+
* - evaluateConditional(node) -> Promise<RillValue>
|
|
13
|
+
* - evaluateWhileLoop(node) -> Promise<RillValue>
|
|
14
|
+
* - evaluateDoWhileLoop(node) -> Promise<RillValue>
|
|
15
|
+
* - evaluateBlockExpression(node) -> Promise<RillValue>
|
|
16
|
+
* - evaluateBody(node) -> Promise<RillValue>
|
|
17
|
+
* - evaluateBodyExpression(node) -> Promise<RillValue>
|
|
18
|
+
*
|
|
19
|
+
* Error Handling:
|
|
20
|
+
* - Non-boolean conditions throw RuntimeError(RUNTIME_TYPE_ERROR) [EC-15]
|
|
21
|
+
* - BreakSignal/ReturnSignal are caught and handled appropriately [EC-16]
|
|
22
|
+
* - Body evaluation errors propagate correctly [EC-17]
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
import { RuntimeError, RILL_ERROR_CODES } from '../../../../types.js';
|
|
27
|
+
import { inferType } from '../../values.js';
|
|
28
|
+
import { createChildContext } from '../../context.js';
|
|
29
|
+
import { BreakSignal, ReturnSignal } from '../../signals.js';
|
|
30
|
+
/**
|
|
31
|
+
* Default maximum iteration count for while/do-while loops.
|
|
32
|
+
* Can be overridden with ^(limit: N) annotation.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_MAX_ITERATIONS = 10000;
|
|
35
|
+
/**
|
|
36
|
+
* ControlFlowMixin implementation.
|
|
37
|
+
*
|
|
38
|
+
* Evaluates conditionals, loops, blocks, and body nodes.
|
|
39
|
+
* Handles BreakSignal and ReturnSignal for control flow.
|
|
40
|
+
*
|
|
41
|
+
* Depends on:
|
|
42
|
+
* - EvaluatorBase: ctx, checkAborted(), getNodeLocation()
|
|
43
|
+
* - evaluateExpression() (from future CoreMixin composition)
|
|
44
|
+
* - evaluateGroupedExpr() (from ExpressionsMixin)
|
|
45
|
+
* - evaluatePostfixExpr() (from future CoreMixin composition)
|
|
46
|
+
* - evaluatePipeChain() (from future CoreMixin composition)
|
|
47
|
+
* - executeStatement() (from future CoreMixin composition)
|
|
48
|
+
*
|
|
49
|
+
* Methods added:
|
|
50
|
+
* - evaluateConditional(node) -> Promise<RillValue>
|
|
51
|
+
* - evaluateWhileLoop(node) -> Promise<RillValue>
|
|
52
|
+
* - evaluateDoWhileLoop(node) -> Promise<RillValue>
|
|
53
|
+
* - evaluateBlock(node) -> Promise<RillValue>
|
|
54
|
+
* - evaluateBlockExpression(node) -> Promise<RillValue>
|
|
55
|
+
* - evaluateBody(node) -> Promise<RillValue>
|
|
56
|
+
* - evaluateBodyExpression(node) -> Promise<RillValue>
|
|
57
|
+
* - getIterationLimit() -> number (helper)
|
|
58
|
+
*/
|
|
59
|
+
function createControlFlowMixin(Base) {
|
|
60
|
+
return class ControlFlowEvaluator extends Base {
|
|
61
|
+
/**
|
|
62
|
+
* Get the iteration limit for loops from the `limit` annotation.
|
|
63
|
+
* Returns the default if not set or if the value is not a positive number.
|
|
64
|
+
*/
|
|
65
|
+
getIterationLimit() {
|
|
66
|
+
const limit = this.ctx.annotationStack.at(-1)?.['limit'];
|
|
67
|
+
if (typeof limit === 'number' && limit > 0) {
|
|
68
|
+
return Math.floor(limit);
|
|
69
|
+
}
|
|
70
|
+
return DEFAULT_MAX_ITERATIONS;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Evaluate conditional expression (ternary if-else).
|
|
74
|
+
*
|
|
75
|
+
* Syntax:
|
|
76
|
+
* cond ? then ! else - explicit condition
|
|
77
|
+
* $ -> ? then ! else - piped conditional ($ is condition)
|
|
78
|
+
*
|
|
79
|
+
* Condition must evaluate to boolean. Branches create child scopes.
|
|
80
|
+
* ReturnSignal propagates up (not caught here).
|
|
81
|
+
*/
|
|
82
|
+
async evaluateConditional(node) {
|
|
83
|
+
// Preserve pipe value before evaluating condition (condition may modify it)
|
|
84
|
+
const savedPipeValue = this.ctx.pipeValue;
|
|
85
|
+
let conditionResult;
|
|
86
|
+
if (node.condition) {
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
const conditionValue = await this.evaluateBodyExpression(node.condition);
|
|
89
|
+
// Condition must be boolean
|
|
90
|
+
if (typeof conditionValue !== 'boolean') {
|
|
91
|
+
throw RuntimeError.fromNode(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Conditional expression must be boolean, got ${inferType(conditionValue)}`, node);
|
|
92
|
+
}
|
|
93
|
+
conditionResult = conditionValue;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// Piped conditional: $ -> ? then ! else
|
|
97
|
+
// The pipe value must be boolean
|
|
98
|
+
if (typeof this.ctx.pipeValue !== 'boolean') {
|
|
99
|
+
throw RuntimeError.fromNode(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Piped conditional requires boolean, got ${inferType(this.ctx.pipeValue)}`, node);
|
|
100
|
+
}
|
|
101
|
+
conditionResult = this.ctx.pipeValue;
|
|
102
|
+
}
|
|
103
|
+
// Restore pipe value for then/else branch evaluation
|
|
104
|
+
this.ctx.pipeValue = savedPipeValue;
|
|
105
|
+
if (conditionResult) {
|
|
106
|
+
// Create child scope for then branch (reads parent, writes local only)
|
|
107
|
+
const thenCtx = createChildContext(this.ctx);
|
|
108
|
+
thenCtx.pipeValue = savedPipeValue;
|
|
109
|
+
// Use evaluateBody (not evaluateBodyExpression) so ReturnSignal
|
|
110
|
+
// propagates up to the containing block rather than being caught here
|
|
111
|
+
const savedCtx = this.ctx;
|
|
112
|
+
this.ctx = thenCtx;
|
|
113
|
+
try {
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
+
return await this.evaluateBody(node.thenBranch);
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
this.ctx = savedCtx;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else if (node.elseBranch) {
|
|
122
|
+
// Create child scope for else branch (reads parent, writes local only)
|
|
123
|
+
const elseCtx = createChildContext(this.ctx);
|
|
124
|
+
elseCtx.pipeValue = savedPipeValue;
|
|
125
|
+
const savedCtx = this.ctx;
|
|
126
|
+
this.ctx = elseCtx;
|
|
127
|
+
try {
|
|
128
|
+
if (node.elseBranch.type === 'Conditional') {
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
return await this.evaluateConditional(node.elseBranch);
|
|
131
|
+
}
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
return await this.evaluateBody(node.elseBranch);
|
|
134
|
+
}
|
|
135
|
+
finally {
|
|
136
|
+
this.ctx = savedCtx;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return this.ctx.pipeValue;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Evaluate while loop: (cond) @ body
|
|
143
|
+
*
|
|
144
|
+
* Condition must evaluate to boolean. Re-evaluated each iteration.
|
|
145
|
+
* Each iteration creates a child scope (reads parent, writes local only).
|
|
146
|
+
* Loop body result becomes the accumulator ($) for next iteration.
|
|
147
|
+
*
|
|
148
|
+
* BreakSignal exits loop and returns break value.
|
|
149
|
+
* ReturnSignal propagates up to containing block.
|
|
150
|
+
*/
|
|
151
|
+
async evaluateWhileLoop(node) {
|
|
152
|
+
// Save original pipe value before evaluating condition
|
|
153
|
+
const originalPipeValue = this.ctx.pipeValue;
|
|
154
|
+
// Evaluate condition
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
|
+
const conditionValue = await this.evaluateExpression(node.condition);
|
|
157
|
+
// Restore original pipe value for loop body
|
|
158
|
+
this.ctx.pipeValue = originalPipeValue;
|
|
159
|
+
// Condition must be boolean
|
|
160
|
+
if (typeof conditionValue !== 'boolean') {
|
|
161
|
+
throw RuntimeError.fromNode(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `While loop condition must be boolean, got ${typeof conditionValue}`, node);
|
|
162
|
+
}
|
|
163
|
+
let value = this.ctx.pipeValue;
|
|
164
|
+
let iterCount = 0;
|
|
165
|
+
const maxIter = this.getIterationLimit();
|
|
166
|
+
try {
|
|
167
|
+
let conditionResult = conditionValue;
|
|
168
|
+
while (conditionResult) {
|
|
169
|
+
iterCount++;
|
|
170
|
+
if (iterCount > maxIter) {
|
|
171
|
+
throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_LIMIT_EXCEEDED, `While loop exceeded ${maxIter} iterations`, this.getNodeLocation(node), { limit: maxIter, iterations: iterCount });
|
|
172
|
+
}
|
|
173
|
+
this.checkAborted(node);
|
|
174
|
+
// Create child scope for this iteration
|
|
175
|
+
const iterCtx = createChildContext(this.ctx);
|
|
176
|
+
iterCtx.pipeValue = value;
|
|
177
|
+
const savedCtx = this.ctx;
|
|
178
|
+
this.ctx = iterCtx;
|
|
179
|
+
try {
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
+
value = await this.evaluateBody(node.body);
|
|
182
|
+
}
|
|
183
|
+
finally {
|
|
184
|
+
this.ctx = savedCtx;
|
|
185
|
+
}
|
|
186
|
+
this.ctx.pipeValue = value;
|
|
187
|
+
// Re-evaluate condition for next iteration
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
+
const nextCondition = await this.evaluateExpression(node.condition);
|
|
190
|
+
if (typeof nextCondition !== 'boolean') {
|
|
191
|
+
throw RuntimeError.fromNode(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `While loop condition must be boolean, got ${typeof nextCondition}`, node);
|
|
192
|
+
}
|
|
193
|
+
conditionResult = nextCondition;
|
|
194
|
+
// Restore pipeValue after condition evaluation
|
|
195
|
+
this.ctx.pipeValue = value;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
if (e instanceof BreakSignal) {
|
|
200
|
+
return e.value;
|
|
201
|
+
}
|
|
202
|
+
throw e;
|
|
203
|
+
}
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Evaluate do-while loop: @ body ? cond
|
|
208
|
+
*
|
|
209
|
+
* Body executes at least once, then condition is checked.
|
|
210
|
+
* Condition must evaluate to boolean.
|
|
211
|
+
* Each iteration creates a child scope (reads parent, writes local only).
|
|
212
|
+
* Loop body result becomes the accumulator ($) for next iteration.
|
|
213
|
+
*
|
|
214
|
+
* BreakSignal exits loop and returns break value.
|
|
215
|
+
* ReturnSignal propagates up to containing block.
|
|
216
|
+
*/
|
|
217
|
+
async evaluateDoWhileLoop(node) {
|
|
218
|
+
let value = this.ctx.pipeValue;
|
|
219
|
+
try {
|
|
220
|
+
// Do-while: body executes first, then condition is checked
|
|
221
|
+
// Each iteration creates a child scope (reads parent, writes local only)
|
|
222
|
+
let shouldContinue = true;
|
|
223
|
+
while (shouldContinue) {
|
|
224
|
+
this.checkAborted(node);
|
|
225
|
+
const iterCtx = createChildContext(this.ctx);
|
|
226
|
+
iterCtx.pipeValue = value;
|
|
227
|
+
const savedCtx = this.ctx;
|
|
228
|
+
this.ctx = iterCtx;
|
|
229
|
+
try {
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
|
+
value = await this.evaluateBody(node.body);
|
|
232
|
+
}
|
|
233
|
+
finally {
|
|
234
|
+
this.ctx = savedCtx;
|
|
235
|
+
}
|
|
236
|
+
this.ctx.pipeValue = value;
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
|
+
const conditionValue = await this.evaluateBodyExpression(node.condition);
|
|
239
|
+
// Condition must be boolean
|
|
240
|
+
if (typeof conditionValue !== 'boolean') {
|
|
241
|
+
throw RuntimeError.fromNode(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Do-while condition must be boolean, got ${inferType(conditionValue)}`, node);
|
|
242
|
+
}
|
|
243
|
+
shouldContinue = conditionValue;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (e) {
|
|
247
|
+
if (e instanceof BreakSignal) {
|
|
248
|
+
return e.value;
|
|
249
|
+
}
|
|
250
|
+
throw e;
|
|
251
|
+
}
|
|
252
|
+
return value;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Evaluate block: { statements }
|
|
256
|
+
*
|
|
257
|
+
* Creates child scope for the block (reads parent, writes local only).
|
|
258
|
+
* All siblings inherit the SAME $ from parent (captured when block entered).
|
|
259
|
+
* Each statement gets fresh child context so siblings don't share $.
|
|
260
|
+
*
|
|
261
|
+
* Variables captured via :> are promoted to block scope for visibility
|
|
262
|
+
* to later siblings.
|
|
263
|
+
*
|
|
264
|
+
* Returns value of last statement.
|
|
265
|
+
* ReturnSignal NOT caught here - propagates up to evaluateBlockExpression.
|
|
266
|
+
*/
|
|
267
|
+
async evaluateBlock(node) {
|
|
268
|
+
// Create child scope for the block: reads from parent, writes to local only
|
|
269
|
+
const blockCtx = createChildContext(this.ctx);
|
|
270
|
+
// All siblings inherit the SAME $ from parent (captured when block entered)
|
|
271
|
+
const parentPipeValue = blockCtx.pipeValue;
|
|
272
|
+
let lastValue = parentPipeValue;
|
|
273
|
+
for (const stmt of node.statements) {
|
|
274
|
+
// Each statement gets fresh child context with parent's $
|
|
275
|
+
// This ensures siblings don't share $ - each sees the block's $
|
|
276
|
+
const stmtCtx = createChildContext(blockCtx);
|
|
277
|
+
stmtCtx.pipeValue = parentPipeValue; // Always parent's $, not previous sibling's
|
|
278
|
+
const savedCtx = this.ctx;
|
|
279
|
+
this.ctx = stmtCtx;
|
|
280
|
+
try {
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
|
+
lastValue = await this.executeStatement(stmt);
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
this.ctx = savedCtx;
|
|
286
|
+
}
|
|
287
|
+
// Variables captured via :> need to be promoted to block scope
|
|
288
|
+
// so they're visible to later siblings
|
|
289
|
+
for (const [name, value] of stmtCtx.variables) {
|
|
290
|
+
if (!blockCtx.variables.has(name)) {
|
|
291
|
+
blockCtx.variables.set(name, value);
|
|
292
|
+
const varType = stmtCtx.variableTypes.get(name);
|
|
293
|
+
if (varType !== undefined) {
|
|
294
|
+
blockCtx.variableTypes.set(name, varType);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return lastValue; // Last sibling's result is block result
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Evaluate block expression: catches ReturnSignal.
|
|
303
|
+
*
|
|
304
|
+
* This is the entry point for blocks used as expressions
|
|
305
|
+
* (e.g., in conditionals, as function bodies).
|
|
306
|
+
*
|
|
307
|
+
* Catches ReturnSignal and returns its value.
|
|
308
|
+
* Other signals (BreakSignal) and errors propagate up.
|
|
309
|
+
*/
|
|
310
|
+
async evaluateBlockExpression(node) {
|
|
311
|
+
try {
|
|
312
|
+
return await this.evaluateBlock(node);
|
|
313
|
+
}
|
|
314
|
+
catch (e) {
|
|
315
|
+
if (e instanceof ReturnSignal) {
|
|
316
|
+
return e.value;
|
|
317
|
+
}
|
|
318
|
+
throw e;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Evaluate a body node (Block, GroupedExpr, PostfixExpr, or PipeChain).
|
|
323
|
+
* Used by conditionals and loops.
|
|
324
|
+
*
|
|
325
|
+
* Does NOT catch ReturnSignal - it propagates up.
|
|
326
|
+
* BreakSignal should be caught by the loop that called this.
|
|
327
|
+
*/
|
|
328
|
+
async evaluateBody(node) {
|
|
329
|
+
switch (node.type) {
|
|
330
|
+
case 'Block':
|
|
331
|
+
return this.evaluateBlock(node);
|
|
332
|
+
case 'GroupedExpr':
|
|
333
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
334
|
+
return this.evaluateGroupedExpr(node);
|
|
335
|
+
case 'PostfixExpr':
|
|
336
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
|
+
return this.evaluatePostfixExpr(node);
|
|
338
|
+
case 'PipeChain':
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
340
|
+
return this.evaluatePipeChain(node);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Evaluate a body node as an expression (catches ReturnSignal).
|
|
345
|
+
*
|
|
346
|
+
* Used when a body needs to be treated as an expression
|
|
347
|
+
* (e.g., conditional condition, do-while condition).
|
|
348
|
+
*
|
|
349
|
+
* Catches ReturnSignal and returns its value.
|
|
350
|
+
* Other signals (BreakSignal) and errors propagate up.
|
|
351
|
+
*/
|
|
352
|
+
async evaluateBodyExpression(node) {
|
|
353
|
+
try {
|
|
354
|
+
return await this.evaluateBody(node);
|
|
355
|
+
}
|
|
356
|
+
catch (e) {
|
|
357
|
+
if (e instanceof ReturnSignal) {
|
|
358
|
+
return e.value;
|
|
359
|
+
}
|
|
360
|
+
throw e;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
// Export with type assertion to work around TS4094 limitation
|
|
366
|
+
// TypeScript can't generate declarations for functions returning classes with protected members
|
|
367
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
368
|
+
export const ControlFlowMixin = createControlFlowMixin;
|
|
369
|
+
//# sourceMappingURL=control-flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-flow.js","sourceRoot":"","sources":["../../../../../src/runtime/core/eval/mixins/control-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EA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Y,YAAY,EAAE,CAAC;oBAC9B,OAAO,CAAC,CAAC,KAAK,CAAC;gBACjB,CAAC;gBACD,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,gGAAgG;AAChG,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAA6B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoreMixin: Main Expression Dispatch
|
|
3
|
+
*
|
|
4
|
+
* Provides the main entry points for expression evaluation and dispatches
|
|
5
|
+
* to specialized evaluators based on AST node type.
|
|
6
|
+
*
|
|
7
|
+
* This is the central coordination point that ties together all other mixins.
|
|
8
|
+
*
|
|
9
|
+
* Interface requirements (from spec IR-5 through IR-13):
|
|
10
|
+
* - evaluateExpression(expr) -> Promise<RillValue> [IR-8]
|
|
11
|
+
* - evaluatePipeChain(chain) -> Promise<RillValue> [IR-9]
|
|
12
|
+
* - evaluatePostfixExpr(expr) -> Promise<RillValue> [IR-10]
|
|
13
|
+
* - evaluatePrimary(primary) -> Promise<RillValue> [IR-11]
|
|
14
|
+
* - evaluatePipeTarget(target, input) -> Promise<RillValue> [IR-12]
|
|
15
|
+
* - evaluateArgs(argExprs) -> Promise<RillValue[]> [IR-13]
|
|
16
|
+
*
|
|
17
|
+
* Error Handling:
|
|
18
|
+
* - Unsupported expression types throw RuntimeError [EC-4]
|
|
19
|
+
* - Aborted execution throws AbortError [EC-5]
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare const CoreMixin: any;
|
|
24
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../../src/runtime/core/eval/mixins/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAqZH,eAAO,MAAM,SAAS,EAAsB,GAAG,CAAC"}
|