@scriptc/compiler 0.0.0 → 0.0.2

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 (206) hide show
  1. package/LICENSE +202 -0
  2. package/ambient/package.json +3 -0
  3. package/ambient/scriptc-node-fallback.d.ts +3001 -0
  4. package/ambient/scriptc-overrides.d.ts +95 -0
  5. package/ambient/scriptc.d.ts +74 -0
  6. package/dist/backend/cc.d.ts +169 -0
  7. package/dist/backend/cc.js +897 -0
  8. package/dist/backend/cc.js.map +1 -0
  9. package/dist/backend/emission/emit-async.d.ts +145 -0
  10. package/dist/backend/emission/emit-async.js +996 -0
  11. package/dist/backend/emission/emit-async.js.map +1 -0
  12. package/dist/backend/emission/emit-exprs.d.ts +3 -0
  13. package/dist/backend/emission/emit-exprs.js +5949 -0
  14. package/dist/backend/emission/emit-exprs.js.map +1 -0
  15. package/dist/backend/emission/emit-island.d.ts +45 -0
  16. package/dist/backend/emission/emit-island.js +271 -0
  17. package/dist/backend/emission/emit-island.js.map +1 -0
  18. package/dist/backend/emission/emit-shapes.d.ts +142 -0
  19. package/dist/backend/emission/emit-shapes.js +575 -0
  20. package/dist/backend/emission/emit-shapes.js.map +1 -0
  21. package/dist/backend/emission/emit-stmts.d.ts +78 -0
  22. package/dist/backend/emission/emit-stmts.js +960 -0
  23. package/dist/backend/emission/emit-stmts.js.map +1 -0
  24. package/dist/backend/emission/emit-types.d.ts +65 -0
  25. package/dist/backend/emission/emit-types.js +652 -0
  26. package/dist/backend/emission/emit-types.js.map +1 -0
  27. package/dist/backend/emission/emit-walkers.d.ts +154 -0
  28. package/dist/backend/emission/emit-walkers.js +1587 -0
  29. package/dist/backend/emission/emit-walkers.js.map +1 -0
  30. package/dist/backend/emission/emitter.d.ts +452 -0
  31. package/dist/backend/emission/emitter.js +1249 -0
  32. package/dist/backend/emission/emitter.js.map +1 -0
  33. package/dist/backend/emission/may-throw.d.ts +15 -0
  34. package/dist/backend/emission/may-throw.js +250 -0
  35. package/dist/backend/emission/may-throw.js.map +1 -0
  36. package/dist/backend/llvm/blocks.d.ts +21 -0
  37. package/dist/backend/llvm/blocks.js +68 -0
  38. package/dist/backend/llvm/blocks.js.map +1 -0
  39. package/dist/backend/llvm/classes.d.ts +84 -0
  40. package/dist/backend/llvm/classes.js +438 -0
  41. package/dist/backend/llvm/classes.js.map +1 -0
  42. package/dist/backend/llvm/dyn.d.ts +123 -0
  43. package/dist/backend/llvm/dyn.js +2624 -0
  44. package/dist/backend/llvm/dyn.js.map +1 -0
  45. package/dist/backend/llvm/emitter.d.ts +3 -0
  46. package/dist/backend/llvm/emitter.js +10102 -0
  47. package/dist/backend/llvm/emitter.js.map +1 -0
  48. package/dist/backend/llvm/shapes.d.ts +78 -0
  49. package/dist/backend/llvm/shapes.js +754 -0
  50. package/dist/backend/llvm/shapes.js.map +1 -0
  51. package/dist/backend/llvm/unsupported.d.ts +6 -0
  52. package/dist/backend/llvm/unsupported.js +12 -0
  53. package/dist/backend/llvm/unsupported.js.map +1 -0
  54. package/dist/backend/llvm/walkers.d.ts +58 -0
  55. package/dist/backend/llvm/walkers.js +793 -0
  56. package/dist/backend/llvm/walkers.js.map +1 -0
  57. package/dist/backend/mangle.d.ts +124 -0
  58. package/dist/backend/mangle.js +232 -0
  59. package/dist/backend/mangle.js.map +1 -0
  60. package/dist/coverage/report.d.ts +65 -0
  61. package/dist/coverage/report.js +238 -0
  62. package/dist/coverage/report.js.map +1 -0
  63. package/dist/diagnostics/diagnostic.d.ts +140 -0
  64. package/dist/diagnostics/diagnostic.js +458 -0
  65. package/dist/diagnostics/diagnostic.js.map +1 -0
  66. package/dist/diagnostics/render.d.ts +11 -0
  67. package/dist/diagnostics/render.js +58 -0
  68. package/dist/diagnostics/render.js.map +1 -0
  69. package/dist/frontend/cjs-lexer.d.ts +20 -0
  70. package/dist/frontend/cjs-lexer.js +813 -0
  71. package/dist/frontend/cjs-lexer.js.map +1 -0
  72. package/dist/frontend/lowering/http2-constants.d.ts +1 -0
  73. package/dist/frontend/lowering/http2-constants.js +251 -0
  74. package/dist/frontend/lowering/http2-constants.js.map +1 -0
  75. package/dist/frontend/lowering/lib-boundary.d.ts +6 -0
  76. package/dist/frontend/lowering/lib-boundary.js +143 -0
  77. package/dist/frontend/lowering/lib-boundary.js.map +1 -0
  78. package/dist/frontend/lowering/lower-assert.d.ts +18 -0
  79. package/dist/frontend/lowering/lower-assert.js +1269 -0
  80. package/dist/frontend/lowering/lower-assert.js.map +1 -0
  81. package/dist/frontend/lowering/lower-builtins.d.ts +511 -0
  82. package/dist/frontend/lowering/lower-builtins.js +5249 -0
  83. package/dist/frontend/lowering/lower-builtins.js.map +1 -0
  84. package/dist/frontend/lowering/lower-calls.d.ts +581 -0
  85. package/dist/frontend/lowering/lower-calls.js +6286 -0
  86. package/dist/frontend/lowering/lower-calls.js.map +1 -0
  87. package/dist/frontend/lowering/lower-classes.d.ts +727 -0
  88. package/dist/frontend/lowering/lower-classes.js +4701 -0
  89. package/dist/frontend/lowering/lower-classes.js.map +1 -0
  90. package/dist/frontend/lowering/lower-comptime.d.ts +53 -0
  91. package/dist/frontend/lowering/lower-comptime.js +244 -0
  92. package/dist/frontend/lowering/lower-comptime.js.map +1 -0
  93. package/dist/frontend/lowering/lower-containers.d.ts +486 -0
  94. package/dist/frontend/lowering/lower-containers.js +6345 -0
  95. package/dist/frontend/lowering/lower-containers.js.map +1 -0
  96. package/dist/frontend/lowering/lower-dgram.d.ts +20 -0
  97. package/dist/frontend/lowering/lower-dgram.js +319 -0
  98. package/dist/frontend/lowering/lower-dgram.js.map +1 -0
  99. package/dist/frontend/lowering/lower-emitter.d.ts +10 -0
  100. package/dist/frontend/lowering/lower-emitter.js +688 -0
  101. package/dist/frontend/lowering/lower-emitter.js.map +1 -0
  102. package/dist/frontend/lowering/lower-enums.d.ts +22 -0
  103. package/dist/frontend/lowering/lower-enums.js +235 -0
  104. package/dist/frontend/lowering/lower-enums.js.map +1 -0
  105. package/dist/frontend/lowering/lower-expando.d.ts +35 -0
  106. package/dist/frontend/lowering/lower-expando.js +276 -0
  107. package/dist/frontend/lowering/lower-expando.js.map +1 -0
  108. package/dist/frontend/lowering/lower-exprs.d.ts +524 -0
  109. package/dist/frontend/lowering/lower-exprs.js +8111 -0
  110. package/dist/frontend/lowering/lower-exprs.js.map +1 -0
  111. package/dist/frontend/lowering/lower-generators.d.ts +50 -0
  112. package/dist/frontend/lowering/lower-generators.js +421 -0
  113. package/dist/frontend/lowering/lower-generators.js.map +1 -0
  114. package/dist/frontend/lowering/lower-inspect.d.ts +20 -0
  115. package/dist/frontend/lowering/lower-inspect.js +1074 -0
  116. package/dist/frontend/lowering/lower-inspect.js.map +1 -0
  117. package/dist/frontend/lowering/lower-island.d.ts +108 -0
  118. package/dist/frontend/lowering/lower-island.js +650 -0
  119. package/dist/frontend/lowering/lower-island.js.map +1 -0
  120. package/dist/frontend/lowering/lower-mixins.d.ts +96 -0
  121. package/dist/frontend/lowering/lower-mixins.js +534 -0
  122. package/dist/frontend/lowering/lower-mixins.js.map +1 -0
  123. package/dist/frontend/lowering/lower-modules.d.ts +135 -0
  124. package/dist/frontend/lowering/lower-modules.js +1613 -0
  125. package/dist/frontend/lowering/lower-modules.js.map +1 -0
  126. package/dist/frontend/lowering/lower-namespaces.d.ts +168 -0
  127. package/dist/frontend/lowering/lower-namespaces.js +706 -0
  128. package/dist/frontend/lowering/lower-namespaces.js.map +1 -0
  129. package/dist/frontend/lowering/lower-server.d.ts +90 -0
  130. package/dist/frontend/lowering/lower-server.js +3471 -0
  131. package/dist/frontend/lowering/lower-server.js.map +1 -0
  132. package/dist/frontend/lowering/lower-stmts.d.ts +361 -0
  133. package/dist/frontend/lowering/lower-stmts.js +5341 -0
  134. package/dist/frontend/lowering/lower-stmts.js.map +1 -0
  135. package/dist/frontend/lowering/lower-stream.d.ts +88 -0
  136. package/dist/frontend/lowering/lower-stream.js +1533 -0
  137. package/dist/frontend/lowering/lower-stream.js.map +1 -0
  138. package/dist/frontend/lowering/lower-test.d.ts +27 -0
  139. package/dist/frontend/lowering/lower-test.js +353 -0
  140. package/dist/frontend/lowering/lower-test.js.map +1 -0
  141. package/dist/frontend/lowering/lowerer.d.ts +1748 -0
  142. package/dist/frontend/lowering/lowerer.js +6257 -0
  143. package/dist/frontend/lowering/lowerer.js.map +1 -0
  144. package/dist/frontend/lowering/surfaces.d.ts +272 -0
  145. package/dist/frontend/lowering/surfaces.js +1096 -0
  146. package/dist/frontend/lowering/surfaces.js.map +1 -0
  147. package/dist/frontend/npm-static.d.ts +55 -0
  148. package/dist/frontend/npm-static.js +300 -0
  149. package/dist/frontend/npm-static.js.map +1 -0
  150. package/dist/frontend/npm.d.ts +330 -0
  151. package/dist/frontend/npm.js +1259 -0
  152. package/dist/frontend/npm.js.map +1 -0
  153. package/dist/frontend/program.d.ts +186 -0
  154. package/dist/frontend/program.js +2255 -0
  155. package/dist/frontend/program.js.map +1 -0
  156. package/dist/frontend/provenance-registry.d.ts +48 -0
  157. package/dist/frontend/provenance-registry.js +87 -0
  158. package/dist/frontend/provenance-registry.js.map +1 -0
  159. package/dist/frontend/provenance.d.ts +6 -0
  160. package/dist/frontend/provenance.js +459 -0
  161. package/dist/frontend/provenance.js.map +1 -0
  162. package/dist/frontend/resolve.d.ts +56 -0
  163. package/dist/frontend/resolve.js +682 -0
  164. package/dist/frontend/resolve.js.map +1 -0
  165. package/dist/frontend/shared.d.ts +67 -0
  166. package/dist/frontend/shared.js +241 -0
  167. package/dist/frontend/shared.js.map +1 -0
  168. package/dist/frontend/ts7/adapter.d.ts +7 -0
  169. package/dist/frontend/ts7/adapter.js +54 -0
  170. package/dist/frontend/ts7/adapter.js.map +1 -0
  171. package/dist/frontend/ts7/ast.d.ts +50 -0
  172. package/dist/frontend/ts7/ast.js +211 -0
  173. package/dist/frontend/ts7/ast.js.map +1 -0
  174. package/dist/frontend/ts7/census-check.d.ts +1 -0
  175. package/dist/frontend/ts7/census-check.js +12 -0
  176. package/dist/frontend/ts7/census-check.js.map +1 -0
  177. package/dist/frontend/ts7/checker.d.ts +140 -0
  178. package/dist/frontend/ts7/checker.js +544 -0
  179. package/dist/frontend/ts7/checker.js.map +1 -0
  180. package/dist/frontend/ts7/enums.d.ts +18 -0
  181. package/dist/frontend/ts7/enums.js +43 -0
  182. package/dist/frontend/ts7/enums.js.map +1 -0
  183. package/dist/frontend/ts7/program.d.ts +99 -0
  184. package/dist/frontend/ts7/program.js +278 -0
  185. package/dist/frontend/ts7/program.js.map +1 -0
  186. package/dist/frontend/ts7/world-check.d.ts +3 -0
  187. package/dist/frontend/ts7/world-check.js +34 -0
  188. package/dist/frontend/ts7/world-check.js.map +1 -0
  189. package/dist/frontend/types.d.ts +205 -0
  190. package/dist/frontend/types.js +2485 -0
  191. package/dist/frontend/types.js.map +1 -0
  192. package/dist/index.d.ts +85 -0
  193. package/dist/index.js +429 -0
  194. package/dist/index.js.map +1 -0
  195. package/dist/ir/nodes.d.ts +4334 -0
  196. package/dist/ir/nodes.js +1906 -0
  197. package/dist/ir/nodes.js.map +1 -0
  198. package/dist/ir/serialize.d.ts +4 -0
  199. package/dist/ir/serialize.js +34 -0
  200. package/dist/ir/serialize.js.map +1 -0
  201. package/dist/ir/validate.d.ts +36 -0
  202. package/dist/ir/validate.js +4885 -0
  203. package/dist/ir/validate.js.map +1 -0
  204. package/package.json +30 -6
  205. package/README.md +0 -3
  206. package/index.js +0 -2
@@ -0,0 +1,361 @@
1
+ import * as ts from "../ts7/adapter.js";
2
+ import type { Lowerer } from "./lowerer.js";
3
+ import { IrExpr, IrLocal, IrStmt, IrType, SrcLoc } from "../../ir/nodes.js";
4
+ /** --provenance-sources: true when `decl` is a declarator of a
5
+ * pureAnnotatedDeadConst statement in a FETCHED SOURCE module whose
6
+ * declared type has no static mapping — the declaration ELIDES: no
7
+ * global registers, no code emits, no build diagnostic. The `@__PURE__`
8
+ * annotation is the author's own declaration that dropping the unused
9
+ * initializer is safe (the bundler contract — tree-shaken dists of these
10
+ * packages genuinely ship without it), and a REACHED use of the binding
11
+ * still fails the build through its per-site fence (no storage exists to
12
+ * resolve to), so only genuinely-unused bindings ride this. Third-party
13
+ * fetched source only: the program's own TypeScript keeps its compile
14
+ * fences. The type probe's diagnostics roll back — elision must not leak
15
+ * them onto the build — and the elision records ONCE (by position) into
16
+ * provenanceElided for the coverage report's provenance section. Both
17
+ * collectGlobals and lowerVarDecl gate on this, BEFORE the mixin/alias
18
+ * probes that would otherwise claim (and diagnose) the call-initializer
19
+ * shape. */
20
+ export declare function provenanceElidedConstDecl(L: Lowerer, decl: ts.VariableDeclaration): boolean;
21
+ /** Lowers statements, one poison catch per statement so one unsupported
22
+ * construct doesn't hide the rest of the file's diagnostics. A single
23
+ * source statement may expand to several IR statements (multi-declaration
24
+ * `let a = 1, b = a + 1;`) but is counted once. */
25
+ export declare function lowerStmts(L: Lowerer, stmts: readonly ts.Statement[]): IrStmt[];
26
+ /** The hoisted-handler shape: a function declared BEFORE a const it
27
+ * captures, in the same (or an enclosing) statement list —
28
+ *
29
+ * const cleanup = () => { process.removeListener("SIGINT", onSigInt); };
30
+ * const onSigInt = () => handleSignal("SIGINT");
31
+ *
32
+ * JS hoists the BINDING to scope entry (TDZ) and initializes it at the
33
+ * declaration; a read before initialization throws ReferenceError. Model
34
+ * exactly that: when a reference fails to resolve anywhere on the
35
+ * function stack, look for its declaration LATER in an open statement
36
+ * list — a const with an initializer, pointer-backed type — and
37
+ * pre-declare it there as a TDZ box (varDecl init:null, boxed, tdz),
38
+ * registered in the list's scope frame so resolution finds it and
39
+ * threads captures normally. The source declaration later becomes the
40
+ * initializing `assign` (lowerVarDecl consumes tdzPredeclared). Reads
41
+ * test the box and throw Node's exact catchable ReferenceError while it
42
+ * is empty. CONST ONLY: `let` would need the same trap on writes, a
43
+ * surface nothing yet needs. */
44
+ export declare function predeclareForwardCapture(L: Lowerer, symbol: ts.Symbol): boolean;
45
+ /** The FUNCTION-DECLARATION twin of predeclareForwardCapture: JS hoists a
46
+ * nested `function f() {}` to scope entry — the binding is LIVE from the
47
+ * first statement, so a reference lexically above the declaration in the
48
+ * SAME function lowers the declaration eagerly at the reference (varDecl
49
+ * pushed before the current statement's IR, registered in the list's
50
+ * scope frame) and the statement loop skips the source statement when it
51
+ * arrives (L.hoistedFnDecls). Same-function only: the declaration's own
52
+ * lowering runs under the ctx that owns its statement list, and a
53
+ * cross-function early capture would need lowering under a DIFFERENT
54
+ * ctx than the one currently open — that shape keeps the honest fence. */
55
+ export declare function predeclareForwardFnDecl(L: Lowerer, symbol: ts.Symbol): boolean;
56
+ /** True when `decl` (a variable declaration or a pattern name inside one)
57
+ * was declared with `var` — no const/let/using flag anywhere on its
58
+ * binding chain. */
59
+ export declare function isVarDeclared(decl: ts.Node): boolean;
60
+ /** `for (var x of ...)` loop variables: the ONE function-scoped binding
61
+ * every for-of desugar must ASSIGN per iteration instead of declaring a
62
+ * fresh per-pass local — a captured `var` loop variable is shared by
63
+ * every closure made in the loop (where `let` gets a fresh binding per
64
+ * iteration), and it persists after the loop. Returns the write target
65
+ * (a module global for top-level loops, the hoisted function slot
66
+ * otherwise); null when the binding isn't a `var` identifier. */
67
+ export declare function forOfVarTarget(L: Lowerer, decl: ts.VariableDeclaration): {
68
+ id: string;
69
+ type: IrType;
70
+ } | null;
71
+ /** `var` declarations hoist to their FUNCTION: the binding exists across
72
+ * the whole enclosing function body regardless of block position, and
73
+ * every same-name `var` in that function is the SAME binding (tsc merges
74
+ * the declarations into one symbol, so symbol-keyed resolution gets the
75
+ * merge for free). This mints the one function-scoped slot on first
76
+ * encounter: an IrLocal registered in the function's ROOT scope frame
77
+ * (never popped by block exits) whose `varDecl` is PUSHED into the
78
+ * function-root statement list at the current position — everything
79
+ * already lowered never referenced the symbol (resolution would have
80
+ * found it), so the position is observationally function entry. Types
81
+ * with an undefined arm initialize to the interned undefined (JS's
82
+ * hoisted value — reads before the first assignment are `undefined`, and
83
+ * tsc's flow analysis rejects such reads for every OTHER type); the rest
84
+ * start empty, their pre-assignment reads impossible by that analysis.
85
+ * A `var` merging with a PARAMETER of the same name (one symbol in JS
86
+ * and in tsc's binder) resolves to the parameter's slot — `var x = 2`
87
+ * simply overwrites the argument, exactly Node. The source declaration
88
+ * lowers to a plain `assign` (see lowerVarDecl), so a declaration inside
89
+ * a loop re-ASSIGNS the one binding per pass and never resets it — the
90
+ * classic capture semantics fall out: closures made in a loop share the
91
+ * single boxed binding, where `let` gets a fresh box per iteration. */
92
+ export declare function hoistVarBinding(L: Lowerer, symbol: ts.Symbol, nameNode: ts.Identifier): IrLocal;
93
+ /** The forward twin of hoistVarBinding, entered from resolution failure: a
94
+ * reference to a `var` whose declaration statement has not lowered yet —
95
+ * a read/write lexically above the declaration in the same function
96
+ * (legal under tsc exactly when the type carries `undefined`), or a
97
+ * nested function created above it that captures the binding. JS gives
98
+ * such reads `undefined`, never a TDZ error, so the hoisted slot must
99
+ * hold `undefined` from function entry — which is only honest for
100
+ * undefined-armed union types (the interned arm) and checked-dynamic
101
+ * bindings (the DOM undefined). Everything else returns false
102
+ * and the reference lands on the named fence in rejectUnresolvedSymbol:
103
+ * a slot of a narrower type has no bit pattern for the `undefined` Node
104
+ * would yield if the capture ran early, and guessing "it won't" is the
105
+ * silent-wrong-output sin. */
106
+ export declare function predeclareForwardVar(L: Lowerer, symbol: ts.Symbol): boolean;
107
+ /** Records the symbols a poisoned DECLARATION statement would have bound
108
+ * (identifier and pattern names alike, for-initializers included) so
109
+ * later references report the SC2004 cascade. Registered bindings win:
110
+ * lowerVarDecl's salvage path declares the local when it can, and
111
+ * resolution checks locals/globals before the fallthroughs consult
112
+ * blockedBindings. */
113
+ export declare function noteBlockedBindings(L: Lowerer, stmt: ts.Statement): void;
114
+ /** True when a reference/assignment fell through resolution because the
115
+ * binding's DECLARATION never compiled: a poisoned declaration statement
116
+ * (blockedBindings) or a deferred-diagnostic declaration (a blocked
117
+ * signature/class/global — deferred now, flushed earlier this pass, or
118
+ * flushed by the emit pass). */
119
+ export declare function isBlockedBinding(L: Lowerer, symbol: ts.Symbol | null): boolean;
120
+ /** Lowers a statement in a fresh lexical scope (if/while/for bodies). */
121
+ export declare function lowerScopedBlock(L: Lowerer, stmt: ts.Statement): IrStmt[];
122
+ /** The finally fences. `return` crossing OUT of a try/catch body guarded
123
+ * by a finally is SUPPORTED now (the backend's pending-return path runs
124
+ * every crossed finally inner-to-outer before the function returns, the
125
+ * value snapshotted first — Node-exact); what stays rejected is (a) any
126
+ * jump out of a finally BLOCK itself (a return there would REPLACE a
127
+ * pending completion — clearing a still-propagating exception or
128
+ * abandoning a pending return, a model the emitter doesn't implement),
129
+ * and (b) break/continue crossing a try-with-finally (their targets bind
130
+ * inside the function; the pending-action plumbing exists only for
131
+ * return, the shape real code needs). Rejected, not miscompiled. Plain
132
+ * try/catch is transparent to jumps (it never appears in ctl). A LABELED
133
+ * jump walks outward past every construct (labeled targets can be
134
+ * arbitrarily far out) until the entry carrying its label, applying the
135
+ * same finally fences to everything crossed on the way. */
136
+ export declare function rejectJumpCrossingFinally(L: Lowerer, kw: "break" | "continue" | "return", stmt: ts.Statement, label?: string): void;
137
+ /** `lbl: stmt` — labeled statements. A label chain collapses to one name
138
+ * list (`a: b: while ...` — both names target the same loop, JS-exact).
139
+ * Loops and switches take the labels DIRECTLY (a labeled continue needs
140
+ * the loop's own continue point — the condition/update — and a labeled
141
+ * switch-break its end): pendingLabels hands them to the construct's own
142
+ * lowering, which consumes them before lowering anything nested (so an
143
+ * inner loop can never steal them). Every other labeled statement wraps
144
+ * in a labeled BLOCK — `break lbl` exits it (the only jump tsc allows to
145
+ * target a non-loop label), and a label nothing jumps to is just the
146
+ * statement itself. Loop shapes whose lowering is a label-free desugar
147
+ * (container/matchAll/stdin for-ofs, union switches) DROP the labels
148
+ * after consuming them: an unused label costs nothing, and a labeled
149
+ * jump naming one fences by name at the jump site instead of compiling
150
+ * against the wrong target. */
151
+ export declare function lowerLabeled(L: Lowerer, stmt: ts.LabeledStatement): IrStmt | IrStmt[] | null;
152
+ export declare function lowerStmt(L: Lowerer, stmt: ts.Statement): IrStmt | IrStmt[] | null;
153
+ /** A variable statement may carry several declarators (`let a = 1,
154
+ * b = a + 1;`): each lowers to its own varDecl IN ORDER, so later
155
+ * initializers see earlier bindings (JS-exact). `var` declarators ride
156
+ * the same path — their "declaration" is an assignment into the
157
+ * function-scoped hoisted slot (hoistVarBinding), so the mutability flag
158
+ * passed down covers let AND var. */
159
+ export declare function lowerVarStatement(L: Lowerer, stmt: ts.VariableStatement): IrStmt[];
160
+ /** Destructuring declarations, desugared as sugar over indexed/field
161
+ * reads: the initializer evaluates ONCE into a hidden temp, then each
162
+ * bound name declares (or assigns its pre-registered module global) from
163
+ * a read of that temp — `const [a, b] = arr` reads indices 0 and 1,
164
+ * `const { x, y: z } = rec` reads the fields, nested patterns recurse
165
+ * through their own temps. Sources are arrays and records; array reads
166
+ * inherit the array divergence (a pattern longer than the array traps
167
+ * where JS binds undefined). Defaults, rest elements, and computed keys
168
+ * are fenced — each would need machinery beyond a read (an undefined
169
+ * test, surplus packing, dynamic lookup). */
170
+ export declare function lowerDestructuringDecl(L: Lowerer, decl: ts.VariableDeclaration, isLet: boolean): IrStmt[];
171
+ /** One pattern level: emits a declaration (or global assignment) per
172
+ * bound name, recursing through hidden temps for nested patterns. */
173
+ export declare function lowerBindingPattern(L: Lowerer, pattern: ts.ArrayBindingPattern | ts.ObjectBindingPattern, srcRef: () => IrExpr, srcType: IrType, isLet: boolean, out: IrStmt[]): void;
174
+ /** The STATIC property name of a destructuring key: identifiers spell
175
+ * themselves, string/numeric-literal keys and COMPUTED keys fold through
176
+ * foldedStringKeyOf — pure single-name expressions only (`{ [k]: v }`
177
+ * where k's checker type spells one property name; tsc late-bound the
178
+ * source's field under exactly that name, and pure keys make skipping
179
+ * the evaluation exact). Null for runtime-valued keys — the callers
180
+ * fence, or route island sources to the engine pattern. */
181
+ export declare function patternKeyNameOf(L: Lowerer, prop: ts.PropertyName): string | null;
182
+ /** The fences the island's element-wise object path shares: no rest
183
+ * (surplus packing over a handle) and no defaults (an engine undefined
184
+ * test) — the static positions now take both through their own
185
+ * machinery above. */
186
+ export declare function checkBindingElement(L: Lowerer, el: ts.BindingElement, allowDefault?: boolean): void;
187
+ /** A declaration pattern rebuilt as ENGINE source with every bound name
188
+ * renamed __0..__n (pattern order): holes, nesting, rest, and
189
+ * transportable defaults all survive verbatim, so the engine runs the
190
+ * REAL pattern — the iterator protocol on array patterns,
191
+ * RequireObjectCoercible on object patterns, JS's own default rule.
192
+ * Null when any element has no engine form (computed keys — a compiled
193
+ * expression the pattern text cannot carry — or untransportable
194
+ * defaults). */
195
+ export declare function enginePatternSpec(L: Lowerer, pattern: ts.ArrayBindingPattern | ts.ObjectBindingPattern): {
196
+ text: string;
197
+ binds: ts.Identifier[];
198
+ extras: ts.Expression[];
199
+ } | null;
200
+ /** Declaration-position destructuring over an ISLAND source: the ENGINE
201
+ * runs the real pattern — a synthesized strict-mode
202
+ * `new Function("v", ...)` exactly like the assignment chain's
203
+ * (lowerJsvalDestructuringChain) — and the extracted values bind the
204
+ * declared names: a name whose declared type is a primitive exits
205
+ * eagerly (the island property-read rule), everything else stays a
206
+ * HANDLE whose use sites dispatch to engine ops. Holes, nesting, empty
207
+ * patterns (the object coercion check and the array iterator get+close
208
+ * both run — destructuring undefined throws Node's TypeError at Node's
209
+ * exit), rest, and transportable defaults all ride. False when the
210
+ * pattern has no engine form (the caller fences). */
211
+ export declare function lowerJsvalBindingPattern(L: Lowerer, pattern: ts.ArrayBindingPattern | ts.ObjectBindingPattern, srcRef: () => IrExpr, isLet: boolean, out: IrStmt[]): boolean;
212
+ /** Binds one destructured name to its value — the identifier tail of
213
+ * lowerVarDecl (module-global assignment for pre-registered file-scope
214
+ * names, declareLocal otherwise), or a nested pattern through its own
215
+ * hidden temp. */
216
+ export declare function bindPatternTarget(L: Lowerer, name: ts.BindingName, value: IrExpr, isLet: boolean, out: IrStmt[]): void;
217
+ /** For-loop initializers. let/const stay restricted to ONE declarator (JS
218
+ * per-iteration binding copies for several captured loop variables are
219
+ * not modeled yet); `var` initializers take any number — a `var` is ONE
220
+ * function-scoped binding with no per-iteration copies to model, so
221
+ * `for (var i = 0, n = xs.length; ...)` is just two hoisted-slot
222
+ * assignments (wrapped in a block when several). Statement position goes
223
+ * through lowerVarStatement. */
224
+ export declare function lowerVarDeclList(L: Lowerer, list: ts.VariableDeclarationList): IrStmt | null;
225
+ export declare function lowerVarDecl(L: Lowerer, decl: ts.VariableDeclaration, isLet: boolean): IrStmt | null;
226
+ /** JS-exact switch (see docs/ir.md): one shared lexical scope for all case
227
+ * bodies, lazy source-order test evaluation, fall-through. tsc has already
228
+ * checked case-test comparability (TS2678) — the kind check below is the
229
+ * backstop for cases tsc lets through (e.g. `unknown as` casts). */
230
+ export declare function lowerSwitch(L: Lowerer, stmt: ts.SwitchStatement): IrStmt;
231
+ /** Switch on a UNION-typed discriminant (`switch (m.type)` over
232
+ * `string | undefined`): desugared to an if/else-if chain of per-union
233
+ * strict-equality tests (unionEq — the case value wraps into the union,
234
+ * exactly `disc === test`), because the backend switch compares plain
235
+ * primitives only. The desugar is JS-exact for the shape it accepts and
236
+ * fences everything it cannot reproduce:
237
+ * - the discriminant rides every test, so it must be a plain
238
+ * side-effect-free read (bind it to a const first otherwise);
239
+ * - tests evaluate lazily in source order (the chain's short-circuit IS
240
+ * the switch's test order — grouped empty cases `case a: case b:` OR
241
+ * their tests, still in order);
242
+ * - each non-final clause must EXIT (a trailing unconditional break —
243
+ * dropped, it's the chain's own exit — or a return/throw/continue):
244
+ * real fall-through between bodies has no if/else shape;
245
+ * - any OTHER unlabeled break binding to this switch (a conditional
246
+ * early break) is fenced — desugared, it would bind to an enclosing
247
+ * loop instead;
248
+ * - `default` may sit anywhere in source (JS tests every case first;
249
+ * the chain's final else reproduces that as long as its body exits or
250
+ * is last).
251
+ * Case bodies share ONE lexical scope, exactly like the real switch. */
252
+ export declare function lowerUnionSwitch(L: Lowerer, stmt: ts.SwitchStatement, disc: IrExpr): IrStmt;
253
+ /** try/catch/finally. Supported subset:
254
+ * - `catch { }` (bindingless) discards the thrown value on entry.
255
+ * - `catch (e)` binds it as a CAUGHT local — a snapshot of the exception
256
+ * cell, deliberately narrower than dyn: the supported uses are the
257
+ * narrowing tests (`e instanceof C` over hierarchy classes, `typeof e
258
+ * === "string"/"number"/"boolean"`), reads under a proven narrow
259
+ * (caughtRead bridges them with caughtNarrow, trust-the-checker like
260
+ * unionNarrow), and rethrow (`throw e`). Raw uses, captures, and
261
+ * assignment are fenced (SC1063 and friends); destructuring patterns
262
+ * are SC1062. The `: any` / `: unknown` annotations tsc admits both
263
+ * lower the same way (tsc narrows either through the tests).
264
+ * - `finally` runs on normal completion, on exception paths, and on the
265
+ * way out of a `return` in the try/catch body (the backend's
266
+ * pending-return path — inner-to-outer through nested finallys, the
267
+ * value snapshotted before the finally runs, Node-exact).
268
+ * break/continue crossing a try-with-finally stay rejected, as does
269
+ * any jump out of the finally body itself (it would replace a pending
270
+ * completion — rejectJumpCrossingFinally). Plain try/catch places no
271
+ * restriction on jumps.
272
+ * Each block is its own lexical scope (the binding lives in a scope
273
+ * WRAPPING the catch block, like the spec's catch environment). */
274
+ export declare function lowerTry(L: Lowerer, stmt: ts.TryStatement): IrStmt;
275
+ /** Expression-position statements: assignments, calls. Shared with
276
+ * for-loop init/update. Parens unwrap first — `(x = v);` is the plain
277
+ * assignment, and `({ a, b } = e);` (destructuring ASSIGNMENT, which JS
278
+ * requires parenthesized in statement position) lands in the
279
+ * object-literal-target branch below. */
280
+ export declare function lowerExprStatement(L: Lowerer, expr: ts.Expression): IrStmt;
281
+ /** `({ a, b: x } = e);`, `[a, b = 0, ...rest] = xs;` — destructuring
282
+ * assignment to EXISTING writable bindings, statement position, from a
283
+ * PRE-LOWERED source: for-of expression heads hand the per-iteration
284
+ * element in directly (no RHS expression exists there, so
285
+ * checked-dynamic sources fence — V8's TypeError spells the source
286
+ * text). Plain assignment statements ride
287
+ * lowerDestructuringAssignParts, which keeps the RHS expression for
288
+ * that spelling. */
289
+ export declare function lowerDestructuringAssign(L: Lowerer, target: ts.ObjectLiteralExpression | ts.ArrayLiteralExpression, init: IrExpr, blame: ts.Node, loc: SrcLoc): IrStmt;
290
+ /** Destructuring ASSIGNMENT (existing bindings — the declaration twin is
291
+ * lowerDestructuringDecl): the RHS evaluates ONCE into a hidden temp,
292
+ * each target assigns in source order, and the parts' VALUE is the
293
+ * temp — JS's assignment-expression value is the RHS value, so the same
294
+ * parts serve statement position (block) and expression position
295
+ * (seqExpr). Object patterns cover shorthand/renamed identifier targets
296
+ * over record sources and checked-dynamic sources (keyed reads behind
297
+ * V8's exact RequireObjectCoercible TypeError); array patterns cover
298
+ * identifier targets with optional defaults over arrays, tuples, and
299
+ * checked-dynamic sources (dynIterN's GetIterator semantics), elisions,
300
+ * a sole leading rest whose operand is itself an array pattern
301
+ * (`[...[a, b = 0]] = t` consumes the same elements as the inner
302
+ * pattern alone), and the EMPTY patterns (`({} = e)` requires object-
303
+ * coercibility, `[] = e` requires iterability — both pure for sources
304
+ * whose static type already proves it). Object patterns over record
305
+ * sources take defaults (`{ x = 1 }` — the undefined-arm test against
306
+ * the TARGET's own type) and rest (`{ ...bar }` — the unconsumed fields
307
+ * pack into a fresh record, JS's CopyDataProperties stance); array
308
+ * patterns take defaults everywhere (arrays carry the bounds test JS's
309
+ * past-the-end undefined demands) and rest packing the tail fresh
310
+ * (array slices, tuple tails). Nesting, computed keys, and member
311
+ * targets keep fences. */
312
+ export declare function lowerDestructuringAssignParts(L: Lowerer, target: ts.ObjectLiteralExpression | ts.ArrayLiteralExpression, rhs: ts.Expression, loc: SrcLoc): {
313
+ stmts: IrStmt[];
314
+ value: IrExpr;
315
+ };
316
+ /** `for (const x of arr)` — arrays only. The lib types strings and Maps
317
+ * as iterable too, so those for-ofs typecheck and are fenced below with
318
+ * specific diagnostics; other iterables fail on their types. The loop
319
+ * variable is a fresh const binding per iteration (its own scope, like a
320
+ * loop body). */
321
+ export declare function lowerForOf(L: Lowerer, stmt: ts.ForOfStatement): IrStmt;
322
+ /** A DIRECT `s.matchAll(re)` call: a stdlib matchAll property call on a
323
+ * string-typed receiver with one regex-typed argument (parens stripped).
324
+ * The shape the companion-index machinery serves. */
325
+ export declare function directMatchAllCallOf(L: Lowerer, e: ts.Expression): ts.CallExpression | null;
326
+ /** for-in loops. The key set is Node's own-enumerable-keys walk, lowered
327
+ * per receiver kind:
328
+ * - RECORDS (fixed shapes): iteration over exactly the keys Object.keys
329
+ * answers — the shared interned keys helper (recordKeysArrayCall):
330
+ * declaration order, fields holding the undefined arm of their union
331
+ * skipped at runtime (SEMANTICS.md 37's rules verbatim). The key list
332
+ * snapshots at loop entry, which IS Node's for-in contract for keys
333
+ * ADDED during the walk (never visited); fixed shapes cannot lose keys
334
+ * mid-loop (no delete), so the snapshot is exact.
335
+ * - INDEX-SIGNATURE shapes: the same Object.keys hybrid/pure walk
336
+ * (declared fields first, then the overflow in JS own-key order —
337
+ * objectIterOverIndexShape's "keys" arm, same intern key). Adds during
338
+ * the loop are correctly NOT visited (the snapshot); PURE shapes —
339
+ * the one record kind where `delete obj[k]` is lowered — additionally
340
+ * guard every visit with a live presence test, Node's HasProperty
341
+ * re-check, so keys deleted before their turn are skipped exactly
342
+ * like Node.
343
+ * - ARRAYS: Node's canonical ascending index strings. The key set
344
+ * snapshots at entry (pushes during the body are NOT visited — V8's
345
+ * own-keys snapshot, verified against Node) while each visit re-checks
346
+ * presence (i < live length), so pops during the body skip exactly
347
+ * like Node. Sparse arrays cannot exist here (hole creation traps).
348
+ * - globalThis: the harness's leaked-globals sweep — a compiled binary's
349
+ * global bindings are compile-time names, never enumerable runtime
350
+ * properties, so the enumeration is honestly EMPTY (zero iterations;
351
+ * the body typechecked but never evaluates — SEMANTICS.md documents
352
+ * the divergence).
353
+ * - class instances fence: which keys exist on one depends on runtime
354
+ * property creation (unset declared fields, useDefineForClassFields)
355
+ * that the struct model does not track — named, not guessed.
356
+ * Bindings mirror for-of's: const/let declare the per-iteration string
357
+ * local, `var` assigns the hoisted shared slot, a pre-declared
358
+ * identifier target assigns per pass; destructuring heads are tsc
359
+ * errors. */
360
+ export declare function lowerForIn(L: Lowerer, stmt: ts.ForInStatement): IrStmt;
361
+ export declare function lowerForStatement(L: Lowerer, stmt: ts.ForStatement): IrStmt;