@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,135 @@
|
|
|
1
|
+
import * as ts from "../ts7/adapter.js";
|
|
2
|
+
import type { Lowerer } from "./lowerer.js";
|
|
3
|
+
import { IrClassDef, IrFunction, IrRecordShape, IrStmt, IrUnionDef } from "../../ir/nodes.js";
|
|
4
|
+
/** One file's declarations, split for collection and init-body lowering. */
|
|
5
|
+
export interface FileParts {
|
|
6
|
+
sf: ts.SourceFile;
|
|
7
|
+
fnDecls: ts.FunctionDeclaration[];
|
|
8
|
+
classDecls: ts.ClassDeclaration[];
|
|
9
|
+
topStmts: ts.Statement[];
|
|
10
|
+
}
|
|
11
|
+
/** Splits each file into function/class declarations and the top-level
|
|
12
|
+
* statements that form its init body. Node's evaluation order (depth-first
|
|
13
|
+
* postorder, entry last), computed by preflight. Single-file programs
|
|
14
|
+
* (tests, coverage on broken files) may arrive with an empty order — fall
|
|
15
|
+
* back to the entry alone. */
|
|
16
|
+
export declare function splitFiles(L: Lowerer): FileParts[];
|
|
17
|
+
/** A source file dynamic `import("<relative>")` can host as a COMPILED
|
|
18
|
+
* module namespace (lowerOwnModuleImport): a non-declaration program file
|
|
19
|
+
* that is not JSON and not CommonJS-flavored (a CJS namespace is built
|
|
20
|
+
* from module.exports through Node's lexer — a different surface with no
|
|
21
|
+
* static story here). Null for everything else. */
|
|
22
|
+
export declare function dynamicImportProgramTargetOf(program: ts.Program, sf: ts.SourceFile, spec: string): ts.SourceFile | null;
|
|
23
|
+
/** --dynamic builds: program modules reachable ONLY through dynamic
|
|
24
|
+
* `import()` join the compiled module graph — appended to `order` (before
|
|
25
|
+
* the entry, which stays last) in depth-first postorder over their own
|
|
26
|
+
* static import edges, exactly like preflight ordered the static graph.
|
|
27
|
+
* NOTHING calls their %init at startup (%main runs only the entry's init,
|
|
28
|
+
* and no static import header names these), so a dynamic-only module
|
|
29
|
+
* still evaluates exactly when Node evaluates it: the import() site's
|
|
30
|
+
* namespace builder calls the guarded init on the engine microtask.
|
|
31
|
+
* Fixpoint: an added module's own import() sites are scanned too. Static
|
|
32
|
+
* cycles inside the added subgraph get preflight's SC1016 via `onCycle`
|
|
33
|
+
* (preflight only walked the entry's static graph, so it never saw
|
|
34
|
+
* these). Idempotent — re-running on an already-extended order adds
|
|
35
|
+
* nothing (both lowering passes share one array). */
|
|
36
|
+
export declare function appendDynamicImportModules(program: ts.Program, order: ts.SourceFile[], onCycle: (cycle: string) => void): void;
|
|
37
|
+
/** Collect pass over the WHOLE program: signatures, class shapes, and
|
|
38
|
+
* file-scope globals visible everywhere → hoisting, mutual recursion, and
|
|
39
|
+
* cross-module references fall out for free. Runs in both passes —
|
|
40
|
+
* signatures are cheap and calls resolve against them; only BODY lowering
|
|
41
|
+
* is reachability-gated. */
|
|
42
|
+
export declare function collectProgram(L: Lowerer, parts: FileParts[]): void;
|
|
43
|
+
/** The npm-import chokepoint, run once per pass during collection (so
|
|
44
|
+
* bodies lowered in ANY pass resolve the bindings). In a static build
|
|
45
|
+
* every value-importing npm import reports the requires-dynamic
|
|
46
|
+
* diagnostic naming the package — the package's shipped JS has exactly
|
|
47
|
+
* one execution home, the embedded engine. Under --dynamic each value
|
|
48
|
+
* binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
|
|
49
|
+
* importing the same export share one global) and initialized at the
|
|
50
|
+
* top of the importing module's %init by island.import — the engine's
|
|
51
|
+
* module registry caches, so re-imports are lookups, not re-evaluations.
|
|
52
|
+
* The runtime graph (the package entry plus everything it reaches)
|
|
53
|
+
* builds here too; its failures are ordinary diagnostics at the import
|
|
54
|
+
* site. Type-only imports are free either way: the .d.ts is a type
|
|
55
|
+
* surface, not code. */
|
|
56
|
+
export declare function collectNpmImports(L: Lowerer, parts: FileParts[]): void;
|
|
57
|
+
/** JSON module default imports (`import pkg from "../package.json"`):
|
|
58
|
+
* the document is DATA known at build time, so the binding bakes into a
|
|
59
|
+
* record global — the checker's structural type for the module (thanks
|
|
60
|
+
* to resolveJsonModule) maps to a record shape, the JSON text parses in
|
|
61
|
+
* the compiler, and comptimeValueToIr turns the value into literal IR
|
|
62
|
+
* assigned in the importing module's %init prelude (evaluation order:
|
|
63
|
+
* imports before the importer's body, like npm bindings). Two importers
|
|
64
|
+
* of the same document share one global (keyed by the ALIASED symbol).
|
|
65
|
+
* Shapes outside the bakeable surface (null-valued fields, mixed
|
|
66
|
+
* arrays, ...) report the standard unsupported-type diagnostic at the
|
|
67
|
+
* import site. Preflight already fenced named/namespace JSON imports
|
|
68
|
+
* and kept .json files out of the module order. */
|
|
69
|
+
export declare function collectJsonImports(L: Lowerer, parts: FileParts[]): void;
|
|
70
|
+
/** The classes, records, and unions the emitted module carries: exactly
|
|
71
|
+
* what the lowered functions and globals reference, closed transitively
|
|
72
|
+
* over record fields, union arms, class field types, base chains, and
|
|
73
|
+
* WHOLE hierarchies (hierarchy membership decides object layout:
|
|
74
|
+
* dropping an unused subclass must not turn its base into a standalone
|
|
75
|
+
* class at emit time). Registry entries interned while collecting
|
|
76
|
+
* signatures nothing reaches stay out — an unreached type leaves no
|
|
77
|
+
* trace. A referenced class with no registration had its collection
|
|
78
|
+
* deferred: the reference flushes those diagnostics. Methods whose
|
|
79
|
+
* bodies were not lowered leave the def's method list, so vtable slots
|
|
80
|
+
* exist exactly for emitted overrides. */
|
|
81
|
+
export declare function moduleArtifacts(L: Lowerer, functions: IrFunction[]): {
|
|
82
|
+
classes: IrClassDef[];
|
|
83
|
+
records: IrRecordShape[];
|
|
84
|
+
unions: IrUnionDef[];
|
|
85
|
+
};
|
|
86
|
+
export declare function collectGlobals(L: Lowerer, sf: ts.SourceFile, topStmts: ts.Statement[]): void;
|
|
87
|
+
/** The checker's symbol for a module's default export — the symbol a
|
|
88
|
+
* default import of this module aliases to (getAliasedSymbol), so keying
|
|
89
|
+
* the default's global by it makes every importer resolve to the same
|
|
90
|
+
* storage through the ordinary globalOf path. Null for modules without
|
|
91
|
+
* a default export (or non-module files). */
|
|
92
|
+
export declare function defaultExportSymbolOf(L: Lowerer, sf: ts.SourceFile): ts.Symbol | null;
|
|
93
|
+
/** The declaration symbol of a top-level function/class declaration,
|
|
94
|
+
* covering the one legal NAMELESS form: `export default function () {}` /
|
|
95
|
+
* `export default class {}`. A named declaration answers through its
|
|
96
|
+
* name node; the anonymous default IS the module's `default` export
|
|
97
|
+
* symbol (the binder declares it there), so collection, reachability,
|
|
98
|
+
* and body lowering all key that one identity — which is also what a
|
|
99
|
+
* default import's alias chain resolves to. */
|
|
100
|
+
export declare function declSymbolOf(L: Lowerer, decl: ts.FunctionDeclaration | ts.ClassDeclaration): ts.Symbol | undefined;
|
|
101
|
+
/** `export default <expr>` in a module's init body: the first (and only)
|
|
102
|
+
* assignment of the pre-registered `default` global — evaluated at the
|
|
103
|
+
* statement's source position, exactly where Node runs it (Node's
|
|
104
|
+
* expression defaults snapshot exactly once, here). ENTITY-NAME defaults
|
|
105
|
+
* are alias plumbing with no storage of their own: the statement lowers
|
|
106
|
+
* to nothing — collection either accepted the alias (const/function/
|
|
107
|
+
* class targets, where importers' alias-resolved reads equal the
|
|
108
|
+
* snapshot) or already fenced it (mutable targets), and re-lowering
|
|
109
|
+
* would double-report. A NON-alias default whose type had no
|
|
110
|
+
* registration (collection reported the blocker) re-lowers the
|
|
111
|
+
* expression so the expression's OWN diagnostic wins when it has one,
|
|
112
|
+
* then poisons. */
|
|
113
|
+
export declare function lowerDefaultExport(L: Lowerer, stmt: ts.ExportAssignment): IrStmt | null;
|
|
114
|
+
/** One file's top-level statements as its init function — RUN-ONCE like a
|
|
115
|
+
* Node module body: non-entry inits open with a guard flag test (already
|
|
116
|
+
* ran → return) and set the flag before anything else, so every caller —
|
|
117
|
+
* hoisted import headers, inline require statements, diamonds, cache-hit
|
|
118
|
+
* re-requires — gets Node's module-cache semantics from the same call.
|
|
119
|
+
* After the guard comes the file's HOISTED module-edge header: one
|
|
120
|
+
* guarded %init call per imported user module and the island loads for
|
|
121
|
+
* npm imports, in import order (Node evaluates every imported module
|
|
122
|
+
* before the importer's body — depth-first postorder falls out of the
|
|
123
|
+
* nesting). CommonJS requires are NOT in the header: Node runs them at
|
|
124
|
+
* their statements, so the statement lowering emits their %init calls
|
|
125
|
+
* inline in the body. JSON-import bindings (pure data) load next; then
|
|
126
|
+
* the body. Top-level var statements assign the pre-registered globals
|
|
127
|
+
* instead of declaring locals. */
|
|
128
|
+
export declare function lowerFileInit(L: Lowerer, sf: ts.SourceFile, stmts: ts.Statement[], name: string): IrFunction;
|
|
129
|
+
/** %main is just the entry's %init call: Node's whole module evaluation
|
|
130
|
+
* order lives in the init functions themselves — each file's hoisted
|
|
131
|
+
* import header runs its dependencies first (depth-first postorder by
|
|
132
|
+
* nesting), CommonJS require statements call dependency inits inline in
|
|
133
|
+
* their bodies, and the run-once guards turn every revisit (diamonds,
|
|
134
|
+
* re-imports, re-requires) into a cache hit. */
|
|
135
|
+
export declare function buildMain(L: Lowerer): IrFunction;
|