eliscript 0.0.4 → 0.1.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 (192) hide show
  1. package/README.md +9 -8
  2. package/bootstrap/compiler/emitter.eli +161 -63
  3. package/bootstrap/host/check-cli.mjs +0 -1
  4. package/bootstrap/host/check-cli.mjs.map +1 -1
  5. package/bootstrap/host/compiler-session.eli +2 -1
  6. package/bootstrap/host/eliscript-cli.mjs +2 -9
  7. package/bootstrap/host/eliscript-cli.mjs.map +1 -1
  8. package/bootstrap/host/project-cli.mjs +1 -11
  9. package/bootstrap/host/project-cli.mjs.map +1 -1
  10. package/bootstrap/host/project.mjs +2 -8
  11. package/bootstrap/host/project.mjs.map +1 -1
  12. package/browser/README.md +1 -1
  13. package/compiler/README.md +2 -2
  14. package/compiler/eliscript-emitter.el +229 -85
  15. package/compiler/eliscript-ir-emitter.el +64 -34
  16. package/compiler/eliscript-project.el +20 -5
  17. package/dist/backends/async.mjs +1 -90
  18. package/dist/backends/async.mjs.map +1 -1
  19. package/dist/backends/binary.mjs +1 -91
  20. package/dist/backends/binary.mjs.map +1 -1
  21. package/dist/backends/capabilities.mjs +1 -90
  22. package/dist/backends/capabilities.mjs.map +1 -1
  23. package/dist/backends/elf.mjs +1 -90
  24. package/dist/backends/elf.mjs.map +1 -1
  25. package/dist/backends/managed.mjs +1 -94
  26. package/dist/backends/managed.mjs.map +1 -1
  27. package/dist/backends/memory.mjs +1 -90
  28. package/dist/backends/memory.mjs.map +1 -1
  29. package/dist/backends/native.mjs +1 -91
  30. package/dist/backends/native.mjs.map +1 -1
  31. package/dist/backends/numeric.mjs +1 -90
  32. package/dist/backends/numeric.mjs.map +1 -1
  33. package/dist/backends/optimize.mjs +1 -90
  34. package/dist/backends/optimize.mjs.map +1 -1
  35. package/dist/backends/regexp.mjs +1 -91
  36. package/dist/backends/regexp.mjs.map +1 -1
  37. package/dist/backends/sha256.mjs +2 -96
  38. package/dist/backends/sha256.mjs.map +1 -1
  39. package/dist/backends/wasm.mjs +1 -90
  40. package/dist/backends/wasm.mjs.map +1 -1
  41. package/dist/bootstrap/analyzer.mjs +1 -95
  42. package/dist/bootstrap/analyzer.mjs.map +1 -1
  43. package/dist/bootstrap/compiler.mjs +1 -105
  44. package/dist/bootstrap/compiler.mjs.map +1 -1
  45. package/dist/bootstrap/emitter.mjs +848 -807
  46. package/dist/bootstrap/emitter.mjs.map +1 -1
  47. package/dist/bootstrap/expander.mjs +1 -96
  48. package/dist/bootstrap/expander.mjs.map +1 -1
  49. package/dist/bootstrap/formatter.mjs +1 -104
  50. package/dist/bootstrap/formatter.mjs.map +1 -1
  51. package/dist/bootstrap/ir.mjs +18 -172
  52. package/dist/bootstrap/ir.mjs.map +1 -1
  53. package/dist/bootstrap/lower.mjs +1 -92
  54. package/dist/bootstrap/lower.mjs.map +1 -1
  55. package/dist/bootstrap/project.mjs +23 -209
  56. package/dist/bootstrap/project.mjs.map +1 -1
  57. package/dist/bootstrap/reader.mjs +1 -96
  58. package/dist/bootstrap/reader.mjs.map +1 -1
  59. package/dist/bootstrap/source-map.mjs +7 -112
  60. package/dist/bootstrap/source-map.mjs.map +1 -1
  61. package/dist/bootstrap/symbol.mjs +7 -114
  62. package/dist/bootstrap/symbol.mjs.map +1 -1
  63. package/dist/bootstrap/syntax.mjs +10 -176
  64. package/dist/bootstrap/syntax.mjs.map +1 -1
  65. package/dist/bootstrap/transient-analysis.mjs +1 -93
  66. package/dist/bootstrap/transient-analysis.mjs.map +1 -1
  67. package/dist/browser/compiler.js +105 -104
  68. package/dist/browser/loader.js +1 -1
  69. package/dist/browser/loader.mjs +5 -124
  70. package/dist/compiler-artifact.json +1 -1
  71. package/dist/host/compiler-session.mjs +205 -297
  72. package/dist/host/compiler-session.mjs.map +1 -1
  73. package/dist/host/compiler-tools.mjs +1 -91
  74. package/dist/host/compiler-tools.mjs.map +1 -1
  75. package/dist/literal-sources/runtime/core/order.eli +32 -10
  76. package/dist/literal-sources/runtime/core/sequence.eli +69 -28
  77. package/dist/literal-sources/runtime/core/vector.eli +2 -4
  78. package/dist/literal-sources/stdlib/managed-literal-protocols.eli +5 -5
  79. package/dist/literal-sources/stdlib/managed-literals.eli +1 -1
  80. package/dist/package.json +1 -0
  81. package/dist/runtime/math.mjs +62 -252
  82. package/dist/runtime/math.mjs.map +1 -1
  83. package/dist/runtime/prelude.mjs +95 -0
  84. package/dist/runtime/prelude.mjs.macro-origins.json +1 -0
  85. package/dist/runtime/prelude.mjs.map +1 -0
  86. package/dist/runtime/unicode-case-data.mjs +1 -95
  87. package/dist/runtime/unicode-case-data.mjs.map +1 -1
  88. package/dist/runtime/unicode-case.mjs +3 -97
  89. package/dist/runtime/unicode-case.mjs.map +1 -1
  90. package/dist/stage3-release.json +1 -1
  91. package/editor/README.md +9 -4
  92. package/editor/eliscript-abi.el +170 -0
  93. package/editor/eliscript-async.el +375 -0
  94. package/editor/eliscript-bind.el +822 -0
  95. package/editor/eliscript-compat.el +346 -0
  96. package/editor/eliscript-contract.el +334 -0
  97. package/editor/eliscript-data.el +1544 -0
  98. package/editor/eliscript-js.el +318 -0
  99. package/editor/eliscript-mode.el +1 -1
  100. package/editor/eliscript-module.el +340 -0
  101. package/editor/eliscript-repl.el +1 -1
  102. package/package.json +4 -1
  103. package/runtime/README.md +21 -1
  104. package/runtime/core/protocol-impl.mjs +1 -115
  105. package/runtime/core/protocol-impl.mjs.map +1 -1
  106. package/runtime/core/text-impl.mjs +1 -90
  107. package/runtime/core/text-impl.mjs.map +1 -1
  108. package/runtime/core/vector.eli +1 -1
  109. package/runtime/core/vector.mjs +0 -9
  110. package/runtime/emacs-compat.eli +5957 -0
  111. package/runtime/emacs-compat.mjs +13734 -0
  112. package/runtime/emacs-compat.mjs.map +1 -0
  113. package/runtime/math.mjs +62 -252
  114. package/runtime/math.mjs.map +1 -1
  115. package/runtime/prelude.eli +4 -0
  116. package/runtime/prelude.mjs +95 -0
  117. package/runtime/prelude.mjs.map +1 -0
  118. package/runtime/unicode-case-data.mjs +1 -95
  119. package/runtime/unicode-case-data.mjs.map +1 -1
  120. package/runtime/unicode-case.mjs +3 -97
  121. package/runtime/unicode-case.mjs.map +1 -1
  122. package/stdlib/managed-literals.eli +1 -1
  123. package/stdlib/managed-runtime-vector.eli +2 -4
  124. package/tools/backends/compiler-build.mjs +3 -93
  125. package/tools/backends/compiler-cli.mjs +2 -15
  126. package/tools/backends/compiler-corpus-bit.mjs +2 -95
  127. package/tools/backends/compiler-corpus-cli-adapters.mjs +1 -97
  128. package/tools/backends/compiler-corpus-debugging.mjs +2 -95
  129. package/tools/backends/compiler-corpus-emitter.mjs +1 -97
  130. package/tools/backends/compiler-corpus-execution.mjs +2 -108
  131. package/tools/backends/compiler-corpus-fuzz.mjs +2 -95
  132. package/tools/backends/compiler-corpus-host-context.mjs +2 -99
  133. package/tools/backends/compiler-corpus-identity-host.mjs +18 -123
  134. package/tools/backends/compiler-corpus-identity-value-adapters.mjs +0 -9
  135. package/tools/backends/compiler-corpus-literal-provider.mjs +1 -91
  136. package/tools/backends/compiler-corpus-managed-adapters.mjs +1 -99
  137. package/tools/backends/compiler-corpus-managed-fixtures.mjs +2 -113
  138. package/tools/backends/compiler-corpus-matchers.mjs +3 -106
  139. package/tools/backends/compiler-corpus-original-program.mjs +1 -91
  140. package/tools/backends/compiler-corpus-process.mjs +1 -92
  141. package/tools/backends/compiler-corpus-program-driver.mjs +1 -3
  142. package/tools/backends/compiler-corpus-project-adapters.mjs +1 -95
  143. package/tools/backends/compiler-corpus-project-entry-host.mjs +2 -92
  144. package/tools/backends/compiler-corpus-project-transport.mjs +1 -90
  145. package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1 -91
  146. package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1 -92
  147. package/tools/backends/compiler-corpus-raw-math-fixture.mjs +1 -91
  148. package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +1 -91
  149. package/tools/backends/compiler-corpus-reference.mjs +1 -90
  150. package/tools/backends/compiler-corpus-runtime-adapters.mjs +2 -110
  151. package/tools/backends/compiler-corpus-tools-cli.mjs +1 -95
  152. package/tools/backends/compiler-corpus-tools-reference.mjs +22 -163
  153. package/tools/backends/compiler-corpus.mjs +3 -125
  154. package/tools/backends/compiler-matrix.mjs +1 -92
  155. package/tools/backends/compiler-package-browser.mjs +1 -90
  156. package/tools/backends/compiler-package.mjs +3 -95
  157. package/tools/backends/compiler-unicode-profile-host.mjs +1 -91
  158. package/tools/backends/dist/bootstrap-js-stages.mjs +1 -91
  159. package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -1
  160. package/tools/backends/dist/managed-ir-inventory.mjs +1 -91
  161. package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -1
  162. package/tools/backends/dist/record-grid.mjs +1 -91
  163. package/tools/backends/dist/record-grid.mjs.map +1 -1
  164. package/tools/backends/dist/release-cli.mjs +4 -94
  165. package/tools/backends/dist/release-cli.mjs.map +1 -1
  166. package/tools/backends/dist/run-artifact.mjs +1 -91
  167. package/tools/backends/dist/run-artifact.mjs.map +1 -1
  168. package/tools/backends/eliscript/compiler-corpus-bit.eli +1 -0
  169. package/tools/backends/managed-foreign-binding.mjs +1 -95
  170. package/tools/backends/managed-host-lifecycle.mjs +1 -91
  171. package/tools/backends/managed-host-object-provider.mjs +18 -59
  172. package/tools/backends/managed-host-object-realm.mjs +1 -91
  173. package/tools/backends/managed-host-proxy.mjs +9 -18
  174. package/tools/backends/managed-host-runtime.mjs +3 -105
  175. package/tools/backends/managed-host.mjs +1 -104
  176. package/tools/backends/managed-module-graph.mjs +1 -97
  177. package/tools/backends/managed-runtime.mjs +1 -96
  178. package/tools/backends/managed-source-view.mjs +13 -108
  179. package/tools/backends/native-managed-runtime.mjs +1 -91
  180. package/tools/backends/native-memory.mjs +1 -91
  181. package/tools/backends/stage3-targets.mjs +1 -91
  182. package/tools/bootstrap-runtime.el +3 -2
  183. package/tools/project/project.eli +1 -1
  184. package/tools/testing/stdlib-bit-corpus-host.mjs +1 -90
  185. package/tools/testing/stdlib-bit.mjs +1 -90
  186. package/dist/bootstrap/package.json +0 -1
  187. package/dist/bootstrap/runtime/math.mjs +0 -1117
  188. package/dist/bootstrap/runtime/math.mjs.map +0 -1
  189. package/dist/bootstrap/runtime/unicode-case-data.mjs +0 -10125
  190. package/dist/bootstrap/runtime/unicode-case-data.mjs.map +0 -1
  191. package/dist/bootstrap/runtime/unicode-case.mjs +0 -281
  192. package/dist/bootstrap/runtime/unicode-case.mjs.map +0 -1
@@ -49,25 +49,40 @@
49
49
  (defun eliscript-ir-emitter--tdz-defaults (node scope state)
50
50
  (when (eliscript-ir-property node :pattern)
51
51
  (eliscript-ir-emitter--tdz-pattern-defaults (car (eliscript-ir-node-children node)) scope state)))
52
- (defun eliscript-ir-emitter--tdz-predeclare (nodes scope state)
53
- (let ((pending (list nodes)))
52
+ (defun eliscript-ir-emitter--tdz-statements (nodes)
53
+ "Return top-level statement NODES with module declarations flattened."
54
+ (let ((pending (list nodes)) statements)
54
55
  (while pending
55
56
  (let ((siblings (pop pending)))
56
57
  (when siblings
57
58
  (let ((node (car siblings)))
58
59
  (push (cdr siblings) pending)
59
- (pcase (eliscript-ir-node-kind node)
60
- ('module-declaration (push (eliscript-ir-node-children node) pending))
61
- ('variable-declaration
62
- (let ((record (list :index (length (plist-get state :variables)) :name (eliscript-ir-node-value node)
63
- :mutable (eliscript-ir-property node :mutable))))
64
- (setf (plist-get state :variables) (append (plist-get state :variables) (list record)))
65
- (puthash node record (plist-get state :declarations))
66
- (puthash (eliscript-emitter--binding-name (eliscript-ir-node-value node)) record (car scope))))
67
- ('function-declaration (puthash (eliscript-emitter--binding-name (eliscript-ir-node-value node)) nil (car scope)))
68
- ('import-declaration
69
- (dolist (child (eliscript-ir-node-children node))
70
- (puthash (eliscript-emitter--binding-name (eliscript-ir-node-value child)) nil (car scope)))))))))))
60
+ (if (eq (eliscript-ir-node-kind node) 'module-declaration)
61
+ (push (eliscript-ir-node-children node) pending)
62
+ (push node statements))))))
63
+ (nreverse statements)))
64
+
65
+ (defun eliscript-ir-emitter--tdz-predeclare (statements scope state)
66
+ (dolist (node statements)
67
+ (let ((name (eliscript-ir-node-value node)))
68
+ (pcase (eliscript-ir-node-kind node)
69
+ ('variable-declaration
70
+ (let ((record (eliscript-emitter--tdz-declare state name (eliscript-ir-property node :mutable))))
71
+ (puthash node record (plist-get state :declarations))
72
+ (puthash (eliscript-emitter--binding-name name) record (car scope))))
73
+ ('function-declaration
74
+ (let ((key (eliscript-emitter--binding-name name)))
75
+ (puthash key (eliscript-emitter--tdz-function state key) (car scope))
76
+ (when (eliscript-ir-property node :portable)
77
+ (push key (plist-get state :exported)))))
78
+ ('export-declaration
79
+ (dolist (reference (eliscript-ir-node-children node))
80
+ (push (eliscript-emitter--binding-name (eliscript-ir-node-value reference)) (plist-get state :exported))))
81
+ ('import-declaration
82
+ (setf (plist-get state :imports) t)
83
+ (dolist (child (eliscript-ir-node-children node))
84
+ (puthash (eliscript-emitter--binding-name (eliscript-ir-node-value child)) nil (car scope))))))
85
+ (setf (plist-get state :position) (1+ (plist-get state :position)))))
71
86
 
72
87
  (defun eliscript-ir-emitter--tdz-walk (node scope state &optional jobs)
73
88
  "Resolve TDZ references in source order with explicit scope actions."
@@ -91,8 +106,12 @@
91
106
  (pcase kind
92
107
  ((or 'reference 'assignment-pair)
93
108
  (let ((record (eliscript-ir-emitter--tdz-find current (eliscript-emitter--tdz-root (eliscript-ir-node-value item)))))
94
- (when record (puthash item record (plist-get state (if (eq kind 'reference) :reads :writes)))))
109
+ (cond ((eliscript-emitter--tdz-variable-p record)
110
+ (eliscript-emitter--tdz-site state (if (eq kind 'reference) :read :write) record item))
111
+ ((and record (eq kind 'reference))
112
+ (eliscript-emitter--tdz-reference state record))))
95
113
  (setq tasks (mapcar (lambda (child) (list :walk child current)) children)))
114
+ ('raw-javascript (eliscript-emitter--tdz-raw state))
96
115
  ((or 'function-declaration 'function-expression)
97
116
  (let* ((count (eliscript-ir-property item :parameter-count)) (parameters (seq-take children count))
98
117
  (child (eliscript-ir-emitter--tdz-scope current)))
@@ -117,20 +136,27 @@
117
136
  (let ((child (eliscript-ir-emitter--tdz-scope current)))
118
137
  (setq tasks (append (list (list :defaults (car children) current) (list :bind (car children) child))
119
138
  (mapcar (lambda (body) (list :walk body child)) (cdr children))))))
120
- ((or 'quoted-literal 'raw-javascript 'import-declaration) nil)
139
+ ((or 'quoted-literal 'import-declaration 'export-declaration) nil)
121
140
  (_ (setq tasks (mapcar (lambda (child) (list :walk child current)) children))))))
122
141
  (dolist (task (reverse tasks)) (push task pending))))))
123
142
 
124
143
  (defun eliscript-ir-emitter--tdz-prepare (program)
125
- (let ((state (list :variables nil :declarations (make-hash-table :test #'eq)
126
- :reads (make-hash-table :test #'eq) :writes (make-hash-table :test #'eq)))
127
- (scope (eliscript-ir-emitter--tdz-scope nil)))
128
- (eliscript-ir-emitter--tdz-predeclare (eliscript-ir-program-body program) scope state)
144
+ (let ((state (eliscript-emitter--tdz-state-create))
145
+ (scope (eliscript-ir-emitter--tdz-scope nil))
146
+ (statements (eliscript-ir-emitter--tdz-statements (eliscript-ir-program-body program))))
147
+ (eliscript-ir-emitter--tdz-predeclare statements scope state)
129
148
  ;; No lookup can resolve to a tracked module variable in this case. In
130
149
  ;; particular a function-only runtime needs no second walk of every body.
131
150
  (when (plist-get state :variables)
132
- (dolist (node (eliscript-ir-program-body program))
133
- (eliscript-ir-emitter--tdz-walk node scope state)))
151
+ (let ((position 0))
152
+ (dolist (node statements)
153
+ (setf (plist-get state :owner)
154
+ (if (eq (eliscript-ir-node-kind node) 'function-declaration)
155
+ (eliscript-emitter--binding-name (eliscript-ir-node-value node))
156
+ position))
157
+ (setq position (1+ position))
158
+ (eliscript-ir-emitter--tdz-walk node scope state)))
159
+ (eliscript-emitter--tdz-finalize state))
134
160
  state))
135
161
 
136
162
 
@@ -1732,7 +1758,8 @@ Only IR nodes are cached; list tails remain ordinary sibling continuations."
1732
1758
  (if children (eliscript-ir-emitter-emit-expression (car children)) "null"))
1733
1759
  (let ((record (and eliscript-ir-emitter--tdz-state
1734
1760
  (gethash node (plist-get eliscript-ir-emitter--tdz-state :declarations)))))
1735
- (when record (concat "\n" (eliscript-emitter--tdz-ready-name record) " = true;")))))
1761
+ (when (eliscript-emitter--tdz-guarded-p record)
1762
+ (concat "\n" (eliscript-emitter--tdz-ready-name record) " = true;")))))
1736
1763
  ('function-declaration
1737
1764
  (pcase-let ((`(,parameters ,body)
1738
1765
  (eliscript-ir-emitter--split-counted-children
@@ -1811,6 +1838,17 @@ JavaScript property or tag string rather than an Eliscript value."
1811
1838
  "Emit IR PROGRAM, retaining source marks when recording is active."
1812
1839
  (unless (eliscript-ir-program-p program)
1813
1840
  (eliscript-emitter--fail "expected an IR program: %S" program))
1841
+ (if (let ((body (eliscript-ir-program-body program)))
1842
+ (and (equal (length body) 1)
1843
+ (eq (eliscript-ir-node-kind (car body)) 'module-declaration)
1844
+ (null (eliscript-ir-node-children (car body)))
1845
+ (eliscript-emitter--prelude-capsule-p
1846
+ (eliscript-ir-program-filename program) (eliscript-ir-node-value (car body)))))
1847
+ eliscript-emitter--prelude-module
1848
+ (eliscript-ir-emitter--emit-ordinary-module program)))
1849
+
1850
+ (defun eliscript-ir-emitter--emit-ordinary-module (program)
1851
+ "Emit every IR PROGRAM except the shared helper module."
1814
1852
  (let ((eliscript-emitter--temporary-counter 0)
1815
1853
  (eliscript-ir-emitter--binding-temporaries nil)
1816
1854
  ;; IR is immutable during emission. Rechecking each synchronous if/let
@@ -1828,7 +1866,6 @@ JavaScript property or tag string rather than an Eliscript value."
1828
1866
  uses-imul
1829
1867
  uses-array-text
1830
1868
  uses-math-runtime
1831
- names-global-root
1832
1869
  portable-functions
1833
1870
  exported-bindings)
1834
1871
  (eliscript-ir-emitter--walk-program
@@ -1840,10 +1877,6 @@ JavaScript property or tag string rather than an Eliscript value."
1840
1877
  (when (and (eq (eliscript-ir-node-kind node) 'intrinsic)
1841
1878
  (eq (eliscript-ir-node-value node) 'imul32))
1842
1879
  (setq uses-imul t))
1843
- (when (and (eq (eliscript-ir-node-value node) 'globalThis)
1844
- (not (memq (eliscript-ir-node-kind node)
1845
- '(literal raw-javascript))))
1846
- (setq names-global-root t))
1847
1880
  (when (eq (eliscript-ir-node-kind node) 'map-binding-pattern)
1848
1881
  (setq uses-binding-runtime t))
1849
1882
  (when (or (and (eq (eliscript-ir-node-kind node) 'method-call)
@@ -1896,7 +1929,9 @@ JavaScript property or tag string rather than an Eliscript value."
1896
1929
  (eliscript-ir-program-filename program) (eliscript-ir-node-value (car body)))))
1897
1930
  "" eliscript-emitter--unicode-runtime-import)
1898
1931
  (if uses-math-runtime eliscript-emitter--math-runtime-import "")
1899
- (if uses-array-text eliscript-emitter--array-text-import "")
1932
+ (eliscript-emitter--prelude-import
1933
+ uses-array-text (or uses-number-conversion uses-numeric-coercion)
1934
+ uses-numeric-coercion uses-imul)
1900
1935
  (if uses-literal-runtime
1901
1936
  eliscript-ir-emitter--literal-runtime-import
1902
1937
  "")
@@ -1913,11 +1948,6 @@ JavaScript property or tag string rather than an Eliscript value."
1913
1948
  eliscript-ir-emitter--value-runtime-import
1914
1949
  "")
1915
1950
  "const __eliscript_truthy = (value) => value !== false && value != null;\n"
1916
- (if (or uses-number-conversion uses-numeric-coercion)
1917
- (eliscript-emitter--number-conversion-prologue names-global-root)
1918
- "")
1919
- (if uses-numeric-coercion eliscript-emitter--numeric-operator-helper "")
1920
- (if uses-imul (eliscript-emitter--imul-prologue names-global-root) "")
1921
1951
  (if uses-host-identity-token
1922
1952
  eliscript-emitter--host-identity-token-helper
1923
1953
  "")
@@ -555,11 +555,26 @@ FILENAME and SPAN identify the import responsible for PATH."
555
555
  (digest . ,(eliscript-project-macro-dependency-digest dependency))))
556
556
  dependencies)))
557
557
 
558
+ (defun eliscript-project--source-file-p (path)
559
+ "Return non-nil when PATH uses a `.eli' or `.el' source extension."
560
+ (and (stringp path)
561
+ (or (string-suffix-p ".eli" path)
562
+ (string-suffix-p ".el" path))))
563
+
564
+ (defun eliscript-project--strip-source-extension (path)
565
+ "Remove a trailing `.eli' or `.el' suffix from PATH."
566
+ (cond
567
+ ((string-suffix-p ".eli" path)
568
+ (string-remove-suffix ".eli" path))
569
+ ((string-suffix-p ".el" path)
570
+ (string-remove-suffix ".el" path))
571
+ (t path)))
572
+
558
573
  (defun eliscript-project--source-output (source root out-dir)
559
574
  "Map Eliscript SOURCE below ROOT into its ESM path below OUT-DIR."
560
575
  (let ((relative (file-relative-name source root)))
561
576
  (expand-file-name
562
- (concat (string-remove-suffix ".eli" relative) ".mjs")
577
+ (concat (eliscript-project--strip-source-extension relative) ".mjs")
563
578
  out-dir)))
564
579
 
565
580
  (defun eliscript-project--same-file-path-p (left right)
@@ -645,7 +660,7 @@ artifacts onto an input, another artifact, or outside OUT-DIR."
645
660
 
646
661
  (defun eliscript-project--local-import-p (specifier)
647
662
  "Return non-nil when SPECIFIER is a relative Eliscript source import."
648
- (and (string-suffix-p ".eli" specifier)
663
+ (and (eliscript-project--source-file-p specifier)
649
664
  (or (string-prefix-p "./" specifier)
650
665
  (string-prefix-p "../" specifier))))
651
666
 
@@ -1393,7 +1408,7 @@ unchanged."
1393
1408
  (car canonical-entries) nil
1394
1409
  "project entries resolve to duplicate sources"))
1395
1410
  (dolist (entry canonical-entries)
1396
- (unless (string-suffix-p ".eli" entry)
1411
+ (unless (eliscript-project--source-file-p entry)
1397
1412
  (eliscript-project--fail
1398
1413
  entry nil "entry file must use the .eli extension")))
1399
1414
  (when (file-exists-p resolved-out-dir)
@@ -1452,7 +1467,7 @@ unchanged."
1452
1467
  (setf (eliscript-ir-node-value node)
1453
1468
  (eliscript-project--relative-import
1454
1469
  dependency-output output-path))))
1455
- ((string-suffix-p ".eli" specifier)
1470
+ ((eliscript-project--source-file-p specifier)
1456
1471
  (eliscript-project--fail
1457
1472
  source (eliscript-ir-node-span node)
1458
1473
  "Eliscript source import must be relative: %s"
@@ -1555,7 +1570,7 @@ only the requested declarations, immutable constants, and portable imports."
1555
1570
  (requests (make-hash-table :test #'equal))
1556
1571
  queue
1557
1572
  modules)
1558
- (unless (string-suffix-p ".eli" canonical-entry)
1573
+ (unless (eliscript-project--source-file-p canonical-entry)
1559
1574
  (eliscript-project--fail
1560
1575
  canonical-entry nil "entry file must use the .eli extension"))
1561
1576
  (when (file-exists-p resolved-out-dir)
@@ -1,96 +1,7 @@
1
1
  // Generated by Eliscript. Do not edit.
2
2
  import "eliscript/runtime/unicode-case.mjs";
3
+ import { __eliscript_to_number, __eliscript_numeric_decrement, __eliscript_numeric_relation, __eliscript_numeric_sub, __eliscript_numeric_mul, __eliscript_numeric_div, __eliscript_numeric_rem, __eliscript_numeric_and, __eliscript_numeric_or, __eliscript_numeric_xor, __eliscript_numeric_shl, __eliscript_numeric_shr, __eliscript_numeric_ushr, __eliscript_numeric_neg, __eliscript_numeric_int32, __eliscript_numeric_uint32, __eliscript_numeric_not } from "eliscript/runtime/prelude.mjs";
3
4
  const __eliscript_truthy = (value) => value !== false && value != null;
4
- const __eliscript_number_intrinsic = globalThis.Number;
5
- const __eliscript_bigint_intrinsic = globalThis.BigInt;
6
- const __eliscript_numeric_apply = globalThis.Reflect.apply;
7
- const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
8
- const __eliscript_numeric_error = globalThis.TypeError;
9
- const __eliscript_numeric_trim = globalThis.String.prototype.trim;
10
- const __eliscript_numeric_slice = globalThis.String.prototype.slice;
11
- const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
12
- const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
13
- const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
14
- const __eliscript_numeric_primitive = (value) => {
15
- if (!__eliscript_numeric_object(value)) return value;
16
- const exotic = value[__eliscript_numeric_symbol];
17
- if (exotic !== void 0 && exotic !== null) {
18
- const result = __eliscript_numeric_apply(exotic, value, ["number"]);
19
- if (!__eliscript_numeric_object(result)) return result;
20
- throw new __eliscript_numeric_error("Cannot convert object to primitive value");
21
- }
22
- for (let index = 0; index < 2; index++) {
23
- const method = value[index === 0 ? "valueOf" : "toString"];
24
- if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
25
- const result = __eliscript_numeric_apply(method, value, []);
26
- if (!__eliscript_numeric_object(result)) return result;
27
- }
28
- }
29
- throw new __eliscript_numeric_error("Cannot convert object to primitive value");
30
- };
31
- const __eliscript_to_number = (value) => {
32
- const primitive = __eliscript_numeric_primitive(value);
33
- if (typeof primitive === "string") {
34
- const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
35
- if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
36
- let first = 2;
37
- while (first < text.length && text[first] === "0") first++;
38
- if (first === text.length) return 0;
39
- const prefix = text[1];
40
- const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
41
- if (text.length - first > limit) return 1 / 0;
42
- const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
43
- return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
44
- }
45
- }
46
- return __eliscript_number_intrinsic(primitive);
47
- };
48
- const __eliscript_numeric = (value) => {
49
- if (typeof value === "number" || typeof value === "bigint") return value;
50
- const primitive = __eliscript_numeric_primitive(value);
51
- if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
52
- return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
53
- };
54
- const __eliscript_implicit_number = (value) => {
55
- if (typeof value === "number") return value;
56
- const primitive = __eliscript_numeric_primitive(value);
57
- if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
58
- return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
59
- };
60
- const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
61
- const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
62
- const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
63
- const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
64
- const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
65
- const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
66
- const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
67
- const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
68
- const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
69
- const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
70
- const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
71
- const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
72
- const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
73
- const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
74
- const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
75
- const __eliscript_numeric_relation = (operator, left, right) => {
76
- if (typeof left === "number" && typeof right === "number") {
77
- if (operator === "<") return left < right;
78
- if (operator === "<=") return left <= right;
79
- if (operator === ">") return left > right;
80
- return left >= right;
81
- }
82
- let a = __eliscript_numeric_primitive(left);
83
- let b = __eliscript_numeric_primitive(right);
84
- const x = typeof a, y = typeof b;
85
- if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
86
- a = __eliscript_numeric(a);
87
- b = __eliscript_numeric(b);
88
- }
89
- if (operator === "<") return a < b;
90
- if (operator === "<=") return a <= b;
91
- if (operator === ">") return a > b;
92
- return a >= b;
93
- };
94
5
 
95
6
  import {binding_name} from "../bootstrap/symbol.mjs";
96
7
  function async_node(kind, value, children, properties = null) {
@@ -1 +1 @@
1
- {"version":3,"file":"backends/async.mjs","sources":["bootstrap/backends/async.eli"],"sourcesContent":["(module eliscript.backend.async\n (import \"../bootstrap/symbol.mjs\" binding-name)\n ;; This pass produces ordinary closures. Suspension is represented solely by\n ;; runtime reactions; tail records trampoline synchronous continuation calls.\n (defun async-node (kind value children &optional properties)\n (js-object :kind kind :value value :children children :properties properties :span nil))\n (defun async-intrinsic (name children) (async-node \"intrinsic\" name children))\n (defun async-reference (name) (async-node \"reference\" name (js-array)))\n (defun async-literal (value) (async-node \"literal\" value (js-array)))\n (defun async-fresh (state)\n (let ((name (str (get state :prefix) (get state :next))))\n (put state :next (1+ (get state :next))) name))\n (defun async-lambda (name body)\n (async-node \"function-expression\" nil\n (js-array (async-node \"parameter-binding\" name (js-array) (js-object :parameterKind \"required\")) body)\n (js-object :parameterCount 1 :async false)))\n (defun async-call (function value)\n (async-intrinsic \"managed-async-tail\" (js-array function value)))\n (defun async-bind (name value body)\n (async-node \"lexical-bindings\" nil\n (js-array (async-node \"lexical-binding\" name (js-array value)) body)\n (js-object :bindingCount 1 :sequential t)))\n (defun async-await-p (node)\n (let ((found false))\n (when node\n (if (= (get node :kind) \"await-expression\") (setq found t)\n (unless (or (= (get node :kind) \"function-expression\") (= (get node :kind) \"function-declaration\"))\n (js-call (get node :children) :forEach (lambda (child) (when (async-await-p child) (setq found t))))))) found))\n (defun async-guard (expression reject state)\n (let ((error (async-fresh state)))\n (async-node \"try-expression\" nil\n (js-array expression (async-node \"catch-clause\" nil\n (js-array (async-node \"catch-binding\" error (js-array)) (async-call reject (async-reference error)))))\n (js-object :bodyCount 1))))\n (defun async-copy (node children)\n (js-call globalThis.Object :assign (js-object) node (js-object :children children :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node))))\n (defun async-children (nodes index values done reject state)\n (if (= index (js-length nodes)) (done values)\n (let ((node (js-nth index nodes)))\n (if (or (= (get node :kind) \"object-property\") (= (get node :kind) \"assignment-pair\"))\n (async-children (get node :children) 0 (js-array)\n (lambda (parts)\n (let ((next (js-call values :slice)))\n (js-call next :push (async-copy node parts))\n (async-children nodes (1+ index) next done reject state))) reject state)\n (let ((name (async-fresh state)))\n (async-cps node\n (async-lambda name\n (let ((next (js-call values :slice)))\n (js-call next :push (async-reference name))\n (async-children nodes (1+ index) next done reject state))) reject state))))))\n (defun async-sequence (nodes index next reject state)\n (if (= index (js-length nodes)) (async-call next (async-literal nil))\n (if (= (1+ index) (js-length nodes)) (async-cps (js-nth index nodes) next reject state)\n (async-cps (js-nth index nodes)\n (async-lambda (async-fresh state) (async-sequence nodes (1+ index) next reject state)) reject state))))\n (defun async-short (node index next reject state)\n (let ((nodes (get node :children)) (operator (get node :value)))\n (if (= index (js-length nodes)) (async-call next (async-literal (= operator \"and\")))\n (if (= (1+ index) (js-length nodes)) (async-cps (js-nth index nodes) next reject state)\n (let ((name (async-fresh state)))\n (async-cps (js-nth index nodes)\n (async-lambda name\n (let ((tail (async-short node (1+ index) next reject state))\n (stop (async-call next (async-reference name))))\n (async-node \"conditional\" nil\n (if (= operator \"and\") (js-array (async-reference name) tail stop)\n (js-array (async-reference name) stop tail))))) reject state))))))\n (defun async-chain (clauses index next reject state)\n (if (= index (js-length clauses)) (async-call next (async-literal nil))\n (let* ((nodes (get (js-nth index clauses) :children)) (name (async-fresh state)))\n (async-cps (js-nth 0 nodes)\n (async-lambda name (async-node \"conditional\" nil\n (js-array (async-reference name)\n (if (= (js-length nodes) 1) (async-call next (async-reference name))\n (async-sequence (js-call nodes :slice 1) 0 next reject state))\n (async-chain clauses (1+ index) next reject state)))) reject state))))\n (defun async-bindings (node next reject state)\n (let* ((nodes (get node :children)) (count (get (get node :properties) :bindingCount))\n (sequential (get (get node :properties) :sequential)) (bindings (js-call nodes :slice 0 count))\n (body (js-call nodes :slice count)))\n (if sequential\n (async-bind-sequential bindings 0 body next reject state)\n (let ((initializers (js-call bindings :map (lambda (binding)\n (if (= (js-length (get binding :children)) 0) (async-literal nil) (js-nth 0 (get binding :children)))))))\n (async-children initializers 0 (js-array)\n (lambda (values)\n (let ((output (js-call bindings :map (lambda (binding index) (async-copy binding (js-array (js-nth index values)))))))\n (js-call output :push (async-sequence body 0 next reject state))\n (async-copy node output))) reject state)))))\n (defun async-bind-sequential (bindings index body next reject state)\n (if (= index (js-length bindings)) (async-sequence body 0 next reject state)\n (let* ((binding (js-nth index bindings)) (temporary (async-fresh state))\n (initializer (if (= (js-length (get binding :children)) 0) (async-literal nil) (js-nth 0 (get binding :children)))))\n (async-cps initializer\n (async-lambda temporary\n (async-node \"lexical-bindings\" nil\n (js-array (async-copy binding (js-array (async-reference temporary)))\n (async-bind-sequential bindings (1+ index) body next reject state))\n (js-object :bindingCount 1 :sequential t))) reject state))))\n (defun async-try (node next reject state)\n (let* ((nodes (get node :children)) (count (get (get node :properties) :bodyCount))\n (handler nil) (finalizer nil) (normal next) (abrupt reject))\n (js-call (js-call nodes :slice count) :forEach (lambda (clause)\n (if (= (get clause :kind) \"catch-clause\") (setq handler clause) (setq finalizer clause))))\n (when finalizer\n (let ((value (async-fresh state)) (error (async-fresh state)))\n (setq normal (async-lambda value\n (async-sequence (get finalizer :children) 0\n (async-lambda (async-fresh state) (async-call next (async-reference value))) reject state)))\n (setq abrupt (async-lambda error\n (async-sequence (get finalizer :children) 0\n (async-lambda (async-fresh state) (async-call reject (async-reference error))) reject state)))))\n (let ((catcher abrupt))\n (when handler\n (let ((error (async-fresh state)) (parts (get handler :children)))\n ;; Use the existing catch-binding lowering for TDZ, defaults,\n ;; destructuring and iterator closing rather than rebinding by hand.\n (setq catcher (async-lambda error\n (async-guard\n (async-node \"try-expression\" nil\n (js-array (async-node \"throw-expression\" nil (js-array (async-reference error)))\n (async-node \"catch-clause\" nil\n (js-array (js-nth 0 parts)\n (async-sequence (js-call parts :slice 1) 0 normal abrupt state))))\n (js-object :bodyCount 1)) abrupt state)))))\n (async-sequence (js-call nodes :slice 0 count) 0 normal catcher state))))\n (defun async-while (node next reject state)\n (let* ((loop-name (async-fresh state)) (test-name (async-fresh state)) (ignored (async-fresh state))\n (nodes (get node :children))\n (again (async-lambda ignored (async-call (async-reference loop-name) (async-literal nil))))\n (step (async-lambda ignored\n (async-cps (js-nth 0 nodes)\n (async-lambda test-name (async-node \"conditional\" nil\n (js-array (async-reference test-name)\n (async-sequence (js-call nodes :slice 1) 0 again reject state)\n (async-call next (async-literal nil))))) reject state))))\n (async-bind loop-name (async-literal nil)\n (async-node \"sequence\" nil\n (js-array (async-node \"assignment\" \"setq\"\n (js-array (async-node \"assignment-pair\" loop-name (js-array step))))\n (async-call (async-reference loop-name) (async-literal nil)))))))\n (defun async-assignment (node index next reject state)\n (let ((pairs (get node :children)))\n (if (= index (js-length pairs)) (async-call next (async-literal nil))\n (let* ((pair (js-nth index pairs)) (name (async-fresh state))\n (assignment (async-copy node (js-array (async-copy pair (js-array (async-reference name)))))))\n (async-cps (js-nth 0 (get pair :children))\n (async-lambda name\n (if (= (1+ index) (js-length pairs)) (async-guard (async-call next assignment) reject state)\n (async-guard (async-node \"sequence\" nil (js-array assignment (async-assignment node (1+ index) next reject state))) reject state))) reject state)))))\n (defun async-cps (node next reject state)\n (let ((kind (get node :kind)) (nodes (get node :children)))\n (cond\n ((not (async-await-p node)) (async-guard (async-call next (async-transform-node node state)) reject state))\n ((and (= kind \"intrinsic\") (= (get node :value) \"host-identity-token\"))\n (let ((capture (async-intrinsic \"managed-host-identity-capture\" (js-array))))\n (put capture :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node))\n (async-cps (async-intrinsic \"managed-host-identity-apply\" (js-array capture (js-nth 0 nodes))) next reject state)))\n ((= kind \"await-expression\")\n (let ((name (async-fresh state)))\n (async-cps (js-nth 0 nodes)\n (async-lambda name (async-guard (async-intrinsic \"managed-promise-await\"\n (js-array (async-reference name) next reject)) reject state)) reject state)))\n ((= kind \"sequence\") (async-sequence nodes 0 next reject state))\n ((= kind \"lexical-bindings\") (async-bindings node next reject state))\n ((= kind \"try-expression\") (async-try node next reject state))\n ((= kind \"throw-expression\") (async-cps (js-nth 0 nodes) reject reject state))\n ((= kind \"short-circuit\") (async-short node 0 next reject state))\n ((= kind \"conditional-chain\") (async-chain nodes 0 next reject state))\n ((= kind \"conditional-sugar\")\n (async-cps (async-node \"conditional\" nil\n (if (= (get node :value) \"unless\")\n (js-array (js-nth 0 nodes) (async-literal nil) (async-node \"sequence\" nil (js-call nodes :slice 1)))\n (js-array (js-nth 0 nodes) (async-node \"sequence\" nil (js-call nodes :slice 1)) (async-literal nil)))) next reject state))\n ((= kind \"conditional\")\n (let ((name (async-fresh state)))\n (async-cps (js-nth 0 nodes)\n (async-lambda name (async-node \"conditional\" nil\n (js-array (async-reference name) (async-cps (js-nth 1 nodes) next reject state)\n (async-cps (js-nth 2 nodes) next reject state)))) reject state)))\n ((and (= kind \"loop\") (= (get node :value) \"while\")) (async-while node next reject state))\n ((= kind \"assignment\") (async-assignment node 0 next reject state))\n ((= kind \"constructor-call\")\n (async-children (js-call nodes :slice 1) 0 (js-array)\n (lambda (arguments)\n (async-guard (async-call next (async-copy node\n (js-call (js-array (js-nth 0 nodes)) :concat arguments))) reject state)) reject state))\n ((= kind \"method-call\")\n (async-cps (async-node \"call\" nil\n (js-call (js-array (async-intrinsic \"managed-async-method-capture\" (js-call nodes :slice 0 2)))\n :concat (js-call nodes :slice 2))) next reject state))\n (t\n (async-children nodes 0 (js-array)\n (lambda (values) (async-guard (async-call next (async-copy node values)) reject state)) reject state)))))\n (defun async-function (node state)\n (let* ((properties (get node :properties)) (count (get properties :parameterCount))\n (nodes (get node :children)) (promise (async-fresh state)) (result (async-fresh state)) (error (async-fresh state))\n (accept (async-lambda result (async-intrinsic \"managed-promise-resolve\" (js-array (async-reference promise) (async-reference result)))))\n (reject (async-lambda error (async-intrinsic \"managed-promise-reject\" (js-array (async-reference promise) (async-reference error)))))\n (start (async-lambda (async-fresh state) (async-guard (async-sequence (js-call nodes :slice count) 0 accept reject state) reject state)))\n (body (async-bind promise (async-intrinsic \"managed-promise-new\" (js-array))\n (async-node \"sequence\" nil\n (js-array (async-guard (async-intrinsic \"managed-async-run\" (js-array start (async-literal nil))) reject state)\n (async-reference promise)))))\n (output (js-call nodes :slice 0 count)))\n (js-call output :push body)\n (js-call globalThis.Object :assign (js-object) node\n (js-object :children output :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node) :properties (js-call globalThis.Object :assign (js-object) properties (js-object :async false :managedAsync t))))))\n (defun async-transform-node (node state)\n (if (and (or (= (get node :kind) \"function-expression\") (= (get node :kind) \"function-declaration\"))\n (get (get node :properties) :async)) (async-function node state)\n (let* ((changed false)\n (children (js-call (get node :children) :map (lambda (child)\n (let ((copy (async-transform-node child state)))\n (unless (eq copy child) (setq changed t)) copy)))))\n (if changed (async-copy node children) node))))\n (defun lower-async-program (program)\n (let ((names (new globalThis.Set)) (pending (js-call (get program :body) :slice)) (prefix \"eliscript_async_\"))\n (while (> (js-length pending) 0)\n (let ((node (js-call pending :pop)))\n (when (= (value-type (get node :value)) \"string\")\n (let ((name (get node :value)))\n (js-call names :add (try (binding-name name) (catch error name)))))\n (js-call (get node :children) :forEach (lambda (child) (js-call pending :push child)))))\n (while (js-call (Array/from names) :some (lambda (name) (js-call name :startsWith prefix))) (setq prefix (str \"_\" prefix)))\n (let ((state (js-object :prefix prefix :next 0)))\n (js-call globalThis.Object :assign (js-object) program\n (js-object :body (js-call (get program :body) :map (lambda (node) (async-transform-node node state))))))))\n (export lower-async-program))\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACE,QAAkC;AAGlC,oBAAmB,MAAK,OAAM,UAAmB;EAC/C,OAAA,EAAW,QAAM,MAAK,SAAO,OAAM,YAAU,UAAS,cAAY,YAAW,QAAM;;AACrF,yBAAwB,MAAK;EAAU,OAAC,WAAW,aAAY,MAAK;;AACpE,yBAAwB;EAAM,OAAC,WAAW,aAAY,MAAK;;AAC3D,uBAAsB;EAAO,OAAC,WAAW,WAAU,OAAM;;AACzD,qBAAoB;EAClB;gCAAY,QAAK,CAAK,OAAM,oBAAS,CAAK,OAAM;;UAA1C;MACJ,EAAK,OAAM,UAAM,CAAI,CAAK,OAAM;MAAS,OAAA;;;;AAC7C,sBAAqB,MAAK;EACxB,OAAC,WAAW,uBAAsB,MAChC,CAAW,WAAW,qBAAoB,MAAK,IAAW,EAAW,iBAAe,eAAa,OACjG,EAAW,kBAAgB,GAAE,SAAO;;AACxC,oBAAmB,WAAS;EAC1B,OAAC,gBAAgB,sBAAqB,CAAU,WAAS;;AAC3D,oBAAmB,MAAK,OAAM;EAC5B,OAAC,WAAW,oBAAmB,MAC7B,CAAW,WAAW,mBAAkB,MAAK,CAAU,SAAQ,OAC/D,EAAW,gBAAc,GAAE,cAAY;;AAC3C,uBAAsB;EACpB;gCAAa;;UAAP;MACJ,uBAAM;QACJ,IAAI,CAAG,CAAK,MAAK,YAAO;UAAoB,CAAM,CAAA,QAAM;;UACtD,MAAQ,CAAI,CAAG,CAAK,MAAK,YAAO,0BAAuB,CAAG,CAAK,MAAK,YAAO;YACzE,CAAS,CAAK,MAAK,aAAW,WAA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QACrD;uCAAa,qBAAqB,OAAM;;gBAAlC;YACJ,MAAQ,CAAI,SAAK;cAAO,CAAM,CAAA,UAAQ;;YAAI,OAAA;;;;MAClD,uBAAI;QAAQ,OAAC,WAAW,MAAK;;QAAU,OAAA;;;;;AAC7C,6BAA4B;EAC1B;iCAAa,KAAK;iCAA0B,CAAS,CAAK,SAAQ,SAAO;iCAAiB;;UAApF;UAA6B;UAA+C;MAChF,OAAO,kCAAG,EAAW,wBAAS;QAC5B;uCAAY,CAAS,SAAQ;;gBAAvB;YACJ,IAAM,CAAG,s7BAAY,CAAK,MAAK,cAAS;cACtC;6CAAY,CAAK,MAAK;;sBAAhB;kBACJ,CAAS,OAAM,OAAK;;sBAAK,OAAC,aAAa;qBAAM,QAAO;sBAAM,OAAA;;;;;;YAC9D,CAAS,CAAK,MAAK,aAAW,WAAS,EAAS;cAAO,OAAA,CAAS,SAAQ,QAAM;;;;;MAClF,0BAAO,CAAU,WAAW,QAAO,QAAM,EAAS;QAAM,OAAA,CAAS,MAAK,cAAY;;QAAU,CAAM,CAAA,SAAO,QAAK,cAAI;;MAClH;qCAAa,EAAW,UAAQ,QAAO,QAAM;;cAAvC;UACJ,OAAA,CAAS,mBAAkB,UAAQ,MAAY,SAC7C,EAAW,QAAM,CAAS,CAAK,SAAQ,SAAO,OAAK,EAAS;YAAM,OAAC,qBAAqB,MAAK;;;;;;;AACrG,QAAQ"}
1
+ {"version":3,"file":"backends/async.mjs","sources":["bootstrap/backends/async.eli"],"sourcesContent":["(module eliscript.backend.async\n (import \"../bootstrap/symbol.mjs\" binding-name)\n ;; This pass produces ordinary closures. Suspension is represented solely by\n ;; runtime reactions; tail records trampoline synchronous continuation calls.\n (defun async-node (kind value children &optional properties)\n (js-object :kind kind :value value :children children :properties properties :span nil))\n (defun async-intrinsic (name children) (async-node \"intrinsic\" name children))\n (defun async-reference (name) (async-node \"reference\" name (js-array)))\n (defun async-literal (value) (async-node \"literal\" value (js-array)))\n (defun async-fresh (state)\n (let ((name (str (get state :prefix) (get state :next))))\n (put state :next (1+ (get state :next))) name))\n (defun async-lambda (name body)\n (async-node \"function-expression\" nil\n (js-array (async-node \"parameter-binding\" name (js-array) (js-object :parameterKind \"required\")) body)\n (js-object :parameterCount 1 :async false)))\n (defun async-call (function value)\n (async-intrinsic \"managed-async-tail\" (js-array function value)))\n (defun async-bind (name value body)\n (async-node \"lexical-bindings\" nil\n (js-array (async-node \"lexical-binding\" name (js-array value)) body)\n (js-object :bindingCount 1 :sequential t)))\n (defun async-await-p (node)\n (let ((found false))\n (when node\n (if (= (get node :kind) \"await-expression\") (setq found t)\n (unless (or (= (get node :kind) \"function-expression\") (= (get node :kind) \"function-declaration\"))\n (js-call (get node :children) :forEach (lambda (child) (when (async-await-p child) (setq found t))))))) found))\n (defun async-guard (expression reject state)\n (let ((error (async-fresh state)))\n (async-node \"try-expression\" nil\n (js-array expression (async-node \"catch-clause\" nil\n (js-array (async-node \"catch-binding\" error (js-array)) (async-call reject (async-reference error)))))\n (js-object :bodyCount 1))))\n (defun async-copy (node children)\n (js-call globalThis.Object :assign (js-object) node (js-object :children children :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node))))\n (defun async-children (nodes index values done reject state)\n (if (= index (js-length nodes)) (done values)\n (let ((node (js-nth index nodes)))\n (if (or (= (get node :kind) \"object-property\") (= (get node :kind) \"assignment-pair\"))\n (async-children (get node :children) 0 (js-array)\n (lambda (parts)\n (let ((next (js-call values :slice)))\n (js-call next :push (async-copy node parts))\n (async-children nodes (1+ index) next done reject state))) reject state)\n (let ((name (async-fresh state)))\n (async-cps node\n (async-lambda name\n (let ((next (js-call values :slice)))\n (js-call next :push (async-reference name))\n (async-children nodes (1+ index) next done reject state))) reject state))))))\n (defun async-sequence (nodes index next reject state)\n (if (= index (js-length nodes)) (async-call next (async-literal nil))\n (if (= (1+ index) (js-length nodes)) (async-cps (js-nth index nodes) next reject state)\n (async-cps (js-nth index nodes)\n (async-lambda (async-fresh state) (async-sequence nodes (1+ index) next reject state)) reject state))))\n (defun async-short (node index next reject state)\n (let ((nodes (get node :children)) (operator (get node :value)))\n (if (= index (js-length nodes)) (async-call next (async-literal (= operator \"and\")))\n (if (= (1+ index) (js-length nodes)) (async-cps (js-nth index nodes) next reject state)\n (let ((name (async-fresh state)))\n (async-cps (js-nth index nodes)\n (async-lambda name\n (let ((tail (async-short node (1+ index) next reject state))\n (stop (async-call next (async-reference name))))\n (async-node \"conditional\" nil\n (if (= operator \"and\") (js-array (async-reference name) tail stop)\n (js-array (async-reference name) stop tail))))) reject state))))))\n (defun async-chain (clauses index next reject state)\n (if (= index (js-length clauses)) (async-call next (async-literal nil))\n (let* ((nodes (get (js-nth index clauses) :children)) (name (async-fresh state)))\n (async-cps (js-nth 0 nodes)\n (async-lambda name (async-node \"conditional\" nil\n (js-array (async-reference name)\n (if (= (js-length nodes) 1) (async-call next (async-reference name))\n (async-sequence (js-call nodes :slice 1) 0 next reject state))\n (async-chain clauses (1+ index) next reject state)))) reject state))))\n (defun async-bindings (node next reject state)\n (let* ((nodes (get node :children)) (count (get (get node :properties) :bindingCount))\n (sequential (get (get node :properties) :sequential)) (bindings (js-call nodes :slice 0 count))\n (body (js-call nodes :slice count)))\n (if sequential\n (async-bind-sequential bindings 0 body next reject state)\n (let ((initializers (js-call bindings :map (lambda (binding)\n (if (= (js-length (get binding :children)) 0) (async-literal nil) (js-nth 0 (get binding :children)))))))\n (async-children initializers 0 (js-array)\n (lambda (values)\n (let ((output (js-call bindings :map (lambda (binding index) (async-copy binding (js-array (js-nth index values)))))))\n (js-call output :push (async-sequence body 0 next reject state))\n (async-copy node output))) reject state)))))\n (defun async-bind-sequential (bindings index body next reject state)\n (if (= index (js-length bindings)) (async-sequence body 0 next reject state)\n (let* ((binding (js-nth index bindings)) (temporary (async-fresh state))\n (initializer (if (= (js-length (get binding :children)) 0) (async-literal nil) (js-nth 0 (get binding :children)))))\n (async-cps initializer\n (async-lambda temporary\n (async-node \"lexical-bindings\" nil\n (js-array (async-copy binding (js-array (async-reference temporary)))\n (async-bind-sequential bindings (1+ index) body next reject state))\n (js-object :bindingCount 1 :sequential t))) reject state))))\n (defun async-try (node next reject state)\n (let* ((nodes (get node :children)) (count (get (get node :properties) :bodyCount))\n (handler nil) (finalizer nil) (normal next) (abrupt reject))\n (js-call (js-call nodes :slice count) :forEach (lambda (clause)\n (if (= (get clause :kind) \"catch-clause\") (setq handler clause) (setq finalizer clause))))\n (when finalizer\n (let ((value (async-fresh state)) (error (async-fresh state)))\n (setq normal (async-lambda value\n (async-sequence (get finalizer :children) 0\n (async-lambda (async-fresh state) (async-call next (async-reference value))) reject state)))\n (setq abrupt (async-lambda error\n (async-sequence (get finalizer :children) 0\n (async-lambda (async-fresh state) (async-call reject (async-reference error))) reject state)))))\n (let ((catcher abrupt))\n (when handler\n (let ((error (async-fresh state)) (parts (get handler :children)))\n ;; Use the existing catch-binding lowering for TDZ, defaults,\n ;; destructuring and iterator closing rather than rebinding by hand.\n (setq catcher (async-lambda error\n (async-guard\n (async-node \"try-expression\" nil\n (js-array (async-node \"throw-expression\" nil (js-array (async-reference error)))\n (async-node \"catch-clause\" nil\n (js-array (js-nth 0 parts)\n (async-sequence (js-call parts :slice 1) 0 normal abrupt state))))\n (js-object :bodyCount 1)) abrupt state)))))\n (async-sequence (js-call nodes :slice 0 count) 0 normal catcher state))))\n (defun async-while (node next reject state)\n (let* ((loop-name (async-fresh state)) (test-name (async-fresh state)) (ignored (async-fresh state))\n (nodes (get node :children))\n (again (async-lambda ignored (async-call (async-reference loop-name) (async-literal nil))))\n (step (async-lambda ignored\n (async-cps (js-nth 0 nodes)\n (async-lambda test-name (async-node \"conditional\" nil\n (js-array (async-reference test-name)\n (async-sequence (js-call nodes :slice 1) 0 again reject state)\n (async-call next (async-literal nil))))) reject state))))\n (async-bind loop-name (async-literal nil)\n (async-node \"sequence\" nil\n (js-array (async-node \"assignment\" \"setq\"\n (js-array (async-node \"assignment-pair\" loop-name (js-array step))))\n (async-call (async-reference loop-name) (async-literal nil)))))))\n (defun async-assignment (node index next reject state)\n (let ((pairs (get node :children)))\n (if (= index (js-length pairs)) (async-call next (async-literal nil))\n (let* ((pair (js-nth index pairs)) (name (async-fresh state))\n (assignment (async-copy node (js-array (async-copy pair (js-array (async-reference name)))))))\n (async-cps (js-nth 0 (get pair :children))\n (async-lambda name\n (if (= (1+ index) (js-length pairs)) (async-guard (async-call next assignment) reject state)\n (async-guard (async-node \"sequence\" nil (js-array assignment (async-assignment node (1+ index) next reject state))) reject state))) reject state)))))\n (defun async-cps (node next reject state)\n (let ((kind (get node :kind)) (nodes (get node :children)))\n (cond\n ((not (async-await-p node)) (async-guard (async-call next (async-transform-node node state)) reject state))\n ((and (= kind \"intrinsic\") (= (get node :value) \"host-identity-token\"))\n (let ((capture (async-intrinsic \"managed-host-identity-capture\" (js-array))))\n (put capture :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node))\n (async-cps (async-intrinsic \"managed-host-identity-apply\" (js-array capture (js-nth 0 nodes))) next reject state)))\n ((= kind \"await-expression\")\n (let ((name (async-fresh state)))\n (async-cps (js-nth 0 nodes)\n (async-lambda name (async-guard (async-intrinsic \"managed-promise-await\"\n (js-array (async-reference name) next reject)) reject state)) reject state)))\n ((= kind \"sequence\") (async-sequence nodes 0 next reject state))\n ((= kind \"lexical-bindings\") (async-bindings node next reject state))\n ((= kind \"try-expression\") (async-try node next reject state))\n ((= kind \"throw-expression\") (async-cps (js-nth 0 nodes) reject reject state))\n ((= kind \"short-circuit\") (async-short node 0 next reject state))\n ((= kind \"conditional-chain\") (async-chain nodes 0 next reject state))\n ((= kind \"conditional-sugar\")\n (async-cps (async-node \"conditional\" nil\n (if (= (get node :value) \"unless\")\n (js-array (js-nth 0 nodes) (async-literal nil) (async-node \"sequence\" nil (js-call nodes :slice 1)))\n (js-array (js-nth 0 nodes) (async-node \"sequence\" nil (js-call nodes :slice 1)) (async-literal nil)))) next reject state))\n ((= kind \"conditional\")\n (let ((name (async-fresh state)))\n (async-cps (js-nth 0 nodes)\n (async-lambda name (async-node \"conditional\" nil\n (js-array (async-reference name) (async-cps (js-nth 1 nodes) next reject state)\n (async-cps (js-nth 2 nodes) next reject state)))) reject state)))\n ((and (= kind \"loop\") (= (get node :value) \"while\")) (async-while node next reject state))\n ((= kind \"assignment\") (async-assignment node 0 next reject state))\n ((= kind \"constructor-call\")\n (async-children (js-call nodes :slice 1) 0 (js-array)\n (lambda (arguments)\n (async-guard (async-call next (async-copy node\n (js-call (js-array (js-nth 0 nodes)) :concat arguments))) reject state)) reject state))\n ((= kind \"method-call\")\n (async-cps (async-node \"call\" nil\n (js-call (js-array (async-intrinsic \"managed-async-method-capture\" (js-call nodes :slice 0 2)))\n :concat (js-call nodes :slice 2))) next reject state))\n (t\n (async-children nodes 0 (js-array)\n (lambda (values) (async-guard (async-call next (async-copy node values)) reject state)) reject state)))))\n (defun async-function (node state)\n (let* ((properties (get node :properties)) (count (get properties :parameterCount))\n (nodes (get node :children)) (promise (async-fresh state)) (result (async-fresh state)) (error (async-fresh state))\n (accept (async-lambda result (async-intrinsic \"managed-promise-resolve\" (js-array (async-reference promise) (async-reference result)))))\n (reject (async-lambda error (async-intrinsic \"managed-promise-reject\" (js-array (async-reference promise) (async-reference error)))))\n (start (async-lambda (async-fresh state) (async-guard (async-sequence (js-call nodes :slice count) 0 accept reject state) reject state)))\n (body (async-bind promise (async-intrinsic \"managed-promise-new\" (js-array))\n (async-node \"sequence\" nil\n (js-array (async-guard (async-intrinsic \"managed-async-run\" (js-array start (async-literal nil))) reject state)\n (async-reference promise)))))\n (output (js-call nodes :slice 0 count)))\n (js-call output :push body)\n (js-call globalThis.Object :assign (js-object) node\n (js-object :children output :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node) :properties (js-call globalThis.Object :assign (js-object) properties (js-object :async false :managedAsync t))))))\n (defun async-transform-node (node state)\n (if (and (or (= (get node :kind) \"function-expression\") (= (get node :kind) \"function-declaration\"))\n (get (get node :properties) :async)) (async-function node state)\n (let* ((changed false)\n (children (js-call (get node :children) :map (lambda (child)\n (let ((copy (async-transform-node child state)))\n (unless (eq copy child) (setq changed t)) copy)))))\n (if changed (async-copy node children) node))))\n (defun lower-async-program (program)\n (let ((names (new globalThis.Set)) (pending (js-call (get program :body) :slice)) (prefix \"eliscript_async_\"))\n (while (> (js-length pending) 0)\n (let ((node (js-call pending :pop)))\n (when (= (value-type (get node :value)) \"string\")\n (let ((name (get node :value)))\n (js-call names :add (try (binding-name name) (catch error name)))))\n (js-call (get node :children) :forEach (lambda (child) (js-call pending :push child)))))\n (while (js-call (Array/from names) :some (lambda (name) (js-call name :startsWith prefix))) (setq prefix (str \"_\" prefix)))\n (let ((state (js-object :prefix prefix :next 0)))\n (js-call globalThis.Object :assign (js-object) program\n (js-object :body (js-call (get program :body) :map (lambda (node) (async-transform-node node state))))))))\n (export lower-async-program))\n"],"names":[],"mappings":";;;;;AACE,QAAkC;AAGlC,oBAAmB,MAAK,OAAM,UAAmB;EAC/C,OAAA,EAAW,QAAM,MAAK,SAAO,OAAM,YAAU,UAAS,cAAY,YAAW,QAAM;;AACrF,yBAAwB,MAAK;EAAU,OAAC,WAAW,aAAY,MAAK;;AACpE,yBAAwB;EAAM,OAAC,WAAW,aAAY,MAAK;;AAC3D,uBAAsB;EAAO,OAAC,WAAW,WAAU,OAAM;;AACzD,qBAAoB;EAClB;gCAAY,QAAK,CAAK,OAAM,oBAAS,CAAK,OAAM;;UAA1C;MACJ,EAAK,OAAM,UAAM,CAAI,CAAK,OAAM;MAAS,OAAA;;;;AAC7C,sBAAqB,MAAK;EACxB,OAAC,WAAW,uBAAsB,MAChC,CAAW,WAAW,qBAAoB,MAAK,IAAW,EAAW,iBAAe,eAAa,OACjG,EAAW,kBAAgB,GAAE,SAAO;;AACxC,oBAAmB,WAAS;EAC1B,OAAC,gBAAgB,sBAAqB,CAAU,WAAS;;AAC3D,oBAAmB,MAAK,OAAM;EAC5B,OAAC,WAAW,oBAAmB,MAC7B,CAAW,WAAW,mBAAk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
  import "eliscript/runtime/math.mjs";
4
- import { c as __eliscript_at, d as __eliscript_at_direct } from "data:text/javascript;base64,dmFyIG09UmVmbGVjdC5hcHBseSx0dD1OdW1iZXIucHJvdG90eXBlLnZhbHVlT2Ysaj1OdW1iZXIucHJvdG90eXBlLnRvU3RyaW5nLFU9TnVtYmVyLG50PU9iamVjdC5jcmVhdGUsaD1CaWdJbnQsZXQ9RGF0YVZpZXcsb3Q9QXJyYXlCdWZmZXIsaXQ9RGF0YVZpZXcucHJvdG90eXBlLnNldEZsb2F0NjQsSj1EYXRhVmlldy5wcm90b3R5cGUuZ2V0VWludDMyLHJ0PVJhbmdlRXJyb3I7ZnVuY3Rpb24gY3QodCxuKXtsZXQgZT1oKG4pLG89aCh0KSxpPSIiO2lmKG88MG4pbz0tbztkb3tsZXQgZj1vJWU7aT0iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltVKGYpXStpLG8vPWV9d2hpbGUobyE9PTBuKTtyZXR1cm4gdDwwPyItIitpOml9ZnVuY3Rpb24gc3QodCxuKXtsZXQgZT1uZXcgZXQobmV3IG90KDgpKTttKGl0LGUsWzAsdCwhMV0pO2xldCBvPW0oSixlLFswLCExXSksaT1tKEosZSxbNCwhMV0pLGY9bz4+PjIwJjIwNDcsYj1vJjEwNDg1NzUscD1vPj4+MzEscj1oKGIpPDwzMm58aChpKTtpZihmIT09MClyKz0xbjw8NTJuO3I8PD0ybjtsZXQgbD00bix1PWY+MSYmYj09PTAmJmk9PT0wPzFuOjJuLGs9Mm47aWYoZj49MTA3NSl7bGV0IGM9aChmLTEwNzUpO3I8PD1jLHU8PD1jLGs8PD1jfWVsc2UgbDw8PWgoZj09PTA/MTA3NDoxMDc1LWYpO2xldCBkPWgobiksZz1udChudWxsKSxhPTAsUz0wLEQ9MDtpZihyPGwpd2hpbGUocjxsKXtpZihyKjJuPmwmJnIraz5sKWJyZWFrO3IqPWQsdSo9ZCxrKj1kLFMtLX1lbHNlIH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PWk7Y29udGludWV9aWYodD09PXMpe2xldCBvPXkoZSwwKSxpPXkoZSwxKTtpZighQShvKSlyZXR1cm4gcyh0LG4sZSk7ZT1aKHkoZSwyKSwhMSksdD1vLG49aTtjb250aW51ZX1pZih0PT09RSl7bGV0IG89cyh0LG4sZSk7aWYobiE9PWomJm4hPT1LJiZuIT09eiYmbiE9PU0mJm4hPT1OJiZuIT09cyYmbiE9PUUpcmV0dXJuIG87bGV0IGk9bixmPXkoZSwwKSxiPVgoZSwxKSxwPSguLi51KT0+TChpLGYsU3QoYix1KSk7VChwLHB0LHt2YWx1ZToodSk9PnUgaW5zdGFuY2VvZiBpLGNvbmZpZ3VyYWJsZTohMH0pO2xldCByPXMoRSxwLFt2b2lkIDBdKTt1dChyLGZ0KG8pKTtsZXQgbD1hdChvKTtmb3IobGV0IHU9MDt1PGwubGVuZ3RoO3UrKylUKHIsbFt1XSxsdChvLGxbdV0pKTtyZXR1cm4gcn1yZXR1cm4gcyh0LG4sZSl9fWZ1bmN0aW9uIFJ0KHQsbil7bGV0IGU9dFtuXTtyZXR1cm4oLi4ubyk9PkwoZSx0LG8pfWZ1bmN0aW9uIEF0KHQsbiwuLi5lKXtsZXQgbz10W25dO3JldHVybiBMKG8sdCxlKX1leHBvcnR7UnQgYXMgYyxBdCBhcyBkfTs=";
4
+ import { __eliscript_at, __eliscript_at_direct, __eliscript_to_number, __eliscript_numeric_decrement, __eliscript_numeric_relation, __eliscript_numeric_sub, __eliscript_numeric_mul, __eliscript_numeric_div, __eliscript_numeric_rem, __eliscript_numeric_and, __eliscript_numeric_or, __eliscript_numeric_xor, __eliscript_numeric_shl, __eliscript_numeric_shr, __eliscript_numeric_ushr, __eliscript_numeric_neg, __eliscript_numeric_int32, __eliscript_numeric_uint32, __eliscript_numeric_not } from "eliscript/runtime/prelude.mjs";
5
5
  const __eliscript_truthy = (value) => value !== false && value != null;
6
- const __eliscript_number_intrinsic = globalThis.Number;
7
- const __eliscript_bigint_intrinsic = globalThis.BigInt;
8
- const __eliscript_numeric_apply = globalThis.Reflect.apply;
9
- const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
10
- const __eliscript_numeric_error = globalThis.TypeError;
11
- const __eliscript_numeric_trim = globalThis.String.prototype.trim;
12
- const __eliscript_numeric_slice = globalThis.String.prototype.slice;
13
- const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
14
- const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
15
- const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
16
- const __eliscript_numeric_primitive = (value) => {
17
- if (!__eliscript_numeric_object(value)) return value;
18
- const exotic = value[__eliscript_numeric_symbol];
19
- if (exotic !== void 0 && exotic !== null) {
20
- const result = __eliscript_numeric_apply(exotic, value, ["number"]);
21
- if (!__eliscript_numeric_object(result)) return result;
22
- throw new __eliscript_numeric_error("Cannot convert object to primitive value");
23
- }
24
- for (let index = 0; index < 2; index++) {
25
- const method = value[index === 0 ? "valueOf" : "toString"];
26
- if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
27
- const result = __eliscript_numeric_apply(method, value, []);
28
- if (!__eliscript_numeric_object(result)) return result;
29
- }
30
- }
31
- throw new __eliscript_numeric_error("Cannot convert object to primitive value");
32
- };
33
- const __eliscript_to_number = (value) => {
34
- const primitive = __eliscript_numeric_primitive(value);
35
- if (typeof primitive === "string") {
36
- const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
37
- if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
38
- let first = 2;
39
- while (first < text.length && text[first] === "0") first++;
40
- if (first === text.length) return 0;
41
- const prefix = text[1];
42
- const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
43
- if (text.length - first > limit) return 1 / 0;
44
- const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
45
- return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
46
- }
47
- }
48
- return __eliscript_number_intrinsic(primitive);
49
- };
50
- const __eliscript_numeric = (value) => {
51
- if (typeof value === "number" || typeof value === "bigint") return value;
52
- const primitive = __eliscript_numeric_primitive(value);
53
- if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
54
- return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
55
- };
56
- const __eliscript_implicit_number = (value) => {
57
- if (typeof value === "number") return value;
58
- const primitive = __eliscript_numeric_primitive(value);
59
- if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
60
- return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
61
- };
62
- const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
63
- const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
64
- const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
65
- const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
66
- const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
67
- const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
68
- const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
69
- const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
70
- const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
71
- const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
72
- const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
73
- const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
74
- const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
75
- const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
76
- const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
77
- const __eliscript_numeric_relation = (operator, left, right) => {
78
- if (typeof left === "number" && typeof right === "number") {
79
- if (operator === "<") return left < right;
80
- if (operator === "<=") return left <= right;
81
- if (operator === ">") return left > right;
82
- return left >= right;
83
- }
84
- let a = __eliscript_numeric_primitive(left);
85
- let b = __eliscript_numeric_primitive(right);
86
- const x = typeof a, y = typeof b;
87
- if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
88
- a = __eliscript_numeric(a);
89
- b = __eliscript_numeric(b);
90
- }
91
- if (operator === "<") return a < b;
92
- if (operator === "<=") return a <= b;
93
- if (operator === ">") return a > b;
94
- return a >= b;
95
- };
96
6
 
97
7
  import {backend_fail} from "./numeric.mjs";
98
8
  function binary_output(options = null) {