@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,727 @@
1
+ import * as ts from "../ts7/adapter.js";
2
+ import type { Lowerer } from "./lowerer.js";
3
+ import { IrClassDef, IrExpr, IrFunction, IrLocal, IrStmt, IrType, SrcLoc } from "../../ir/nodes.js";
4
+ import { type GenericFnInfo, type ParamShape } from "./lower-calls.js";
5
+ import { type MixinInstanceInfo } from "./lower-mixins.js";
6
+ export interface ClassInfo {
7
+ def: IrClassDef;
8
+ /** ALL fields visible on instances — the inherited ones included — for
9
+ * receiver-side lookup (def.fields carries the layout order). */
10
+ fields: Map<string, IrType>;
11
+ /** OWN fields only (declaration order) with their initializers: the
12
+ * class's constructor runs exactly these — inherited fields initialize in
13
+ * the base constructor, before/via super(). */
14
+ fieldOrder: {
15
+ name: string;
16
+ type: IrType;
17
+ initializer: ts.Expression | undefined;
18
+ }[];
19
+ /** OWN declared methods only — inherited lookups walk the base chain
20
+ * (findMethodOn). An `abstract` entry is a signature with no body (and
21
+ * no module function): it declares the vtable slot; concrete subclasses
22
+ * fill it (tsc guarantees every instantiable class implements). */
23
+ methods: Map<string, {
24
+ params: ParamShape[];
25
+ ret: IrType;
26
+ abstract?: true;
27
+ async?: true;
28
+ }>;
29
+ /** OWN GENERIC instance methods (own type parameters — `m<T>(x: T)`),
30
+ * monomorphized per call site like top-level generic functions: instance
31
+ * `n` is the module function `%C.m%n` taking `this` as param 0. They
32
+ * never enter `methods` (no single ABI signature, no vtable slot), so
33
+ * dispatch is STATIC — calls resolve the nearest declarer on the
34
+ * receiver's static class, and a receiver whose runtime class could
35
+ * override (genericOverrideBelow) must be exact or fences. Inherited
36
+ * lookups walk the base chain (findGenericMethodOn). */
37
+ genericMethods?: Map<string, GenericFnInfo>;
38
+ /** OWN GENERIC static methods — `%C.static:m%n` module functions, the
39
+ * generic twin of staticMethods (same this/super fence, same
40
+ * through-a-VALUE shadowing rules via staticShadowBelow). */
41
+ genericStatics?: Map<string, GenericFnInfo>;
42
+ /** null for the builtin error classes (runtime-provided; no source).
43
+ * Class EXPRESSIONS carry their ts.ClassExpression here — members,
44
+ * accessors, and locs read identically off either form. */
45
+ decl: ts.ClassLikeDeclaration | null;
46
+ /** Runtime-provided builtin (the Error hierarchy): no bodies lower, `new`
47
+ * and super() calls become error.* libCalls, toString is the runtime's. */
48
+ builtinError?: true;
49
+ /** Runtime-provided node:events EventEmitter: no bodies lower, `new` and
50
+ * super() become emitter.* libCalls, and the whole method surface
51
+ * (on/emit/...) lowers through lower-emitter.ts over any class rooted
52
+ * here. Subclass structs embed the ScrEmitter prefix. */
53
+ builtinEmitter?: true;
54
+ /** Runtime-provided node:stream class (Readable/Writable/Duplex/
55
+ * Transform/PassThrough — emitter-rooted): no bodies lower, `new`
56
+ * becomes a stream constructor libCall, the stream method/property
57
+ * surface lowers through lower-stream.ts, and the emitter surface rides
58
+ * the base chain. The value names which SIDES the class carries. User
59
+ * `extends` of these classes is fenced at the declaration (phase 1). */
60
+ builtinStream?: "r" | "w" | "rw";
61
+ ctor: ts.ConstructorDeclaration | null;
62
+ /** PARAMETER PROPERTIES (`constructor(public x: number)`), in parameter
63
+ * order: each declares a field (placed BEFORE the class's declared
64
+ * fields in the layout — Node's transform hoists the definitions to the
65
+ * top of the class body, verified) and assigns it from the parameter's
66
+ * body local AFTER the field initializers run (Node's order: super() →
67
+ * field initializers → parameter-property assignments → ctor body). */
68
+ paramProps?: {
69
+ name: string;
70
+ type: IrType;
71
+ param: ts.ParameterDeclaration;
72
+ }[];
73
+ /** EFFECTIVE constructor params: the own constructor's, or (constructor
74
+ * omitted) the base's — `new Derived(...)` is typed by tsc against the
75
+ * inherited signature, and the synthesized constructor forwards to it
76
+ * (forwarding the completed ABI values; defaults apply in the base). */
77
+ ctorParams: ParamShape[];
78
+ base: ClassInfo | null;
79
+ /** DIRECT subclasses, filled as derived classes collect — the frontend's
80
+ * side of whole-program devirtualization (overrideBelow). */
81
+ subclasses: ClassInfo[];
82
+ /** Property names whose setter this class SYNTHESIZES as a throw: a
83
+ * getter-only override shadows an inherited get/set pair in JS, so a
84
+ * base-typed write reaches this class and throws TypeError (Node's
85
+ * behavior, matched exactly — see collectClassShape). */
86
+ throwingSetters: string[];
87
+ /** STATIC fields with initializers — the honest static subset: each is
88
+ * a module global (`%g.s.<C>.<name>`), assigned once in the declaring
89
+ * file's %init at the class statement's source position (exactly when
90
+ * JS evaluates static initializers, so an initializer reading earlier
91
+ * module bindings sees their values), and read as `C.name` anywhere
92
+ * (lowerStaticFieldRead). Writable (non-readonly) fields are MUTABLE
93
+ * globals; writes lower only through the DECLARING class's own name
94
+ * (`D.x = v` where x is inherited creates an OWN property on D in JS —
95
+ * different storage — and writes through class VALUES would need the
96
+ * same dynamic story: both are named fences). Accessors and
97
+ * initializer-less fields keep the fence. */
98
+ staticFields: {
99
+ name: string;
100
+ type: IrType;
101
+ initializer: ts.Expression;
102
+ globalId: string;
103
+ readonly: boolean;
104
+ }[];
105
+ /** STATIC methods — ordinary module functions named `%C.static:m` (the
106
+ * accessor-colon trick: no user identifier can spell it, and statics
107
+ * never join vtables, so IrClassDef doesn't know them). `C.m(args)` is
108
+ * a direct call; `const f = C.m` a zero-capture closure; calls through
109
+ * class VALUES devirtualize when no strict descendant redeclares the
110
+ * member. `this`/`super` inside fence at lowering (JS binds `this` to
111
+ * the RECEIVER class — dynamic). Absent on builtin classes. */
112
+ staticMethods?: Map<string, {
113
+ params: ParamShape[];
114
+ ret: IrType;
115
+ member: ts.MethodDeclaration;
116
+ }>;
117
+ /** `static { ... }` blocks, in declaration order. They are DECLARATION-TIME
118
+ * CODE, not shape: JS runs each block once when the class statement
119
+ * evaluates, whether or not anything ever references the class — so their
120
+ * statements lower into the declaring file's %init at the class statement's
121
+ * source position, interleaved with the static field initializers in member
122
+ * order (lowerStaticFieldInits). `this` inside a block (the class
123
+ * constructor value — no value form here) fences at collection. Absent on
124
+ * builtin classes and classes without blocks. */
125
+ staticBlocks?: ts.ClassStaticBlockDeclaration[];
126
+ /** SYMBOL-KEYED fields (`this[kLimit] = v` where kLimit is a module-level
127
+ * `const k = Symbol(...)`): the key's unique-symbol identity is a
128
+ * compile-time constant, so each key resolves to an ORDINARY hidden slot
129
+ * in the static layout — no runtime symbol table exists. The map goes
130
+ * key-symbol → layout field name (`Symbol(limit)`, Node's inspect
131
+ * spelling); inherited entries are seeded from the base like `fields`.
132
+ * Absent on builtin classes and classes with no symbol-keyed fields. */
133
+ symbolFields?: Map<ts.Symbol, string>;
134
+ /** GENERIC class FAMILY (`class Box<T>` itself): the synthetic,
135
+ * never-constructed ancestor every instantiation extends. It owns what
136
+ * JS's one runtime `Box` owns — the statics (one storage location for
137
+ * every instantiation) and the `instanceof Box` interval — and declares
138
+ * no fields, no instance methods, no constructor function. Construction
139
+ * and instance types resolve to instantiations instead (`generic`
140
+ * carries the instance table). */
141
+ generic?: GenericClassInfo;
142
+ /** GENERIC class INSTANTIATION (`Box%0` for `Box<number>`): the family,
143
+ * the type-parameter bindings member lowering runs under (the
144
+ * generic-fn typeParamResolver mechanism), the rendered type arguments
145
+ * for diagnostics, and the demand ordinal (only the FIRST instantiation
146
+ * counts statements toward coverage — re-instantiations re-visit the
147
+ * same source lines). */
148
+ genericInstance?: {
149
+ family: ClassInfo;
150
+ bindings: Map<ts.Symbol, IrType>;
151
+ typeArgsText: string;
152
+ ordinal: number;
153
+ };
154
+ /** MIXIN instantiation (`%mx<start>.<name>` for `M(Base)` at one call
155
+ * site): the call that minted it, the base-parameter type binding its
156
+ * members lower under, the forwarding-constructor flag, and where its
157
+ * static declaration-time code emits (lower-mixins.ts). */
158
+ mixinInstance?: MixinInstanceInfo;
159
+ /** CLASS decorators (`@dec class C`) — standard (TC39 stage-3 / TS 5+)
160
+ * semantics, lowered statically as declaration-time CALLS in %init at
161
+ * the class statement's position: decorator expressions evaluate in
162
+ * source order, applications run in REVERSE order over the class object,
163
+ * and static field initializers/blocks run AFTER the applications (the
164
+ * verified Node order). Present exactly when the declaration carries
165
+ * class-level decorators; `shapes` fills in the post-collection analysis
166
+ * pass (a decorator's return type may name a subclass declared BELOW the
167
+ * class, so analysis cannot run while shapes are still collecting). */
168
+ classDecorators?: ClassDecorationInfo;
169
+ /** The class's decoration PROVABLY throws before anything else in its
170
+ * definition evaluates (the first effectful item in TC39 evaluation
171
+ * order — class decorators, then heritage, then member decorators and
172
+ * computed keys interleaved — is an AMBIENT decorator name nothing
173
+ * defines; Node erases the declaration, so the read is a
174
+ * ReferenceError). The class registers as an empty SHELL: no members
175
+ * collect (nothing after the throw ever runs — member fences would be
176
+ * fences on dead code), the %init at the class statement is exactly the
177
+ * throw, and every VALUE use (new, the class as a value, extends)
178
+ * fences — the binding never initializes, so compiled code can never
179
+ * legitimately reach one. */
180
+ decorationThrows?: {
181
+ name: string;
182
+ };
183
+ }
184
+ /** A decorated class's decoration state (see ClassInfo.classDecorators). */
185
+ export interface ClassDecorationInfo {
186
+ /** The class-level decorator nodes, source order. */
187
+ nodes: ts.Decorator[];
188
+ /** Per-decorator analysis (parallel to `nodes`). `call`: the decorator
189
+ * expression's completed function type — the type its VALUE lowers to
190
+ * and the ABI the application call dispatches — and whether it can
191
+ * REPLACE the class (return type is the class or a subclass, per the
192
+ * classval flow rule) rather than returning void/undefined.
193
+ * `ambientThrow`: the decorator names an ambient declaration NOTHING
194
+ * defines (`declare let dec: any`, `declare function dec<T>(t: T): T`)
195
+ * — Node erases it, so evaluating the decorator expression throws the
196
+ * ReferenceError; the program compiles to exactly that crash. */
197
+ shapes?: ({
198
+ kind: "call";
199
+ funcType: Extract<IrType, {
200
+ kind: "func";
201
+ }>;
202
+ replaces: boolean;
203
+ } | {
204
+ kind: "ambientThrow";
205
+ name: string;
206
+ })[];
207
+ /** Analysis fenced — diagnostics already reported; emission skips. */
208
+ poisoned?: true;
209
+ /** The MUTABLE classval module global holding the decoration RESULT,
210
+ * present exactly when some decorator can replace the class. TC39 binds
211
+ * the class NAME to the last non-undefined decorator return, so every
212
+ * reference to the name routes through this value: bare reads load it,
213
+ * `new C()` dispatches newValue through it, `C.x` takes the
214
+ * through-a-VALUE static paths, and `instanceof C` reads its interval
215
+ * (instanceOfValue). Absent when every decorator returns void/undefined
216
+ * — the binding provably stays the original class object and every
217
+ * direct path stays direct. */
218
+ valueGlobalId?: string;
219
+ }
220
+ /** A generic class declaration's monomorphization state, hung off the
221
+ * FAMILY ClassInfo (registered under the class's own qualified name and
222
+ * bound to its symbol — `new`, `instanceof`, statics, and extends all
223
+ * resolve to the family first and reroute to instantiations from there).
224
+ * Instances key by comma-joined type-argument typeKeys; `info` is null
225
+ * WHILE the instance's shape collects (self-referential layouts — `next:
226
+ * Box<T> | null` — re-enter by key and take the name without recursing)
227
+ * and stays null with `poisoned` set when collection fenced. */
228
+ export interface GenericClassInfo {
229
+ decl: ts.ClassDeclaration;
230
+ /** Unqualified source name, for diagnostics. */
231
+ baseName: string;
232
+ /** Declaration-order type parameter symbols. */
233
+ typeParams: ts.Symbol[];
234
+ family: ClassInfo;
235
+ instances: Map<string, {
236
+ name: string;
237
+ info: ClassInfo | null;
238
+ poisoned?: boolean;
239
+ }>;
240
+ }
241
+ /** The builtin Error hierarchy (Error + TypeError/RangeError/SyntaxError)
242
+ * as eagerly-registered ClassInfos: mapType names them the moment a lib
243
+ * Error type appears, so the infos must exist before any lowering. They
244
+ * are runtime-provided — no decl, no lowerable bodies; `new`/super()/
245
+ * toString reach them through dedicated error.* libCall lowerings, and
246
+ * user classes extend them like any base (the emitted subclass struct
247
+ * embeds ScrError's prefix). */
248
+ export declare function registerBuiltinErrorClasses(L: Lowerer): void;
249
+ /** The runtime-provided node:events EventEmitter as an eagerly-registered
250
+ * ClassInfo (the error-hierarchy story): mapType names `%EventEmitter`
251
+ * the moment an emitter type appears, so the info must exist before any
252
+ * lowering. No decl, no lowerable bodies — `new`/super() reach it
253
+ * through emitter.* libCalls, the method surface lowers through
254
+ * lower-emitter.ts, and user classes extend it like any base (the
255
+ * emitted subclass struct embeds ScrEmitter's registry/name prefix —
256
+ * carried by the BACKEND, not by IR fields, so the fields list stays
257
+ * empty and subclass field layout starts right after the prefix). */
258
+ export declare function registerBuiltinEmitterClass(L: Lowerer): void;
259
+ /** The runtime-provided node:stream classes as eagerly-registered
260
+ * ClassInfos (the emitter story): mapType names `%Readable` et al the
261
+ * moment a stream type appears, so the infos must exist before any
262
+ * lowering. Each roots at the emitter through its base chain, so the
263
+ * EventEmitter method surface, upcasts, and instanceof intervals apply
264
+ * unchanged; the stream method/property surface lowers through
265
+ * lower-stream.ts. No decl, no lowerable bodies, empty field lists —
266
+ * every instance is runtime-allocated (user `extends` is fenced). */
267
+ export declare function registerBuiltinStreamClasses(L: Lowerer): void;
268
+ /** The stream ClassInfo a VALUE symbol refers to (`new Readable(...)`,
269
+ * `x instanceof Writable`) — any import spelling resolves to the
270
+ * ambient class. Provenance: a stdlib-file CLASS declaration inside the
271
+ * "stream" ambient module, EXCLUDING @types/node's (whose stream.Readable
272
+ * also types child stdio — under @types/node the childStream mapping
273
+ * keeps priority and the static stream classes stand down; the shipped
274
+ * fallback declarations are the supported surface). */
275
+ export declare function builtinStreamInfoOf(L: Lowerer, symbol: ts.Symbol | null | undefined): ClassInfo | null;
276
+ /** The emitter ClassInfo a VALUE symbol refers to (`new EventEmitter`,
277
+ * `extends EventEmitter`, `x instanceof EventEmitter`) — any import
278
+ * spelling (named/default/namespace member, CJS require) resolves to
279
+ * the ambient class. Provenance-checked like the error classes: only a
280
+ * stdlib-file declaration inside the "events" ambient module counts. */
281
+ export declare function builtinEmitterInfoOf(L: Lowerer, symbol: ts.Symbol | null | undefined): ClassInfo | null;
282
+ /** The builtin error ClassInfo a VALUE symbol refers to (`new Error`,
283
+ * `extends TypeError`, `x instanceof RangeError`), or null. Provenance-
284
+ * checked: only the standard library's declarations count — a user's own
285
+ * `class Error` resolves through classBySymbol instead. */
286
+ export declare function builtinErrorInfoOf(L: Lowerer, symbol: ts.Symbol | null | undefined): ClassInfo | null;
287
+ /** The instance-method surface the runtime EventEmitter owns — subclass
288
+ * members with these names are fenced (collectClassShapeInner) and calls
289
+ * to them on emitter-rooted receivers lower through lower-emitter.ts. */
290
+ export declare const EMITTER_API_MEMBERS: ReadonlySet<string>;
291
+ /** The decorators of a class-like or member node (they live in
292
+ * `modifiers` since TS 4.8). */
293
+ export declare function decoratorNodesOf(n: ts.Node): ts.Decorator[];
294
+ /** The AMBIENT name a decorator expression's evaluation throws on, or
295
+ * null. Node erases ambient declarations (`declare let dec: any`,
296
+ * `declare const instance: T`, `declare function dec<T>(t: T): T`), so
297
+ * reading the name is a ReferenceError. Factory spellings ride along —
298
+ * `@dec(...)` evaluates the CALLEE before any argument — and property
299
+ * chains throw at their ROOT (`@instance.decorate` reads `instance`
300
+ * first). */
301
+ export declare function ambientDecoratorThrowNameOf(L: Lowerer, dExpr: ts.Expression): string | null;
302
+ /** The guaranteed decoration THROW of a decorated class, or null. Walks
303
+ * the class definition's evaluation-order items — class decorators
304
+ * (source order), the heritage expression, then per member in body
305
+ * order its decorators and computed key (the verified TC39/tsc-downlevel
306
+ * order) — and answers the first AMBIENT decorator name, provided every
307
+ * item BEFORE it is provably effect-free and non-throwing: bare
308
+ * identifier decorators over defined values (a pure read), an absent /
309
+ * `null` / bare-identifier heritage, literal or bare-identifier
310
+ * computed keys. Anything richer (factory calls over defined values,
311
+ * property-access reads, computed-key calls) stops the proof — the
312
+ * named fences answer instead. */
313
+ export declare function guaranteedDecorationThrow(L: Lowerer, decl: ts.ClassLikeDeclaration): {
314
+ name: string;
315
+ node: ts.Decorator;
316
+ } | null;
317
+ export declare function collectClassShape(L: Lowerer, decl: ts.ClassDeclaration): void;
318
+ export declare function collectClassShapeInner(L: Lowerer, decl: ts.ClassLikeDeclaration, jsNameOverride?: string, inst?: {
319
+ family: ClassInfo;
320
+ name: string;
321
+ bindings: Map<ts.Symbol, IrType>;
322
+ typeArgsText: string;
323
+ ordinal: number;
324
+ },
325
+ /** MIXIN instantiation mode (lower-mixins.ts): the class inside a
326
+ * mixin function, collected per call site — `base` is the ARGUMENT
327
+ * class (the heritage clause names the mixin's parameter and is
328
+ * resolved here, never through the loop below), `name` the
329
+ * position-derived instance name. */
330
+ mixin?: {
331
+ base: ClassInfo;
332
+ name: string;
333
+ call: ts.CallExpression;
334
+ bindings: Map<ts.Symbol, IrType>;
335
+ context: string;
336
+ ordinal: number;
337
+ }): void;
338
+ /** mapType's generic-class hook: the INSTANTIATION a concrete type
339
+ * reference (`Box<number>`) names — registered on first demand. The
340
+ * instance's NAME reserves its key before the shape collects, so
341
+ * self-referential layouts (`next: Box<T> | null`) re-enter here and
342
+ * take the name without recursing; a poisoned collection (a field type
343
+ * with no lowering under these bindings — the diagnostic carries the
344
+ * instantiation context) leaves the entry poisoned and the type
345
+ * unmapped, the fenced-JS-class story. Null answers (unmappable type
346
+ * arguments, the instance cap, an uncollected family) make the whole
347
+ * reference unmappable — per-site diagnostics own the fence. */
348
+ export declare function genericClassInstanceType(L: Lowerer, decl: ts.ClassLikeDeclaration, ref: ts.Type): IrType | null;
349
+ /** Runs a member-lowering thunk under an INSTANTIATION's type-parameter
350
+ * bindings (the generic-fn typeParamResolver mechanism) — the checker
351
+ * keeps reporting the unsubstituted `T`s inside the shared body AST.
352
+ * Coverage counts a generic class's statements once: only the FIRST
353
+ * instantiation contributes (the lowerGenericInstance rule). A no-op
354
+ * for ordinary classes. */
355
+ export declare function withInstanceBindings<T>(L: Lowerer, info: ClassInfo, fn: () => T): T;
356
+ /** The `%init` statements for one class's static readonly fields AND
357
+ * static blocks, interleaved in member order — emitted at the class
358
+ * statement's source position (see lowerFileInit's merge), exactly when
359
+ * JS evaluates static initializers and blocks. Field failures poison per
360
+ * field, like fieldInitStmts; a block lowers as the block statement it
361
+ * is, so its statements poison individually inside lowerStmts. */
362
+ export declare function lowerStaticFieldInits(L: Lowerer, info: ClassInfo): IrStmt[];
363
+ /** Post-collection analysis of a decorated class (all shapes registered —
364
+ * a decorator's return type may name a subclass declared BELOW the
365
+ * class). Classifies every class-level decorator by its checker type:
366
+ * exactly one parameter, itself a classval the decorated class legally
367
+ * flows into (the class, or a base sharing its completed constructor
368
+ * ABI — the classval widening rule), returning void/undefined (an
369
+ * effect-only decorator) or the class/a same-ABI subclass (a REPLACING
370
+ * decorator, whose result rebinds the name). Everything else is a named
371
+ * fence: the standard context parameter, structural sibling
372
+ * replacements tsc admits but the nominal classval world cannot carry,
373
+ * unions mixing the class with undefined. A replacing decorator
374
+ * registers the mutable classval global the name rebinds through, and
375
+ * fences the two shapes the value rebinding cannot keep exact —
376
+ * subclasses of the decorated class (the compiled hierarchy is fixed at
377
+ * build time; the runtime base would be the decoration result) and
378
+ * namespace-nested declarations (qualified references resolve the class
379
+ * directly, not through the rebound value). */
380
+ export declare function analyzeClassDecoration(L: Lowerer, info: ClassInfo): void;
381
+ /** The decoration statements of a decorated class — the %init code that
382
+ * runs at the class statement's position, BEFORE its static field
383
+ * initializers and blocks (lowerStaticFieldInits composes them; the
384
+ * lower-modules interleave places the whole bundle). Verified Node
385
+ * order: decorator expressions evaluate in SOURCE order (factories run
386
+ * here), then applications run in REVERSE member order over the class
387
+ * object, each replacing decorator's non-undefined result feeding the
388
+ * next application; the final value binds the class name (the mutable
389
+ * classval global) when any decorator can replace. */
390
+ export declare function lowerClassDecoration(L: Lowerer, info: ClassInfo): IrStmt[];
391
+ /** The nearest declaration of static member `name` at or above `info` —
392
+ * the compile-time prototype-chain walk (`D.x` reads C's global when C
393
+ * declared x and nothing between redeclares it; a redeclaration shadows
394
+ * with its OWN storage, exactly JS). */
395
+ export declare function findStaticOn(L: Lowerer, info: ClassInfo | null, name: string): {
396
+ declarer: ClassInfo;
397
+ field: ClassInfo["staticFields"][number];
398
+ method?: undefined;
399
+ } | {
400
+ declarer: ClassInfo;
401
+ method: {
402
+ params: ParamShape[];
403
+ ret: IrType;
404
+ member: ts.MethodDeclaration;
405
+ };
406
+ field?: undefined;
407
+ } | null;
408
+ /** True when some STRICT descendant of `info` redeclares static `name` —
409
+ * the through-a-VALUE devirtualization test: a classval(info) slot can
410
+ * hold any descendant, and a shadowing redeclaration means the runtime
411
+ * class decides which storage answers. */
412
+ export declare function staticShadowBelow(L: Lowerer, info: ClassInfo, name: string): boolean;
413
+ /** The nearest GENERIC static declaration of `name` at/above `info` —
414
+ * findStaticOn's twin over the genericStatics tables. */
415
+ export declare function findGenericStaticOn(L: Lowerer, info: ClassInfo | null, name: string): {
416
+ declarer: ClassInfo;
417
+ info: GenericFnInfo;
418
+ } | null;
419
+ /** The class itself taken as a VALUE (`const X = C`, an argument, an
420
+ * array element, a class expression's result): the classRef over the
421
+ * per-class immortal class object. The construct thunk needs a thunk-
422
+ * shaped constructor, so classes whose construction is libCall-shaped —
423
+ * the runtime-provided builtins and anything inheriting a builtin
424
+ * constructor (Error/EventEmitter/stream chains complete their `new`
425
+ * by special rules) — are named fences here. The constructor edge is
426
+ * noted at every classRef: a value can always be constructed through. */
427
+ export declare function classValueRef(L: Lowerer, info: ClassInfo, blame: ts.Node): IrExpr;
428
+ /** Constructor-ABI equality — the classval widening rule: a classval(D)
429
+ * value may flow into a classval(C) slot only when D's completed
430
+ * constructor signature equals C's (same count, modes, and ABI types),
431
+ * which is what keeps newValue completion against C's one signature
432
+ * sound for every value legally in the slot. */
433
+ export declare function ctorAbiEquals(L: Lowerer, sub: ClassInfo, sup: ClassInfo): boolean;
434
+ /** `C.x` where C is a class declared in the program and x a static
435
+ * member of its chain: field reads are the module global, static
436
+ * methods become interned closures, and `.name` folds to the class's
437
+ * compile-time name. Null for everything else — unresolved members
438
+ * fall through to the ordinary chain so the static fence or the
439
+ * generic member rejection names the site. */
440
+ export declare function lowerStaticFieldRead(L: Lowerer, expr: ts.PropertyAccessExpression): IrExpr | null;
441
+ /** A class EXPRESSION's ClassInfo: collection on first encounter (the
442
+ * declaration path over the shared ClassLikeDeclaration machinery, with
443
+ * NamedEvaluation supplying the runtime .name), idempotent per node —
444
+ * probeLower's speculative visits and the heritage recursion reuse the
445
+ * first collection. The honest v1 boundary is TOP-LEVEL evaluation
446
+ * positions only: each evaluation of a class expression in JS mints a
447
+ * DISTINCT class (fresh identity, fresh statics), and one immortal
448
+ * class object is exact only for expressions that evaluate exactly
449
+ * once. Statics-bearing expressions additionally restrict to positions
450
+ * where "immediately before the enclosing statement" IS the evaluation
451
+ * point (lowerFileInit drains pendingClassExprInits there). */
452
+ export declare function lowerClassExpressionInfo(L: Lowerer, expr: ts.ClassExpression): ClassInfo;
453
+ /** `class {…}` in expression position: a class definition bound to no
454
+ * statement — once the static side is a value, the expression IS the
455
+ * definition plus a classRef over it. A DECORATED class expression
456
+ * whose decoration provably throws (the ambient-decorator shape) never
457
+ * mints a class at all: evaluating the expression IS the
458
+ * ReferenceError, so it lowers to exactly that read — every evaluation
459
+ * throws identically, which is why the once-evaluated restriction and
460
+ * the member fences don't apply. */
461
+ export declare function lowerClassExpression(L: Lowerer, expr: ts.ClassExpression): IrExpr;
462
+ /** The EXACT class a receiver expression is statically known to BE (not
463
+ * merely be typed by): the class name itself, or a `const` binding
464
+ * whose initializer is a class expression / class name. Such receivers
465
+ * can never hold a subclass at runtime, so static WRITES through them
466
+ * hit the declaring class's storage exactly (the shadowing hazards of
467
+ * general class values don't arise). Null for everything else. */
468
+ export declare function exactClassOfReceiver(L: Lowerer, expr: ts.Expression): ClassInfo | null;
469
+ /** The class a PROPERTY-ASSIGNMENT binding pins — the salsa/CJS
470
+ * declaration forms of a class expression: `Common.I = class {…}`
471
+ * (expando members of a plain object), `exports.I = class {…}` /
472
+ * `module.exports.I = class {…}` (CJS member exports), and
473
+ * `module.exports = class {…}` (the whole-export replacement, whose
474
+ * export symbol requirer bindings alias to). The symbol arrives in two
475
+ * shapes — an ALIAS resolving to the class expression's own symbol
476
+ * (valueDeclaration IS the ts.ClassExpression), or the expando property
477
+ * symbol whose declarations are the assignment BinaryExpressions — and
478
+ * both pin the class exactly when ONE top-level assignment declares it:
479
+ * a reassigned property is a dynamic binding (the runtime class is
480
+ * whichever assignment ran last), so it answers null and the caller's
481
+ * fence names it. Collection is on demand and idempotent
482
+ * (lowerClassExpressionInfo), so resolution order between files and
483
+ * passes never matters. */
484
+ export declare function propertyAssignedClassInfoOf(L: Lowerer, symbol: ts.Symbol | null | undefined): ClassInfo | null;
485
+ /** `C.m(args)` / `X.m(args)` — static method calls, on the class name
486
+ * directly or through a class VALUE. Resolution walks the chain
487
+ * (nearest declarer, the compile-time prototype chain); through a
488
+ * VALUE the call devirtualizes exactly when no strict descendant
489
+ * redeclares the member (values never leave the static class's
490
+ * subtree). A func-typed static FIELD in call position reads the
491
+ * global and calls through the value. Null when the receiver isn't a
492
+ * class name/value or the member doesn't resolve (the fences name the
493
+ * site downstream). */
494
+ export declare function lowerStaticMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
495
+ /** Static member access through a class VALUE (`X.m` where X is
496
+ * classval-typed): devirtualized — the member resolves against the
497
+ * static class's chain, exact when no strict descendant redeclares it
498
+ * (values in the slot never leave the subtree). `X.name` is the one
499
+ * genuinely dynamic member: the class.name libCall reads the runtime
500
+ * class object's stored name. Null when the receiver isn't a class
501
+ * value or the member doesn't resolve. */
502
+ export declare function lowerClassValueProperty(L: Lowerer, expr: ts.PropertyAccessExpression): IrExpr | null;
503
+ /** The nearest declaration of `name` at or above `info` — the method a
504
+ * receiver of that static class runs when nothing below overrides it. */
505
+ export declare function findMethodOn(L: Lowerer, info: ClassInfo | null, name: string): {
506
+ declarer: ClassInfo;
507
+ sig: {
508
+ params: ParamShape[];
509
+ ret: IrType;
510
+ abstract?: true;
511
+ async?: true;
512
+ };
513
+ } | null;
514
+ /** True when `sub` is a STRICT descendant of `sup` in the class graph. */
515
+ export declare function isSubclassOf(L: Lowerer, sub: string, sup: string): boolean;
516
+ /** In an extends-hierarchy (as base or derived): the class carries a
517
+ * vtable and participates in dynamic instanceof; standalone classes keep
518
+ * their exact pre-inheritance layout and behavior. */
519
+ export declare function inHierarchy(L: Lowerer, info: ClassInfo): boolean;
520
+ /** True when some STRICT descendant of `info` declares `name` with a BODY
521
+ * — the whole-program devirtualization test: a call through this static
522
+ * class can reach a distinct implementation, so it must dispatch
523
+ * dynamically. Abstract re-declarations don't count (they carry no
524
+ * implementation; the concrete ones below them do, via the recursion). */
525
+ export declare function overrideBelow(L: Lowerer, info: ClassInfo, name: string): boolean;
526
+ /** The nearest GENERIC-method declaration of `name` at/above `info` —
527
+ * findMethodOn's twin over the genericMethods tables. */
528
+ export declare function findGenericMethodOn(L: Lowerer, info: ClassInfo | null, name: string): {
529
+ declarer: ClassInfo;
530
+ info: GenericFnInfo;
531
+ } | null;
532
+ /** True when some STRICT descendant of `info` re-declares the generic
533
+ * method `name` — overrideBelow's twin: generic methods have no vtable
534
+ * slot, so a call that could reach an override compiles only when the
535
+ * receiver's runtime class is statically exact. */
536
+ export declare function genericOverrideBelow(L: Lowerer, info: ClassInfo, name: string): boolean;
537
+ /** The receiver's EXACT runtime class, when the expression proves it: a
538
+ * `new C(...)` expression directly, or a const binding initialized with
539
+ * one (the binding can never be reassigned to a subclass instance).
540
+ * The class is read off the mapped INITIALIZER type — a `const b: Base =
541
+ * new D()` receiver is exactly D, not its annotation. Distinct from
542
+ * exactClassOfReceiver, which answers for CLASS-VALUE receivers. */
543
+ export declare function exactInstanceClassOf(L: Lowerer, expr: ts.Expression): ClassInfo | null;
544
+ /** `recv.m<T>(args)` — a GENERIC method call, dispatched STATICALLY: the
545
+ * checker's resolved signature (type arguments substituted, inferred or
546
+ * explicit) keys one instantiation of the nearest declarer's body, and
547
+ * the call is a direct `call` of `%C.m%n` over the (up/down)cast
548
+ * receiver. No per-instantiation vtable slots exist, so a receiver whose
549
+ * runtime class could OVERRIDE the method (genericOverrideBelow) must be
550
+ * statically exact (exactInstanceClassOf) — the override set then
551
+ * resolves at compile time — or fences by name. */
552
+ export declare function lowerClassGenericMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, recvInfo: ClassInfo, found: {
553
+ declarer: ClassInfo;
554
+ info: GenericFnInfo;
555
+ }): IrExpr;
556
+ /** Wraps a derived-class expression in an upcast when the target base
557
+ * class differs (a no-op reinterpret at runtime; keeps IR types exact). */
558
+ export declare function upcastTo(L: Lowerer, expr: IrExpr, className: string): IrExpr;
559
+ export declare function lowerClassMembers(L: Lowerer, info: ClassInfo): IrFunction[];
560
+ /** The constructor function `%C.constructor`. Synthesized when absent: a
561
+ * base class runs just its field initializers; a derived class inherits
562
+ * the base's signature — forward every param to super(), then run own
563
+ * field initializers. */
564
+ export declare function lowerClassCtor(L: Lowerer, info: ClassInfo): IrFunction;
565
+ /** The lowered method-map name of a class member: identifier text, a
566
+ * COMPUTED name that folds to one compile-time string
567
+ * (foldedStringKeyOf — the object-literal computed-key machinery
568
+ * applied to method positions; tsc late-bound the member under exactly
569
+ * that name), or the reserved slot "sym:iterator" for
570
+ * `[Symbol.iterator]` (a name no user identifier can spell — the
571
+ * accessor "get:x" convention; for-of, spreads, and array destructuring
572
+ * dispatch to it through the iterator protocol). Null for genuinely
573
+ * runtime-keyed names — the computed-member fences stay. */
574
+ export declare function classMemberNameOf(L: Lowerer, name: ts.PropertyName): string | null;
575
+ /** A class type's ITERATOR PROTOCOL shape, statically resolved: the
576
+ * receiver declares (or inherits) `[Symbol.iterator]()` (the
577
+ * "sym:iterator" method slot) returning a class whose zero-parameter
578
+ * `next()` returns a record with a `value` field and an optional
579
+ * boolean `done` field (`{ value, done: false }` — the self-iterator
580
+ * idiom returns `this`, so the iterator class is usually the receiver
581
+ * itself). A MISSING done field never terminates — exactly JS, where
582
+ * `undefined` is falsy forever (Node loops forever too; corpus
583
+ * iterators of that shape are deliberately infinite). Iterator classes
584
+ * declaring `return`/`throw` members stay out — the desugars below
585
+ * never call IteratorClose, and silently skipping a declared return()
586
+ * would drop user cleanup. Null when the shape doesn't hold — callers
587
+ * keep their fences. */
588
+ export interface ClassIteratorInfo {
589
+ /** The `[Symbol.iterator]()` call's receiver class + its declarer. */
590
+ className: string;
591
+ /** The iterator object's type (the method's return). */
592
+ iterT: IrType & {
593
+ kind: "object";
594
+ };
595
+ /** next()'s result record type. */
596
+ resultT: IrType & {
597
+ kind: "record";
598
+ };
599
+ valueT: IrType;
600
+ /** False: no done field — the protocol never terminates. */
601
+ hasDone: boolean;
602
+ }
603
+ export declare function classIteratorOf(L: Lowerer, t: IrType): ClassIteratorInfo | null;
604
+ /** The `it.next()` step of a class iterator as an ordinary (possibly
605
+ * virtual) method call. */
606
+ export declare function classIteratorNextCall(L: Lowerer, cit: ClassIteratorInfo, itRef: IrExpr, loc: SrcLoc): IrExpr;
607
+ /** `recv[Symbol.iterator]()` as an ordinary method call. */
608
+ export declare function classIteratorOpenCall(L: Lowerer, cit: ClassIteratorInfo, recv: IrExpr, loc: SrcLoc): IrExpr;
609
+ /** `[...new C]` / `f(...new C)` over a CLASS ITERABLE: the eager drain —
610
+ * an interned `%iter.drain.<n>(recv)` lifted function running the
611
+ * whole protocol into a fresh element array (a doneless iterator loops
612
+ * forever, exactly Node's spread of an infinite iterator). `elemT`
613
+ * (default: the iterator's own value type) is the DESTINATION element —
614
+ * a spread into a union-element literal (`[...numbers, ...symbols]` as
615
+ * `(number | symbol)[]`) pushes each value wrapped into its arm. Null
616
+ * when the value isn't a recognized class iterable or the element
617
+ * doesn't coerce — spread fences stay. */
618
+ export declare function classIteratorDrainCall(L: Lowerer, src: IrExpr, loc: SrcLoc, elemT?: IrType): IrExpr | null;
619
+ /** The tail of a class iterable's protocol from an already-open ITERATOR
620
+ * object (`var [a, ...rest] = new C` — the rest element drains whatever
621
+ * next() still yields): the drain loop keyed by the iterator class. */
622
+ export declare function classIteratorRestDrainCall(L: Lowerer, cit: ClassIteratorInfo, itVal: IrExpr, loc: SrcLoc): IrExpr;
623
+ /** One method or accessor body as its module function `%C.name`
624
+ * (accessors are methods with property syntax: "get:x"/"set:x" entries —
625
+ * see collectClassShape). */
626
+ export declare function lowerClassMethodMember(L: Lowerer, info: ClassInfo, fnLike: ts.MethodDeclaration | ts.AccessorDeclaration): IrFunction | null;
627
+ /** One static method body as its module function `%C.static:m` — an
628
+ * ordinary function with NO `this` param. `this` and `super` inside
629
+ * name the RECEIVER class in JS (dynamic — `F.who()` sees F even when
630
+ * who() is declared on E), which has no static story here: both are
631
+ * named fences, with arrow functions transparent (they inherit the
632
+ * method's `this`) and this-binding function forms opaque — the static-
633
+ * block rule verbatim. */
634
+ export declare function lowerStaticMethod(L: Lowerer, info: ClassInfo, name: string): IrFunction | null;
635
+ /** A synthesized throwing setter: a getter-only override shadows the
636
+ * inherited pair (JS), so a base-typed write dispatches HERE and must
637
+ * throw exactly like Node's TypeError — a real instance (a typed catch's
638
+ * `e instanceof TypeError` matches), catchable, exit 1 uncaught (message
639
+ * text is compiler-worded; stdout and exit code are the contract). */
640
+ export declare function throwingSetterFn(L: Lowerer, info: ClassInfo, prop: string): IrFunction;
641
+ /** The base a constructor chain actually CALLS into: generic FAMILIES are
642
+ * never constructed (no `%<family>.constructor` exists), so an
643
+ * instantiation's construction-relevant base is the family's own base —
644
+ * null when the generic class extends nothing, exactly the source's
645
+ * story (tsc forbids super() there). Ordinary classes answer their base
646
+ * unchanged. */
647
+ export declare function superBaseOf(info: ClassInfo): ClassInfo | null;
648
+ /** The class's OWN field initializers as fieldSet statements (declaration
649
+ * order) — a base constructor's prologue, a derived constructor's
650
+ * super()-return continuation. */
651
+ export declare function fieldInitStmts(L: Lowerer, info: ClassInfo, thisLocal: IrLocal): IrStmt[];
652
+ /** PARAMETER-PROPERTY assignments (`this.x = x`, synthesized): run AFTER
653
+ * the field initializers — Node's transform defines the fields at the
654
+ * top of the class body (undefined until assigned) and injects the
655
+ * assignments at the start of the constructor body, i.e. after super()
656
+ * and after the (native) field initializers ran (probed: a field
657
+ * initializer reading `this.x` sees undefined; the body sees the value).
658
+ * Each assignment reads the parameter's BODY local (defaults already
659
+ * applied by the declareParams prologue), whose type the collection made
660
+ * the field's type — slot-exact by construction. */
661
+ export declare function paramPropInitStmts(L: Lowerer, info: ClassInfo, thisLocal: IrLocal): IrStmt[];
662
+ /** A derived constructor's body: statements lower as usual EXCEPT the
663
+ * top-level `super(...)` statement, which becomes a direct call to the
664
+ * base constructor over the same `this`, immediately followed by this
665
+ * class's field initializers (JS runs them when super returns). tsc
666
+ * guarantees a super call exists and runs before any this-use; the
667
+ * supported form is a top-level expression statement — anywhere else
668
+ * (conditionals, expression positions) is rejected, not misordered. */
669
+ export declare function lowerDerivedCtorBody(L: Lowerer, info: ClassInfo, thisLocal: IrLocal,
670
+ /** Mixin forwarding-constructor mode: `super(...args)` forwards these
671
+ * pre-declared synthetic params directly (the spread never lowers —
672
+ * the base's ABI is this constructor's ABI). */
673
+ forward?: IrExpr[]): IrStmt[];
674
+ /** `super(args)` → direct call of the base constructor with the SAME
675
+ * `this` (upcast; retained by the varRef read — the callee owns and
676
+ * releases its param per the universal convention). */
677
+ export declare function superCallStmt(L: Lowerer, info: ClassInfo, thisLocal: IrLocal, args: IrExpr[], loc: SrcLoc): IrStmt;
678
+ /** `super.method(args)`: the base chain's implementation, called
679
+ * DIRECTLY over this method's own `this` (upcast to the declarer) —
680
+ * super dispatch is static in JS too, never through the dynamic class. */
681
+ export declare function lowerSuperMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr;
682
+ /** The `this` reference for super accessor reads/writes, with the shared
683
+ * validity checks (derived-class body, resolvable this). */
684
+ export declare function superThisRef(L: Lowerer, access: ts.PropertyAccessExpression): {
685
+ thisRef: IrExpr;
686
+ base: ClassInfo;
687
+ };
688
+ /** `super.x` read: a DIRECT call of the base chain's getter over this
689
+ * method's own `this` (upcast to the declarer) — like super.method(),
690
+ * never through the vtable. */
691
+ export declare function lowerSuperAccessorRead(L: Lowerer, access: ts.PropertyAccessExpression): IrExpr;
692
+ /** `super.x = v`: a DIRECT call of the base chain's setter (same
693
+ * static-dispatch rule as every super member access). */
694
+ export declare function lowerSuperAccessorWrite(L: Lowerer, access: ts.PropertyAccessExpression, rhs: ts.Expression, loc: SrcLoc): IrStmt;
695
+ /** True when `info`'s EFFECTIVE constructor — its own, or the one
696
+ * inherited through ctor-less bases — is a builtin error class's. Such
697
+ * classes construct with the error message rule, and their synthesized
698
+ * constructors forward one plain string to error.ctor. */
699
+ export declare function inheritsBuiltinErrorCtor(L: Lowerer, info: ClassInfo): boolean;
700
+ /** The EventEmitter twin: a ctor-less chain into the emitter base
701
+ * inherits `new C()` — zero arguments (the options bag fences). */
702
+ export declare function inheritsBuiltinEmitterCtor(L: Lowerer, info: ClassInfo): boolean;
703
+ /** The stream twin: a ctor-less chain into a runtime stream base
704
+ * inherits `new C()` — zero arguments (the synthesized constructor runs
705
+ * super() with default options; passing options through an inherited
706
+ * constructor would need the literal at the new-site to plumb, so it
707
+ * asks for a declared constructor instead). */
708
+ export declare function inheritsBuiltinStreamCtor(L: Lowerer, info: ClassInfo): boolean;
709
+ /** `new C(args)` for a class declared in the program (imports resolve
710
+ * through aliases, so cross-module classes construct too). */
711
+ /** The single message argument of a builtin Error construction or
712
+ * super() call: "" when omitted or explicitly undefined (Node's message
713
+ * property default), the string otherwise. The lib signature's second
714
+ * parameter (options/cause) has no lowering. */
715
+ export declare function errorMessageArg(L: Lowerer, args: readonly ts.Expression[], loc: SrcLoc, blame: ts.Node): IrExpr;
716
+ /** A class whose decoration provably throws has no reachable VALUE form:
717
+ * the binding never initializes (the %init ReferenceError unwinds first),
718
+ * so `new`, the class as a value, and `extends` all fence — reaching one
719
+ * in compiled code would require executing past the throw. */
720
+ export declare function fenceDecorationThrows(L: Lowerer, info: ClassInfo, blame: ts.Node): void;
721
+ export declare function lowerNew(L: Lowerer, expr: ts.NewExpression): IrExpr;
722
+ /** A getter/setter invocation over an accessor target's receiver — the
723
+ * same whole-program devirtualization as method calls: a virtualCall
724
+ * when some strict subclass of the receiver's static class overrides
725
+ * this HALF of the accessor (get and set devirtualize independently),
726
+ * a direct call of the nearest declaration otherwise. */
727
+ export declare function accessorCall(L: Lowerer, className: string, member: string, obj: IrExpr, extraArgs: IrExpr[], ret: IrType, loc: SrcLoc): IrExpr;