@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.
Files changed (295) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +187 -0
  3. package/dist/cli.d.ts +11 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +69 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/demo.d.ts +6 -0
  8. package/dist/demo.d.ts.map +1 -0
  9. package/dist/demo.js +121 -0
  10. package/dist/demo.js.map +1 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +9 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/lexer/errors.d.ts +9 -0
  16. package/dist/lexer/errors.d.ts.map +1 -0
  17. package/dist/lexer/errors.js +12 -0
  18. package/dist/lexer/errors.js.map +1 -0
  19. package/dist/lexer/helpers.d.ts +14 -0
  20. package/dist/lexer/helpers.d.ts.map +1 -0
  21. package/dist/lexer/helpers.js +30 -0
  22. package/dist/lexer/helpers.js.map +1 -0
  23. package/dist/lexer/index.d.ts +8 -0
  24. package/dist/lexer/index.d.ts.map +1 -0
  25. package/dist/lexer/index.js +8 -0
  26. package/dist/lexer/index.js.map +1 -0
  27. package/dist/lexer/operators.d.ts +11 -0
  28. package/dist/lexer/operators.d.ts.map +1 -0
  29. package/dist/lexer/operators.js +58 -0
  30. package/dist/lexer/operators.js.map +1 -0
  31. package/dist/lexer/readers.d.ts +12 -0
  32. package/dist/lexer/readers.d.ts.map +1 -0
  33. package/dist/lexer/readers.js +144 -0
  34. package/dist/lexer/readers.js.map +1 -0
  35. package/dist/lexer/state.d.ts +18 -0
  36. package/dist/lexer/state.d.ts.map +1 -0
  37. package/dist/lexer/state.js +37 -0
  38. package/dist/lexer/state.js.map +1 -0
  39. package/dist/lexer/tokenizer.d.ts +9 -0
  40. package/dist/lexer/tokenizer.d.ts.map +1 -0
  41. package/dist/lexer/tokenizer.js +100 -0
  42. package/dist/lexer/tokenizer.js.map +1 -0
  43. package/dist/lexer.d.ts +19 -0
  44. package/dist/lexer.d.ts.map +1 -0
  45. package/dist/lexer.js +344 -0
  46. package/dist/lexer.js.map +1 -0
  47. package/dist/parser/arithmetic.d.ts +16 -0
  48. package/dist/parser/arithmetic.d.ts.map +1 -0
  49. package/dist/parser/arithmetic.js +128 -0
  50. package/dist/parser/arithmetic.js.map +1 -0
  51. package/dist/parser/boolean.d.ts +15 -0
  52. package/dist/parser/boolean.d.ts.map +1 -0
  53. package/dist/parser/boolean.js +20 -0
  54. package/dist/parser/boolean.js.map +1 -0
  55. package/dist/parser/control-flow.d.ts +56 -0
  56. package/dist/parser/control-flow.d.ts.map +1 -0
  57. package/dist/parser/control-flow.js +167 -0
  58. package/dist/parser/control-flow.js.map +1 -0
  59. package/dist/parser/expressions.d.ts +23 -0
  60. package/dist/parser/expressions.d.ts.map +1 -0
  61. package/dist/parser/expressions.js +950 -0
  62. package/dist/parser/expressions.js.map +1 -0
  63. package/dist/parser/extraction.d.ts +48 -0
  64. package/dist/parser/extraction.d.ts.map +1 -0
  65. package/dist/parser/extraction.js +279 -0
  66. package/dist/parser/extraction.js.map +1 -0
  67. package/dist/parser/functions.d.ts +20 -0
  68. package/dist/parser/functions.d.ts.map +1 -0
  69. package/dist/parser/functions.js +96 -0
  70. package/dist/parser/functions.js.map +1 -0
  71. package/dist/parser/helpers.d.ts +94 -0
  72. package/dist/parser/helpers.d.ts.map +1 -0
  73. package/dist/parser/helpers.js +225 -0
  74. package/dist/parser/helpers.js.map +1 -0
  75. package/dist/parser/index.d.ts +49 -0
  76. package/dist/parser/index.d.ts.map +1 -0
  77. package/dist/parser/index.js +73 -0
  78. package/dist/parser/index.js.map +1 -0
  79. package/dist/parser/literals.d.ts +37 -0
  80. package/dist/parser/literals.d.ts.map +1 -0
  81. package/dist/parser/literals.js +373 -0
  82. package/dist/parser/literals.js.map +1 -0
  83. package/dist/parser/parser-collect.d.ts +16 -0
  84. package/dist/parser/parser-collect.d.ts.map +1 -0
  85. package/dist/parser/parser-collect.js +125 -0
  86. package/dist/parser/parser-collect.js.map +1 -0
  87. package/dist/parser/parser-control.d.ts +20 -0
  88. package/dist/parser/parser-control.d.ts.map +1 -0
  89. package/dist/parser/parser-control.js +120 -0
  90. package/dist/parser/parser-control.js.map +1 -0
  91. package/dist/parser/parser-expr.d.ts +37 -0
  92. package/dist/parser/parser-expr.d.ts.map +1 -0
  93. package/dist/parser/parser-expr.js +639 -0
  94. package/dist/parser/parser-expr.js.map +1 -0
  95. package/dist/parser/parser-extract.d.ts +17 -0
  96. package/dist/parser/parser-extract.d.ts.map +1 -0
  97. package/dist/parser/parser-extract.js +222 -0
  98. package/dist/parser/parser-extract.js.map +1 -0
  99. package/dist/parser/parser-functions.d.ts +21 -0
  100. package/dist/parser/parser-functions.d.ts.map +1 -0
  101. package/dist/parser/parser-functions.js +155 -0
  102. package/dist/parser/parser-functions.js.map +1 -0
  103. package/dist/parser/parser-literals.d.ts +22 -0
  104. package/dist/parser/parser-literals.d.ts.map +1 -0
  105. package/dist/parser/parser-literals.js +288 -0
  106. package/dist/parser/parser-literals.js.map +1 -0
  107. package/dist/parser/parser-script.d.ts +21 -0
  108. package/dist/parser/parser-script.d.ts.map +1 -0
  109. package/dist/parser/parser-script.js +174 -0
  110. package/dist/parser/parser-script.js.map +1 -0
  111. package/dist/parser/parser-variables.d.ts +20 -0
  112. package/dist/parser/parser-variables.d.ts.map +1 -0
  113. package/dist/parser/parser-variables.js +146 -0
  114. package/dist/parser/parser-variables.js.map +1 -0
  115. package/dist/parser/parser.d.ts +49 -0
  116. package/dist/parser/parser.d.ts.map +1 -0
  117. package/dist/parser/parser.js +54 -0
  118. package/dist/parser/parser.js.map +1 -0
  119. package/dist/parser/script.d.ts +14 -0
  120. package/dist/parser/script.d.ts.map +1 -0
  121. package/dist/parser/script.js +196 -0
  122. package/dist/parser/script.js.map +1 -0
  123. package/dist/parser/state.d.ts +40 -0
  124. package/dist/parser/state.d.ts.map +1 -0
  125. package/dist/parser/state.js +129 -0
  126. package/dist/parser/state.js.map +1 -0
  127. package/dist/parser/variables.d.ts +10 -0
  128. package/dist/parser/variables.d.ts.map +1 -0
  129. package/dist/parser/variables.js +215 -0
  130. package/dist/parser/variables.js.map +1 -0
  131. package/dist/runtime/ast-equals.d.ts +13 -0
  132. package/dist/runtime/ast-equals.d.ts.map +1 -0
  133. package/dist/runtime/ast-equals.js +447 -0
  134. package/dist/runtime/ast-equals.js.map +1 -0
  135. package/dist/runtime/builtins.d.ts +13 -0
  136. package/dist/runtime/builtins.d.ts.map +1 -0
  137. package/dist/runtime/builtins.js +180 -0
  138. package/dist/runtime/builtins.js.map +1 -0
  139. package/dist/runtime/callable.d.ts +88 -0
  140. package/dist/runtime/callable.d.ts.map +1 -0
  141. package/dist/runtime/callable.js +98 -0
  142. package/dist/runtime/callable.js.map +1 -0
  143. package/dist/runtime/context.d.ts +13 -0
  144. package/dist/runtime/context.d.ts.map +1 -0
  145. package/dist/runtime/context.js +73 -0
  146. package/dist/runtime/context.js.map +1 -0
  147. package/dist/runtime/core/callable.d.ts +171 -0
  148. package/dist/runtime/core/callable.d.ts.map +1 -0
  149. package/dist/runtime/core/callable.js +246 -0
  150. package/dist/runtime/core/callable.js.map +1 -0
  151. package/dist/runtime/core/context.d.ts +29 -0
  152. package/dist/runtime/core/context.d.ts.map +1 -0
  153. package/dist/runtime/core/context.js +154 -0
  154. package/dist/runtime/core/context.js.map +1 -0
  155. package/dist/runtime/core/equals.d.ts +9 -0
  156. package/dist/runtime/core/equals.d.ts.map +1 -0
  157. package/dist/runtime/core/equals.js +381 -0
  158. package/dist/runtime/core/equals.js.map +1 -0
  159. package/dist/runtime/core/eval/base.d.ts +65 -0
  160. package/dist/runtime/core/eval/base.d.ts.map +1 -0
  161. package/dist/runtime/core/eval/base.js +112 -0
  162. package/dist/runtime/core/eval/base.js.map +1 -0
  163. package/dist/runtime/core/eval/evaluator.d.ts +47 -0
  164. package/dist/runtime/core/eval/evaluator.d.ts.map +1 -0
  165. package/dist/runtime/core/eval/evaluator.js +73 -0
  166. package/dist/runtime/core/eval/evaluator.js.map +1 -0
  167. package/dist/runtime/core/eval/index.d.ts +57 -0
  168. package/dist/runtime/core/eval/index.d.ts.map +1 -0
  169. package/dist/runtime/core/eval/index.js +95 -0
  170. package/dist/runtime/core/eval/index.js.map +1 -0
  171. package/dist/runtime/core/eval/mixins/annotations.d.ts +19 -0
  172. package/dist/runtime/core/eval/mixins/annotations.d.ts.map +1 -0
  173. package/dist/runtime/core/eval/mixins/annotations.js +146 -0
  174. package/dist/runtime/core/eval/mixins/annotations.js.map +1 -0
  175. package/dist/runtime/core/eval/mixins/closures.d.ts +49 -0
  176. package/dist/runtime/core/eval/mixins/closures.d.ts.map +1 -0
  177. package/dist/runtime/core/eval/mixins/closures.js +479 -0
  178. package/dist/runtime/core/eval/mixins/closures.js.map +1 -0
  179. package/dist/runtime/core/eval/mixins/collections.d.ts +24 -0
  180. package/dist/runtime/core/eval/mixins/collections.d.ts.map +1 -0
  181. package/dist/runtime/core/eval/mixins/collections.js +466 -0
  182. package/dist/runtime/core/eval/mixins/collections.js.map +1 -0
  183. package/dist/runtime/core/eval/mixins/control-flow.d.ts +27 -0
  184. package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +1 -0
  185. package/dist/runtime/core/eval/mixins/control-flow.js +369 -0
  186. package/dist/runtime/core/eval/mixins/control-flow.js.map +1 -0
  187. package/dist/runtime/core/eval/mixins/core.d.ts +24 -0
  188. package/dist/runtime/core/eval/mixins/core.d.ts.map +1 -0
  189. package/dist/runtime/core/eval/mixins/core.js +335 -0
  190. package/dist/runtime/core/eval/mixins/core.js.map +1 -0
  191. package/dist/runtime/core/eval/mixins/expressions.d.ts +19 -0
  192. package/dist/runtime/core/eval/mixins/expressions.d.ts.map +1 -0
  193. package/dist/runtime/core/eval/mixins/expressions.js +202 -0
  194. package/dist/runtime/core/eval/mixins/expressions.js.map +1 -0
  195. package/dist/runtime/core/eval/mixins/extraction.d.ts +10 -0
  196. package/dist/runtime/core/eval/mixins/extraction.d.ts.map +1 -0
  197. package/dist/runtime/core/eval/mixins/extraction.js +250 -0
  198. package/dist/runtime/core/eval/mixins/extraction.js.map +1 -0
  199. package/dist/runtime/core/eval/mixins/literals.d.ts +23 -0
  200. package/dist/runtime/core/eval/mixins/literals.d.ts.map +1 -0
  201. package/dist/runtime/core/eval/mixins/literals.js +180 -0
  202. package/dist/runtime/core/eval/mixins/literals.js.map +1 -0
  203. package/dist/runtime/core/eval/mixins/types.d.ts +20 -0
  204. package/dist/runtime/core/eval/mixins/types.d.ts.map +1 -0
  205. package/dist/runtime/core/eval/mixins/types.js +109 -0
  206. package/dist/runtime/core/eval/mixins/types.js.map +1 -0
  207. package/dist/runtime/core/eval/mixins/variables.d.ts +34 -0
  208. package/dist/runtime/core/eval/mixins/variables.d.ts.map +1 -0
  209. package/dist/runtime/core/eval/mixins/variables.js +247 -0
  210. package/dist/runtime/core/eval/mixins/variables.js.map +1 -0
  211. package/dist/runtime/core/eval/types.d.ts +41 -0
  212. package/dist/runtime/core/eval/types.d.ts.map +1 -0
  213. package/dist/runtime/core/eval/types.js +10 -0
  214. package/dist/runtime/core/eval/types.js.map +1 -0
  215. package/dist/runtime/core/evaluate.d.ts +42 -0
  216. package/dist/runtime/core/evaluate.d.ts.map +1 -0
  217. package/dist/runtime/core/evaluate.debug.js +1251 -0
  218. package/dist/runtime/core/evaluate.js +1913 -0
  219. package/dist/runtime/core/evaluate.js.map +1 -0
  220. package/dist/runtime/core/execute.d.ts +26 -0
  221. package/dist/runtime/core/execute.d.ts.map +1 -0
  222. package/dist/runtime/core/execute.js +177 -0
  223. package/dist/runtime/core/execute.js.map +1 -0
  224. package/dist/runtime/core/signals.d.ts +19 -0
  225. package/dist/runtime/core/signals.d.ts.map +1 -0
  226. package/dist/runtime/core/signals.js +26 -0
  227. package/dist/runtime/core/signals.js.map +1 -0
  228. package/dist/runtime/core/types.d.ts +177 -0
  229. package/dist/runtime/core/types.d.ts.map +1 -0
  230. package/dist/runtime/core/types.js +50 -0
  231. package/dist/runtime/core/types.js.map +1 -0
  232. package/dist/runtime/core/values.d.ts +66 -0
  233. package/dist/runtime/core/values.d.ts.map +1 -0
  234. package/dist/runtime/core/values.js +240 -0
  235. package/dist/runtime/core/values.js.map +1 -0
  236. package/dist/runtime/evaluate.d.ts +32 -0
  237. package/dist/runtime/evaluate.d.ts.map +1 -0
  238. package/dist/runtime/evaluate.js +1111 -0
  239. package/dist/runtime/evaluate.js.map +1 -0
  240. package/dist/runtime/execute.d.ts +26 -0
  241. package/dist/runtime/execute.d.ts.map +1 -0
  242. package/dist/runtime/execute.js +121 -0
  243. package/dist/runtime/execute.js.map +1 -0
  244. package/dist/runtime/ext/builtins.d.ts +16 -0
  245. package/dist/runtime/ext/builtins.d.ts.map +1 -0
  246. package/dist/runtime/ext/builtins.js +528 -0
  247. package/dist/runtime/ext/builtins.js.map +1 -0
  248. package/dist/runtime/ext/content-parser.d.ts +83 -0
  249. package/dist/runtime/ext/content-parser.d.ts.map +1 -0
  250. package/dist/runtime/ext/content-parser.js +536 -0
  251. package/dist/runtime/ext/content-parser.js.map +1 -0
  252. package/dist/runtime/index.d.ts +28 -0
  253. package/dist/runtime/index.d.ts.map +1 -0
  254. package/dist/runtime/index.js +34 -0
  255. package/dist/runtime/index.js.map +1 -0
  256. package/dist/runtime/signals.d.ts +19 -0
  257. package/dist/runtime/signals.d.ts.map +1 -0
  258. package/dist/runtime/signals.js +26 -0
  259. package/dist/runtime/signals.js.map +1 -0
  260. package/dist/runtime/types.d.ts +169 -0
  261. package/dist/runtime/types.d.ts.map +1 -0
  262. package/dist/runtime/types.js +50 -0
  263. package/dist/runtime/types.js.map +1 -0
  264. package/dist/runtime/values.d.ts +50 -0
  265. package/dist/runtime/values.d.ts.map +1 -0
  266. package/dist/runtime/values.js +209 -0
  267. package/dist/runtime/values.js.map +1 -0
  268. package/dist/runtime.d.ts +254 -0
  269. package/dist/runtime.d.ts.map +1 -0
  270. package/dist/runtime.js +2014 -0
  271. package/dist/runtime.js.map +1 -0
  272. package/dist/types.d.ts +752 -0
  273. package/dist/types.d.ts.map +1 -0
  274. package/dist/types.js +189 -0
  275. package/dist/types.js.map +1 -0
  276. package/docs/00_INDEX.md +65 -0
  277. package/docs/01_guide.md +390 -0
  278. package/docs/02_types.md +399 -0
  279. package/docs/03_variables.md +314 -0
  280. package/docs/04_operators.md +551 -0
  281. package/docs/05_control-flow.md +350 -0
  282. package/docs/06_closures.md +353 -0
  283. package/docs/07_collections.md +686 -0
  284. package/docs/08_iterators.md +330 -0
  285. package/docs/09_strings.md +205 -0
  286. package/docs/10_parsing.md +366 -0
  287. package/docs/11_reference.md +350 -0
  288. package/docs/12_examples.md +771 -0
  289. package/docs/13_modules.md +519 -0
  290. package/docs/14_host-integration.md +826 -0
  291. package/docs/15_grammar.ebnf +693 -0
  292. package/docs/16_conventions.md +696 -0
  293. package/docs/99_llm-reference.txt +300 -0
  294. package/docs/assets/logo.png +0 -0
  295. package/package.json +70 -0
@@ -0,0 +1,247 @@
1
+ /**
2
+ * VariablesMixin: Variable Access and Mutation
3
+ *
4
+ * Handles variable access, mutation, and capture operations:
5
+ * - Variable lookup with scope chain traversal
6
+ * - Variable assignment with type checking
7
+ * - Capture syntax (:> $name)
8
+ *
9
+ * LIMITATIONS:
10
+ * - Property access chains ($data.field[0]) require AccessMixin
11
+ * - Existence checks (.?field) require AccessMixin
12
+ * - Default values ($data ?? default) require AccessMixin or ControlFlowMixin
13
+ *
14
+ * Interface requirements (from spec):
15
+ * - setVariable(name, value, explicitType?, location?) -> void
16
+ * - evaluateVariable(node) -> RillValue
17
+ * - evaluateVariableAsync(node) -> Promise<RillValue>
18
+ * - evaluateCapture(node, input) -> RillValue
19
+ *
20
+ * Depends on:
21
+ * - EvaluatorBase: ctx, checkAborted(), getNodeLocation()
22
+ * - context utilities: getVariable, hasVariable
23
+ *
24
+ * Extended by:
25
+ * - AccessMixin: Will add property chain evaluation to evaluateVariableAsync
26
+ *
27
+ * Error Handling:
28
+ * - Undefined variables throw RuntimeError(RUNTIME_UNDEFINED_VARIABLE) [EC-8]
29
+ * - Type mismatches throw RuntimeError(RUNTIME_TYPE_ERROR) [EC-9]
30
+ *
31
+ * @internal
32
+ */
33
+ import { RuntimeError, RILL_ERROR_CODES } from '../../../../types.js';
34
+ import { inferType } from '../../values.js';
35
+ import { getVariable, hasVariable } from '../../context.js';
36
+ import { isDict } from '../../callable.js';
37
+ /**
38
+ * VariablesMixin implementation.
39
+ *
40
+ * Provides variable access and mutation functionality. Variables follow
41
+ * lexical scoping with type locking on first assignment. Outer scope
42
+ * variables cannot be reassigned from child scopes.
43
+ *
44
+ * Depends on:
45
+ * - EvaluatorBase: ctx, checkAborted(), getNodeLocation()
46
+ * - context utilities: getVariable, hasVariable
47
+ *
48
+ * Methods added:
49
+ * - setVariable(name, value, explicitType?, location?) -> void
50
+ * - evaluateVariable(node) -> RillValue
51
+ * - evaluateVariableAsync(node) -> Promise<RillValue>
52
+ * - evaluateCapture(node, input) -> RillValue
53
+ */
54
+ function createVariablesMixin(Base) {
55
+ return class VariablesEvaluator extends Base {
56
+ /**
57
+ * Set a variable with type checking.
58
+ * - First assignment locks the type (inferred or explicit)
59
+ * - Subsequent assignments must match the locked type
60
+ * - Explicit type annotation is validated against value type
61
+ * - Cannot shadow outer scope variables (produces error)
62
+ */
63
+ setVariable(name, value, explicitType, location) {
64
+ const valueType = inferType(value);
65
+ // Check explicit type annotation matches value
66
+ if (explicitType !== undefined && explicitType !== valueType) {
67
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Type mismatch: cannot assign ${valueType} to $${name}:${explicitType}`, location, {
68
+ variableName: name,
69
+ expectedType: explicitType,
70
+ actualType: valueType,
71
+ });
72
+ }
73
+ // Check if this is a new variable that would reassign an outer scope variable
74
+ // (error: cannot reassign outer scope variables from child scopes)
75
+ if (!this.ctx.variables.has(name) &&
76
+ this.ctx.parent &&
77
+ hasVariable(this.ctx.parent, name)) {
78
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Cannot reassign outer variable $${name} from child scope`, location, { variableName: name });
79
+ }
80
+ // Check if variable already has a locked type in current scope
81
+ const lockedType = this.ctx.variableTypes.get(name);
82
+ if (lockedType !== undefined && lockedType !== valueType) {
83
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Type mismatch: cannot assign ${valueType} to $${name} (locked as ${lockedType})`, location, {
84
+ variableName: name,
85
+ expectedType: lockedType,
86
+ actualType: valueType,
87
+ });
88
+ }
89
+ // Set the variable and lock its type in current scope
90
+ this.ctx.variables.set(name, value);
91
+ if (!this.ctx.variableTypes.has(name)) {
92
+ // Lock type: use explicit annotation if provided, otherwise infer from value
93
+ // This enables `$x:string` to lock type before assignment while still
94
+ // supporting type inference for bare captures like `:> $x`
95
+ this.ctx.variableTypes.set(name, explicitType ?? valueType);
96
+ }
97
+ }
98
+ /**
99
+ * Evaluate variable access synchronously.
100
+ * Handles bare variable references: $name or $.
101
+ *
102
+ * Note: This is a simplified synchronous version. The full implementation
103
+ * with property access chains is in evaluateVariableAsync.
104
+ */
105
+ evaluateVariable(node) {
106
+ // Handle pipe variable ($)
107
+ if (node.isPipeVar && !node.name) {
108
+ if (this.ctx.pipeValue === null) {
109
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_UNDEFINED_VARIABLE, 'Undefined variable: $', this.getNodeLocation(node), { variable: '$' });
110
+ }
111
+ return this.ctx.pipeValue;
112
+ }
113
+ // Handle named variable ($name)
114
+ if (node.name) {
115
+ const result = getVariable(this.ctx, node.name);
116
+ if (result === undefined) {
117
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_UNDEFINED_VARIABLE, `Undefined variable: $${node.name}`, this.getNodeLocation(node), { variable: node.name });
118
+ }
119
+ return result;
120
+ }
121
+ // Should not reach here - all variable nodes have either isPipeVar or name
122
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_UNDEFINED_VARIABLE, 'Invalid variable node', this.getNodeLocation(node));
123
+ }
124
+ /**
125
+ * Evaluate variable access asynchronously.
126
+ * Async variant that supports access chains ($.field, $var.field).
127
+ *
128
+ * Handles property access chains and default values.
129
+ */
130
+ async evaluateVariableAsync(node) {
131
+ // Get base value ($ or $name)
132
+ let value;
133
+ if (node.isPipeVar && !node.name) {
134
+ // Pipe variable ($)
135
+ if (this.ctx.pipeValue === null) {
136
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_UNDEFINED_VARIABLE, 'Undefined variable: $', this.getNodeLocation(node), { variable: '$' });
137
+ }
138
+ value = this.ctx.pipeValue;
139
+ }
140
+ else if (node.name) {
141
+ // Named variable ($name)
142
+ const result = getVariable(this.ctx, node.name);
143
+ if (result === undefined) {
144
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_UNDEFINED_VARIABLE, `Undefined variable: $${node.name}`, this.getNodeLocation(node), { variable: node.name });
145
+ }
146
+ value = result;
147
+ }
148
+ else {
149
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_UNDEFINED_VARIABLE, 'Invalid variable node', this.getNodeLocation(node));
150
+ }
151
+ // Apply access chain ($.field, $var.field, etc.)
152
+ for (const access of node.accessChain) {
153
+ if (value === null) {
154
+ // Use default value if available
155
+ if (node.defaultValue) {
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
+ return this.evaluateBody(node.defaultValue);
158
+ }
159
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Cannot access property on null`, this.getNodeLocation(node));
160
+ }
161
+ // Check if this is a bracket access
162
+ if ('accessKind' in access) {
163
+ // Bracket access: [expr]
164
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
+ const indexValue = await this.evaluatePipeChain(access.expression);
166
+ if (Array.isArray(value)) {
167
+ if (typeof indexValue !== 'number') {
168
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `List index must be number, got ${inferType(indexValue)}`, this.getNodeLocation(node));
169
+ }
170
+ let index = indexValue;
171
+ // Handle negative indices
172
+ if (index < 0) {
173
+ index = value.length + index;
174
+ }
175
+ const result = value[index];
176
+ if (result === undefined) {
177
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `List index out of bounds: ${indexValue}`, this.getNodeLocation(node));
178
+ }
179
+ value = result;
180
+ }
181
+ else if (isDict(value)) {
182
+ if (typeof indexValue !== 'string') {
183
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Dict key must be string, got ${inferType(indexValue)}`, this.getNodeLocation(node));
184
+ }
185
+ const result = value[indexValue];
186
+ if (result === undefined) {
187
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Undefined dict key: ${indexValue}`, this.getNodeLocation(node));
188
+ }
189
+ value = result;
190
+ }
191
+ else {
192
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Cannot index ${inferType(value)}`, this.getNodeLocation(node));
193
+ }
194
+ continue;
195
+ }
196
+ // Must be a FieldAccess
197
+ if (access.kind === 'literal') {
198
+ const field = access.field;
199
+ if (isDict(value)) {
200
+ // Allow missing fields if there's a default value
201
+ const allowMissing = node.defaultValue !== null;
202
+ value = await this.accessDictField(value, field, this.getNodeLocation(node), allowMissing);
203
+ }
204
+ else {
205
+ value = null;
206
+ }
207
+ }
208
+ else {
209
+ // Other field access types (variable, computed, block, alternatives)
210
+ throw new RuntimeError(RILL_ERROR_CODES.RUNTIME_TYPE_ERROR, `Field access kind '${access.kind}' not yet supported`, this.getNodeLocation(node));
211
+ }
212
+ }
213
+ // Apply default value if final result is null
214
+ if (value === null && node.defaultValue) {
215
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
216
+ return this.evaluateBody(node.defaultValue);
217
+ }
218
+ return value;
219
+ }
220
+ /**
221
+ * Evaluate capture: :> $name
222
+ * Handles capture syntax which assigns the piped value to a variable.
223
+ * Calls setVariable for type checking and fires observability callback.
224
+ */
225
+ evaluateCapture(node, input) {
226
+ this.setVariable(node.name, input, node.typeName ?? undefined, node.span.start);
227
+ this.ctx.observability.onCapture?.({ name: node.name, value: input });
228
+ return input;
229
+ }
230
+ /**
231
+ * Handle statement capture (public API wrapper).
232
+ * Returns capture info if a capture occurred.
233
+ * This overrides the stub in EvaluatorBase.
234
+ */
235
+ handleCapture(capture, value) {
236
+ if (!capture)
237
+ return undefined;
238
+ this.evaluateCapture(capture, value);
239
+ return { name: capture.name, value };
240
+ }
241
+ };
242
+ }
243
+ // Export with type assertion to work around TS4094 limitation
244
+ // TypeScript can't generate declarations for functions returning classes with protected members
245
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
246
+ export const VariablesMixin = createVariablesMixin;
247
+ //# sourceMappingURL=variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../../../src/runtime/core/eval/mixins/variables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAQH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAI3C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,oBAAoB,CAAC,IAAyC;IACrE,OAAO,MAAM,kBAAmB,SAAQ,IAAI;QAC1C;;;;;;WAMG;QACO,WAAW,CACnB,IAAY,EACZ,KAAgB,EAChB,YAA2B,EAC3B,QAAyB;YAEzB,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;YAEnC,+CAA+C;YAC/C,IAAI,YAAY,KAAK,SAAS,IAAI,YAAY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IAAI,qBAAqB,EACtD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAC3B,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,8CAA8C;YAC9C,IAAI,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACxC,8DAA8D;gBAC9D,OAAQ,IAAY,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACvD,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAED;;;;WAIG;QACO,eAAe,CAAC,IAAiB,EAAE,KAAgB;YAC3D,IAAI,CAAC,WAAW,CACd,IAAI,CAAC,IAAI,EACT,KAAK,EACL,IAAI,CAAC,QAAQ,IAAI,SAAS,EAC1B,IAAI,CAAC,IAAI,CAAC,KAAK,CAChB,CAAC;YACF,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,OAAO,KAAK,CAAC;QACf,CAAC;QAED;;;;WAIG;QACgB,aAAa,CAC9B,OAA2B,EAC3B,KAAgB;YAEhB,IAAI,CAAC,OAAO;gBAAE,OAAO,SAAS,CAAC;YAE/B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACrC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,gGAAgG;AAChG,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,oBAA2B,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Type Infrastructure for Evaluator Mixins
3
+ *
4
+ * Defines the constructor types and constraints for the mixin pattern.
5
+ * Mixins receive a base constructor and return an extended constructor.
6
+ *
7
+ * @internal
8
+ */
9
+ import type { EvaluatorBase } from './base.js';
10
+ /**
11
+ * Constructor type for EvaluatorBase or any class extending it.
12
+ * This is the input type for mixin functions.
13
+ *
14
+ * Type parameter TBase must extend EvaluatorBase to ensure all mixins
15
+ * have access to the base utilities (ctx, checkAborted, etc.).
16
+ *
17
+ * Note: `any[]` is required for constructor args because mixins don't know
18
+ * what parameters the base constructor accepts. This is the standard TypeScript
19
+ * mixin pattern.
20
+ */
21
+ export type EvaluatorConstructor<TBase extends EvaluatorBase = EvaluatorBase> = new (...args: any[]) => TBase;
22
+ /**
23
+ * Mixin function type.
24
+ * Receives a constructor extending EvaluatorBase and returns an extended constructor.
25
+ *
26
+ * @template TBase - The base class being extended (must extend EvaluatorBase)
27
+ * @template TExtension - The extended class returned by the mixin
28
+ *
29
+ * Example usage:
30
+ * ```typescript
31
+ * const CoreMixin: Mixin<EvaluatorBase, CoreEvaluator> = (Base) => {
32
+ * return class extends Base {
33
+ * protected async evaluateExpression(expr: ExpressionNode): Promise<RillValue> {
34
+ * // implementation
35
+ * }
36
+ * };
37
+ * };
38
+ * ```
39
+ */
40
+ export type Mixin<TBase extends EvaluatorBase = EvaluatorBase, TExtension extends TBase = TBase> = (Base: EvaluatorConstructor<TBase>) => EvaluatorConstructor<TExtension>;
41
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/runtime/core/eval/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,CAAC,KAAK,SAAS,aAAa,GAAG,aAAa,IAE1E,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC;AAEhC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,KAAK,CACf,KAAK,SAAS,aAAa,GAAG,aAAa,EAC3C,UAAU,SAAS,KAAK,GAAG,KAAK,IAC9B,CAAC,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC,KAAK,oBAAoB,CAAC,UAAU,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type Infrastructure for Evaluator Mixins
3
+ *
4
+ * Defines the constructor types and constraints for the mixin pattern.
5
+ * Mixins receive a base constructor and return an extended constructor.
6
+ *
7
+ * @internal
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/runtime/core/eval/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Expression Evaluation
3
+ *
4
+ * Internal module for AST evaluation. Not part of public API.
5
+ * All evaluation functions are internal implementation details.
6
+ *
7
+ * @internal
8
+ */
9
+ import type { AnnotatedStatementNode, ASTNode, CaptureNode, ExpressionNode, RillTypeName, SourceLocation, StatementNode } from '../../types.js';
10
+ import type { RuntimeContext } from './types.js';
11
+ import { type RillValue } from './values.js';
12
+ /**
13
+ * Check if execution has been aborted via AbortSignal.
14
+ * Throws AbortError if signal is aborted.
15
+ */
16
+ export declare function checkAborted(ctx: RuntimeContext, node?: ASTNode): void;
17
+ /**
18
+ * Check if the current pipe value matches any autoException pattern.
19
+ * Only checks string values. Throws AutoExceptionError on match.
20
+ */
21
+ export declare function checkAutoExceptions(value: RillValue, ctx: RuntimeContext, node?: ASTNode): void;
22
+ /**
23
+ * Handle statement capture: set variable and fire observability event.
24
+ * Returns capture info if a capture occurred.
25
+ */
26
+ export declare function handleCapture(capture: CaptureNode | null, value: RillValue, ctx: RuntimeContext): {
27
+ name: string;
28
+ value: RillValue;
29
+ } | undefined;
30
+ /**
31
+ * Assert that a value is of the expected type.
32
+ * Returns the value unchanged if assertion passes, throws on mismatch.
33
+ * Exported for use by type assertion evaluation.
34
+ */
35
+ export declare function assertType(value: RillValue, expected: RillTypeName, location?: SourceLocation): RillValue;
36
+ export declare function evaluateExpression(expr: ExpressionNode, ctx: RuntimeContext): Promise<RillValue>;
37
+ export declare function executeStatement(stmt: StatementNode | AnnotatedStatementNode, ctx: RuntimeContext): Promise<RillValue>;
38
+ /**
39
+ * Get the current value of an annotation from the annotation stack.
40
+ */
41
+ export declare function getAnnotation(ctx: RuntimeContext, key: string): RillValue | undefined;
42
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../../src/runtime/core/evaluate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,sBAAsB,EAGtB,OAAO,EAIP,WAAW,EAOX,cAAc,EAed,YAAY,EAIZ,cAAc,EAEd,aAAa,EAQd,MAAM,gBAAgB,CAAC;AAkBxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAYL,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAkBrB;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAItE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,cAAc,EACnB,IAAI,CAAC,EAAE,OAAO,GACb,IAAI,CAcN;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,cAAc,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAOhD;AAMD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,cAAc,GACxB,SAAS,CAWX;AA8GD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cA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