@scriptc/compiler 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/ambient/package.json +3 -0
- package/ambient/scriptc-node-fallback.d.ts +3001 -0
- package/ambient/scriptc-overrides.d.ts +95 -0
- package/ambient/scriptc.d.ts +74 -0
- package/dist/backend/cc.d.ts +169 -0
- package/dist/backend/cc.js +897 -0
- package/dist/backend/cc.js.map +1 -0
- package/dist/backend/emission/emit-async.d.ts +145 -0
- package/dist/backend/emission/emit-async.js +996 -0
- package/dist/backend/emission/emit-async.js.map +1 -0
- package/dist/backend/emission/emit-exprs.d.ts +3 -0
- package/dist/backend/emission/emit-exprs.js +5947 -0
- package/dist/backend/emission/emit-exprs.js.map +1 -0
- package/dist/backend/emission/emit-island.d.ts +45 -0
- package/dist/backend/emission/emit-island.js +271 -0
- package/dist/backend/emission/emit-island.js.map +1 -0
- package/dist/backend/emission/emit-shapes.d.ts +142 -0
- package/dist/backend/emission/emit-shapes.js +575 -0
- package/dist/backend/emission/emit-shapes.js.map +1 -0
- package/dist/backend/emission/emit-stmts.d.ts +78 -0
- package/dist/backend/emission/emit-stmts.js +960 -0
- package/dist/backend/emission/emit-stmts.js.map +1 -0
- package/dist/backend/emission/emit-types.d.ts +65 -0
- package/dist/backend/emission/emit-types.js +652 -0
- package/dist/backend/emission/emit-types.js.map +1 -0
- package/dist/backend/emission/emit-walkers.d.ts +154 -0
- package/dist/backend/emission/emit-walkers.js +1587 -0
- package/dist/backend/emission/emit-walkers.js.map +1 -0
- package/dist/backend/emission/emitter.d.ts +452 -0
- package/dist/backend/emission/emitter.js +1249 -0
- package/dist/backend/emission/emitter.js.map +1 -0
- package/dist/backend/emission/may-throw.d.ts +15 -0
- package/dist/backend/emission/may-throw.js +250 -0
- package/dist/backend/emission/may-throw.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +21 -0
- package/dist/backend/llvm/blocks.js +68 -0
- package/dist/backend/llvm/blocks.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +84 -0
- package/dist/backend/llvm/classes.js +438 -0
- package/dist/backend/llvm/classes.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +123 -0
- package/dist/backend/llvm/dyn.js +2624 -0
- package/dist/backend/llvm/dyn.js.map +1 -0
- package/dist/backend/llvm/emitter.d.ts +3 -0
- package/dist/backend/llvm/emitter.js +10087 -0
- package/dist/backend/llvm/emitter.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +78 -0
- package/dist/backend/llvm/shapes.js +754 -0
- package/dist/backend/llvm/shapes.js.map +1 -0
- package/dist/backend/llvm/unsupported.d.ts +6 -0
- package/dist/backend/llvm/unsupported.js +12 -0
- package/dist/backend/llvm/unsupported.js.map +1 -0
- package/dist/backend/llvm/walkers.d.ts +58 -0
- package/dist/backend/llvm/walkers.js +793 -0
- package/dist/backend/llvm/walkers.js.map +1 -0
- package/dist/backend/mangle.d.ts +124 -0
- package/dist/backend/mangle.js +232 -0
- package/dist/backend/mangle.js.map +1 -0
- package/dist/coverage/report.d.ts +64 -0
- package/dist/coverage/report.js +226 -0
- package/dist/coverage/report.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +140 -0
- package/dist/diagnostics/diagnostic.js +458 -0
- package/dist/diagnostics/diagnostic.js.map +1 -0
- package/dist/diagnostics/render.d.ts +11 -0
- package/dist/diagnostics/render.js +58 -0
- package/dist/diagnostics/render.js.map +1 -0
- package/dist/frontend/cjs-lexer.d.ts +20 -0
- package/dist/frontend/cjs-lexer.js +813 -0
- package/dist/frontend/cjs-lexer.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.d.ts +1 -0
- package/dist/frontend/lowering/http2-constants.js +251 -0
- package/dist/frontend/lowering/http2-constants.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +6 -0
- package/dist/frontend/lowering/lib-boundary.js +143 -0
- package/dist/frontend/lowering/lib-boundary.js.map +1 -0
- package/dist/frontend/lowering/lower-assert.d.ts +18 -0
- package/dist/frontend/lowering/lower-assert.js +1269 -0
- package/dist/frontend/lowering/lower-assert.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +511 -0
- package/dist/frontend/lowering/lower-builtins.js +5249 -0
- package/dist/frontend/lowering/lower-builtins.js.map +1 -0
- package/dist/frontend/lowering/lower-calls.d.ts +581 -0
- package/dist/frontend/lowering/lower-calls.js +6281 -0
- package/dist/frontend/lowering/lower-calls.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +727 -0
- package/dist/frontend/lowering/lower-classes.js +4701 -0
- package/dist/frontend/lowering/lower-classes.js.map +1 -0
- package/dist/frontend/lowering/lower-comptime.d.ts +53 -0
- package/dist/frontend/lowering/lower-comptime.js +244 -0
- package/dist/frontend/lowering/lower-comptime.js.map +1 -0
- package/dist/frontend/lowering/lower-containers.d.ts +483 -0
- package/dist/frontend/lowering/lower-containers.js +6281 -0
- package/dist/frontend/lowering/lower-containers.js.map +1 -0
- package/dist/frontend/lowering/lower-dgram.d.ts +20 -0
- package/dist/frontend/lowering/lower-dgram.js +319 -0
- package/dist/frontend/lowering/lower-dgram.js.map +1 -0
- package/dist/frontend/lowering/lower-emitter.d.ts +10 -0
- package/dist/frontend/lowering/lower-emitter.js +688 -0
- package/dist/frontend/lowering/lower-emitter.js.map +1 -0
- package/dist/frontend/lowering/lower-enums.d.ts +22 -0
- package/dist/frontend/lowering/lower-enums.js +235 -0
- package/dist/frontend/lowering/lower-enums.js.map +1 -0
- package/dist/frontend/lowering/lower-expando.d.ts +35 -0
- package/dist/frontend/lowering/lower-expando.js +276 -0
- package/dist/frontend/lowering/lower-expando.js.map +1 -0
- package/dist/frontend/lowering/lower-exprs.d.ts +524 -0
- package/dist/frontend/lowering/lower-exprs.js +8099 -0
- package/dist/frontend/lowering/lower-exprs.js.map +1 -0
- package/dist/frontend/lowering/lower-generators.d.ts +50 -0
- package/dist/frontend/lowering/lower-generators.js +421 -0
- package/dist/frontend/lowering/lower-generators.js.map +1 -0
- package/dist/frontend/lowering/lower-inspect.d.ts +20 -0
- package/dist/frontend/lowering/lower-inspect.js +1069 -0
- package/dist/frontend/lowering/lower-inspect.js.map +1 -0
- package/dist/frontend/lowering/lower-island.d.ts +108 -0
- package/dist/frontend/lowering/lower-island.js +650 -0
- package/dist/frontend/lowering/lower-island.js.map +1 -0
- package/dist/frontend/lowering/lower-mixins.d.ts +96 -0
- package/dist/frontend/lowering/lower-mixins.js +534 -0
- package/dist/frontend/lowering/lower-mixins.js.map +1 -0
- package/dist/frontend/lowering/lower-modules.d.ts +135 -0
- package/dist/frontend/lowering/lower-modules.js +1613 -0
- package/dist/frontend/lowering/lower-modules.js.map +1 -0
- package/dist/frontend/lowering/lower-namespaces.d.ts +168 -0
- package/dist/frontend/lowering/lower-namespaces.js +706 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -0
- package/dist/frontend/lowering/lower-server.d.ts +90 -0
- package/dist/frontend/lowering/lower-server.js +3471 -0
- package/dist/frontend/lowering/lower-server.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +361 -0
- package/dist/frontend/lowering/lower-stmts.js +5341 -0
- package/dist/frontend/lowering/lower-stmts.js.map +1 -0
- package/dist/frontend/lowering/lower-stream.d.ts +88 -0
- package/dist/frontend/lowering/lower-stream.js +1533 -0
- package/dist/frontend/lowering/lower-stream.js.map +1 -0
- package/dist/frontend/lowering/lower-test.d.ts +27 -0
- package/dist/frontend/lowering/lower-test.js +353 -0
- package/dist/frontend/lowering/lower-test.js.map +1 -0
- package/dist/frontend/lowering/lowerer.d.ts +1748 -0
- package/dist/frontend/lowering/lowerer.js +6256 -0
- package/dist/frontend/lowering/lowerer.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +272 -0
- package/dist/frontend/lowering/surfaces.js +1096 -0
- package/dist/frontend/lowering/surfaces.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +55 -0
- package/dist/frontend/npm-static.js +300 -0
- package/dist/frontend/npm-static.js.map +1 -0
- package/dist/frontend/npm.d.ts +330 -0
- package/dist/frontend/npm.js +1259 -0
- package/dist/frontend/npm.js.map +1 -0
- package/dist/frontend/program.d.ts +186 -0
- package/dist/frontend/program.js +2172 -0
- package/dist/frontend/program.js.map +1 -0
- package/dist/frontend/provenance-registry.d.ts +48 -0
- package/dist/frontend/provenance-registry.js +87 -0
- package/dist/frontend/provenance-registry.js.map +1 -0
- package/dist/frontend/provenance.d.ts +6 -0
- package/dist/frontend/provenance.js +459 -0
- package/dist/frontend/provenance.js.map +1 -0
- package/dist/frontend/resolve.d.ts +56 -0
- package/dist/frontend/resolve.js +682 -0
- package/dist/frontend/resolve.js.map +1 -0
- package/dist/frontend/shared.d.ts +60 -0
- package/dist/frontend/shared.js +232 -0
- package/dist/frontend/shared.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +7 -0
- package/dist/frontend/ts7/adapter.js +54 -0
- package/dist/frontend/ts7/adapter.js.map +1 -0
- package/dist/frontend/ts7/ast.d.ts +50 -0
- package/dist/frontend/ts7/ast.js +211 -0
- package/dist/frontend/ts7/ast.js.map +1 -0
- package/dist/frontend/ts7/census-check.d.ts +1 -0
- package/dist/frontend/ts7/census-check.js +12 -0
- package/dist/frontend/ts7/census-check.js.map +1 -0
- package/dist/frontend/ts7/checker.d.ts +140 -0
- package/dist/frontend/ts7/checker.js +544 -0
- package/dist/frontend/ts7/checker.js.map +1 -0
- package/dist/frontend/ts7/enums.d.ts +18 -0
- package/dist/frontend/ts7/enums.js +43 -0
- package/dist/frontend/ts7/enums.js.map +1 -0
- package/dist/frontend/ts7/program.d.ts +99 -0
- package/dist/frontend/ts7/program.js +278 -0
- package/dist/frontend/ts7/program.js.map +1 -0
- package/dist/frontend/ts7/world-check.d.ts +3 -0
- package/dist/frontend/ts7/world-check.js +34 -0
- package/dist/frontend/ts7/world-check.js.map +1 -0
- package/dist/frontend/types.d.ts +205 -0
- package/dist/frontend/types.js +2485 -0
- package/dist/frontend/types.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +424 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/nodes.d.ts +4334 -0
- package/dist/ir/nodes.js +1906 -0
- package/dist/ir/nodes.js.map +1 -0
- package/dist/ir/serialize.d.ts +4 -0
- package/dist/ir/serialize.js +34 -0
- package/dist/ir/serialize.js.map +1 -0
- package/dist/ir/validate.d.ts +36 -0
- package/dist/ir/validate.js +4884 -0
- package/dist/ir/validate.js.map +1 -0
- package/package.json +30 -6
- package/README.md +0 -3
- package/index.js +0 -2
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import * as ts from "../ts7/adapter.js";
|
|
2
|
+
import type { Lowerer } from "./lowerer.js";
|
|
3
|
+
import { IrExpr, IrFunction, IrStmt, IrType, SrcLoc } from "../../ir/nodes.js";
|
|
4
|
+
import { type ClassInfo } from "./lower-classes.js";
|
|
5
|
+
/** How a parameter participates in CALL-SITE COMPLETION (the frontend
|
|
6
|
+
* completes every call to the one full signature, so the IR and backends
|
|
7
|
+
* stay count-exact — see docs/ir.md). `required` params must be passed;
|
|
8
|
+
* `omittable` params (declared `x?: T` or `x: T = e`) may be omitted by a
|
|
9
|
+
* trailing-suffix call, and the frontend appends the interned undefined arm;
|
|
10
|
+
* `rest` (always last) receives the surplus arguments packed into one array
|
|
11
|
+
* literal at each call site. */
|
|
12
|
+
export type ParamMode = "required" | "omittable" | "rest" | "dynRest";
|
|
13
|
+
/** One parameter of a signature, as call sites and callee prologues see it.
|
|
14
|
+
* `type` is the ABI type — what the emitted C parameter carries: the
|
|
15
|
+
* checker's `T | undefined` union for `x?: T`, a synthesized `T | undefined`
|
|
16
|
+
* union for `x: T = e`, `T[]` for `...xs: T[]`, the plain declared type
|
|
17
|
+
* otherwise. `bodyType` is present exactly for DEFAULTED params: the plain T
|
|
18
|
+
* the body sees after the prologue applies the default (see declareParams). */
|
|
19
|
+
export interface ParamShape {
|
|
20
|
+
type: IrType;
|
|
21
|
+
mode: ParamMode;
|
|
22
|
+
bodyType?: IrType;
|
|
23
|
+
}
|
|
24
|
+
export interface FnSig {
|
|
25
|
+
name: string;
|
|
26
|
+
params: ParamShape[];
|
|
27
|
+
/** Call-site result type — Promise<inner> for async functions, the
|
|
28
|
+
* generator type for generator functions. */
|
|
29
|
+
returnType: IrType;
|
|
30
|
+
/** Async: the IrFunction's returnType is the promise's INNER type. */
|
|
31
|
+
isAsync?: boolean;
|
|
32
|
+
/** Generator: the IrFunction's returnType is the TReturn channel; the
|
|
33
|
+
* yield/next channels ride here (IrFunction.generator's exact shape). */
|
|
34
|
+
generator?: {
|
|
35
|
+
yieldT: IrType;
|
|
36
|
+
nextT: IrType;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Instantiation cap per generic function: same-key recursion (`len<T>`
|
|
40
|
+
* calling itself) converges, but POLYMORPHIC recursion (`f<T>` calling
|
|
41
|
+
* `f<T[]>`) would request new instances forever — the cap turns that into a
|
|
42
|
+
* diagnostic instead of a hang. */
|
|
43
|
+
export declare const MAX_GENERIC_INSTANCES = 100;
|
|
44
|
+
/** A generic function-like declaration, collected instead of an FnSig —
|
|
45
|
+
* top-level generic function declarations, class GENERIC METHODS (own type
|
|
46
|
+
* parameters, instance and static), and object-literal generic methods.
|
|
47
|
+
* The body is NOT lowered at collection: each call site's checker-resolved
|
|
48
|
+
* signature (type arguments substituted) becomes an instantiation key, and
|
|
49
|
+
* the body is lowered once per distinct key (monomorphization). */
|
|
50
|
+
export interface GenericFnInfo {
|
|
51
|
+
decl: ts.FunctionDeclaration | ts.MethodDeclaration | ts.FunctionExpression | ts.ArrowFunction;
|
|
52
|
+
/** Unqualified source name, for diagnostics. */
|
|
53
|
+
baseName: string;
|
|
54
|
+
/** Program-wide qualified name; instance `n` is named `<qualified>%<n>`
|
|
55
|
+
* ('%' cannot appear in a TS identifier, so instance names can never
|
|
56
|
+
* collide with user functions). */
|
|
57
|
+
qualifiedName: string;
|
|
58
|
+
/** Declaration-order type parameter symbols. */
|
|
59
|
+
typeParams: ts.Symbol[];
|
|
60
|
+
/** Instantiation key (comma-joined typeKeys of the mapped param types +
|
|
61
|
+
* `=>` + return typeKey) → instance. Key identity IS signature identity:
|
|
62
|
+
* two call sites whose inferred types map to the same IR types share one
|
|
63
|
+
* native function. */
|
|
64
|
+
instances: Map<string, GenericInstance>;
|
|
65
|
+
/** CLASS-member generic methods: the declaring ClassInfo and flavor.
|
|
66
|
+
* Instance methods take `this` (object:<declarer>) as param 0 and lower
|
|
67
|
+
* under the declarer's instantiation bindings (generic-class receivers)
|
|
68
|
+
* MERGED with the method instantiation's own; statics lower as plain
|
|
69
|
+
* module functions with the static-method this/super fence. Absent for
|
|
70
|
+
* top-level functions and object-literal methods. */
|
|
71
|
+
member?: {
|
|
72
|
+
cls: ClassInfo;
|
|
73
|
+
kind: "method" | "static";
|
|
74
|
+
};
|
|
75
|
+
/** Object-literal generic methods (`{ m<T>(x: T) {...} }` and generic
|
|
76
|
+
* arrow/function-expression properties): lowered as plain module
|
|
77
|
+
* functions — `this` inside is fenced (rejectThisInObjectMethod) and the
|
|
78
|
+
* defining literal must sit at module scope (no enclosing frame to
|
|
79
|
+
* capture). */
|
|
80
|
+
objectLiteral?: true;
|
|
81
|
+
/** IMPLICIT-ANY monomorphization (npm-static JS): parallel to
|
|
82
|
+
* decl.parameters — the param's own symbol when the slot is a BINDABLE
|
|
83
|
+
* implicit-any parameter (untyped, identifier-named, never written in
|
|
84
|
+
* the body), null for typed or unbindable slots. Present ⇔ this info
|
|
85
|
+
* monomorphizes over its implicit-any params instead of declared type
|
|
86
|
+
* parameters (typeParams stays empty): each call site's WIDENED argument
|
|
87
|
+
* checker types key an instantiation, exactly the generic machinery —
|
|
88
|
+
* the untyped params ARE the type parameters (see implicitCallInstance). */
|
|
89
|
+
implicitParams?: (ts.Symbol | null)[];
|
|
90
|
+
}
|
|
91
|
+
export interface GenericInstance {
|
|
92
|
+
name: string;
|
|
93
|
+
/** 0 for the first instance of a base function — the only one whose
|
|
94
|
+
* statements count toward coverage stats (re-instantiations re-visit the
|
|
95
|
+
* same source lines). */
|
|
96
|
+
ordinal: number;
|
|
97
|
+
params: ParamShape[];
|
|
98
|
+
returnType: IrType;
|
|
99
|
+
/** Type-parameter symbol → concrete IR type, consulted by mapType (via
|
|
100
|
+
* typeParamResolver) while the instance body lowers. */
|
|
101
|
+
bindings: Map<ts.Symbol, IrType>;
|
|
102
|
+
/** Rendered type arguments ("<number, string>") for diagnostics. */
|
|
103
|
+
typeArgsText: string;
|
|
104
|
+
/** Implicit instances only: param symbol → the call site's (widened)
|
|
105
|
+
* checker type, consulted by the Lowerer's typeOf while this instance's
|
|
106
|
+
* body lowers (the implicit twin of `bindings`). */
|
|
107
|
+
implicitArgTypes?: Map<ts.Symbol, ts.Type>;
|
|
108
|
+
/** Implicit instances only: eager-lowering lifecycle. "lowering" while
|
|
109
|
+
* the body builds (a re-demand is same-key recursion: the caller uses
|
|
110
|
+
* the PINNED fallback returnType and returnPinned locks it); "done" once
|
|
111
|
+
* returnType holds the inferred (or pinned) truth. */
|
|
112
|
+
implicitState?: "lowering" | "done";
|
|
113
|
+
/** Same-key recursion observed the fallback return type mid-lowering, so
|
|
114
|
+
* the ABI is locked to it — the return post-pass coerces every return
|
|
115
|
+
* value to the pinned type instead of adopting the inferred one. */
|
|
116
|
+
returnPinned?: boolean;
|
|
117
|
+
/** Implicit instances only: the declared return did not map (the
|
|
118
|
+
* any-params poisoned it) — the body lowers in return-INFERENCE mode
|
|
119
|
+
* (returnType holds the DYN recursion pin until the post-pass settles). */
|
|
120
|
+
implicitInferReturn?: true;
|
|
121
|
+
}
|
|
122
|
+
/** One parameter's ParamShape — the shared signature-shaped collection
|
|
123
|
+
* point for function declarations, methods, constructors, and lambdas
|
|
124
|
+
* (generic declarations defer to their call sites, where the resolved
|
|
125
|
+
* types exist; see lowerGenericCall).
|
|
126
|
+
*
|
|
127
|
+
* - `x?: T`: the checker already types the param `T | undefined` under
|
|
128
|
+
* strictNullChecks, so the ABI type IS that union and the body narrows
|
|
129
|
+
* with `!== undefined` like any union local.
|
|
130
|
+
* - `x: T = e`: the ABI type is a synthesized `T | undefined` union (the
|
|
131
|
+
* caller may omit the arg or pass undefined — both trigger the default,
|
|
132
|
+
* JS-exact); the body sees plain T through the two-local prologue
|
|
133
|
+
* (declareParams). A single-arm T narrows in the prologue; a UNION T
|
|
134
|
+
* re-tags through the interned retag helper (the undefined arm is the
|
|
135
|
+
* one stranded case, unreachable from the else-branch by construction).
|
|
136
|
+
* - `...xs: T[]`: the ABI type is the array; call sites pack the surplus.
|
|
137
|
+
*/
|
|
138
|
+
export declare function paramShape(L: Lowerer, param: ts.ParameterDeclaration): ParamShape;
|
|
139
|
+
/** ParamShapes for a whole parameter list. */
|
|
140
|
+
/** A `this` PARAMETER declaration (`function f(this: void, x: {}) ...`)
|
|
141
|
+
* — type-world only: tsc types the receiver with it, callers never pass
|
|
142
|
+
* it, and signature.getParameters() excludes it. The syntactic walks
|
|
143
|
+
* (paramShapes, declareParams) skip it with this predicate so ABI slots
|
|
144
|
+
* and call completion stay aligned with what JS actually passes. */
|
|
145
|
+
export declare function isThisParameter(param: ts.ParameterDeclaration): boolean;
|
|
146
|
+
export declare function paramShapes(L: Lowerer, params: readonly ts.ParameterDeclaration[]): ParamShape[];
|
|
147
|
+
/** The fences on a defaulted parameter's body type: it becomes the value
|
|
148
|
+
* arm of the synthesized `T | undefined` ABI union, so it must be a valid
|
|
149
|
+
* single arm. func and Set ARE valid here: the ABI union's only test is
|
|
150
|
+
* the prologue's own undefined-tag check (never a user narrowing, which
|
|
151
|
+
* is what keeps map/set out of general unions), so `runner: Runner =
|
|
152
|
+
* defaultRunner` and `skip: Set<string> = new Set()` arm like any ref
|
|
153
|
+
* kind — the nullable-callback union shape, built by the compiler. */
|
|
154
|
+
export declare function checkDefaultParamBodyType(L: Lowerer, param: ts.ParameterDeclaration, bodyType: IrType): void;
|
|
155
|
+
/** CALL-SITE COMPLETION — the frontend half of the one-signature contract
|
|
156
|
+
* (docs/ir.md): every call lowers to exactly the callee's full ABI
|
|
157
|
+
* parameter list, so backends and the validator stay count-exact and no
|
|
158
|
+
* runtime arity machinery exists. Omitted trailing args for omittable
|
|
159
|
+
* params become the interned undefined arm (which is also what an
|
|
160
|
+
* explicitly-passed `undefined` wraps to — both trigger a default, JS-
|
|
161
|
+
* exact); a rest param packs the surplus args (possibly zero) into one
|
|
162
|
+
* array literal, evaluated in source order at the call site. */
|
|
163
|
+
export declare function completeArgs(L: Lowerer, argNodes: readonly ts.Expression[], shapes: readonly ParamShape[], loc: SrcLoc, blame: ts.Node,
|
|
164
|
+
/** Pre-lowered values virtually PREPENDED to the argument list — the
|
|
165
|
+
* tagged-template strings object, which has no ts.Expression to lower
|
|
166
|
+
* (lowerTaggedTemplate builds it). Each rides the same slot-directed
|
|
167
|
+
* coercion an ordinary argument gets (coerceInto against its shape,
|
|
168
|
+
* DYN conversion in a dyn rest, element coercion in a typed rest). */
|
|
169
|
+
leading?: readonly IrExpr[]): IrExpr[];
|
|
170
|
+
/** The undefined arm of an undefined-armed union `type`, wrapped (a
|
|
171
|
+
* unitLit under a unionWrap) — the value every "absent" slot holds: an
|
|
172
|
+
* omitted optional argument, an omitted optional record field. Null when
|
|
173
|
+
* `type` has no undefined arm to wrap into. */
|
|
174
|
+
export declare function wrappedUndefined(L: Lowerer, type: IrType, loc: SrcLoc): IrExpr | null;
|
|
175
|
+
/** The synthesized argument for an omitted omittable param: the interned
|
|
176
|
+
* undefined arm of the param's `T | undefined` ABI union, or the DOM
|
|
177
|
+
* undefined for a checked-dynamic param (`bar?: any`). */
|
|
178
|
+
/** The "absent argument" value for a param SLOT type, or null when the
|
|
179
|
+
* slot cannot hold one: the interned undefined arm for undefined-armed
|
|
180
|
+
* unions, the DOM undefined for checked-dynamic slots, the engine's own
|
|
181
|
+
* undefined for island slots. Shared by every call-completion loop
|
|
182
|
+
* (direct calls and calls through func-typed values). */
|
|
183
|
+
export declare function omittedArgFor(L: Lowerer, type: IrType, loc: SrcLoc): IrExpr | null;
|
|
184
|
+
export declare function undefinedArgFor(L: Lowerer, type: IrType, loc: SrcLoc, blame: ts.Node): IrExpr;
|
|
185
|
+
/** DECISION (docs/ir.md): function VALUES keep exact-arity semantics — a
|
|
186
|
+
* func-typed IrType spells one completed signature, so a function whose
|
|
187
|
+
* declaration has optional/default/rest parameters can become a value only
|
|
188
|
+
* where the target type spells that exact signature with required
|
|
189
|
+
* parameters (`x?: T` / `x: T = e` params appear as literal `T | undefined`
|
|
190
|
+
* unions; a rest signature is never spellable without `...`, which func
|
|
191
|
+
* types reject). Direct calls get the full feature. */
|
|
192
|
+
export declare function requireExactArityValue(L: Lowerer, blame: ts.Node, contextual: ts.Expression | null, shapes: readonly ParamShape[], funcType: IrType): void;
|
|
193
|
+
/** The BODY-facing return type of a (possibly async) function: an async
|
|
194
|
+
* body's `return v` fulfills its promise with v, so the body returns the
|
|
195
|
+
* promise's INNER type while call sites keep Promise<T>. The declared
|
|
196
|
+
* type of an async function is always a promise (collectSignature /
|
|
197
|
+
* lowerLambda reject anything else before calling this). */
|
|
198
|
+
export declare function bodyReturnType(L: Lowerer, isAsync: boolean, declared: IrType): IrType;
|
|
199
|
+
/** A union-returning body may complete WITHOUT returning — JS yields
|
|
200
|
+
* undefined then (`(): string | undefined => { if (c) return "x"; }`), so
|
|
201
|
+
* an undefined-armed union return gets a trailing `return <undefined
|
|
202
|
+
* arm>` appended unless the body's last statement already returns or
|
|
203
|
+
* throws (deeper always-returning control flow keeps the appended return
|
|
204
|
+
* as dead code — harmless).
|
|
205
|
+
*
|
|
206
|
+
* Every OTHER non-void body gets a trailing UNREACHABLE trap instead:
|
|
207
|
+
* tsc's reachability can prove completions the validator's conservative
|
|
208
|
+
* alwaysReturns cannot (an exhaustive `switch (typeof x)` with a return
|
|
209
|
+
* in every case — signature 16), and those bodies end without a terminal
|
|
210
|
+
* statement of their own. The trap satisfies the must-return rule as the
|
|
211
|
+
* dead code it is; it can only fire if the checker's proof was violated,
|
|
212
|
+
* which would be a lowering bug — hence the please-report wording. */
|
|
213
|
+
export declare function appendImplicitUndefinedReturn(L: Lowerer, body: IrStmt[], bodyReturn: IrType, loc: SrcLoc): void;
|
|
214
|
+
/** A declaration's checker-derived IR return type. The unmappable-type
|
|
215
|
+
* diagnostic points at `blame` (the name for top-level declarations, the
|
|
216
|
+
* whole node for lambda-likes — preserving each caller's historical loc). */
|
|
217
|
+
export declare function declaredReturnType(L: Lowerer, decl: ts.SignatureDeclaration, blame: ts.Node): IrType;
|
|
218
|
+
export declare function collectSignature(L: Lowerer, decl: ts.FunctionDeclaration): void;
|
|
219
|
+
export declare function collectSignatureInner(L: Lowerer, decl: ts.FunctionDeclaration): void;
|
|
220
|
+
/** Registers a top-level generic function. Only the SYNTAX is checked
|
|
221
|
+
* here — parameter/return types mention the type parameters and cannot
|
|
222
|
+
* map yet; the body is lowered per instantiation, on demand (an unused
|
|
223
|
+
* generic function costs nothing, like a C++ template). Called inside
|
|
224
|
+
* collectSignature's poison catch. */
|
|
225
|
+
export declare function collectGenericSignature(L: Lowerer, decl: ts.FunctionDeclaration): void;
|
|
226
|
+
export declare function genericFnOf(L: Lowerer, ident: ts.Identifier): GenericFnInfo | null;
|
|
227
|
+
/** Call of a generic top-level function. The checker already inferred (or
|
|
228
|
+
* was told, via explicit type arguments) the concrete signature —
|
|
229
|
+
* getResolvedSignature returns it with type arguments substituted. The
|
|
230
|
+
* mapped param+return IR types form the INSTANTIATION KEY; the first call
|
|
231
|
+
* with a new key queues the body for monomorphic lowering as
|
|
232
|
+
* `<qualifiedName>%<n>`, and every call lowers to a direct `call` of that
|
|
233
|
+
* instance. */
|
|
234
|
+
export declare function lowerGenericCall(L: Lowerer, expr: ts.CallExpression, info: GenericFnInfo): IrExpr;
|
|
235
|
+
/** The instance a CALL of a generic function-like names: resolved
|
|
236
|
+
* signature → mapped param shapes/return → interned instance. Shared by
|
|
237
|
+
* top-level generic calls, class generic-method calls (the caller
|
|
238
|
+
* prepends the receiver), and object-literal generic-method calls. */
|
|
239
|
+
export declare function genericCallInstance(L: Lowerer, expr: ts.CallExpression, info: GenericFnInfo): GenericInstance;
|
|
240
|
+
/** The one instance table both instantiation routes share: key identity IS
|
|
241
|
+
* signature identity, so a call (`identity(1)`) and a pinned VALUE
|
|
242
|
+
* (`const f: (x: number) => number = identity`) reuse one compiled
|
|
243
|
+
* instance. `makeBindings` runs only for a NEW key (binding inference
|
|
244
|
+
* costs checker walks). */
|
|
245
|
+
export declare function internGenericInstance(L: Lowerer, blame: ts.Node, info: GenericFnInfo, params: ParamShape[], returnType: IrType, makeBindings: () => Map<ts.Symbol, IrType>): GenericInstance;
|
|
246
|
+
/** Type-parameter symbol → concrete IR type for one instantiation.
|
|
247
|
+
* Explicit type arguments bind directly; the rest come from structurally
|
|
248
|
+
* matching each DECLARED param/return type (which mentions the type
|
|
249
|
+
* parameters) against the checker's INSTANTIATED one — the latter is the
|
|
250
|
+
* former with the substitution applied, so the shapes are parallel by
|
|
251
|
+
* construction. A type parameter left unbound only matters if the body
|
|
252
|
+
* mentions it, where mapType fails with SC2001 (carrying the
|
|
253
|
+
* instantiation context). */
|
|
254
|
+
export declare function inferTypeParamBindings(L: Lowerer, expr: ts.CallExpression, info: GenericFnInfo, rsig: ts.Signature): Map<ts.Symbol, IrType>;
|
|
255
|
+
/** Type parameters still unbound after unification take their declared
|
|
256
|
+
* DEFAULT (`<T = number>`), mapped — the checker already substituted the
|
|
257
|
+
* default into every resolved signature, so this only fills the bindings
|
|
258
|
+
* an instance body's mapType consults. */
|
|
259
|
+
export declare function bindDefaultTypeParams(L: Lowerer, typeParams: readonly ts.Symbol[], typeParamDecls: readonly ts.TypeParameterDeclaration[] | undefined, bindings: Map<ts.Symbol, IrType>): void;
|
|
260
|
+
/** The structural half of binding inference: unify the DECLARED signature
|
|
261
|
+
* (whose types mention the type parameters) against a TARGET signature
|
|
262
|
+
* with the substitution applied — a call's resolved signature, or the
|
|
263
|
+
* completed signature a VALUE reference is pinned to (the contextual
|
|
264
|
+
* type's one call signature). Mutates `bindings`; already-bound
|
|
265
|
+
* parameters (explicit type arguments) win. */
|
|
266
|
+
export declare function unifySignatureBindings(L: Lowerer, info: GenericFnInfo, rsig: ts.Signature, bindings: Map<ts.Symbol, IrType>): void;
|
|
267
|
+
/** Lowers ONE monomorphic instance of a generic function: the same body
|
|
268
|
+
* AST, re-lowered with the type parameters bound (threaded into every
|
|
269
|
+
* mapType call via typeParamResolver — the checker keeps reporting the
|
|
270
|
+
* unsubstituted `T`s inside the body). Coverage stats count a base
|
|
271
|
+
* function's statements once: only the FIRST instance contributes. */
|
|
272
|
+
export declare function lowerGenericInstance(L: Lowerer, info: GenericFnInfo, inst: GenericInstance): IrFunction;
|
|
273
|
+
/** A generic function taken as a VALUE, monomorphized by flow. A function
|
|
274
|
+
* value needs ONE concrete signature; tsc pins one at exactly two
|
|
275
|
+
* reference shapes — an instantiation EXPRESSION (`identity<number>`,
|
|
276
|
+
* whose own checker type is the substituted signature) and a reference
|
|
277
|
+
* whose CONTEXTUAL type completes the signature (`const f: (x: number) =>
|
|
278
|
+
* number = identity`, `take(identity)`). The declared signature unifies
|
|
279
|
+
* against the pinned one to recover the bindings; the instance then
|
|
280
|
+
* registers in the SAME table call sites use (one compiled copy per
|
|
281
|
+
* signature however it is reached), and the value is the instance's
|
|
282
|
+
* zero-capture closure — `f === f` holds within an instantiation, the
|
|
283
|
+
* declared-function identity rule. References with no pinning context
|
|
284
|
+
* (the slot keeps `<T>(x: T) => T`) fence by name. */
|
|
285
|
+
export declare function lowerGenericFnValue(L: Lowerer, ref: ts.Expression, info: GenericFnInfo): IrExpr;
|
|
286
|
+
/** The npm-static gate: implicit-any monomorphization applies to functions
|
|
287
|
+
* DECLARED in an opted-in package's JS files (user JS keeps today's
|
|
288
|
+
* checked-dynamic story until the corpus is re-baselined). */
|
|
289
|
+
export declare function implicitMonoFile(sf: ts.SourceFile): boolean;
|
|
290
|
+
/** The implicit-type-parameter slots of a JS function-like: parallel to
|
|
291
|
+
* decl.parameters, the param SYMBOL where the slot is a bindable
|
|
292
|
+
* implicit-any param (identifier-named, no annotation/JSDoc type, not
|
|
293
|
+
* rest/optional/defaulted, never written), null elsewhere. Null overall
|
|
294
|
+
* when nothing qualifies — the declaration keeps today's path. */
|
|
295
|
+
export declare function implicitAnyParamSymbolsOf(L: Lowerer, decl: ts.FunctionDeclaration | ts.MethodDeclaration | ts.FunctionExpression | ts.ArrowFunction): (ts.Symbol | null)[] | null;
|
|
296
|
+
/** The instance a CALL of an implicit-any function-like names: each
|
|
297
|
+
* bindable implicit param takes the call's WIDENED argument checker type
|
|
298
|
+
* when it maps statically (DYN otherwise — today's slot), typed params
|
|
299
|
+
* keep their declared shapes, and the param-type tuple is the
|
|
300
|
+
* instantiation key. New keys lower EAGERLY (return inference — see the
|
|
301
|
+
* section comment); a same-key re-demand mid-lowering pins the fallback
|
|
302
|
+
* return type. */
|
|
303
|
+
export declare function implicitCallInstance(L: Lowerer, call: ts.CallExpression, info: GenericFnInfo): GenericInstance;
|
|
304
|
+
/** The all-dyn DEFAULT instance — today's compiled body exactly: what a
|
|
305
|
+
* VALUE reference of an implicit-any function names (indirect calls
|
|
306
|
+
* carry no per-site types to bind). */
|
|
307
|
+
export declare function implicitDefaultInstance(L: Lowerer, blame: ts.Node, info: GenericFnInfo): GenericInstance;
|
|
308
|
+
/** The implicit-any twin of bindingGenericFnNodeOf, for LOCAL and module
|
|
309
|
+
* bindings alike (`const knownBy = (cmd) => [cmd.name()].concat(...)`
|
|
310
|
+
* inside a method body — commander's _registerCommand shape): the
|
|
311
|
+
* initializer function-like when the WHOLE declaration qualifies for
|
|
312
|
+
* implicit monomorphization, else null — non-qualifying shapes keep
|
|
313
|
+
* today's closure story silently (never a fence: the flag must not make
|
|
314
|
+
* working code worse). Qualification: an npm-static JS file, a const (or
|
|
315
|
+
* never-reassigned, never-redeclared) identifier binding, an
|
|
316
|
+
* arrow/function-expression initializer with bindable implicit-any
|
|
317
|
+
* params, and a body with NO captures — no `this`/`super`, and no
|
|
318
|
+
* reference to a function-scoped declaration outside itself (compiled
|
|
319
|
+
* instances are module functions; module-scope references are fine).
|
|
320
|
+
* Cached per declaration on L.implicitLocalFns. */
|
|
321
|
+
export declare function implicitLocalFnNodeOf(L: Lowerer, decl: ts.VariableDeclaration): ts.FunctionExpression | ts.ArrowFunction | null;
|
|
322
|
+
/** Registers (or returns) the GenericFnInfo of a qualifying implicit-any
|
|
323
|
+
* function-value binding — implicitLocalFnNodeOf's companion, the
|
|
324
|
+
* bindingGenericFnInfoOf shape: the info enters genericFnsBySymbol under
|
|
325
|
+
* the binding's symbol (and a named function expression's inner name),
|
|
326
|
+
* so calls and value references resolve through genericFnOf; the
|
|
327
|
+
* declaration statement emits nothing and the binding has no runtime
|
|
328
|
+
* value. The declaration's source position joins the qualified name —
|
|
329
|
+
* two same-named locals in one file stay distinct. */
|
|
330
|
+
export declare function implicitLocalFnInfoOf(L: Lowerer, decl: ts.VariableDeclaration, fnNode: ts.FunctionExpression | ts.ArrowFunction): GenericFnInfo;
|
|
331
|
+
/** An island call result the .d.ts DECLARES as a primitive exits eagerly
|
|
332
|
+
* to that static type — the member-read rule's call sibling (see the
|
|
333
|
+
* getProp lowering in lower-exprs.ts): primitives copy by value, every
|
|
334
|
+
* static consumer works on the result, and a lying declaration throws the
|
|
335
|
+
* catchable TypeError. Chain-handled forms stay jsval (the optChain's
|
|
336
|
+
* unit path is the engine's undefined). */
|
|
337
|
+
export declare function islandPrimitiveExit(L: Lowerer, call: ts.CallExpression, result: IrExpr): IrExpr;
|
|
338
|
+
/** The trailing-argument timer forms — `setTimeout(cb, ms, ...args)`,
|
|
339
|
+
* `setInterval(cb, ms, ...args)`, `setImmediate(cb, ...args)` — invoke
|
|
340
|
+
* the callback WITH those arguments (Node passes them through). The
|
|
341
|
+
* callback and every argument box into dyn and an interned per-arity
|
|
342
|
+
* thunk delivers the dynCall at fire time: JS's exact call semantics
|
|
343
|
+
* (per-argument checks against the callee's declared signature, extras
|
|
344
|
+
* ignored, a non-function callee throwing the catchable TypeError).
|
|
345
|
+
* Non-boxable callbacks fence. */
|
|
346
|
+
export declare function timerStyleCallback(L: Lowerer, callArgs: readonly ts.Expression[], what: string, loc: SrcLoc): IrExpr;
|
|
347
|
+
/** The timer surface's member names — the ambient globals AND the
|
|
348
|
+
* node:timers module's exports (one set: Node's timers module re-exports
|
|
349
|
+
* the globals). */
|
|
350
|
+
export declare const TIMER_MODULE_MEMBERS: ReadonlySet<string>;
|
|
351
|
+
/** One timer call by MEMBER NAME — the shared lowering behind the ambient
|
|
352
|
+
* globals, the node:timers named/destructured imports, and the namespace
|
|
353
|
+
* form (`timers.setTimeout(...)`). Null when the member isn't a lowered
|
|
354
|
+
* timer function (the caller's fence machinery takes over). */
|
|
355
|
+
export declare function lowerTimersMemberCall(L: Lowerer, expr: ts.CallExpression, member: string, loc: SrcLoc): IrExpr | null;
|
|
356
|
+
export declare function lowerCall(L: Lowerer, expr: ts.CallExpression): IrExpr;
|
|
357
|
+
/** The SHARED prototype names scr_dyn_invoke dispatches at runtime (the
|
|
358
|
+
* subset of DOM_PROTO_METHOD_NAMES with a receiver-kind dispatch): the
|
|
359
|
+
* runtime runs the real method for the receiver's kind, throws Node's
|
|
360
|
+
* is-not-a-function where the kind's prototype lacks the name, and
|
|
361
|
+
* fences LOUDLY on real-but-unimplemented pairs. */
|
|
362
|
+
export declare const DYN_DISPATCH_METHODS: Set<string>;
|
|
363
|
+
/** Radix-free `.toString()` on a PRIMITIVE receiver: numbers take the
|
|
364
|
+
* STATIC JS-exact number formatter — the same `toString` node templates
|
|
365
|
+
* and String(n) lower to (Number::toString with radix 10 IS that
|
|
366
|
+
* conversion, per spec) — booleans the "true"/"false" texts, and strings
|
|
367
|
+
* the identity read (String.prototype.toString returns `this`). The
|
|
368
|
+
* explicit-radix number form keeps its island lowering (ISLAND_SURFACE);
|
|
369
|
+
* null for other receivers, argument shapes, or non-lib members (a
|
|
370
|
+
* user's own `.toString` takes the ordinary paths). */
|
|
371
|
+
export declare function lowerNumberToStringCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
372
|
+
/** Radix-free `.toString()` on a UNION receiver whose every arm has one
|
|
373
|
+
* (string identity, JS-exact number/bool texts, and the Buffer arm's
|
|
374
|
+
* utf8 decode — Node's default encoding): the per-union ToString
|
|
375
|
+
* helper dispatches on the tag, so `chunk.toString()` over the ngrok
|
|
376
|
+
* `Buffer | string` listener param needs no narrowing. Unit-armed
|
|
377
|
+
* unions stay out — `(undefined).toString()` THROWS in JS, and
|
|
378
|
+
* claiming it here would silently print "undefined" instead. Null for
|
|
379
|
+
* other receivers/arms (the narrow-first fences stay). */
|
|
380
|
+
export declare function lowerUnionToStringCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
381
|
+
/** `x.toString()` resolving to Object.prototype.toString (stdlib
|
|
382
|
+
* provenance, zero arguments) on a RECORD or program-class receiver:
|
|
383
|
+
* the spec's default answer is the constant "[object Object]". Records
|
|
384
|
+
* carry no method storage at all, and a class receiver folds only when
|
|
385
|
+
* neither its chain nor ANY subclass declares toString (dynamic
|
|
386
|
+
* dispatch could reach an override otherwise — and a resolved override
|
|
387
|
+
* is the USER's symbol, which never lands here). Pure receivers elide
|
|
388
|
+
* evaluation; effectful ones evaluate through an interned identity
|
|
389
|
+
* helper so the receiver's effects keep their place. */
|
|
390
|
+
export declare function lowerDefaultToStringCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
391
|
+
/** The remaining PRIMITIVE prototype surface with a static story, in both
|
|
392
|
+
* member spellings (`x.hasOwnProperty(...)` and `x['hasOwnProperty'](...)`
|
|
393
|
+
* — JS resolves the two identically, so the element spelling routes here
|
|
394
|
+
* from lowerCall's element-access hook):
|
|
395
|
+
* - `n.toExponential()` / `n.toFixed()` with the fraction digits
|
|
396
|
+
* OMITTED — the static runtime formatters (num.toExponential's
|
|
397
|
+
* shortest-mantissa form, num.toFixed0's ties-up integer). The
|
|
398
|
+
* explicit-digits forms keep their island/fence story.
|
|
399
|
+
* - `hasOwnProperty(lit)` on number/boolean receivers — the boxes own
|
|
400
|
+
* NOTHING, so any key answers false (a compile-time constant; the
|
|
401
|
+
* receiver must be effect-free since the constant elides it).
|
|
402
|
+
* - `hasOwnProperty(lit)` on string receivers — "length" is true,
|
|
403
|
+
* a canonical array index answers `index < s.length` (indices ARE
|
|
404
|
+
* own properties of the box, per spec), every other literal false.
|
|
405
|
+
* - the element-access spellings of `toString()` (the primitive
|
|
406
|
+
* lowering above) and `charAt(i)` — the two the element hook needs
|
|
407
|
+
* beyond this file's own claims.
|
|
408
|
+
* Null elsewhere: non-literal keys, other members, other receivers. */
|
|
409
|
+
export declare function lowerPrimitiveProtoCall(L: Lowerer, call: ts.CallExpression, recv: ts.Expression, name: string, memberSym: ts.Symbol | undefined): IrExpr | null;
|
|
410
|
+
/** Tagged templates `tag\`a${x}b\`` — ES's call: tag(strings, ...values).
|
|
411
|
+
* The strings object is the per-SITE interned cooked array (the
|
|
412
|
+
* templateStrings node: one immortal string[] per occurrence, so the
|
|
413
|
+
* spec's identity contract holds — the same site evaluated twice hands
|
|
414
|
+
* the tag the SAME array; two sites never share). TemplateStringsArray
|
|
415
|
+
* maps to string[] (types.ts), so the array rides the ordinary
|
|
416
|
+
* slot-directed coercion into whatever the tag's first parameter wants
|
|
417
|
+
* — string[] exactly, an `any` slot through the dyn boundary, a rest
|
|
418
|
+
* pack's first element. `.raw` does not exist on the lowered object:
|
|
419
|
+
* reads fence per member, and String.raw itself lowered above (the raw
|
|
420
|
+
* spans splice directly, no array materializes).
|
|
421
|
+
*
|
|
422
|
+
* Tag forms: a top-level declared function (the direct-call fast path —
|
|
423
|
+
* overload sets reconcile through the resolved signature exactly like
|
|
424
|
+
* plain calls), an island value under --dynamic (engine method/function
|
|
425
|
+
* call: the engine side sees a plain marshaled array — a tag reading
|
|
426
|
+
* `.raw` there answers undefined where Node carries the raw spans), and
|
|
427
|
+
* a checked-dynamic value (the dynCall boundary — a non-function tag
|
|
428
|
+
* throws Node's catchable TypeError). Everything else — generic tags,
|
|
429
|
+
* method tags, function-value bindings — fences by name. */
|
|
430
|
+
export declare function lowerTaggedTemplate(L: Lowerer, expr: ts.TaggedTemplateExpression): IrExpr;
|
|
431
|
+
/** True when the identifier resolves (through import aliases) to a
|
|
432
|
+
* top-level function declaration of ANY program file (not merely a
|
|
433
|
+
* same-named local shadowing one). Functions declared directly in a
|
|
434
|
+
* FLATTENED namespace block count — splitFiles hoisted them into the
|
|
435
|
+
* same collection lists top-level declarations ride. */
|
|
436
|
+
export declare function isTopLevelFnSymbol(L: Lowerer, ident: ts.Identifier): boolean;
|
|
437
|
+
/** Nested `function name(...) {...}`: lowered as `const name = <lambda>`
|
|
438
|
+
* at the declaration's statement position (JS hoists function declarations
|
|
439
|
+
* to the top of the enclosing function — calling one before this statement
|
|
440
|
+
* is a compile error here, not a silent divergence). Self-references inside
|
|
441
|
+
* the body lower to `selfRef`, not a capture: a box holding its own
|
|
442
|
+
* closure would be an RC cycle. */
|
|
443
|
+
export declare function lowerNestedFunctionDecl(L: Lowerer, stmt: ts.FunctionDeclaration): IrStmt;
|
|
444
|
+
/** Signature checks + param shapes + IR func type for any lambda-like
|
|
445
|
+
* node. The func type's params are the ABI types, so a lambda with
|
|
446
|
+
* optional/default params has the same IR type as one spelling the
|
|
447
|
+
* `T | undefined` unions with required params — exactly the exact-arity
|
|
448
|
+
* value rule (requireExactArityValue decides who may become a value). */
|
|
449
|
+
export declare function lambdaSignature(L: Lowerer, node: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | ts.MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration): {
|
|
450
|
+
shapes: ParamShape[];
|
|
451
|
+
funcType: IrType & {
|
|
452
|
+
kind: "func";
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
/** Does this function's OWN body read `arguments`? Nested plain functions
|
|
456
|
+
* and methods have their own `arguments` (the walk skips them); arrows
|
|
457
|
+
* see the enclosing one (the walk descends). Exported for the lowerer's
|
|
458
|
+
* dynFallbackType: tsgo does not synthesize the `arguments` rest
|
|
459
|
+
* parameter into inferred signatures (5.9.3 did — its param-count
|
|
460
|
+
* mismatch was the detector), so the 7 world asks the BODY directly. */
|
|
461
|
+
export declare function bodyReadsArguments(fn: {
|
|
462
|
+
body?: ts.Node | undefined;
|
|
463
|
+
}): boolean;
|
|
464
|
+
/** Lifts an arrow function / function expression / nested declaration /
|
|
465
|
+
* object-literal shorthand method to a module-level function and yields
|
|
466
|
+
* the `closure` expression creating it. */
|
|
467
|
+
export declare function lowerLambda(L: Lowerer, node: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration | ts.MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration): IrExpr;
|
|
468
|
+
export declare function lowerPromiseMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
469
|
+
/** NARROWING `a.filter(...)` — the two callback forms whose result the
|
|
470
|
+
* checker types as a NARROWER array than the receiver:
|
|
471
|
+
*
|
|
472
|
+
* xs.filter((x) => x !== undefined) // TS-inferred type predicate
|
|
473
|
+
* xs.filter(Boolean) // BooleanConstructor overload
|
|
474
|
+
*
|
|
475
|
+
* Trust discipline: only tests the RUNTIME actually performs may re-tag.
|
|
476
|
+
* An INFERRED predicate (inline arrow/function expression with no return
|
|
477
|
+
* annotation — TS 5.5 only infers `x is T` when the body proves it) and
|
|
478
|
+
* `Boolean` (retained elements are truthy, hence never the undefined/
|
|
479
|
+
* null arm) both qualify; a HAND-WRITTEN `x is T` annotation is an
|
|
480
|
+
* unchecked assertion (a lying one would corrupt the extraction) and
|
|
481
|
+
* stays fenced. The narrowed element must be a SINGLE arm of the
|
|
482
|
+
* receiver's union — retained elements re-tag through unionNarrow in the
|
|
483
|
+
* synthesized loop; a multi-arm target would need the union-to-union
|
|
484
|
+
* re-tag that doesn't exist (fenced with the annotate-the-callback
|
|
485
|
+
* escape). Null hands non-narrowing filters to the generic HOF path. */
|
|
486
|
+
export declare function lowerFilterNarrowCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
487
|
+
/** The interned keys-array helper over a FIXED record shape: a call of a
|
|
488
|
+
* lifted helper whose body pushes each declared field name in first-seen
|
|
489
|
+
* DECLARATION order, skipping fields currently holding the undefined arm
|
|
490
|
+
* of their union at runtime (Node's missing key — an unset optional
|
|
491
|
+
* never made it into the object; SEMANTICS.md 37's rules). ONE
|
|
492
|
+
* construction, interned per shape, shared by Object.keys and for-in —
|
|
493
|
+
* for-in iterates exactly the keys Object.keys answers. */
|
|
494
|
+
export declare function recordKeysArrayCall(L: Lowerer, receiver: IrExpr, argIr: IrType & {
|
|
495
|
+
kind: "record";
|
|
496
|
+
}, shape: {
|
|
497
|
+
declaredOrder?: string[];
|
|
498
|
+
fields: {
|
|
499
|
+
name: string;
|
|
500
|
+
type: IrType;
|
|
501
|
+
}[];
|
|
502
|
+
}, loc: SrcLoc): IrExpr;
|
|
503
|
+
export declare function lowerFunction(L: Lowerer, decl: ts.FunctionDeclaration): IrFunction | null;
|
|
504
|
+
export declare function lowerRecordFieldCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
505
|
+
/** The function-like node behind an object-literal generic-method member:
|
|
506
|
+
* the MethodDeclaration itself (`{ m<T>(x: T) {...} }`) or a generic
|
|
507
|
+
* arrow/function-expression property's initializer (`{ m: <T>(x: T) =>
|
|
508
|
+
* ... }`). Null when the property's declaration isn't that shape. */
|
|
509
|
+
export declare function objLitGenericFnNodeOf(L: Lowerer, propSym: ts.Symbol): {
|
|
510
|
+
fnNode: ts.MethodDeclaration | ts.FunctionExpression | ts.ArrowFunction;
|
|
511
|
+
literal: ts.ObjectLiteralExpression;
|
|
512
|
+
} | null;
|
|
513
|
+
/** The interned GenericFnInfo for one object-literal generic method, with
|
|
514
|
+
* the supportability fences applied ONCE per declaration: the defining
|
|
515
|
+
* literal must sit at module scope (the compiled instance is a plain
|
|
516
|
+
* module function — an enclosing frame would need captures), and
|
|
517
|
+
* async/generator forms keep the method fences. The name is source-
|
|
518
|
+
* position-derived (`%ol<start>.<name>`, qualified per file) —
|
|
519
|
+
* deterministic across the discovery and emit passes. */
|
|
520
|
+
export declare function objLitGenericFnInfoOf(L: Lowerer, blame: ts.Node, name: string, found: {
|
|
521
|
+
fnNode: ts.MethodDeclaration | ts.FunctionExpression | ts.ArrowFunction;
|
|
522
|
+
literal: ts.ObjectLiteralExpression;
|
|
523
|
+
}): GenericFnInfo;
|
|
524
|
+
/** True when nothing in `sym`'s DECLARING FILE ever writes it after the
|
|
525
|
+
* initializer: assignments (plain and compound, destructuring targets
|
|
526
|
+
* included), ++/--, and for-of/for-in expression targets all count.
|
|
527
|
+
* Sound file-locally for module-scope bindings because ESM import
|
|
528
|
+
* bindings are read-only — no other file can write one. Cached per
|
|
529
|
+
* symbol (the scan walks the whole file once). */
|
|
530
|
+
export declare function bindingNeverReassigned(L: Lowerer, sym: ts.Symbol, decl: ts.Node): boolean;
|
|
531
|
+
/** The generic function-like INITIALIZER behind a binding declaration —
|
|
532
|
+
* `const f = <T>(x: T) => x` or `const f = function g<T>(x: T) {...}`
|
|
533
|
+
* (parens stripped). Null when the declaration isn't that shape; the
|
|
534
|
+
* SHAPE only — whether the binding qualifies (module scope, never
|
|
535
|
+
* reassigned) is bindingGenericFnInfoOf's business. */
|
|
536
|
+
export declare function bindingGenericFnNodeOf(decl: ts.VariableDeclaration): ts.FunctionExpression | ts.ArrowFunction | null;
|
|
537
|
+
/** The interned GenericFnInfo for one generic arrow/function-expression
|
|
538
|
+
* binding initializer, with the supportability fences applied ONCE per
|
|
539
|
+
* declaration: the binding must sit at module scope (the compiled
|
|
540
|
+
* instances are plain module functions — an enclosing frame would need
|
|
541
|
+
* captures) and must provably HOLD the initializer once initialized — a
|
|
542
|
+
* const, or a let/var nothing in its declaring file ever writes (ESM
|
|
543
|
+
* import bindings are read-only, so the file scan is the whole story;
|
|
544
|
+
* observing the UNINITIALIZED state needs a hoisted early call, the
|
|
545
|
+
* same temporal hole const TDZ leaves — the object-literal generic-
|
|
546
|
+
* method receiver stance). Successful registration enters the info
|
|
547
|
+
* in genericFnsBySymbol under the binding's symbol — and under a named
|
|
548
|
+
* function expression's own inner name (it binds itself inside the
|
|
549
|
+
* body, the class-expression rule) — so every genericFnOf consumer
|
|
550
|
+
* (calls, pinned values, instantiation expressions, namespace and CJS
|
|
551
|
+
* member paths) resolves it like a top-level generic declaration. */
|
|
552
|
+
export declare function bindingGenericFnInfoOf(L: Lowerer, decl: ts.VariableDeclaration, fnNode: ts.FunctionExpression | ts.ArrowFunction): GenericFnInfo;
|
|
553
|
+
/** Static resolution stands in for the receiver's runtime value, so an
|
|
554
|
+
* object-literal generic-method receiver must provably HOLD the defining
|
|
555
|
+
* literal: a direct read of a binding whose initializer IS that literal
|
|
556
|
+
* and that nothing ever reassigns — a const, or a let with no write in
|
|
557
|
+
* its declaring file (ESM import bindings are read-only, so the file
|
|
558
|
+
* scan is the whole story). The read is pure — call and value sites skip
|
|
559
|
+
* evaluating it entirely. A reassignable binding could hold a
|
|
560
|
+
* structurally identical literal with a DIFFERENT body, which static
|
|
561
|
+
* resolution would silently miss. */
|
|
562
|
+
export declare function requireObjLitGenericReceiver(L: Lowerer, blame: ts.Node, recvExpr: ts.Expression, literal: ts.ObjectLiteralExpression, name: string): void;
|
|
563
|
+
/** `o.m(args)` where `m` is an object-literal GENERIC method (own type
|
|
564
|
+
* parameters — the member is excluded from the record shape, see
|
|
565
|
+
* isGenericCallableMemberType): monomorphized per call site against the
|
|
566
|
+
* DEFINING literal's declaration, exactly like top-level generic
|
|
567
|
+
* functions. Resolution is static, so the receiver must provably BE the
|
|
568
|
+
* defining literal: a const binding whose initializer is that literal,
|
|
569
|
+
* read directly. The receiver read is pure and the compiled instance is
|
|
570
|
+
* a plain module function (no `this`, fenced), so the call lowers to a
|
|
571
|
+
* direct `call` of the instance with the receiver unevaluated. Claims
|
|
572
|
+
* every call whose member is generic-callable — lowering it or fencing
|
|
573
|
+
* with a named message. */
|
|
574
|
+
export declare function lowerObjLitGenericMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
575
|
+
/** `obj.method(args)` — whole-program devirtualization decides the form:
|
|
576
|
+
* a method some strict subclass of the receiver's STATIC class overrides
|
|
577
|
+
* must dispatch on the dynamic class (`virtualCall`, through the vtable);
|
|
578
|
+
* everything else — standalone classes, non-overridden methods, leaf
|
|
579
|
+
* receivers — stays a direct `call` of the nearest declaration, exactly
|
|
580
|
+
* as before inheritance existed. */
|
|
581
|
+
export declare function lowerObjectMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|