eliscript 0.0.1

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 (195) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +135 -0
  3. package/bin/eliscript +16 -0
  4. package/bin/eliscript-bootstrap +15 -0
  5. package/bin/eliscript-build +15 -0
  6. package/bin/eliscript-check +15 -0
  7. package/bin/eliscript-eval +15 -0
  8. package/bin/eliscript-format +15 -0
  9. package/bin/eliscript-org +10 -0
  10. package/bin/eliscript-portable +17 -0
  11. package/bin/eliscript-seed +10 -0
  12. package/bin/eliscript-seed-build +10 -0
  13. package/bin/eliscript-watch +15 -0
  14. package/bootstrap/README.md +100 -0
  15. package/bootstrap/compiler/analyzer.eli +1426 -0
  16. package/bootstrap/compiler/compiler.eli +472 -0
  17. package/bootstrap/compiler/emitter.eli +1745 -0
  18. package/bootstrap/compiler/expander.eli +2522 -0
  19. package/bootstrap/compiler/formatter.eli +359 -0
  20. package/bootstrap/compiler/ir.eli +297 -0
  21. package/bootstrap/compiler/lower.eli +661 -0
  22. package/bootstrap/compiler/project.eli +1120 -0
  23. package/bootstrap/compiler/reader.eli +321 -0
  24. package/bootstrap/compiler/source-map.eli +165 -0
  25. package/bootstrap/compiler/symbol.eli +92 -0
  26. package/bootstrap/compiler/syntax.eli +54 -0
  27. package/bootstrap/compiler/transient-analysis.eli +825 -0
  28. package/bootstrap/host/build.mjs +28 -0
  29. package/bootstrap/host/bun.mjs +282 -0
  30. package/bootstrap/host/check-cli.mjs +163 -0
  31. package/bootstrap/host/eliscript-cli.mjs +36 -0
  32. package/bootstrap/host/evaluation-cli.mjs +401 -0
  33. package/bootstrap/host/evaluation.mjs +560 -0
  34. package/bootstrap/host/format-cli.mjs +139 -0
  35. package/bootstrap/host/project-cli.mjs +295 -0
  36. package/bootstrap/host/project.mjs +1080 -0
  37. package/bootstrap/host/watch-cli.mjs +129 -0
  38. package/bootstrap/host/watch.mjs +267 -0
  39. package/browser/host.mjs +357 -0
  40. package/browser/worker.mjs +60 -0
  41. package/compiler/README.md +118 -0
  42. package/compiler/eliscript-analyzer.el +716 -0
  43. package/compiler/eliscript-cli.el +108 -0
  44. package/compiler/eliscript-diagnostic.el +158 -0
  45. package/compiler/eliscript-emitter.el +1351 -0
  46. package/compiler/eliscript-evaluation.el +259 -0
  47. package/compiler/eliscript-expander.el +1630 -0
  48. package/compiler/eliscript-form.el +79 -0
  49. package/compiler/eliscript-ir-emitter.el +1460 -0
  50. package/compiler/eliscript-ir.el +356 -0
  51. package/compiler/eliscript-lower.el +463 -0
  52. package/compiler/eliscript-macro-eval.el +811 -0
  53. package/compiler/eliscript-parameters.el +324 -0
  54. package/compiler/eliscript-portable.el +492 -0
  55. package/compiler/eliscript-project-cli.el +156 -0
  56. package/compiler/eliscript-project.el +1676 -0
  57. package/compiler/eliscript-reader.el +421 -0
  58. package/compiler/eliscript-source-map.el +192 -0
  59. package/compiler/eliscript-symbol.el +101 -0
  60. package/compiler/eliscript-transient-analysis.el +817 -0
  61. package/compiler/eliscript.el +239 -0
  62. package/dist/bootstrap/analyzer.mjs +968 -0
  63. package/dist/bootstrap/analyzer.mjs.map +1 -0
  64. package/dist/bootstrap/compiler.mjs +228 -0
  65. package/dist/bootstrap/compiler.mjs.map +1 -0
  66. package/dist/bootstrap/emitter.mjs +1173 -0
  67. package/dist/bootstrap/emitter.mjs.map +1 -0
  68. package/dist/bootstrap/expander.mjs +1469 -0
  69. package/dist/bootstrap/expander.mjs.map +1 -0
  70. package/dist/bootstrap/formatter.mjs +304 -0
  71. package/dist/bootstrap/formatter.mjs.map +1 -0
  72. package/dist/bootstrap/ir.mjs +193 -0
  73. package/dist/bootstrap/ir.mjs.map +1 -0
  74. package/dist/bootstrap/lower.mjs +344 -0
  75. package/dist/bootstrap/lower.mjs.map +1 -0
  76. package/dist/bootstrap/project.mjs +585 -0
  77. package/dist/bootstrap/project.mjs.map +1 -0
  78. package/dist/bootstrap/reader.mjs +259 -0
  79. package/dist/bootstrap/reader.mjs.map +1 -0
  80. package/dist/bootstrap/source-map.mjs +154 -0
  81. package/dist/bootstrap/source-map.mjs.map +1 -0
  82. package/dist/bootstrap/symbol.mjs +74 -0
  83. package/dist/bootstrap/symbol.mjs.map +1 -0
  84. package/dist/bootstrap/syntax.mjs +38 -0
  85. package/dist/bootstrap/syntax.mjs.map +1 -0
  86. package/dist/bootstrap/transient-analysis.mjs +660 -0
  87. package/dist/bootstrap/transient-analysis.mjs.map +1 -0
  88. package/dist/browser/compiler.js +6491 -0
  89. package/editor/README.md +83 -0
  90. package/editor/eliscript-mode.el +878 -0
  91. package/editor/eliscript-repl.el +501 -0
  92. package/package.json +163 -0
  93. package/platform/README.md +48 -0
  94. package/platform/browser.mjs +204 -0
  95. package/platform/worker.mjs +166 -0
  96. package/runtime/README.md +296 -0
  97. package/runtime/core/collection-internals.mjs +512 -0
  98. package/runtime/core/collection.mjs +645 -0
  99. package/runtime/core/data-text.mjs +532 -0
  100. package/runtime/core/data.mjs +268 -0
  101. package/runtime/core/identifier.mjs +314 -0
  102. package/runtime/core/lazy-sequence.mjs +244 -0
  103. package/runtime/core/list-internals.mjs +18 -0
  104. package/runtime/core/list.mjs +273 -0
  105. package/runtime/core/map-internals.mjs +793 -0
  106. package/runtime/core/map.mjs +394 -0
  107. package/runtime/core/metadata-internals.mjs +14 -0
  108. package/runtime/core/metadata.mjs +44 -0
  109. package/runtime/core/object-impl.mjs +65 -0
  110. package/runtime/core/object-impl.mjs.map +1 -0
  111. package/runtime/core/object.mjs +13 -0
  112. package/runtime/core/order.mjs +234 -0
  113. package/runtime/core/persistent-kind.mjs +43 -0
  114. package/runtime/core/protocol-error.mjs +36 -0
  115. package/runtime/core/protocol-impl.mjs +326 -0
  116. package/runtime/core/protocol-impl.mjs.map +1 -0
  117. package/runtime/core/protocol.mjs +14 -0
  118. package/runtime/core/queue-internals.mjs +27 -0
  119. package/runtime/core/queue.mjs +238 -0
  120. package/runtime/core/record.mjs +346 -0
  121. package/runtime/core/regex.mjs +184 -0
  122. package/runtime/core/sequence.mjs +632 -0
  123. package/runtime/core/set-algebra.mjs +287 -0
  124. package/runtime/core/set-internals.mjs +33 -0
  125. package/runtime/core/set.mjs +378 -0
  126. package/runtime/core/sorted-internals.mjs +215 -0
  127. package/runtime/core/sorted.mjs +598 -0
  128. package/runtime/core/text-impl.mjs +95 -0
  129. package/runtime/core/text-impl.mjs.map +1 -0
  130. package/runtime/core/text.mjs +15 -0
  131. package/runtime/core/transducer.mjs +668 -0
  132. package/runtime/core/transient-internals.mjs +38 -0
  133. package/runtime/core/transient.mjs +53 -0
  134. package/runtime/core/truth.mjs +3 -0
  135. package/runtime/core/type.mjs +262 -0
  136. package/runtime/core/value-internals.mjs +188 -0
  137. package/runtime/core/value.mjs +93 -0
  138. package/runtime/core/vector-internals.mjs +102 -0
  139. package/runtime/core/vector.mjs +951 -0
  140. package/runtime/literals.mjs +34 -0
  141. package/runtime/source-mapping.mjs +220 -0
  142. package/runtime/testing/list.mjs +52 -0
  143. package/runtime/testing/map.mjs +145 -0
  144. package/runtime/testing/queue.mjs +49 -0
  145. package/runtime/testing/set.mjs +61 -0
  146. package/runtime/testing/sorted.mjs +105 -0
  147. package/runtime/testing/value.mjs +17 -0
  148. package/runtime/testing/vector.mjs +102 -0
  149. package/runtime/worker-value-codec.mjs +565 -0
  150. package/runtime/worker-value-stream.mjs +786 -0
  151. package/runtime/worker.mjs +975 -0
  152. package/stdlib/README.md +774 -0
  153. package/stdlib/bit.eli +36 -0
  154. package/stdlib/core/collection.eli +134 -0
  155. package/stdlib/core/data-text.eli +16 -0
  156. package/stdlib/core/data.eli +306 -0
  157. package/stdlib/core/identifier.eli +32 -0
  158. package/stdlib/core/lazy-sequence.eli +63 -0
  159. package/stdlib/core/metadata.eli +20 -0
  160. package/stdlib/core/object.eli +89 -0
  161. package/stdlib/core/order.eli +133 -0
  162. package/stdlib/core/protocol.eli +387 -0
  163. package/stdlib/core/record.eli +16 -0
  164. package/stdlib/core/regex.eli +17 -0
  165. package/stdlib/core/seq.eli +701 -0
  166. package/stdlib/core/set.eli +312 -0
  167. package/stdlib/core/sorted.eli +53 -0
  168. package/stdlib/core/text.eli +103 -0
  169. package/stdlib/core/transducer.eli +59 -0
  170. package/stdlib/core/transient.eli +24 -0
  171. package/stdlib/core/type.eli +19 -0
  172. package/stdlib/core/walk.eli +195 -0
  173. package/stdlib/core/zipper.eli +508 -0
  174. package/stdlib/data-text.eli +1092 -0
  175. package/stdlib/data.eli +42 -0
  176. package/stdlib/deferred.eli +70 -0
  177. package/stdlib/function.eli +120 -0
  178. package/stdlib/hierarchy.eli +245 -0
  179. package/stdlib/identifier.eli +147 -0
  180. package/stdlib/interop/js.eli +616 -0
  181. package/stdlib/json.eli +870 -0
  182. package/stdlib/metadata.eli +56 -0
  183. package/stdlib/multimethod.eli +464 -0
  184. package/stdlib/numeric.eli +193 -0
  185. package/stdlib/object.eli +96 -0
  186. package/stdlib/persistent-list.eli +145 -0
  187. package/stdlib/persistent-map.eli +724 -0
  188. package/stdlib/persistent-queue.eli +32 -0
  189. package/stdlib/persistent-set.eli +236 -0
  190. package/stdlib/persistent-vector.eli +342 -0
  191. package/stdlib/result.eli +141 -0
  192. package/stdlib/sequence.eli +106 -0
  193. package/stdlib/state/atom.eli +265 -0
  194. package/stdlib/text.eli +88 -0
  195. package/stdlib/value.eli +325 -0
@@ -0,0 +1,660 @@
1
+ // Generated by Eliscript. Do not edit.
2
+ const __eliscript_truthy = (value) => value !== false && value != null;
3
+
4
+ import {node_kind, node_span, node_value, node_name, node_items} from "./syntax.mjs";
5
+ const transient_fail = (filename, span, message) => { const file = filename || span?.filename || '<input>'; const start = span ? { offset: span.start, line: span.line, column: span.column } : { offset: 0, line: 1, column: 1 }; const end = span ? { offset: span.end, line: span.endLine, column: span.endColumn } : { offset: 0, line: 1, column: 1 }; const diagnostic = { format: 'eliscript-diagnostic', version: 1, code: 'ELI-A0001', severity: 'error', phase: 'analysis', message, location: { file, start, end } }; const error = new Error(`${file}:${start.line}:${start.column}: ${message}`); error.eliscriptDiagnostic = diagnostic; throw error; };
6
+ const canonical_transient_family = (source) => { if (typeof source !== 'string' || !/(^|\/)(stdlib|runtime)\/core\/transient\.(mjs|eli)$/.test(source)) return null; return /(^|\/)runtime\/core\//.test(source) ? 'runtime' : 'stdlib'; };
7
+ const trusted_core_source_p = (filename) => typeof filename === 'string' && ['stdlib/core/data.eli', 'stdlib/core/seq.eli', 'stdlib/core/set.eli', 'stdlib/core/transient.eli'].some((suffix) => filename === suffix || filename.endsWith('/' + suffix));
8
+ function symbol_node_p(node) {
9
+ return ((__eliscript_value_1) => (__eliscript_truthy(__eliscript_value_1) ? (node_kind(node) === "symbol") : __eliscript_value_1))(node);
10
+ }
11
+ function vector_node_p(node) {
12
+ return ((__eliscript_value_2) => (__eliscript_truthy(__eliscript_value_2) ? (node_kind(node) === "vector") : __eliscript_value_2))(node);
13
+ }
14
+ function map_node_p(node) {
15
+ return ((__eliscript_value_3) => (__eliscript_truthy(__eliscript_value_3) ? ((__eliscript_value_4) => (__eliscript_truthy(__eliscript_value_4) ? ((__eliscript_value_5) => (__eliscript_truthy(__eliscript_value_5) ? ((__eliscript_value_6) => (__eliscript_truthy(__eliscript_value_6) ? (node_name(((((node_items(node)) ?? [])[0]) ?? null)) === "hash-map") : __eliscript_value_6))(symbol_node_p(((((node_items(node)) ?? [])[0]) ?? null))) : __eliscript_value_5))(((node_items(node))["length"] > 0)) : __eliscript_value_4))((node_kind(node) === "list")) : __eliscript_value_3))(node);
16
+ }
17
+ function keyword_node_p(node) {
18
+ return ((__eliscript_value_7) => (__eliscript_truthy(__eliscript_value_7) ? (node_kind(node) === "keyword") : __eliscript_value_7))(node);
19
+ }
20
+ function null_node_p(node) {
21
+ return ((__eliscript_value_8) => (__eliscript_truthy(__eliscript_value_8) ? ((__eliscript_value_9) => (__eliscript_truthy(__eliscript_value_9) ? (node_value(node) == null) : __eliscript_value_9))((node_kind(node) === "literal")) : __eliscript_value_8))(node);
22
+ }
23
+ function list_items(node) {
24
+ return (__eliscript_truthy(((__eliscript_value_10) => (__eliscript_truthy(__eliscript_value_10) ? (node_kind(node) === "list") : __eliscript_value_10))(node)) ? node_items(node) : (__eliscript_truthy(null_node_p(node)) ? [] : undefined));
25
+ }
26
+ function binding_marker_p(name) {
27
+ return (["&optional", "&rest", "&body"])["includes"](name);
28
+ }
29
+ function split_binding_name(name) {
30
+ return ((slash) => {
31
+ return (__eliscript_truthy((slash < 0)) ? ({"namespace": undefined, "local": name}) : ({"namespace": (name)["slice"](0, slash), "local": (name)["slice"]((slash + 1))}));
32
+ })((name)["lastIndexOf"]("/"));
33
+ }
34
+ function map_binding_shortcut_p(node) {
35
+ return ((__eliscript_value_11) => (__eliscript_truthy(__eliscript_value_11) ? (["keys", "strs", "syms"])["includes"]((split_binding_name(node_name(node)))["local"]) : __eliscript_value_11))(keyword_node_p(node));
36
+ }
37
+ function local_binding_node(node) {
38
+ return ({"kind": "symbol", "name": (split_binding_name(node_name(node)))["local"], "span": node_span(node)});
39
+ }
40
+ function binding_nodes(pattern, context) {
41
+ return (__eliscript_truthy(symbol_node_p(pattern)) ? (__eliscript_truthy(binding_marker_p(node_name(pattern))) ? transient_fail((context)["filename"], node_span(pattern), "invalid transient-analysis binding marker") : [pattern]) : (__eliscript_truthy(vector_node_p(pattern)) ? ((result) => {
42
+ (node_items(pattern))["forEach"]((element) => {
43
+ return (__eliscript_truthy((!__eliscript_truthy(((__eliscript_value_12) => (__eliscript_truthy(__eliscript_value_12) ? __eliscript_value_12 : ((__eliscript_value_13) => (__eliscript_truthy(__eliscript_value_13) ? binding_marker_p(node_name(element)) : __eliscript_value_13))(symbol_node_p(element))))(null_node_p(element))))) ? (binding_nodes(element, context))["forEach"]((binding) => {
44
+ return (result)["push"](binding);
45
+ }) : null);
46
+ });
47
+ return result;
48
+ })([]) : (__eliscript_truthy(map_node_p(pattern)) ? ((items, result, index) => {
49
+ (() => {
50
+ while (__eliscript_truthy((index < (items)["length"]))) {
51
+ ((left) => {
52
+ return ((right) => {
53
+ return ((directive) => {
54
+ return (__eliscript_truthy(map_binding_shortcut_p(left)) ? (node_items(right))["forEach"]((binding) => {
55
+ return (result)["push"](local_binding_node(binding));
56
+ }) : (__eliscript_truthy((directive === "as")) ? (result)["push"](right) : (__eliscript_truthy((directive === "or")) ? null : (binding_nodes(left, context))["forEach"]((binding) => {
57
+ return (result)["push"](binding);
58
+ }))));
59
+ })(((__eliscript_value_14) => (__eliscript_truthy(__eliscript_value_14) ? node_name(left) : __eliscript_value_14))(keyword_node_p(left)));
60
+ })(((((items) ?? [])[(index + 1)]) ?? null));
61
+ })(((((items) ?? [])[index]) ?? null));
62
+ ((index = (index + 2)));
63
+ }
64
+ return null;
65
+ })();
66
+ return result;
67
+ })((node_items(pattern))["slice"](1), [], 0) : [])));
68
+ }
69
+ function make_scope(parent) {
70
+ return ({"parent": parent, "names": new Map()});
71
+ }
72
+ function make_binding(node, operation = null, namespace = null) {
73
+ return ({"name": node_name(node), "operation": operation, "namespace": namespace, "resource": null});
74
+ }
75
+ function install_binding(scope, binding) {
76
+ ((scope)["names"])["set"]((binding)["name"], binding);
77
+ return binding;
78
+ }
79
+ function declare_binding(scope, node, operation = null, namespace = null) {
80
+ return install_binding(scope, make_binding(node, operation, namespace));
81
+ }
82
+ function lookup_binding(scope, name) {
83
+ return ((current, binding) => {
84
+ (() => {
85
+ while (__eliscript_truthy(((__eliscript_value_15) => (__eliscript_truthy(__eliscript_value_15) ? (!__eliscript_truthy(binding)) : __eliscript_value_15))(current))) {
86
+ ((binding = ((current)["names"])["get"](name)));
87
+ ((current = (current)["parent"]));
88
+ }
89
+ return null;
90
+ })();
91
+ return binding;
92
+ })(scope, undefined);
93
+ }
94
+ function make_pattern_bindings(pattern, context) {
95
+ return ((result) => {
96
+ (binding_nodes(pattern, context))["forEach"]((node) => {
97
+ return (result)["push"](make_binding(node));
98
+ });
99
+ return result;
100
+ })([]);
101
+ }
102
+ function install_bindings(scope, bindings) {
103
+ (bindings)["forEach"]((binding) => {
104
+ return install_binding(scope, binding);
105
+ });
106
+ return bindings;
107
+ }
108
+ function transient_operation(family, name) {
109
+ return (__eliscript_truthy((family === "stdlib")) ? (__eliscript_truthy((name === "transient")) ? "construct" : (__eliscript_truthy(((__eliscript_value_16) => (__eliscript_truthy(__eliscript_value_16) ? __eliscript_value_16 : ((__eliscript_value_17) => (__eliscript_truthy(__eliscript_value_17) ? __eliscript_value_17 : (name === "dissoc!")))((name === "assoc!"))))((name === "conj!"))) ? "update" : (__eliscript_truthy((name === "persistent!")) ? "complete" : null))) : (__eliscript_truthy((family === "runtime")) ? (__eliscript_truthy((name === "transient")) ? "construct" : (__eliscript_truthy(((__eliscript_value_18) => (__eliscript_truthy(__eliscript_value_18) ? __eliscript_value_18 : ((__eliscript_value_19) => (__eliscript_truthy(__eliscript_value_19) ? __eliscript_value_19 : (name === "dissocBang")))((name === "assocBang"))))((name === "conjBang"))) ? "update" : (__eliscript_truthy((name === "persistentBang")) ? "complete" : null))) : null));
110
+ }
111
+ function operator_binding(operator, scope) {
112
+ return (__eliscript_truthy(symbol_node_p(operator)) ? ((name) => {
113
+ return ((direct) => {
114
+ return (__eliscript_truthy(((__eliscript_value_20) => (__eliscript_truthy(__eliscript_value_20) ? (direct)["operation"] : __eliscript_value_20))(direct)) ? direct : ((separator) => {
115
+ return (__eliscript_truthy(((__eliscript_value_21) => (__eliscript_truthy(__eliscript_value_21) ? (separator === (name)["lastIndexOf"]("/")) : __eliscript_value_21))((separator > 0))) ? ((namespace_name) => {
116
+ return ((member_name) => {
117
+ return ((namespace) => {
118
+ return ((family) => {
119
+ return ((operation) => {
120
+ return ((__eliscript_value_24) => (__eliscript_truthy(__eliscript_value_24) ? ({"name": name, "operation": operation}) : __eliscript_value_24))(operation);
121
+ })(((__eliscript_value_23) => (__eliscript_truthy(__eliscript_value_23) ? transient_operation(family, member_name) : __eliscript_value_23))(family));
122
+ })(((__eliscript_value_22) => (__eliscript_truthy(__eliscript_value_22) ? (namespace)["namespace"] : __eliscript_value_22))(namespace));
123
+ })(lookup_binding(scope, namespace_name));
124
+ })((name)["slice"]((separator + 1)));
125
+ })((name)["slice"](0, separator)) : null);
126
+ })((name)["indexOf"]("/")));
127
+ })(lookup_binding(scope, name));
128
+ })(node_name(operator)) : null);
129
+ }
130
+ function copy_state(context) {
131
+ return ((result) => {
132
+ ((context)["state"])["forEach"]((state, resource) => {
133
+ return (result)["set"](resource, state);
134
+ });
135
+ return result;
136
+ })(new Map());
137
+ }
138
+ function merge_state(baseline, branches) {
139
+ return ((result) => {
140
+ (baseline)["forEach"]((original, resource) => {
141
+ return ((first, same) => {
142
+ (branches)["forEach"]((branch) => {
143
+ return ((state) => {
144
+ return (__eliscript_truthy((first === undefined)) ? ((first = state)) : (__eliscript_truthy((!__eliscript_truthy((state === first)))) ? ((same = false)) : null));
145
+ })((__eliscript_truthy((branch)["has"](resource)) ? (branch)["get"](resource) : original));
146
+ });
147
+ return (result)["set"](resource, (__eliscript_truthy(same) ? first : "maybe"));
148
+ })(undefined, true);
149
+ });
150
+ return result;
151
+ })(new Map());
152
+ }
153
+ function run_with_state(context, state, operation) {
154
+ return ((saved) => {
155
+ ((context)["state"] = ((result) => {
156
+ (state)["forEach"]((value, resource) => {
157
+ return (result)["set"](resource, value);
158
+ });
159
+ return result;
160
+ })(new Map()));
161
+ operation();
162
+ return ((result) => {
163
+ ((context)["state"] = saved);
164
+ return result;
165
+ })((context)["state"]);
166
+ })((context)["state"]);
167
+ }
168
+ function retain_state_keys(context, baseline) {
169
+ return ((current, result) => {
170
+ (baseline)["forEach"]((original, resource) => {
171
+ return (result)["set"](resource, (__eliscript_truthy((current)["has"](resource)) ? (current)["get"](resource) : original));
172
+ });
173
+ return ((context)["state"] = result);
174
+ })((context)["state"], new Map());
175
+ }
176
+ function record_try_prefix(context) {
177
+ return ((prefixes) => {
178
+ return (__eliscript_truthy(prefixes) ? (prefixes)["push"](copy_state(context)) : null);
179
+ })((context)["tryPrefixes"]);
180
+ }
181
+ function resource_state(context, resource) {
182
+ return (__eliscript_truthy(((context)["state"])["has"](resource)) ? ((context)["state"])["get"](resource) : "active");
183
+ }
184
+ function check_owner(binding, context, span) {
185
+ return ((resource, name) => {
186
+ (__eliscript_truthy((!__eliscript_truthy(resource))) ? transient_fail((context)["filename"], span, "transient operation requires a directly bound transient value") : null);
187
+ (__eliscript_truthy((!__eliscript_truthy(((resource)["functionId"] === (context)["functionId"])))) ? transient_fail((context)["filename"], span, (String("transient binding ") + String(name) + String(" cannot cross a function boundary"))) : null);
188
+ return ((state) => {
189
+ return (__eliscript_truthy((state === "active")) ? resource : (__eliscript_truthy((state === "consumed")) ? transient_fail((context)["filename"], span, (String("transient binding ") + String(name) + String(" is no longer editable after persistent!"))) : transient_fail((context)["filename"], span, (String("transient binding ") + String(name) + String(" may already be persistent after conditional control flow")))));
190
+ })(resource_state(context, resource));
191
+ })(((__eliscript_value_25) => (__eliscript_truthy(__eliscript_value_25) ? (binding)["resource"] : __eliscript_value_25))(binding), ((__eliscript_value_26) => (__eliscript_truthy(__eliscript_value_26) ? (binding)["name"] : __eliscript_value_26))(binding));
192
+ }
193
+ function direct_resource(form, scope, context) {
194
+ return ((binding) => {
195
+ return check_owner(binding, context, ((__eliscript_value_28) => (__eliscript_truthy(__eliscript_value_28) ? node_span(form) : __eliscript_value_28))(form));
196
+ })(((__eliscript_value_27) => (__eliscript_truthy(__eliscript_value_27) ? lookup_binding(scope, node_name(form)) : __eliscript_value_27))(symbol_node_p(form)));
197
+ }
198
+ function analyze_reference(form, scope, context) {
199
+ return ((name) => {
200
+ return ((operation) => {
201
+ return ((binding) => {
202
+ return (() => {
203
+ (__eliscript_truthy(operation) ? transient_fail((context)["filename"], node_span(form), (String("transient operation ") + String(name) + String(" must be called directly"))) : null);
204
+ return (__eliscript_truthy(((__eliscript_value_29) => (__eliscript_truthy(__eliscript_value_29) ? (binding)["resource"] : __eliscript_value_29))(binding)) ? ((resource) => {
205
+ (__eliscript_truthy((!__eliscript_truthy(((resource)["functionId"] === (context)["functionId"])))) ? transient_fail((context)["filename"], node_span(form), (String("transient binding ") + String(name) + String(" cannot cross a function boundary"))) : null);
206
+ return ((state) => {
207
+ return (__eliscript_truthy((state === "active")) ? transient_fail((context)["filename"], node_span(form), (String("transient binding ") + String(name) + String(" may only be used by a direct transient operation"))) : (__eliscript_truthy((state === "consumed")) ? transient_fail((context)["filename"], node_span(form), (String("transient binding ") + String(name) + String(" is no longer editable after persistent!"))) : transient_fail((context)["filename"], node_span(form), (String("transient binding ") + String(name) + String(" may already be persistent after conditional control flow")))));
208
+ })(resource_state(context, resource));
209
+ })((binding)["resource"]) : null);
210
+ })();
211
+ })(lookup_binding(scope, name));
212
+ })(operator_binding(form, scope));
213
+ })(node_name(form));
214
+ }
215
+ function binding_pair(binding) {
216
+ return ((items) => {
217
+ return (__eliscript_truthy(((__eliscript_value_30) => (__eliscript_truthy(__eliscript_value_30) ? ((items)["length"] > 0) : __eliscript_value_30))((!__eliscript_truthy((items === undefined))))) ? ({"target": ((((items) ?? [])[0]) ?? null), "initializer": ((((items) ?? [])[1]) ?? null)}) : ({"target": binding, "initializer": null}));
218
+ })(list_items(binding));
219
+ }
220
+ function new_resource(binding, span, context) {
221
+ return ((resource) => {
222
+ ((binding)["resource"] = resource);
223
+ ((context)["state"])["set"](resource, "active");
224
+ return resource;
225
+ })(({"name": (binding)["name"], "functionId": (context)["functionId"], "span": span}));
226
+ }
227
+ function constructor_call_p(form, scope) {
228
+ return ((__eliscript_value_31) => (__eliscript_truthy(__eliscript_value_31) ? ((__eliscript_value_32) => (__eliscript_truthy(__eliscript_value_32) ? ((items) => {
229
+ return ((binding) => {
230
+ return ((__eliscript_value_33) => (__eliscript_truthy(__eliscript_value_33) ? ((binding)["operation"] === "construct") : __eliscript_value_33))(binding);
231
+ })(operator_binding(((((items) ?? [])[0]) ?? null), scope));
232
+ })(node_items(form)) : __eliscript_value_32))((node_kind(form) === "list")) : __eliscript_value_31))(form);
233
+ }
234
+ function analyze_initializer(initializer, scope, bindings, context, predeclared = null) {
235
+ return (__eliscript_truthy(constructor_call_p(initializer, scope)) ? ((items) => {
236
+ return ((arguments$) => {
237
+ return (() => {
238
+ (__eliscript_truthy((!__eliscript_truthy(((bindings)["length"] === 1)))) ? transient_fail((context)["filename"], node_span(initializer), "transient result must be bound directly to one symbol") : null);
239
+ (__eliscript_truthy((!__eliscript_truthy(((arguments$)["length"] === 1)))) ? transient_fail((context)["filename"], node_span(initializer), "transient expects 1 argument") : null);
240
+ analyze_expression(((((arguments$) ?? [])[0]) ?? null), scope, context, true);
241
+ return ((binding) => {
242
+ return (__eliscript_truthy((!__eliscript_truthy(((__eliscript_value_34) => (__eliscript_truthy(__eliscript_value_34) ? (binding)["resource"] : __eliscript_value_34))(predeclared)))) ? new_resource(binding, node_span(initializer), context) : null);
243
+ })(((((bindings) ?? [])[0]) ?? null));
244
+ })();
245
+ })((items)["slice"](1));
246
+ })(node_items(initializer)) : (__eliscript_truthy(initializer) ? analyze_expression(initializer, scope, context, true) : null));
247
+ }
248
+ function analyze_sequence(forms, scope, context, value_context) {
249
+ return ((index) => {
250
+ return (() => {
251
+ while (__eliscript_truthy((index < (forms)["length"]))) {
252
+ analyze_expression(((((forms) ?? [])[index]) ?? null), scope, context, ((__eliscript_value_35) => (__eliscript_truthy(__eliscript_value_35) ? (index === ((forms)["length"] - 1)) : __eliscript_value_35))(value_context));
253
+ ((index = (index + 1)));
254
+ }
255
+ return null;
256
+ })();
257
+ })(0);
258
+ }
259
+ function analyze_let(arguments$, scope, context, sequential, value_context) {
260
+ return ((baseline) => {
261
+ return ((binding_node) => {
262
+ return ((binding_forms) => {
263
+ return ((body) => {
264
+ return ((child) => {
265
+ return (() => {
266
+ (__eliscript_truthy((binding_forms === undefined)) ? transient_fail((context)["filename"], ((__eliscript_value_36) => (__eliscript_truthy(__eliscript_value_36) ? node_span(binding_node) : __eliscript_value_36))(binding_node), "let bindings must be a list") : null);
267
+ (__eliscript_truthy(sequential) ? (binding_forms)["forEach"]((entry) => {
268
+ return ((parsed) => {
269
+ return ((declared) => {
270
+ return (() => {
271
+ analyze_initializer((parsed)["initializer"], child, declared, context);
272
+ return install_bindings(child, declared);
273
+ })();
274
+ })(make_pattern_bindings((parsed)["target"], context));
275
+ })(binding_pair(entry));
276
+ }) : ((parsed, declared) => {
277
+ (binding_forms)["forEach"]((entry) => {
278
+ return ((pair) => {
279
+ return ((bindings) => {
280
+ return (() => {
281
+ (parsed)["push"](pair);
282
+ return (declared)["push"](bindings);
283
+ })();
284
+ })(make_pattern_bindings((pair)["target"], context));
285
+ })(binding_pair(entry));
286
+ });
287
+ ((index) => {
288
+ return (() => {
289
+ while (__eliscript_truthy((index < (parsed)["length"]))) {
290
+ analyze_initializer((((((parsed) ?? [])[index]) ?? null))["initializer"], scope, ((((declared) ?? [])[index]) ?? null), context);
291
+ ((index = (index + 1)));
292
+ }
293
+ return null;
294
+ })();
295
+ })(0);
296
+ return (declared)["forEach"]((bindings) => {
297
+ return install_bindings(child, bindings);
298
+ });
299
+ })([], []));
300
+ analyze_sequence(body, child, context, value_context);
301
+ return retain_state_keys(context, baseline);
302
+ })();
303
+ })(make_scope(scope));
304
+ })((arguments$)["slice"](1));
305
+ })((__eliscript_truthy(binding_node) ? list_items(binding_node) : undefined));
306
+ })(((((arguments$) ?? [])[0]) ?? null));
307
+ })(copy_state(context));
308
+ }
309
+ function declare_parameters(scope, parameters, context) {
310
+ return ((items) => {
311
+ return (items)["forEach"]((parameter) => {
312
+ return (__eliscript_truthy((!__eliscript_truthy(((__eliscript_value_37) => (__eliscript_truthy(__eliscript_value_37) ? binding_marker_p(node_name(parameter)) : __eliscript_value_37))(symbol_node_p(parameter))))) ? install_bindings(scope, make_pattern_bindings(parameter, context)) : null);
313
+ });
314
+ })((__eliscript_truthy((node_kind(parameters) === "list")) ? node_items(parameters) : (__eliscript_truthy((node_kind(parameters) === "vector")) ? node_items(parameters) : [])));
315
+ }
316
+ function analyze_function(parameters, body, scope, context) {
317
+ return ((saved_state, saved_function_id, saved_loop_protected, child) => {
318
+ ((context)["nextFunctionId"] = ((context)["nextFunctionId"] + 1));
319
+ ((context)["functionId"] = (context)["nextFunctionId"]);
320
+ ((context)["state"] = copy_state(context));
321
+ ((context)["loopProtected"] = []);
322
+ declare_parameters(child, parameters, context);
323
+ analyze_sequence(body, child, context, true);
324
+ ((context)["state"] = saved_state);
325
+ ((context)["functionId"] = saved_function_id);
326
+ return ((context)["loopProtected"] = saved_loop_protected);
327
+ })((context)["state"], (context)["functionId"], (context)["loopProtected"], make_scope(scope));
328
+ }
329
+ function analyze_if(arguments$, scope, context, value_context) {
330
+ analyze_expression(((((arguments$) ?? [])[0]) ?? null), scope, context, true);
331
+ return ((baseline) => {
332
+ return ((then_state) => {
333
+ return ((else_state) => {
334
+ return ((context)["state"] = merge_state(baseline, [then_state, else_state]));
335
+ })((__eliscript_truthy(((arguments$)["length"] > 2)) ? run_with_state(context, baseline, () => {
336
+ return analyze_expression(((((arguments$) ?? [])[2]) ?? null), scope, context, value_context);
337
+ }) : baseline));
338
+ })(run_with_state(context, baseline, () => {
339
+ return analyze_expression(((((arguments$) ?? [])[1]) ?? null), scope, context, value_context);
340
+ }));
341
+ })(copy_state(context));
342
+ }
343
+ function analyze_when(arguments$, scope, context, value_context) {
344
+ analyze_expression(((((arguments$) ?? [])[0]) ?? null), scope, context, true);
345
+ return ((baseline) => {
346
+ return ((body_state) => {
347
+ return ((context)["state"] = merge_state(baseline, [baseline, body_state]));
348
+ })(run_with_state(context, baseline, () => {
349
+ return analyze_sequence((arguments$)["slice"](1), scope, context, value_context);
350
+ }));
351
+ })(copy_state(context));
352
+ }
353
+ function analyze_short_circuit(arguments$, scope, context, value_context) {
354
+ return ((exits, index) => {
355
+ (() => {
356
+ while (__eliscript_truthy((index < (arguments$)["length"]))) {
357
+ analyze_expression(((((arguments$) ?? [])[index]) ?? null), scope, context, value_context);
358
+ (exits)["push"](copy_state(context));
359
+ ((index = (index + 1)));
360
+ }
361
+ return null;
362
+ })();
363
+ return (__eliscript_truthy(((exits)["length"] > 0)) ? ((context)["state"] = merge_state(((((exits) ?? [])[0]) ?? null), exits)) : null);
364
+ })([], 0);
365
+ }
366
+ function analyze_cond(clauses, scope, context, value_context) {
367
+ return ((baseline, exits, default_seen, index) => {
368
+ (() => {
369
+ while (__eliscript_truthy(((__eliscript_value_38) => (__eliscript_truthy(__eliscript_value_38) ? (!__eliscript_truthy(default_seen)) : __eliscript_value_38))((index < (clauses)["length"])))) {
370
+ ((items) => {
371
+ return ((test) => {
372
+ return (() => {
373
+ analyze_expression(test, scope, context, true);
374
+ return ((after_test) => {
375
+ return ((body_state) => {
376
+ return (() => {
377
+ (exits)["push"](body_state);
378
+ return (__eliscript_truthy(((__eliscript_value_39) => (__eliscript_truthy(__eliscript_value_39) ? (node_value(test) === true) : __eliscript_value_39))((node_kind(test) === "literal"))) ? ((default_seen = true)) : null);
379
+ })();
380
+ })(run_with_state(context, after_test, () => {
381
+ return analyze_sequence((items)["slice"](1), scope, context, value_context);
382
+ }));
383
+ })(copy_state(context));
384
+ })();
385
+ })(((((items) ?? [])[0]) ?? null));
386
+ })(list_items(((((clauses) ?? [])[index]) ?? null)));
387
+ ((index = (index + 1)));
388
+ }
389
+ return null;
390
+ })();
391
+ (__eliscript_truthy((!__eliscript_truthy(default_seen))) ? (exits)["push"](copy_state(context)) : null);
392
+ return (__eliscript_truthy(((exits)["length"] > 0)) ? ((context)["state"] = merge_state(baseline, exits)) : null);
393
+ })(copy_state(context), [], false, 0);
394
+ }
395
+ function visible_active_resources(context) {
396
+ return ((resources) => {
397
+ ((context)["state"])["forEach"]((state, resource) => {
398
+ return (__eliscript_truthy(((__eliscript_value_40) => (__eliscript_truthy(__eliscript_value_40) ? ((__eliscript_value_41) => (__eliscript_truthy(__eliscript_value_41) ? __eliscript_value_41 : (state === "maybe")))((state === "active")) : __eliscript_value_40))(((resource)["functionId"] === (context)["functionId"]))) ? (resources)["push"](resource) : null);
399
+ });
400
+ (resources)["sort"]((left, right) => {
401
+ return ((left)["name"])["localeCompare"]((right)["name"]);
402
+ });
403
+ return resources;
404
+ })([]);
405
+ }
406
+ function analyze_await(form, arguments$, scope, context) {
407
+ analyze_expression(((((arguments$) ?? [])[0]) ?? null), scope, context, true);
408
+ return ((active) => {
409
+ return (__eliscript_truthy(((active)["length"] > 0)) ? transient_fail((context)["filename"], node_span(form), (String("transient binding ") + String((((((active) ?? [])[0]) ?? null))["name"]) + String(" cannot remain active across await"))) : null);
410
+ })(visible_active_resources(context));
411
+ }
412
+ function analyze_operation(operation, form, arguments$, scope, context, value_context) {
413
+ return (__eliscript_truthy((operation === "construct")) ? transient_fail((context)["filename"], node_span(form), "transient result must be bound directly to one symbol") : (__eliscript_truthy((operation === "update")) ? (() => {
414
+ (__eliscript_truthy(((arguments$)["length"] === 0)) ? transient_fail((context)["filename"], node_span(form), "transient update requires a directly bound transient value") : null);
415
+ direct_resource(((((arguments$) ?? [])[0]) ?? null), scope, context);
416
+ (__eliscript_truthy(value_context) ? transient_fail((context)["filename"], node_span(form), "transient update result cannot be used as an ordinary value") : null);
417
+ return ((index) => {
418
+ return (() => {
419
+ while (__eliscript_truthy((index < (arguments$)["length"]))) {
420
+ analyze_expression(((((arguments$) ?? [])[index]) ?? null), scope, context, true);
421
+ ((index = (index + 1)));
422
+ }
423
+ return null;
424
+ })();
425
+ })(1);
426
+ })() : (__eliscript_truthy((operation === "complete")) ? (() => {
427
+ (__eliscript_truthy((!__eliscript_truthy(((arguments$)["length"] === 1)))) ? transient_fail((context)["filename"], node_span(form), "persistent! expects 1 argument") : null);
428
+ return ((resource) => {
429
+ (__eliscript_truthy(((context)["loopProtected"])["includes"](resource)) ? transient_fail((context)["filename"], node_span(((((arguments$) ?? [])[0]) ?? null)), (String("transient binding ") + String((resource)["name"]) + String(" cannot be completed inside a repeated loop"))) : null);
430
+ return ((context)["state"])["set"](resource, "consumed");
431
+ })(direct_resource(((((arguments$) ?? [])[0]) ?? null), scope, context));
432
+ })() : null)));
433
+ }
434
+ function analyze_loop(arguments$, scope, context, value_context) {
435
+ return ((baseline) => {
436
+ return ((bindings) => {
437
+ return ((child) => {
438
+ return (() => {
439
+ (bindings)["forEach"]((entry) => {
440
+ return ((parsed) => {
441
+ return ((declared) => {
442
+ return (() => {
443
+ analyze_initializer((parsed)["initializer"], scope, declared, context);
444
+ return install_bindings(child, declared);
445
+ })();
446
+ })(make_pattern_bindings((parsed)["target"], context));
447
+ })(binding_pair(entry));
448
+ });
449
+ ((saved, protected$) => {
450
+ (saved)["forEach"]((resource) => {
451
+ return (protected$)["push"](resource);
452
+ });
453
+ ((context)["loopProtected"] = protected$);
454
+ analyze_sequence((arguments$)["slice"](1), child, context, value_context);
455
+ return ((context)["loopProtected"] = saved);
456
+ })((context)["loopProtected"], (visible_active_resources(context))["slice"]());
457
+ return retain_state_keys(context, baseline);
458
+ })();
459
+ })(make_scope(scope));
460
+ })(list_items(((((arguments$) ?? [])[0]) ?? null)));
461
+ })(copy_state(context));
462
+ }
463
+ function analyze_while(arguments$, scope, context) {
464
+ analyze_expression(((((arguments$) ?? [])[0]) ?? null), scope, context, true);
465
+ return ((baseline) => {
466
+ return ((saved) => {
467
+ return ((protected$) => {
468
+ return (() => {
469
+ (saved)["forEach"]((resource) => {
470
+ return (protected$)["push"](resource);
471
+ });
472
+ ((context)["loopProtected"] = protected$);
473
+ return ((body_state) => {
474
+ ((context)["loopProtected"] = saved);
475
+ return ((context)["state"] = merge_state(baseline, [baseline, body_state]));
476
+ })(run_with_state(context, baseline, () => {
477
+ return analyze_sequence((arguments$)["slice"](1), scope, context, false);
478
+ }));
479
+ })();
480
+ })((visible_active_resources(context))["slice"]());
481
+ })((context)["loopProtected"]);
482
+ })(copy_state(context));
483
+ }
484
+ function analyze_assignment(arguments$, scope, context) {
485
+ return ((index) => {
486
+ return (() => {
487
+ while (__eliscript_truthy((index < (arguments$)["length"]))) {
488
+ ((name) => {
489
+ return ((binding) => {
490
+ return (() => {
491
+ (__eliscript_truthy(((__eliscript_value_43) => (__eliscript_truthy(__eliscript_value_43) ? (binding)["resource"] : __eliscript_value_43))(binding)) ? transient_fail((context)["filename"], node_span(name), (String("transient binding ") + String(node_name(name)) + String(" cannot be reassigned"))) : null);
492
+ return analyze_expression(((((arguments$) ?? [])[(index + 1)]) ?? null), scope, context, true);
493
+ })();
494
+ })(((__eliscript_value_42) => (__eliscript_truthy(__eliscript_value_42) ? lookup_binding(scope, node_name(name)) : __eliscript_value_42))(symbol_node_p(name)));
495
+ })(((((arguments$) ?? [])[index]) ?? null));
496
+ ((index = (index + 2)));
497
+ }
498
+ return null;
499
+ })();
500
+ })(0);
501
+ }
502
+ function clause_operator(form) {
503
+ return ((items) => {
504
+ return ((__eliscript_value_44) => (__eliscript_truthy(__eliscript_value_44) ? ((__eliscript_value_45) => (__eliscript_truthy(__eliscript_value_45) ? ((__eliscript_value_46) => (__eliscript_truthy(__eliscript_value_46) ? node_name(((((items) ?? [])[0]) ?? null)) : __eliscript_value_46))(symbol_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_45))(((items)["length"] > 0)) : __eliscript_value_44))((!__eliscript_truthy((items === undefined))));
505
+ })(list_items(form));
506
+ }
507
+ function analyze_try(arguments$, scope, context, value_context) {
508
+ return ((baseline, body, catch_clause, finally_clause) => {
509
+ (arguments$)["forEach"]((argument) => {
510
+ return ((operator) => {
511
+ return (__eliscript_truthy((operator === "catch")) ? ((catch_clause = argument)) : (__eliscript_truthy((operator === "finally")) ? ((finally_clause = argument)) : (body)["push"](argument)));
512
+ })(clause_operator(argument));
513
+ });
514
+ ((saved_prefixes) => {
515
+ return ((prefixes) => {
516
+ return (() => {
517
+ ((context)["tryPrefixes"] = prefixes);
518
+ return ((normal_state) => {
519
+ ((context)["tryPrefixes"] = saved_prefixes);
520
+ return ((exception_state) => {
521
+ return ((catch_state) => {
522
+ return ((context)["state"] = merge_state(baseline, [normal_state, catch_state]));
523
+ })((__eliscript_truthy(catch_clause) ? ((items) => {
524
+ return ((child) => {
525
+ return (() => {
526
+ install_bindings(child, make_pattern_bindings(((((items) ?? [])[1]) ?? null), context));
527
+ return run_with_state(context, exception_state, () => {
528
+ return analyze_sequence((items)["slice"](2), child, context, value_context);
529
+ });
530
+ })();
531
+ })(make_scope(scope));
532
+ })(list_items(catch_clause)) : exception_state));
533
+ })(merge_state(baseline, prefixes));
534
+ })(run_with_state(context, baseline, () => {
535
+ return analyze_sequence(body, scope, context, value_context);
536
+ }));
537
+ })();
538
+ })([baseline]);
539
+ })((context)["tryPrefixes"]);
540
+ return (__eliscript_truthy(finally_clause) ? analyze_sequence((list_items(finally_clause))["slice"](1), scope, context, false) : null);
541
+ })(copy_state(context), [], null, null);
542
+ }
543
+ function analyze_call(form, scope, context, value_context) {
544
+ return ((items) => {
545
+ return ((operator_node) => {
546
+ return ((operator) => {
547
+ return ((arguments$) => {
548
+ return ((binding) => {
549
+ return (__eliscript_truthy(binding) ? analyze_operation((binding)["operation"], form, arguments$, scope, context, value_context) : (__eliscript_truthy(((__eliscript_value_48) => (__eliscript_truthy(__eliscript_value_48) ? __eliscript_value_48 : ((__eliscript_value_49) => (__eliscript_truthy(__eliscript_value_49) ? __eliscript_value_49 : (operator === "async")))((operator === "fn"))))((operator === "lambda"))) ? analyze_function(((((arguments$) ?? [])[0]) ?? null), (arguments$)["slice"](1), scope, context) : (__eliscript_truthy((operator === "await")) ? analyze_await(form, arguments$, scope, context) : (__eliscript_truthy(((__eliscript_value_50) => (__eliscript_truthy(__eliscript_value_50) ? __eliscript_value_50 : (operator === "js*")))((operator === "quote"))) ? null : (__eliscript_truthy((operator === "let")) ? analyze_let(arguments$, scope, context, false, value_context) : (__eliscript_truthy((operator === "let*")) ? analyze_let(arguments$, scope, context, true, value_context) : (__eliscript_truthy((operator === "loop")) ? analyze_loop(arguments$, scope, context, value_context) : (__eliscript_truthy((operator === "while")) ? analyze_while(arguments$, scope, context) : (__eliscript_truthy(((__eliscript_value_51) => (__eliscript_truthy(__eliscript_value_51) ? __eliscript_value_51 : (operator === "set!")))((operator === "setq"))) ? analyze_assignment(arguments$, scope, context) : (__eliscript_truthy((operator === "if")) ? analyze_if(arguments$, scope, context, value_context) : (__eliscript_truthy(((__eliscript_value_52) => (__eliscript_truthy(__eliscript_value_52) ? __eliscript_value_52 : (operator === "unless")))((operator === "when"))) ? analyze_when(arguments$, scope, context, value_context) : (__eliscript_truthy(((__eliscript_value_53) => (__eliscript_truthy(__eliscript_value_53) ? __eliscript_value_53 : (operator === "or")))((operator === "and"))) ? analyze_short_circuit(arguments$, scope, context, value_context) : (__eliscript_truthy((operator === "cond")) ? analyze_cond(arguments$, scope, context, value_context) : (__eliscript_truthy((operator === "try")) ? analyze_try(arguments$, scope, context, value_context) : (__eliscript_truthy(((__eliscript_value_54) => (__eliscript_truthy(__eliscript_value_54) ? __eliscript_value_54 : (operator === "do")))((operator === "progn"))) ? analyze_sequence(arguments$, scope, context, value_context) : (() => {
550
+ ((operator_binding) => {
551
+ return (__eliscript_truthy(((__eliscript_value_56) => (__eliscript_truthy(__eliscript_value_56) ? ((__eliscript_value_57) => (__eliscript_truthy(__eliscript_value_57) ? __eliscript_value_57 : (operator_binding)["resource"]))((operator_binding)["operation"]) : __eliscript_value_56))(operator_binding)) ? analyze_reference(operator_node, scope, context) : null);
552
+ })(((__eliscript_value_55) => (__eliscript_truthy(__eliscript_value_55) ? lookup_binding(scope, operator) : __eliscript_value_55))(operator));
553
+ return (arguments$)["forEach"]((argument) => {
554
+ return analyze_expression(argument, scope, context, true);
555
+ });
556
+ })())))))))))))))));
557
+ })(operator_binding(operator_node, scope));
558
+ })((items)["slice"](1));
559
+ })(((__eliscript_value_47) => (__eliscript_truthy(__eliscript_value_47) ? node_name(operator_node) : __eliscript_value_47))(symbol_node_p(operator_node)));
560
+ })(((((items) ?? [])[0]) ?? null));
561
+ })(node_items(form));
562
+ }
563
+ function analyze_expression(form, scope, context, value_context) {
564
+ return (__eliscript_truthy(form) ? (() => {
565
+ record_try_prefix(context);
566
+ (__eliscript_truthy((node_kind(form) === "symbol")) ? analyze_reference(form, scope, context) : (__eliscript_truthy((node_kind(form) === "vector")) ? (node_items(form))["forEach"]((item) => {
567
+ return analyze_expression(item, scope, context, true);
568
+ }) : (__eliscript_truthy((node_kind(form) === "list")) ? analyze_call(form, scope, context, value_context) : null)));
569
+ return record_try_prefix(context);
570
+ })() : null);
571
+ }
572
+ function import_declarations(arguments$, scope) {
573
+ return ((source) => {
574
+ return ((family) => {
575
+ return ((index) => {
576
+ return (() => {
577
+ while (__eliscript_truthy((index < (arguments$)["length"]))) {
578
+ ((specifier) => {
579
+ return (__eliscript_truthy((node_kind(specifier) === "keyword")) ? ((keyword, name) => {
580
+ declare_binding(scope, name, null, ((__eliscript_value_58) => (__eliscript_truthy(__eliscript_value_58) ? family : __eliscript_value_58))((keyword === "as")));
581
+ return ((index = (index + 2)));
582
+ })(node_name(specifier), ((((arguments$) ?? [])[(index + 1)]) ?? null)) : (() => {
583
+ declare_binding(scope, specifier, ((__eliscript_value_59) => (__eliscript_truthy(__eliscript_value_59) ? transient_operation(family, node_name(specifier)) : __eliscript_value_59))(family));
584
+ return ((index = (index + 1)));
585
+ })());
586
+ })(((((arguments$) ?? [])[index]) ?? null));
587
+ }
588
+ return null;
589
+ })();
590
+ })(1);
591
+ })(canonical_transient_family(source));
592
+ })(node_value(((((arguments$) ?? [])[0]) ?? null)));
593
+ }
594
+ function flatten_modules_into(forms, result) {
595
+ return (forms)["forEach"]((form) => {
596
+ return ((items) => {
597
+ return (__eliscript_truthy(((__eliscript_value_60) => (__eliscript_truthy(__eliscript_value_60) ? ((__eliscript_value_61) => (__eliscript_truthy(__eliscript_value_61) ? ((__eliscript_value_62) => (__eliscript_truthy(__eliscript_value_62) ? (node_name(((((items) ?? [])[0]) ?? null)) === "module") : __eliscript_value_62))(symbol_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_61))(((items)["length"] > 0)) : __eliscript_value_60))((!__eliscript_truthy((items === undefined))))) ? flatten_modules_into((items)["slice"](2), result) : (result)["push"](form));
598
+ })(list_items(form));
599
+ });
600
+ }
601
+ function flatten_modules(forms) {
602
+ return ((result) => {
603
+ flatten_modules_into(forms, result);
604
+ return result;
605
+ })([]);
606
+ }
607
+ function predeclare_top_level(forms, scope, context) {
608
+ (forms)["forEach"]((form) => {
609
+ return ((items) => {
610
+ return (__eliscript_truthy(((__eliscript_value_63) => (__eliscript_truthy(__eliscript_value_63) ? ((__eliscript_value_64) => (__eliscript_truthy(__eliscript_value_64) ? symbol_node_p(((((items) ?? [])[0]) ?? null)) : __eliscript_value_64))(((items)["length"] > 1)) : __eliscript_value_63))((!__eliscript_truthy((items === undefined))))) ? ((operator) => {
611
+ return (__eliscript_truthy(((__eliscript_value_65) => (__eliscript_truthy(__eliscript_value_65) ? __eliscript_value_65 : (operator === "import-portable")))((operator === "import"))) ? import_declarations((items)["slice"](1), scope) : (__eliscript_truthy(((__eliscript_value_66) => (__eliscript_truthy(__eliscript_value_66) ? __eliscript_value_66 : ((__eliscript_value_67) => (__eliscript_truthy(__eliscript_value_67) ? __eliscript_value_67 : ((__eliscript_value_68) => (__eliscript_truthy(__eliscript_value_68) ? __eliscript_value_68 : ((__eliscript_value_69) => (__eliscript_truthy(__eliscript_value_69) ? __eliscript_value_69 : ((__eliscript_value_70) => (__eliscript_truthy(__eliscript_value_70) ? __eliscript_value_70 : (operator === "defasync")))((operator === "defportable"))))((operator === "defn"))))((operator === "defun"))))((operator === "defconst"))))((operator === "defvar"))) ? declare_binding(scope, ((((items) ?? [])[1]) ?? null)) : null));
612
+ })(node_name(((((items) ?? [])[0]) ?? null))) : null);
613
+ })(list_items(form));
614
+ });
615
+ return (forms)["forEach"]((form) => {
616
+ return ((items) => {
617
+ return (__eliscript_truthy(((__eliscript_value_71) => (__eliscript_truthy(__eliscript_value_71) ? ((__eliscript_value_72) => (__eliscript_truthy(__eliscript_value_72) ? ((__eliscript_value_73) => (__eliscript_truthy(__eliscript_value_73) ? ((__eliscript_value_74) => (__eliscript_truthy(__eliscript_value_74) ? constructor_call_p(((((items) ?? [])[2]) ?? null), scope) : __eliscript_value_74))(((__eliscript_value_75) => (__eliscript_truthy(__eliscript_value_75) ? __eliscript_value_75 : (node_name(((((items) ?? [])[0]) ?? null)) === "defconst")))((node_name(((((items) ?? [])[0]) ?? null)) === "defvar"))) : __eliscript_value_73))(symbol_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_72))(((items)["length"] > 2)) : __eliscript_value_71))((!__eliscript_truthy((items === undefined))))) ? new_resource(lookup_binding(scope, node_name(((((items) ?? [])[1]) ?? null))), node_span(((((items) ?? [])[2]) ?? null)), context) : null);
618
+ })(list_items(form));
619
+ });
620
+ }
621
+ function check_export(name, scope, context) {
622
+ return ((binding) => {
623
+ return (__eliscript_truthy(((__eliscript_value_77) => (__eliscript_truthy(__eliscript_value_77) ? (binding)["resource"] : __eliscript_value_77))(binding)) ? transient_fail((context)["filename"], node_span(name), (String("transient binding ") + String(node_name(name)) + String(" cannot be exported"))) : null);
624
+ })(((__eliscript_value_76) => (__eliscript_truthy(__eliscript_value_76) ? lookup_binding(scope, node_name(name)) : __eliscript_value_76))(symbol_node_p(name)));
625
+ }
626
+ function analyze_top_level(form, scope, context) {
627
+ return ((items) => {
628
+ return (__eliscript_truthy(((__eliscript_value_78) => (__eliscript_truthy(__eliscript_value_78) ? __eliscript_value_78 : ((items)["length"] === 0)))((items === undefined))) ? analyze_expression(form, scope, context, false) : ((operator_node) => {
629
+ return ((operator) => {
630
+ return ((arguments$) => {
631
+ return (__eliscript_truthy(((__eliscript_value_80) => (__eliscript_truthy(__eliscript_value_80) ? __eliscript_value_80 : (operator === "import-portable")))((operator === "import"))) ? null : (__eliscript_truthy(((__eliscript_value_81) => (__eliscript_truthy(__eliscript_value_81) ? __eliscript_value_81 : (operator === "defconst")))((operator === "defvar"))) ? ((binding) => {
632
+ return analyze_initializer(((((arguments$) ?? [])[1]) ?? null), scope, [binding], context, true);
633
+ })(lookup_binding(scope, node_name(((((arguments$) ?? [])[0]) ?? null)))) : (__eliscript_truthy(((__eliscript_value_82) => (__eliscript_truthy(__eliscript_value_82) ? __eliscript_value_82 : ((__eliscript_value_83) => (__eliscript_truthy(__eliscript_value_83) ? __eliscript_value_83 : ((__eliscript_value_84) => (__eliscript_truthy(__eliscript_value_84) ? __eliscript_value_84 : (operator === "defasync")))((operator === "defportable"))))((operator === "defn"))))((operator === "defun"))) ? analyze_function(((((arguments$) ?? [])[1]) ?? null), (arguments$)["slice"](2), scope, context) : (__eliscript_truthy((operator === "export")) ? (arguments$)["forEach"]((name) => {
634
+ return check_export(name, scope, context);
635
+ }) : (__eliscript_truthy((operator === "export-default")) ? (() => {
636
+ check_export(((((arguments$) ?? [])[0]) ?? null), scope, context);
637
+ return analyze_expression(((((arguments$) ?? [])[0]) ?? null), scope, context, true);
638
+ })() : analyze_expression(form, scope, context, false))))));
639
+ })((items)["slice"](1));
640
+ })(((__eliscript_value_79) => (__eliscript_truthy(__eliscript_value_79) ? node_name(operator_node) : __eliscript_value_79))(symbol_node_p(operator_node)));
641
+ })(((((items) ?? [])[0]) ?? null)));
642
+ })(list_items(form));
643
+ }
644
+ function analyze_transients(forms, filename) {
645
+ (__eliscript_truthy((!__eliscript_truthy(trusted_core_source_p(filename)))) ? ((context) => {
646
+ return ((flattened) => {
647
+ return ((scope) => {
648
+ return (() => {
649
+ predeclare_top_level(flattened, scope, context);
650
+ return (flattened)["forEach"]((form) => {
651
+ return analyze_top_level(form, scope, context);
652
+ });
653
+ })();
654
+ })(make_scope(null));
655
+ })(flatten_modules(forms));
656
+ })(({"filename": filename, "state": new Map(), "functionId": 0, "nextFunctionId": 0, "loopProtected": [], "tryPrefixes": null})) : null);
657
+ return forms;
658
+ }
659
+ export {analyze_transients};
660
+ //# sourceMappingURL=transient-analysis.mjs.map