@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.
- 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 +5949 -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 +10102 -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 +65 -0
- package/dist/coverage/report.js +238 -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 +6286 -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 +486 -0
- package/dist/frontend/lowering/lower-containers.js +6345 -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 +8111 -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 +1074 -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 +6257 -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 +2255 -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 +67 -0
- package/dist/frontend/shared.js +241 -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 +429 -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 +4885 -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,486 @@
|
|
|
1
|
+
import * as ts from "../ts7/adapter.js";
|
|
2
|
+
import type { Lowerer } from "./lowerer.js";
|
|
3
|
+
import { IrExpr, IrFunction, IrRecordShape, IrStmt, IrType, SrcLoc } from "../../ir/nodes.js";
|
|
4
|
+
/** Ambient array method calls. `push`/`pop`/`indexOf`/`includes`/`join`
|
|
5
|
+
* lower to arrIntrinsic; the HOF family — `map`/`filter`/`forEach`/
|
|
6
|
+
* `find`/`some`/`every`/`flatMap`/`reduce`/`reduceRight` — desugars to a
|
|
7
|
+
* direct call of a synthetic loop function (see lowerArrayHofCall and
|
|
8
|
+
* friends). Null when this isn't an ambient array method call. tsc has
|
|
9
|
+
* already checked arity and argument types against ambient/scriptc.d.ts. */
|
|
10
|
+
export declare function lowerArrayMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
11
|
+
/** `a.map(fn)` / `a.filter(fn)` / `a.forEach(fn)` desugar to a direct
|
|
12
|
+
* call of a synthetic module function — one per method + element/result
|
|
13
|
+
* type + callback-arity combination, interned — whose body is a plain
|
|
14
|
+
* loop over EXISTING IR nodes (varDecl/for/arrayGet/callValue/push/
|
|
15
|
+
* return). No new IR kinds, no backend or runtime involvement. JS
|
|
16
|
+
* semantics: the length is read ONCE up front (Array.prototype.map/
|
|
17
|
+
* filter/forEach cache it — elements appended by the callback are not
|
|
18
|
+
* visited), elements are read fresh each iteration, callbacks run
|
|
19
|
+
* left-to-right and receive whatever prefix of (element, index, array)
|
|
20
|
+
* they declare. */
|
|
21
|
+
export declare function lowerArrayHofCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, method: "map" | "filter" | "forEach", elem: IrType): IrExpr;
|
|
22
|
+
/** Interned synthetic loop function for one (method, elem, fnRet, arity)
|
|
23
|
+
* combo. Named `%arr.<method>.<n>` ('%' keeps it out of the user
|
|
24
|
+
* namespace); rides `liftedFns` into the module like a lifted lambda (it
|
|
25
|
+
* is a plain function — no captures). */
|
|
26
|
+
export declare function arrayHofHelper(L: Lowerer, method: "map" | "filter" | "forEach", elem: IrType, fnRet: IrType, arity: number, loc: SrcLoc): string;
|
|
27
|
+
/** READ-ONLY array methods on TUPLE receivers — `t.slice(...)` and
|
|
28
|
+
* `t.map(f)`: a tuple is a fixed-shape record, but these methods never
|
|
29
|
+
* write, so the positions snapshot into a fresh array (the for-of-over-
|
|
30
|
+
* tuples stance — pure receivers only, since the reads re-emit per
|
|
31
|
+
* position) and the ordinary array machinery runs over it. The element
|
|
32
|
+
* type is the one position type, or the positions' interned union with
|
|
33
|
+
* each read wrapped into its arm (exactly the checker's callback
|
|
34
|
+
* parameter type). Null when this isn't a tuple slice/map — writers and
|
|
35
|
+
* the rest of the surface keep their fences. */
|
|
36
|
+
export declare function lowerTupleReadMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
37
|
+
/** The OOB-SAFE indexed read for --npm-static package files: `xs[i]`
|
|
38
|
+
* answers the interned `elem | undefined` union — the element when `i`
|
|
39
|
+
* is an integer in [0, len), JS's property-miss undefined otherwise —
|
|
40
|
+
* instead of the trap divergence 4 documents for program code.
|
|
41
|
+
* Package JS is inference-typed, guard-style code (`registeredArguments
|
|
42
|
+
* .slice(-1)[0]`, commander's last-element probe), and the trap would
|
|
43
|
+
* fire on working Node idioms; program files keep the documented trap
|
|
44
|
+
* (their annotations can prove bounds). Null when the element is
|
|
45
|
+
* union-typed (the re-tag has no story here) — the caller keeps the
|
|
46
|
+
* ordinary read. */
|
|
47
|
+
export declare function lowerNpmStaticSafeIndexRead(L: Lowerer, arr: IrExpr & {
|
|
48
|
+
type: {
|
|
49
|
+
kind: "array";
|
|
50
|
+
};
|
|
51
|
+
}, index: IrExpr, loc: SrcLoc): IrExpr | null;
|
|
52
|
+
/** Interned synthetic function for one (elem, argument-shape) concat —
|
|
53
|
+
* `%arr.concat.<n>(a, x0, x1, ...)`: a fresh array takes a's elements
|
|
54
|
+
* (pushSpread), then each argument pushes (element) or spreads (array)
|
|
55
|
+
* in order; the receiver and array arguments are only READ. Rides
|
|
56
|
+
* liftedFns like the HOF helpers (a plain function — no captures). */
|
|
57
|
+
export declare function arrayConcatHelper(L: Lowerer, elem: IrType, shape: ("e" | "a")[], loc: SrcLoc): string;
|
|
58
|
+
/** The loop body of one synthetic array HOF, from existing IR nodes:
|
|
59
|
+
*
|
|
60
|
+
* map: out = []; n = a.length; for (i = 0; i < n; i++) out.push(f(a[i])); return out;
|
|
61
|
+
* filter: out = []; n = a.length; for (...) { v = a[i]; if (f(v)) out.push(v); } return out;
|
|
62
|
+
* forEach: n = a.length; for (...) f(a[i]);
|
|
63
|
+
*
|
|
64
|
+
* `filter` reads the element once into `v` so the callback and the push
|
|
65
|
+
* see the same value even if the callback mutates `a[i]` (JS-exact).
|
|
66
|
+
* `arity` is the callback's declared parameter count (1–3): the loop
|
|
67
|
+
* passes the index and the receiver itself after the element when the
|
|
68
|
+
* callback names them, exactly the arguments JS supplies. */
|
|
69
|
+
export declare function buildArrayHofFn(L: Lowerer, name: string, method: "map" | "filter" | "forEach", elem: IrType, fnRet: IrType, arity: number, loc: SrcLoc): IrFunction;
|
|
70
|
+
/** `a.find(f)` / `a.findIndex(f)` / `a.findLast(f)` / `a.findLastIndex(f)`
|
|
71
|
+
* / `a.some(f)` / `a.every(f)` — the early-return HOFs, same
|
|
72
|
+
* desugar-to-loop machinery. some/every return bool from a short-circuit
|
|
73
|
+
* loop; findIndex/findLastIndex return the first matching index or -1
|
|
74
|
+
* (plain f64 — no union). find/findLast return `T | undefined` — the
|
|
75
|
+
* checker's own result union —
|
|
76
|
+
* with the found element wrapped into its arm and the miss producing the
|
|
77
|
+
* undefined unit arm (for REF elements that arm is the unit instance, the
|
|
78
|
+
* standard union machinery). The Last pair is the SAME loop walked
|
|
79
|
+
* backwards (`i = n - 1; i >= 0; i--`), exactly the es2023 spec's
|
|
80
|
+
* descending index walk. All require a bool-returning callback
|
|
81
|
+
* (JS's ToBoolean of arbitrary predicate results has no lowering). */
|
|
82
|
+
export declare function lowerArrayFindLikeCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, method: "find" | "findIndex" | "findLast" | "findLastIndex" | "some" | "every", elem: IrType): IrExpr;
|
|
83
|
+
/** `a.flatMap(f)` — map plus a one-level flatten. A callback returning
|
|
84
|
+
* `U[]` appends the returned array's elements per receiver element; a
|
|
85
|
+
* callback returning a non-array U doesn't flatten (JS pushes it as-is),
|
|
86
|
+
* which IS map — those calls share map's interned helper. A union return
|
|
87
|
+
* mixing array and non-array arms would need a per-value flatten decision
|
|
88
|
+
* — fenced. */
|
|
89
|
+
export declare function lowerArrayFlatMapCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, elem: IrType): IrExpr;
|
|
90
|
+
/** `a.reduce(f)` / `a.reduce(f, init)` and reduceRight — both declared
|
|
91
|
+
* forms. The accumulator type is the call's own checked result: U with an
|
|
92
|
+
* initial value, the element type without one. The callback may declare
|
|
93
|
+
* any prefix of (acc, element, index, array). Without an initial value an
|
|
94
|
+
* empty receiver throws Node's exact TypeError at runtime. */
|
|
95
|
+
export declare function lowerArrayReduceCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, method: "reduce" | "reduceRight", elem: IrType): IrExpr;
|
|
96
|
+
/** `a.sort(cmp)` — in-place, returns the receiver (JS's `this`), desugared
|
|
97
|
+
* to an interned synthetic function like the other array HOFs. The loop
|
|
98
|
+
* is a binary-free INSERTION sort: stable (equal-comparing elements keep
|
|
99
|
+
* their source order, which is what Node's stable TimSort produces for
|
|
100
|
+
* any consistent comparator) and JS-faithful on the comparator contract —
|
|
101
|
+
* an element moves left only while cmp(left, v) > 0, so a NaN or 0
|
|
102
|
+
* result holds position exactly like the spec's "treat as equal". The
|
|
103
|
+
* SEQUENCE of comparator calls differs from V8's TimSort (SEMANTICS.md);
|
|
104
|
+
* results are identical for consistent comparators. The comparator-less
|
|
105
|
+
* form lowers for STRING elements only — JS's default converts every
|
|
106
|
+
* element to string and compares UTF-16 units, which for strings is the
|
|
107
|
+
* relational operator the compiler already has (an interned synthesized
|
|
108
|
+
* comparator); for numbers that default is the notorious string sort
|
|
109
|
+
* ([10, 9, 1] → [1, 10, 9]), deliberately fenced toward an explicit
|
|
110
|
+
* comparator. */
|
|
111
|
+
export declare function lowerArraySortCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, elem: IrType, arrT: IrType & {
|
|
112
|
+
kind: "array";
|
|
113
|
+
}): IrExpr;
|
|
114
|
+
/** `a.at(i)` — the es2022 relative-index read. Desugars to an interned
|
|
115
|
+
* helper over existing IR nodes, ToIntegerOrInfinity-exact: the index
|
|
116
|
+
* truncates toward zero (floor for non-negatives, mirrored floor for
|
|
117
|
+
* negatives, NaN → 0), negatives wrap by the length once, and anything
|
|
118
|
+
* still outside [0, n) answers the undefined arm — never a bounds throw.
|
|
119
|
+
* The result is the checker's own `T | undefined` union, the find
|
|
120
|
+
* machinery's wrap rules (an undefined-armed element type passes
|
|
121
|
+
* through). */
|
|
122
|
+
export declare function lowerArrayAtCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, elem: IrType): IrExpr;
|
|
123
|
+
/** `Array.from({ length: n }, mapfn)` — the counted-generation idiom — on
|
|
124
|
+
* THE stdlib Array global. The source must be an OBJECT LITERAL whose
|
|
125
|
+
* single property is `length` (the shape the idiom always spells; the
|
|
126
|
+
* ArrayLike record never exists as a value). Desugars to an interned
|
|
127
|
+
* synthetic loop calling the mapper with (undefined, i) exactly like JS —
|
|
128
|
+
* the first argument is the dyn undefined singleton, matching the
|
|
129
|
+
* checker's own `unknown` for it — and pushing each result. The loop
|
|
130
|
+
* bound is `i <= n - 1`, which IS ToLength for the finite lengths that
|
|
131
|
+
* terminate (fractional lengths truncate, negative/NaN produce an empty
|
|
132
|
+
* array — Node-exact). Every other Array.from shape (arrays, iterables,
|
|
133
|
+
* no mapper) keeps the fence. Null when the callee isn't an
|
|
134
|
+
* Array-static access. */
|
|
135
|
+
export declare function lowerArrayFromCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
136
|
+
/** `Array.from(s)` / `[...s]` on a STRING: the code-point split into a
|
|
137
|
+
* fresh string[], through one interned helper per module. */
|
|
138
|
+
export declare function strCharsCall(L: Lowerer, src: IrExpr, loc: SrcLoc): IrExpr;
|
|
139
|
+
/** Ambient Map method calls. `get`/`set`/`has`/`delete`/`clear` lower to
|
|
140
|
+
* mapIntrinsic; `forEach` desugars to a direct call of a synthetic loop
|
|
141
|
+
* function over the iteration primitives (lowerMapForEachCall). Null when
|
|
142
|
+
* this isn't an ambient Map method call. tsc has already checked arity
|
|
143
|
+
* and argument types against ambient/scriptc.d.ts. */
|
|
144
|
+
export declare function lowerMapMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
145
|
+
/** `m.forEach(fn)` desugars to a direct call of a synthetic module
|
|
146
|
+
* function — one per key/value type + callback arity, interned — whose
|
|
147
|
+
* body is an index loop over the map's ITERATION PRIMITIVES: read
|
|
148
|
+
* iterCount fresh every pass (entries appended by the callback are
|
|
149
|
+
* visited), skip tombstones with iterLive (deleted entries are skipped),
|
|
150
|
+
* and bracket the loop with iterEnter/iterExit inside try/finally so the
|
|
151
|
+
* runtime never compacts indices out from under it — even when the
|
|
152
|
+
* callback throws. That is JS's live-iteration contract, Node-verified
|
|
153
|
+
* (SEMANTICS.md). The callback receives (value, key) like JS; declaring
|
|
154
|
+
* fewer parameters — (value) or () — is ordinary TS and supported. */
|
|
155
|
+
export declare function lowerMapForEachCall(L: Lowerer, call: ts.CallExpression, receiver: IrExpr, mapT: IrType & {
|
|
156
|
+
kind: "map";
|
|
157
|
+
}): IrExpr;
|
|
158
|
+
/** The loop body of the Map.forEach desugar, from existing IR nodes:
|
|
159
|
+
*
|
|
160
|
+
* m.iterEnter();
|
|
161
|
+
* try {
|
|
162
|
+
* for (i = 0; i < m.iterCount; i++) {
|
|
163
|
+
* if (m.iterLive(i)) { v = m.iterValue(i); k = m.iterKey(i); f(v, k); }
|
|
164
|
+
* }
|
|
165
|
+
* } finally { m.iterExit(); }
|
|
166
|
+
*
|
|
167
|
+
* The finally keeps the runtime's iteration depth exact when the callback
|
|
168
|
+
* throws (unwinding runs the finally with the exception pending and
|
|
169
|
+
* propagation resumes — the emitter's standard contract). */
|
|
170
|
+
export declare function buildMapForEachFn(L: Lowerer, name: string, mapT: IrType & {
|
|
171
|
+
kind: "map";
|
|
172
|
+
}, arity: number, fnRet: IrType, loc: SrcLoc): IrFunction;
|
|
173
|
+
/** Ambient Set method calls — Map's lowering with the value slot gone.
|
|
174
|
+
* `add`/`has`/`delete`/`clear` lower to setIntrinsic; `forEach` desugars
|
|
175
|
+
* like Map's over the shared iteration primitives. Null when this isn't
|
|
176
|
+
* an ambient Set method call. */
|
|
177
|
+
export declare function lowerSetMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
178
|
+
/** `s.forEach(fn)` — Map's desugar shape over the set primitives. JS
|
|
179
|
+
* passes (value, value, set): the second parameter IS the element again,
|
|
180
|
+
* so both one- and two-parameter callbacks receive elem-typed arguments
|
|
181
|
+
* (iterKey read once, passed twice). Same live-iteration bracketing. */
|
|
182
|
+
export declare function lowerSetForEachCall(L: Lowerer, call: ts.CallExpression, receiver: IrExpr, setT: IrType & {
|
|
183
|
+
kind: "set";
|
|
184
|
+
}): IrExpr;
|
|
185
|
+
/** The loop body of the Set.forEach desugar — buildMapForEachFn with
|
|
186
|
+
* iterKey as the (single) element read:
|
|
187
|
+
*
|
|
188
|
+
* s.iterEnter();
|
|
189
|
+
* try {
|
|
190
|
+
* for (i = 0; i < s.iterCount; i++) {
|
|
191
|
+
* if (s.iterLive(i)) { v = s.iterKey(i); f(v, v); }
|
|
192
|
+
* }
|
|
193
|
+
* } finally { s.iterExit(); }
|
|
194
|
+
*/
|
|
195
|
+
export declare function buildSetForEachFn(L: Lowerer, name: string, setT: IrType & {
|
|
196
|
+
kind: "set";
|
|
197
|
+
}, arity: number, fnRet: IrType, loc: SrcLoc): IrFunction;
|
|
198
|
+
/** Object.groupBy / Map.groupBy (ES2024): group an ARRAY's elements by a
|
|
199
|
+
* per-element key. Both lower to one interned helper loop per callback
|
|
200
|
+
* type — the callback runs synchronously per element (index included in
|
|
201
|
+
* the two-parameter form), the first occurrence of a key creates its
|
|
202
|
+
* group in encounter order, and later hits push onto the same array
|
|
203
|
+
* (JS's exact accumulation — the stored arrays are the live groups).
|
|
204
|
+
* Map.groupBy keeps typed keys under SameValueZero; Object.groupBy
|
|
205
|
+
* requires a STRING-KEYED result (Partial<Record<string, T[]>> — a
|
|
206
|
+
* literal-union key type makes a fixed-field record, which has no
|
|
207
|
+
* grouping representation) and stringifies number keys like JS property
|
|
208
|
+
* keys. Node's result carries a null prototype — records here have no
|
|
209
|
+
* prototype at all, so the difference is unobservable except through
|
|
210
|
+
* util.inspect's "[Object: null prototype]" prefix (ledgered). Other
|
|
211
|
+
* iterables fence (spread into an array first); Null when the callee
|
|
212
|
+
* isn't the stdlib Object/Map groupBy. */
|
|
213
|
+
export declare function lowerGroupByStaticCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
214
|
+
/** The lowered iterator-helper chains: `arr.values()` (the array
|
|
215
|
+
* iterator) through any run of map/filter/take/drop/flatMap into a
|
|
216
|
+
* consuming terminal (toArray/forEach/reduce/some/every/find), FUSED
|
|
217
|
+
* into one per-element loop — which IS the helpers' lazy pull order:
|
|
218
|
+
* each source element flows through every stage before the next is
|
|
219
|
+
* touched, take closes the pipeline without pulling upstream again
|
|
220
|
+
* (budget checked before delivery), and short-circuit terminals stop
|
|
221
|
+
* the walk at their hit. Stage callbacks take (value) or (value,
|
|
222
|
+
* counter) — counters count each stage's own input stream, per spec.
|
|
223
|
+
* take/drop budgets validate eagerly AT THE CALL (Node's RangeError,
|
|
224
|
+
* raw value in the message) through an interned checker call inserted
|
|
225
|
+
* at the argument's evaluation position. The source array is iterated
|
|
226
|
+
* LIVE by index against a re-read length, exactly the array iterator's
|
|
227
|
+
* contract. Everything else — iterator objects stored in bindings,
|
|
228
|
+
* generator/Set/Map receivers, Iterator.from — keeps the lib fences.
|
|
229
|
+
* Null when the callee isn't a terminal over such a chain. */
|
|
230
|
+
export declare function lowerIteratorHelperCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
231
|
+
/** The ES2025 Set composition methods (union/intersection/difference/
|
|
232
|
+
* symmetricDifference/isSubsetOf/isSupersetOf/isDisjointFrom): one
|
|
233
|
+
* set-like argument, desugared to an interned two-set helper loop. Only
|
|
234
|
+
* a REAL Set argument of the receiver's element type lowers — the
|
|
235
|
+
* desugar substitutes the builtin has/size for the spec's observable
|
|
236
|
+
* calls, which is exact for Sets and wrong for anything else (a Map or
|
|
237
|
+
* a custom { has, size, keys } object fences). */
|
|
238
|
+
export declare function lowerSetCombineCall(L: Lowerer, call: ts.CallExpression, name: string, receiver: IrExpr, setT: IrType & {
|
|
239
|
+
kind: "set";
|
|
240
|
+
}): IrExpr;
|
|
241
|
+
/** `for (const [k, v] of m)` / `for (const e of m)` — for-of over a Map,
|
|
242
|
+
* desugared IN PLACE (the body is user code, so no helper function) over
|
|
243
|
+
* the same iteration primitives as the forEach desugar, with the same
|
|
244
|
+
* Node-exact live-iteration contract: iterCount re-read every pass
|
|
245
|
+
* (entries appended by the body are visited), tombstones skipped
|
|
246
|
+
* (deleted entries are not). Shape:
|
|
247
|
+
*
|
|
248
|
+
* %m = <iterable>; %m.iterEnter();
|
|
249
|
+
* try {
|
|
250
|
+
* for (%i = 0; %i < %m.iterCount; %i++) {
|
|
251
|
+
* if (%m.iterLive(%i)) { <bindings>; <body> }
|
|
252
|
+
* }
|
|
253
|
+
* } catch (%c) { %m.iterExit(); rethrow %c; }
|
|
254
|
+
* %m.iterExit();
|
|
255
|
+
*
|
|
256
|
+
* catch-and-rethrow instead of a finally because break/continue/return
|
|
257
|
+
* may not cross a finally (the emitter's documented contract) and a
|
|
258
|
+
* for-of body legitimately contains all three: break/continue bind to
|
|
259
|
+
* the desugared loop INSIDE the plain try (jumps out of plain try need
|
|
260
|
+
* nothing), and every `return` in the body gets an iterExit inserted
|
|
261
|
+
* before it (exitBeforeReturns) so the depth count stays exact on that
|
|
262
|
+
* path too. A `[k, v]` head of plain identifiers binds straight from
|
|
263
|
+
* iterKey/iterValue — the tuple record never materializes; an identifier
|
|
264
|
+
* head binds the checker's own [K, V] tuple built per iteration. */
|
|
265
|
+
/** The iterator-method projections a for-of can ride directly:
|
|
266
|
+
* `for (const k of m.keys())`, `.values()`, `.entries()` — the SAME
|
|
267
|
+
* live-iteration walk as `for..of m` (JS's container iterators are live
|
|
268
|
+
* views, not snapshots), just yielding the key, the value, or the pair. */
|
|
269
|
+
export type ForOfIterProjection = "keys" | "values" | "entries";
|
|
270
|
+
/** for-of over a URLSearchParams (and its keys()/values()/entries()
|
|
271
|
+
* projections consumed directly by the head): the LIVE index walk —
|
|
272
|
+
* sp.size re-reads every pass, so entries appended mid-walk are visited
|
|
273
|
+
* and deletes shift, the spec's index-based iterator exactly. No
|
|
274
|
+
* enter/exit bracketing: the pair list compacts immediately (no
|
|
275
|
+
* tombstones), so there is no iteration depth to keep exact. */
|
|
276
|
+
export declare function lowerForOfSearchParams(L: Lowerer, stmt: ts.ForOfStatement, iterable: IrExpr, proj?: ForOfIterProjection): IrStmt;
|
|
277
|
+
export declare function lowerForOfMap(L: Lowerer, stmt: ts.ForOfStatement, iterable: IrExpr, mapT: IrType & {
|
|
278
|
+
kind: "map";
|
|
279
|
+
}, proj?: ForOfIterProjection): IrStmt;
|
|
280
|
+
/** `for (const v of s)` — for-of over a Set: the Map desugar with iterKey
|
|
281
|
+
* as the (single) element read; same live-iteration contract. */
|
|
282
|
+
export declare function lowerForOfSet(L: Lowerer, stmt: ts.ForOfStatement, iterable: IrExpr, setT: IrType & {
|
|
283
|
+
kind: "set";
|
|
284
|
+
}, proj?: ForOfIterProjection): IrStmt;
|
|
285
|
+
/** `new Map(entries)` from a tuple-array VALUE — any `[K, V][]`-typed
|
|
286
|
+
* expression (a variable, a .map() result, a sorted entries spread), not
|
|
287
|
+
* just the pair-literal form lower-classes handles inline. Desugars to a
|
|
288
|
+
* direct call of a synthetic function that constructs the empty map and
|
|
289
|
+
* set()s each pair in array order — JS-exact: pairs are visited in
|
|
290
|
+
* insertion order and a later duplicate key overwrites while keeping the
|
|
291
|
+
* first occurrence's position (set()'s own contract). Null when the
|
|
292
|
+
* argument isn't a matching tuple array (the caller keeps its fence). */
|
|
293
|
+
export declare function lowerMapSeedArrayNew(L: Lowerer, argNode: ts.Expression, mapT: IrType & {
|
|
294
|
+
kind: "map";
|
|
295
|
+
}): IrExpr | null;
|
|
296
|
+
/** Regex method calls, both directions: `re.test(s)` on a regex receiver,
|
|
297
|
+
* and `s.replace(re, tpl)` / `s.replaceAll(re, tpl)` / `s.split(re)` on a
|
|
298
|
+
* string receiver whose FIRST ARGUMENT is a regex (the string-pattern
|
|
299
|
+
* overloads keep their island lowering — the argument's mapped type is
|
|
300
|
+
* what routes here, before lowerIslandMethodCall can claim the name).
|
|
301
|
+
* Null when neither shape matches. */
|
|
302
|
+
export declare function lowerRegexMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, dynReceiver?: () => IrExpr): IrExpr | null;
|
|
303
|
+
/** `s.slice(1, 4)` and friends → strIntrinsic. Null when this isn't an
|
|
304
|
+
* ambient string method call (caller keeps its generic rejection). Missing
|
|
305
|
+
* optional arguments are omitted from `args` — the backend fills the
|
|
306
|
+
* documented defaults; the IR never encodes them (Infinity isn't
|
|
307
|
+
* JSON-safe). tsc has already checked arity and argument types against
|
|
308
|
+
* ambient/scriptc.d.ts. */
|
|
309
|
+
export declare function lowerStringMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, dynReceiver?: () => IrExpr): IrExpr | null;
|
|
310
|
+
/** `new Uint8Array(...)` / `new Uint32Array(...)` / `new Float32Array(...)`
|
|
311
|
+
* (stdlib provenance — a user's own class with the name resolves through
|
|
312
|
+
* classBySymbol). Lowered argument shapes: none (empty), a length
|
|
313
|
+
* (zero-filled; ToIndex at runtime — invalid lengths throw Node's
|
|
314
|
+
* RangeError), a same-kind typed array or Buffer (an independent COPY —
|
|
315
|
+
* the readFile chain's `new Uint8Array(await readFile(p))`), a number[]
|
|
316
|
+
* literal (element-coerced; its contextual type is the lib's
|
|
317
|
+
* ArrayLike/Iterable union, which cannot map — the Set-seed pattern), or
|
|
318
|
+
* a number[]-typed value. ArrayBuffer/view forms are fenced: scriptc
|
|
319
|
+
* typed arrays own their storage. Null when this isn't a stdlib
|
|
320
|
+
* typed-array construction. */
|
|
321
|
+
export declare function lowerBytesNew(L: Lowerer, expr: ts.NewExpression, symbol: ts.Symbol | null | undefined): IrExpr | null;
|
|
322
|
+
/** Method calls on typed-array/Buffer receivers: slice and subarray (BOTH
|
|
323
|
+
* copy — subarray's sharing is the documented divergence), set(src,
|
|
324
|
+
* offset?), and the u8-only Buffer surface: toString(enc?) plus the
|
|
325
|
+
* whole numeric read/write family (fixed widths BE/LE and the
|
|
326
|
+
* variable-width read/writeUIntLE quartet — BUF_NUM_METHODS). Everything
|
|
327
|
+
* else the lib declares (fill, indexOf, reverse, ...) falls through to
|
|
328
|
+
* the SC2020 member fence. Null when this isn't a bytes method call. */
|
|
329
|
+
export declare function lowerBytesMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
330
|
+
/** The literal encoding argument of a Buffer surface, normalized — or a
|
|
331
|
+
* fence when it isn't a literal alias Node knows. */
|
|
332
|
+
export declare function bufEncoding(L: Lowerer, what: string, encNode: ts.Expression): string;
|
|
333
|
+
/** The Buffer statics — `Buffer.from(...)`, `Buffer.alloc(n)`,
|
|
334
|
+
* `Buffer.concat(list)`, `Buffer.isBuffer(x)` — on THE stdlib Buffer
|
|
335
|
+
* global (name + provenance; fallback and @types/node alike). Null when
|
|
336
|
+
* the callee isn't a Buffer-static access. */
|
|
337
|
+
export declare function lowerBufferStaticCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
338
|
+
/** `Object.keys/values/entries` over an INDEX-SIGNATURE (overflow-carrying)
|
|
339
|
+
* record shape: declared fields answer first from the compile-time field
|
|
340
|
+
* list (declaration order, undefined-valued fields skipped — exactly the
|
|
341
|
+
* fixed-shape lowering and SEMANTICS.md 37), then the overflow map's live
|
|
342
|
+
* keys in JS OWN-KEY order (canonical array indices ascending, then
|
|
343
|
+
* insertion order — recordOvfKeys). For a PURE index-signature shape
|
|
344
|
+
* (Record<string, T> — no declared fields, the typical CLI config patterns) the
|
|
345
|
+
* result order is Node-exact; hybrids inherit the documented
|
|
346
|
+
* declared-then-overflow divergence. Values surface as the checker's
|
|
347
|
+
* result element type: identity, an arm-into-union wrap, or (dyn
|
|
348
|
+
* results) the DOM conversion — recordKeyGet's own surfacing rules for
|
|
349
|
+
* the overflow, mirrored statically for declared fields. */
|
|
350
|
+
export declare function lowerObjectIterOverIndexShape(L: Lowerer, call: ts.CallExpression, member: "keys" | "values" | "entries", argIr: IrType & {
|
|
351
|
+
kind: "record";
|
|
352
|
+
}, shape: IrRecordShape): IrExpr;
|
|
353
|
+
/** The construction core, receiver/result pre-resolved — `node` anchors
|
|
354
|
+
* the fences. for-in reuses the "keys" arm directly (it iterates exactly
|
|
355
|
+
* the keys Object.keys answers; same intern key, one helper). */
|
|
356
|
+
export declare function objectIterOverIndexShape(L: Lowerer, node: ts.Node, member: "keys" | "values" | "entries", argIr: IrType & {
|
|
357
|
+
kind: "record";
|
|
358
|
+
}, shape: IrRecordShape, receiver: IrExpr, resultT: IrType & {
|
|
359
|
+
kind: "array";
|
|
360
|
+
}, loc: SrcLoc): IrExpr;
|
|
361
|
+
/** `Object.fromEntries(pairs)` over a `[string, V][]` VALUE into the
|
|
362
|
+
* checker's own index-signature result shape (`{ [k: string]: V }` —
|
|
363
|
+
* always declared-field-free from the lib signature): an interned helper
|
|
364
|
+
* loops the pairs and keyed-writes each into a fresh record's overflow —
|
|
365
|
+
* later duplicates overwrite in place (first insertion position wins for
|
|
366
|
+
* ORDER, last value wins — exactly JS). Values flow into the signature's
|
|
367
|
+
* value slot (dyn slots convert JSON-safe values, identity otherwise).
|
|
368
|
+
* The `as ModelPricing` reshape AFTER it is the width-coercion capture
|
|
369
|
+
* (lowerRecordOvfCaptureHelper). Null when the argument or result shape
|
|
370
|
+
* is outside this (Maps, richer iterables → the SC2020 fence). */
|
|
371
|
+
export declare function lowerObjectFromEntriesCall(L: Lowerer, call: ts.CallExpression, callee: ts.Expression): IrExpr | null;
|
|
372
|
+
/** Interned `%rec.capture.<n>(s)` — the INDEX-SIGNATURE reshape behind
|
|
373
|
+
* `Object.fromEntries(entries) as ModelPricing` (hybrid→hybrid width
|
|
374
|
+
* coercion) and `const r: Record<string, number> = { a: 1, b: 2 }`
|
|
375
|
+
* (a DECLARED-fields shape narrowing into a pure overflow shape — the
|
|
376
|
+
* record becomes width-free key/value storage), both called from
|
|
377
|
+
* widthCoerce after recordWidthHelper declines: builds the target shape
|
|
378
|
+
* fresh — declared fields default to their undefined arms — then
|
|
379
|
+
* keyed-writes every source key into it, declared fields first in the
|
|
380
|
+
* source's DECLARATION order (skipping ones holding the undefined arm,
|
|
381
|
+
* the unset convention — insertion order is what Object.keys/JSON
|
|
382
|
+
* answer, stance 37), then the source overflow in JS own-key order. A
|
|
383
|
+
* key colliding with a target DECLARED field validates through the
|
|
384
|
+
* keyed write's dynCheck (a mismatch throws the catchable TypeError —
|
|
385
|
+
* divergence 34), which is exactly what makes the `as` honest. The
|
|
386
|
+
* result is a COPY (divergence 36's stance). Null when the pair is
|
|
387
|
+
* outside the supported matrix: the target needs an index signature,
|
|
388
|
+
* every source value (declared fields, and the overflow slot when the
|
|
389
|
+
* source carries one) must enter the target's value slot (identity, a
|
|
390
|
+
* width lift — arm wrap/re-tag/nested reshape, or JSON-safe into a dyn
|
|
391
|
+
* slot), and every target field must be optional-flavored (the fresh
|
|
392
|
+
* record's default) and writable at runtime. */
|
|
393
|
+
export declare function lowerRecordOvfCaptureHelper(L: Lowerer, fromId: string, toId: string, loc: SrcLoc): string | null;
|
|
394
|
+
/** `Object.assign(target, ...sources)` into an INDEX-SIGNATURE record:
|
|
395
|
+
* the capture helper's keyed-write walk aimed at the EXISTING target —
|
|
396
|
+
* each source's declared fields write in declaration order (unset
|
|
397
|
+
* optionals skip, stance 37), then its overflow in JS own-key order,
|
|
398
|
+
* and the result IS the target (identity, like JS — later reads through
|
|
399
|
+
* the target see every merged key). One interned `%obj.assign.<n>(t, s)`
|
|
400
|
+
* per (target shape, source shape) pair; multiple sources chain. Null
|
|
401
|
+
* when outside the matrix: the target needs an index signature, every
|
|
402
|
+
* source value must enter its value slot (identity, a width lift, or
|
|
403
|
+
* the dyn conversion), and tsc's `T & U` result type must collapse back
|
|
404
|
+
* to the target's own record shape (the self-shaped merges init-config
|
|
405
|
+
* patterns spell). */
|
|
406
|
+
export declare function lowerObjectAssignIndexShape(L: Lowerer, call: ts.CallExpression): IrExpr | null;
|
|
407
|
+
/** One contributor of a pure-index-record MERGE literal: a full spread of
|
|
408
|
+
* an index-signature record, or one explicit key. */
|
|
409
|
+
export type IndexMergeContributor = {
|
|
410
|
+
kind: "spread";
|
|
411
|
+
shapeId: string;
|
|
412
|
+
value: IrExpr;
|
|
413
|
+
} | {
|
|
414
|
+
kind: "field";
|
|
415
|
+
name: string;
|
|
416
|
+
value: IrExpr;
|
|
417
|
+
}
|
|
418
|
+
/** A RUNTIME-keyed property (`{ ...m, ["a" + "b"]: v }`, `{ [K]: v }`
|
|
419
|
+
* over a runtime string K): the key is its own helper argument, passed
|
|
420
|
+
* immediately BEFORE its value (JS's per-property key-then-value order
|
|
421
|
+
* rides the call's argument evaluation), already stringified by the
|
|
422
|
+
* caller (ToPropertyKey). */
|
|
423
|
+
| {
|
|
424
|
+
kind: "keyedField";
|
|
425
|
+
key: IrExpr;
|
|
426
|
+
value: IrExpr;
|
|
427
|
+
}
|
|
428
|
+
/** `...(cond ? { k: v } : {})` at its literal position: the key writes
|
|
429
|
+
* ONLY when the value isn't the undefined arm (overflow entries model
|
|
430
|
+
* presence — an absent key stays absent, exactly JS's empty-arm spread).
|
|
431
|
+
* The caller builds `value` as `cond ? v : <interned undefined arm of
|
|
432
|
+
* the target's value slot>` — cond evaluates once, `v` lazily — so the
|
|
433
|
+
* target's index-value type must carry an undefined arm. The explicit
|
|
434
|
+
* `{ k: undefined }` true-arm collapses to absence, divergence 56's
|
|
435
|
+
* documented stance. */
|
|
436
|
+
| {
|
|
437
|
+
kind: "condField";
|
|
438
|
+
name: string;
|
|
439
|
+
value: IrExpr;
|
|
440
|
+
};
|
|
441
|
+
/** The interned merge helper behind `{ ...a, ...b, K: v }` literals whose
|
|
442
|
+
* TARGET shape is a PURE index-signature record (no declared fields) —
|
|
443
|
+
* the spawn-env pattern (`{ ...process.env, ...extraEnv }`). Contributors
|
|
444
|
+
* apply in literal order with keyed writes, so JS's last-write-wins holds
|
|
445
|
+
* for colliding runtime keys. Spread sources must be index-signature
|
|
446
|
+
* records whose value slot IS the target's or LIFTS into it (a
|
|
447
|
+
* `Record<string, string>` spreads into a `string | undefined` target by
|
|
448
|
+
* wrapping each copied value); their declared fields copy first (skipping
|
|
449
|
+
* undefined-armed absents — the unset convention), then their overflow in
|
|
450
|
+
* JS own-key order. Explicit values arrive pre-coerced to the target's
|
|
451
|
+
* value slot. Null when a spread source is outside that matrix (the
|
|
452
|
+
* caller keeps its fence). */
|
|
453
|
+
export declare function lowerIndexMergeHelper(L: Lowerer, toId: string, contributors: IndexMergeContributor[], loc: SrcLoc): string | null;
|
|
454
|
+
/** The interned helper flattening an env-shaped record into the
|
|
455
|
+
* [k0, v0, k1, v1, ...] string[] cp.execSync consumes — declared string
|
|
456
|
+
* fields first (undefined-armed absents skipped, the Node-drops-undefined
|
|
457
|
+
* rule), then index-signature overflow in JS own-key order. Every value
|
|
458
|
+
* source must be a string or a `string | undefined` union whose value arm
|
|
459
|
+
* is a string. Null when the shape carries a non-string field/value slot
|
|
460
|
+
* (the caller fences). */
|
|
461
|
+
export declare function lowerEnvToPairsHelper(L: Lowerer, shapeId: string, loc: SrcLoc): string | null;
|
|
462
|
+
/** The validated-STRING extraction of a dyn method receiver — the receiver
|
|
463
|
+
* expression the string/regex method lowerings consume. */
|
|
464
|
+
export declare function dynStringReceiver(L: Lowerer, recv: IrExpr, access: ts.PropertyAccessExpression): IrExpr;
|
|
465
|
+
/** `d.filter(pred)` on a dyn receiver: the receiver must BE a DOM array
|
|
466
|
+
* (else the Node-shaped TypeError above); the predicate runs per element
|
|
467
|
+
* over the DOM value, and each SURVIVOR is validated-extracted into the
|
|
468
|
+
* result's element type T — the type the checker already committed the
|
|
469
|
+
* call to (the contextual `RouteMapping[]`/`string[]` slot). Extraction is
|
|
470
|
+
* the checked-cast machinery: a survivor that doesn't fit T throws the
|
|
471
|
+
* catchable TypeError instead of misreading (a LYING predicate is the only
|
|
472
|
+
* way there). The result is a fresh STATIC array of extracted copies —
|
|
473
|
+
* the dyn boundary's marshal-copy stance (SEMANTICS.md). Null when the
|
|
474
|
+
* call shape isn't claimable (the method-call fence stays). */
|
|
475
|
+
export declare function lowerDynArrayFilterCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, recv: IrExpr): IrExpr | null;
|
|
476
|
+
/** `.flatMap(f)` on a dyn ('unknown'/`any[]`-narrowed) receiver where the
|
|
477
|
+
* callback returns a STATIC array (`parsed.flatMap((v) => typeof v ===
|
|
478
|
+
* "string" ? parseTldList(v) : [])` — the tlds-file shape): the DOM
|
|
479
|
+
* array walks element-by-element, the callback sees each element as the
|
|
480
|
+
* DOM value `unknown` code sees, and its typed results concatenate —
|
|
481
|
+
* depth-1 flatten by construction, no validation needed on the results
|
|
482
|
+
* (they are already typed; only the RECEIVER is dynamic). Non-array
|
|
483
|
+
* receivers throw the Node-shaped TypeError. Callbacks returning
|
|
484
|
+
* NON-array values (JS would keep them as single elements) or dynamic
|
|
485
|
+
* results keep the fence — nothing drives them yet. */
|
|
486
|
+
export declare function lowerDynArrayFlatMapCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression, recv: IrExpr): IrExpr | null;
|