@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,272 @@
|
|
|
1
|
+
import * as ts from "../ts7/adapter.js";
|
|
2
|
+
import type { Lowerer } from "./lowerer.js";
|
|
3
|
+
import { UNSUPPORTED } from "../../diagnostics/diagnostic.js";
|
|
4
|
+
import { IrExpr, IrLibFn, IrStrIntrinsicMethod, IrType } from "../../ir/nodes.js";
|
|
5
|
+
/** Statement-level constructs rejected wholesale, keyed by syntax kind. */
|
|
6
|
+
export declare const UNSUPPORTED_STMT: Partial<Record<ts.SyntaxKind, {
|
|
7
|
+
code: keyof typeof UNSUPPORTED;
|
|
8
|
+
feature?: string;
|
|
9
|
+
}>>;
|
|
10
|
+
export declare const UNSUPPORTED_EXPR: Partial<Record<ts.SyntaxKind, {
|
|
11
|
+
code: keyof typeof UNSUPPORTED;
|
|
12
|
+
feature?: string;
|
|
13
|
+
}>>;
|
|
14
|
+
/** The narrow-first hint every union fence shares — how to get from a
|
|
15
|
+
* union-typed value to the single arm the static compiler can use. One
|
|
16
|
+
* string so the fences speak with one voice (and match SC2003's hint). */
|
|
17
|
+
export declare const NARROW_FIRST = "narrow first: check a discriminant field, or compare with '!== undefined'/'!== null' for unit arms";
|
|
18
|
+
/** True iff evaluating the option value can have no observable effect —
|
|
19
|
+
* the drop-safety test of the options-record stance. Literals, identifier
|
|
20
|
+
* reads (shorthand included), closures (created, never called — the key
|
|
21
|
+
* is unknown, so nothing can reach it), prefix +/-/! over these, and
|
|
22
|
+
* object/array literals of these all qualify; anything with a call,
|
|
23
|
+
* a property read (getters), or an assignment does not. */
|
|
24
|
+
export declare function sideEffectFreeOptionValue(node: ts.Expression): boolean;
|
|
25
|
+
/** The stance's tail: `key` is outside the walk's lowered set. Documented
|
|
26
|
+
* keys of the API fence by name (pointed per-key hints first, the walk's
|
|
27
|
+
* supported-options hint otherwise); undocumented keys drop like Node
|
|
28
|
+
* drops them when the value is side-effect-free, and fence when it is
|
|
29
|
+
* not. `prop` is the property entry (assignment or shorthand) for spans. */
|
|
30
|
+
export declare function fenceOrDropOptionKey(L: Lowerer, prop: ts.ObjectLiteralElementLike, key: string, api: string, documented: ReadonlySet<string>, supportedHint: string, pointedHints?: Record<string, string | undefined>): void;
|
|
31
|
+
/** http.request/http.get's documented option keys (Node v24 — the
|
|
32
|
+
* `http.request(options)` and `net.socket.connect` tables); everything
|
|
33
|
+
* else on a client options literal is undocumented and drops. */
|
|
34
|
+
export declare const HTTP_CLIENT_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
35
|
+
/** http.createServer / http.Server's documented option keys (Node v24 —
|
|
36
|
+
* http.createServer options + the net.Server knobs it forwards). The
|
|
37
|
+
* lowered pair is requireHostHeader/joinDuplicateHeaders; the rest fence
|
|
38
|
+
* by name here, and unknown keys drop like Node drops them. */
|
|
39
|
+
export declare const HTTP_SERVER_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
40
|
+
/** https.request adds tls.connect's client-side TLS knobs. */
|
|
41
|
+
export declare const HTTPS_CLIENT_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
42
|
+
/** tls.createServer / tls.createSecureContext / https.createServer /
|
|
43
|
+
* http2.createSecureServer's documented TLS-side option keys (Node v24 —
|
|
44
|
+
* tls.createSecureContext + tls.createServer + net.createServer). */
|
|
45
|
+
export declare const TLS_SERVER_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
46
|
+
/** http2.createSecureServer's documented keys: the h2 knobs on top of the
|
|
47
|
+
* TLS server set. */
|
|
48
|
+
export declare const HTTP2_SECURE_SERVER_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
49
|
+
/** fs.watch's documented option keys. */
|
|
50
|
+
export declare const FS_WATCH_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
51
|
+
/** fs.readdirSync's documented option keys. */
|
|
52
|
+
export declare const FS_READDIR_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
53
|
+
/** fs.writeFileSync's documented option keys. */
|
|
54
|
+
export declare const FS_WRITE_FILE_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
55
|
+
/** dns.lookup's documented option keys. */
|
|
56
|
+
export declare const DNS_LOOKUP_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
57
|
+
/** readline.createInterface's documented option keys. */
|
|
58
|
+
export declare const READLINE_DOCUMENTED_OPTIONS: ReadonlySet<string>;
|
|
59
|
+
/** The lowered Array<T> method surface. Like STR_METHODS, membership is
|
|
60
|
+
* only half the check — the resolved symbol must be declared by the
|
|
61
|
+
* standard library (isStdlibMember); lib-declared array methods outside
|
|
62
|
+
* this set hit the SC2020 fence. */
|
|
63
|
+
export declare const ARRAY_METHODS: Set<string>;
|
|
64
|
+
/** The lowered Map<K, V> method surface. Like ARRAY_METHODS, membership is
|
|
65
|
+
* only half the check — the resolved symbol must be declared by the
|
|
66
|
+
* standard library (isStdlibMember). `size` is a property, handled in
|
|
67
|
+
* property-access position. */
|
|
68
|
+
export declare const MAP_METHODS: Set<string>;
|
|
69
|
+
/** The lowered Set<T> method surface — Map's minus get/set plus add.
|
|
70
|
+
* `size` is a property, handled in property-access position. */
|
|
71
|
+
export declare const SET_METHODS: Set<string>;
|
|
72
|
+
/** The ES2025 Set composition surface (union/intersection/…): desugared
|
|
73
|
+
* to interned helper loops over the set iteration primitives — no user
|
|
74
|
+
* code runs mid-loop, so the walks need no enter/exit bracketing. The
|
|
75
|
+
* lib accepts any ReadonlySetLike argument; only a real Set lowers (the
|
|
76
|
+
* argument's has/size must be the builtins for the desugar to BE the
|
|
77
|
+
* spec's algorithm). */
|
|
78
|
+
export declare const SET_COMBINE_METHODS: Set<string>;
|
|
79
|
+
export type CompoundOp = "+" | "-" | "*" | "/" | "%" | "**" | "&" | "|" | "^" | "<<" | ">>" | ">>>";
|
|
80
|
+
export declare const COMPOUND_ASSIGN_OPS: Partial<Record<ts.SyntaxKind, CompoundOp>>;
|
|
81
|
+
/** String methods lowered to `strIntrinsic` (`.length` is handled in
|
|
82
|
+
* property-access position). Membership here is only half the check: the
|
|
83
|
+
* resolved symbol must also be declared by the standard library (see
|
|
84
|
+
* isStdlibMember), so a user-declared `slice` on some other type can never
|
|
85
|
+
* smuggle itself in by name. `minArgs`/`maxArgs` pin the LOWERED call
|
|
86
|
+
* forms: the lib declares wider signatures (optional position/fromIndex
|
|
87
|
+
* parameters) that typecheck but have no lowering — those forms are fenced
|
|
88
|
+
* per site instead of silently dropping arguments. */
|
|
89
|
+
export declare const STR_METHODS: Record<string, {
|
|
90
|
+
method: IrStrIntrinsicMethod;
|
|
91
|
+
result: IrType;
|
|
92
|
+
minArgs: number;
|
|
93
|
+
maxArgs: number;
|
|
94
|
+
}>;
|
|
95
|
+
/** One member of the island-backed ambient surface: declared argument
|
|
96
|
+
* types (tsc enforces them at call sites; the arity double-checks the
|
|
97
|
+
* table against the ambient file) and the validated island-exit target the
|
|
98
|
+
* engine's result must satisfy. */
|
|
99
|
+
export interface IslandFnEntry {
|
|
100
|
+
args: IrType[];
|
|
101
|
+
ret: IrType;
|
|
102
|
+
}
|
|
103
|
+
export declare const ISL_N1: IslandFnEntry;
|
|
104
|
+
export declare const ISL_N2: IslandFnEntry;
|
|
105
|
+
export declare const boundaryIntoIslandMsg: (typeName: string) => string;
|
|
106
|
+
export declare const boundaryOutOfIslandMsg: (typeName: string) => string;
|
|
107
|
+
/** The island-backed surface — standard-library APIs with no static
|
|
108
|
+
* runtime implementation (Math.*, number/string methods beyond the
|
|
109
|
+
* intrinsic set, parseFloat, ...). ONE table drives both sides of the
|
|
110
|
+
* gate: under --dynamic each entry lowers to marshal → engine execution →
|
|
111
|
+
* validated exit to the declared return type; without the flag each use
|
|
112
|
+
* site is a per-site SC2012. Membership here is only half the check — the
|
|
113
|
+
* resolved symbol must be declared by the standard library (provenance,
|
|
114
|
+
* never names), so a user's own `parseFloat` or `.toFixed` takes the
|
|
115
|
+
* ordinary paths. The lib declares MORE than this table (extra members,
|
|
116
|
+
* optional-parameter forms): everything untabled falls through to the
|
|
117
|
+
* SC2020 lib fence — never an ICE, never a link error. Exported so the
|
|
118
|
+
* table-vs-lib consistency test can check every entry against the lib's
|
|
119
|
+
* own declarations — a drifted entry fails a test instead of surprising a
|
|
120
|
+
* user. */
|
|
121
|
+
export declare const ISLAND_SURFACE: {
|
|
122
|
+
/** `Math.<fn>(...)` lowers to callMethod(globalGet("Math"), fn, args);
|
|
123
|
+
* the readonly number props (`Math.PI`) to getProp(globalGet("Math")).
|
|
124
|
+
* min/max/atan2/hypot/pow are declared with exactly two parameters
|
|
125
|
+
* (rest/optional parameters aren't representable). */
|
|
126
|
+
math: {
|
|
127
|
+
fns: Record<string, IslandFnEntry | undefined>;
|
|
128
|
+
props: Record<string, IrType | undefined>;
|
|
129
|
+
};
|
|
130
|
+
/** Methods on `number` receivers. The receiver marshals by value; the
|
|
131
|
+
* engine auto-boxes primitives on method calls, so `this` binds the
|
|
132
|
+
* number exactly as in JS. toString takes an EXPLICIT radix (radix-free
|
|
133
|
+
* conversion is the static template-literal path). */
|
|
134
|
+
number: Record<string, IslandFnEntry | undefined>;
|
|
135
|
+
/** Methods on `string` receivers beyond the static strIntrinsic set
|
|
136
|
+
* (split/pad/trimStart/trimEnd moved to STR_METHODS — static now).
|
|
137
|
+
* replace/replaceAll take STRING patterns (no regex is declared). `at`
|
|
138
|
+
* returns `string`: out of range, the engine yields undefined and the
|
|
139
|
+
* validated exit refuses it with a catchable TypeError (the documented
|
|
140
|
+
* divergence from `string | undefined`). */
|
|
141
|
+
string: Record<string, IslandFnEntry | undefined>;
|
|
142
|
+
/** Global functions: parseInt and isNaN are STATIC (lower-calls.ts →
|
|
143
|
+
* num.parseInt/num.isNaN), and parseFloat/isFinite lower statically
|
|
144
|
+
* over EXACTLY-typed arguments (a string for parseFloat, a number for
|
|
145
|
+
* isFinite — num.parseFloat/number.isFinite); these island entries
|
|
146
|
+
* carry every OTHER argument shape, where the ToNumber/ToString
|
|
147
|
+
* coercions stay engine territory. */
|
|
148
|
+
globals: Record<string, IslandFnEntry | undefined>;
|
|
149
|
+
};
|
|
150
|
+
/** Math members with a STATIC lowering — each is one C call that IS the
|
|
151
|
+
* JS operation, at the tabled arity (floor: libm's floor; min/max: the
|
|
152
|
+
* NaN-poisoning ±0-ordered scalar folds; random: arc4random-backed
|
|
153
|
+
* uniform [0,1) — SEMANTICS.md 62). Checked BEFORE the island table
|
|
154
|
+
* (lowerIslandMethodCall), so the tabled arities compile statically and
|
|
155
|
+
* other arities keep the island/fence story; unioned with the island
|
|
156
|
+
* table for the methods-as-values fence (lowerMathProperty). */
|
|
157
|
+
export declare const STATIC_MATH_FNS: Record<string, {
|
|
158
|
+
fn: IrLibFn;
|
|
159
|
+
arity: number;
|
|
160
|
+
} | undefined>;
|
|
161
|
+
/** One lowerable builtin-module FUNCTION: `fn`'s libCall with `params`
|
|
162
|
+
* completed exactly. `variadicPack` marks Node's rest-parameter functions
|
|
163
|
+
* (path.join/resolve): every argument lowers as a string and the frontend
|
|
164
|
+
* packs them into ONE string[] array-literal argument, so the C ABI stays
|
|
165
|
+
* fixed-arity. `defaults` completes omitted TRAILING arguments with string
|
|
166
|
+
* literals (path.basename's suffix → "", a Node no-op). */
|
|
167
|
+
export interface BuiltinModuleFn {
|
|
168
|
+
fn: IrLibFn;
|
|
169
|
+
params: IrType[];
|
|
170
|
+
result: IrType;
|
|
171
|
+
variadicPack?: boolean;
|
|
172
|
+
defaults?: string[];
|
|
173
|
+
}
|
|
174
|
+
export declare const BUILTIN_MODULE_FNS: Record<string, Record<string, BuiltinModuleFn | undefined> | undefined>;
|
|
175
|
+
/** Builtin-module CONSTANTS (value reads of named imports): each lowers to
|
|
176
|
+
* a literal of its value's kind. The bare-module values are the TARGET
|
|
177
|
+
* platform's (builtinModuleConstOf swaps the win32 values in under a win32
|
|
178
|
+
* triple — Node's own platform conditionals); the named namespaces answer
|
|
179
|
+
* THEIR platform's constants everywhere. worker_threads/cluster carry the
|
|
180
|
+
* main-thread truths: a compiled binary IS the main thread (no JS-engine
|
|
181
|
+
* thread machinery) and never runs as a cluster worker (cluster forks the
|
|
182
|
+
* node binary itself) — Node's own answers for a directly-run script. */
|
|
183
|
+
export declare const BUILTIN_MODULE_CONSTS: Record<string, Record<string, string | number | boolean | undefined> | undefined>;
|
|
184
|
+
/** BUILTIN_MODULE_FNS with the platform-conditional modules bound per
|
|
185
|
+
* TARGET: a win32 triple compiles Node-on-Windows semantics — `path` is
|
|
186
|
+
* path.win32 and url's bridge takes the win32 flavors. Fence wording is
|
|
187
|
+
* unaffected — callers keep naming the module the source spelled. */
|
|
188
|
+
export declare function builtinModuleFnsOf(L: Lowerer, module: string): Record<string, BuiltinModuleFn | undefined> | undefined;
|
|
189
|
+
/** One MEMBER's table entry, own-property-safe (`path.toString` must not
|
|
190
|
+
* answer Object.prototype.toString as a BuiltinModuleFn). */
|
|
191
|
+
export declare function builtinModuleFnOf(L: Lowerer, module: string, member: string): BuiltinModuleFn | undefined;
|
|
192
|
+
/** One member's fence hint, own-property-safe (a collision would print an
|
|
193
|
+
* inherited function into the diagnostic text). */
|
|
194
|
+
export declare function builtinFenceHintOf(module: string, member: string): string | undefined;
|
|
195
|
+
/** BUILTIN_MODULE_CONSTS with the win32-target overrides applied — the
|
|
196
|
+
* constants twin of builtinModuleFnsOf. */
|
|
197
|
+
export declare function builtinModuleConstOf(L: Lowerer, module: string, member: string): string | number | boolean | undefined;
|
|
198
|
+
/** The IR literal of a builtin-module constant — one place so both value
|
|
199
|
+
* paths (named-import bindings and namespace member reads) emit the same
|
|
200
|
+
* kinds. */
|
|
201
|
+
export declare function builtinConstLit(value: string | number | boolean, loc: {
|
|
202
|
+
file: string;
|
|
203
|
+
start: number;
|
|
204
|
+
end: number;
|
|
205
|
+
}): IrExpr;
|
|
206
|
+
/** Member-specific hints for RECOGNIZED builtin modules whose member has
|
|
207
|
+
* no lowering. deflateSync/inflateSync lower now (Buffers are real);
|
|
208
|
+
* the rest of the zlib surface points at the lowered pair. */
|
|
209
|
+
export declare const ZLIB_HINT = "deflateSync and inflateSync are the lowered zlib surface";
|
|
210
|
+
export declare const BUILTIN_MODULE_FENCE_HINTS: Record<string, Record<string, string | undefined> | undefined>;
|
|
211
|
+
/** The MEMBER chokepoint of the lib fence: called from the property-read
|
|
212
|
+
* and method-call fallbacks after every lowering has passed. When the
|
|
213
|
+
* accessed member is stdlib-declared, the use is standard-library surface
|
|
214
|
+
* with no lowering — report SC2020 naming `<container>.<member>` (the
|
|
215
|
+
* receiver's global name when it IS a stdlib global like Math or Promise,
|
|
216
|
+
* its widened type text otherwise). Returns silently for non-stdlib
|
|
217
|
+
* members so the caller's generic rejection applies. */
|
|
218
|
+
export declare function stdlibMemberFence(L: Lowerer, access: ts.PropertyAccessExpression): void;
|
|
219
|
+
/** True iff the accessed member is declared by the standard library —
|
|
220
|
+
* the same technique as isConsoleLog: trust declarations, not names. */
|
|
221
|
+
export declare function isStdlibMember(L: Lowerer, access: ts.PropertyAccessExpression): boolean;
|
|
222
|
+
/** The provenance check the CHILD receiver lowerings use: a stdlib
|
|
223
|
+
* member, OR a member the user's own child-shaped interface declares
|
|
224
|
+
* (the NgrokChildProcess idiom — mapType's duck rule admits an
|
|
225
|
+
* interface only when EVERY member names the lowered ChildProcess
|
|
226
|
+
* surface, so accepting its members here cannot widen the surface;
|
|
227
|
+
* the receiver-kind gate already proved the type maps to child). */
|
|
228
|
+
export declare function isChildSurfaceMember(L: Lowerer, access: ts.PropertyAccessExpression): boolean;
|
|
229
|
+
/** True iff some declaration of the symbol lives in the standard library
|
|
230
|
+
* (shipped ambient or default lib — the provenance half of every
|
|
231
|
+
* supported-surface check). `some`, not `[0]`: divergence overrides merge
|
|
232
|
+
* with lib interfaces, so a member can carry declarations from both. A
|
|
233
|
+
* user's own declaration is in neither, so shadowing never matches. */
|
|
234
|
+
export declare function isStdlibSymbol(L: Lowerer, symbol: ts.Symbol | undefined): boolean;
|
|
235
|
+
/** The canonical stdlib-global name `expr` denotes, or null. Three
|
|
236
|
+
* spellings reach the same global (Node's own aliasing):
|
|
237
|
+
* - the bare identifier (`process`), name + provenance checked;
|
|
238
|
+
* - the `global` identifier — Node's alias of globalThis — and
|
|
239
|
+
* `globalThis` itself both canonicalize to "globalThis";
|
|
240
|
+
* - a property read off globalThis (`globalThis.process`,
|
|
241
|
+
* `global.process`) — `declare var` globals ARE properties of
|
|
242
|
+
* `typeof globalThis`, same symbol either way;
|
|
243
|
+
* - a local alias binding (`const process = globalThis.process`, the
|
|
244
|
+
* tamper-guard prologue) registered in stdlibGlobalAliases. */
|
|
245
|
+
export declare function stdlibGlobalNameOf(L: Lowerer, expr: ts.Expression): string | null;
|
|
246
|
+
/** True iff `expr` denotes THE standard-library global `name` — name AND
|
|
247
|
+
* provenance, because neither alone suffices: several globals share
|
|
248
|
+
* member names (Math.log must never lower as console.log), and a user
|
|
249
|
+
* binding shadowing a global's name has a different, non-stdlib symbol.
|
|
250
|
+
* All of stdlibGlobalNameOf's spellings answer (globalThis.process is
|
|
251
|
+
* process; `const process = globalThis.process` aliases through). */
|
|
252
|
+
export declare function isStdlibGlobal(L: Lowerer, expr: ts.Expression, name: string): boolean;
|
|
253
|
+
/** The member name of a `<global>.<member>` access whose receiver is THE
|
|
254
|
+
* standard-library global `name` (console, JSON, process, Math). Null for
|
|
255
|
+
* anything else, so property-lowering chains keep trying other
|
|
256
|
+
* receivers. */
|
|
257
|
+
export declare function stdlibGlobalMember(L: Lowerer, access: ts.PropertyAccessExpression, name: string): string | null;
|
|
258
|
+
/** `const process = globalThis.process` (and any `const x = <stdlib
|
|
259
|
+
* global>` snapshot — the suite harness's tamper-guard prologue): the
|
|
260
|
+
* binding is pure alias plumbing. Nothing in a compiled program can
|
|
261
|
+
* reassign a stdlib global, so the snapshot IS the global: the symbol
|
|
262
|
+
* registers in stdlibGlobalAliases (every receiver check resolves
|
|
263
|
+
* through it — see stdlibGlobalNameOf) and the declaration emits
|
|
264
|
+
* nothing. Only the globals with lowered member surfaces alias this
|
|
265
|
+
* way; aliasing, say, `Math` would change nothing (its members lower
|
|
266
|
+
* by receiver too). Returns true when recognized. */
|
|
267
|
+
export declare function stdlibGlobalAliasDecl(L: Lowerer, nameNode: ts.Node, init: ts.Expression | undefined): boolean;
|
|
268
|
+
/** True iff the symbol is declared ONLY by the adopted @types/node
|
|
269
|
+
* surface (no es-lib or shipped-ambient declaration merges in) — chooses
|
|
270
|
+
* the SC2020 fence's wording: "typed by @types/node", not "standard
|
|
271
|
+
* library". */
|
|
272
|
+
export declare function nodeTypesOnlySymbol(L: Lowerer, sym: ts.Symbol | null | undefined): boolean;
|