@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,95 @@
|
|
|
1
|
+
/* scriptc's divergence and precision overrides — interface merges that
|
|
2
|
+
* re-type a handful of standard-library members to scriptc's documented
|
|
3
|
+
* runtime behavior. Merged interfaces resolve overloads later-declaration-
|
|
4
|
+
* first, so these win at call sites that match them; call forms only the
|
|
5
|
+
* lib signatures accept still typecheck and are fenced by the lowerer.
|
|
6
|
+
*
|
|
7
|
+
* This file is part of the LOWERING program only. Preflight's second-chance
|
|
8
|
+
* pass (checkPreflight) rebuilds the program WITHOUT it — the project's own
|
|
9
|
+
* type world — so a program that typechecks under its own tsc is never
|
|
10
|
+
* rejected over an override-manufactured error; the affected sites meet the
|
|
11
|
+
* lowerer's honest fences instead (SC1100's checked-cast family for
|
|
12
|
+
* JSON.parse results, the executor fences for Promise shapes). The
|
|
13
|
+
* primitives every world needs (comptime, setTimeout, __island_eval) live
|
|
14
|
+
* in scriptc.d.ts, which ships to BOTH programs. */
|
|
15
|
+
|
|
16
|
+
/* `pop(): T`, not the lib's `T | undefined`: popping an empty array traps
|
|
17
|
+
* at runtime — a documented divergence (SEMANTICS.md) this override keeps
|
|
18
|
+
* typecheckable. Check `.length` first, as real code must. */
|
|
19
|
+
interface Array<T> {
|
|
20
|
+
pop(): T;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* `at(): string`, not the lib's `string | undefined`: undefined is
|
|
24
|
+
* unrepresentable, so an out-of-range at() THROWS a catchable TypeError at
|
|
25
|
+
* the validated island exit instead of returning undefined (documented
|
|
26
|
+
* divergence, SEMANTICS.md). */
|
|
27
|
+
interface String {
|
|
28
|
+
at(index: number): string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Object.values/entries with the actual field-value union, not the lib's
|
|
32
|
+
* `any` (the lib's precise overloads only cover index-signature and
|
|
33
|
+
* ArrayLike sources). A PRECISION override, not a divergence: the lowering
|
|
34
|
+
* emits the field list statically and the values are exactly T[keyof T] —
|
|
35
|
+
* without this the result would be `any`-typed and drag every downstream
|
|
36
|
+
* use into the island. */
|
|
37
|
+
interface ObjectConstructor {
|
|
38
|
+
values<T extends object>(o: T): Array<T[keyof T]>;
|
|
39
|
+
entries<T extends object>(o: T): Array<[string, T[keyof T]]>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* `parse` returns `unknown`, not the lib's `any` — the dynamic boundary. A
|
|
43
|
+
* checked cast (`JSON.parse(s) as Config`) validates the value against the
|
|
44
|
+
* target type at runtime and THROWS on mismatch — the mechanism that makes
|
|
45
|
+
* trusting TS types sound at data boundaries. The lib's any-returning
|
|
46
|
+
* overload stays reachable only through the reviver form, which the
|
|
47
|
+
* lowerer rejects (as it does stringify's replacer/space parameters).
|
|
48
|
+
*
|
|
49
|
+
* `stringify` takes `unknown`, not the lib's `any`: the same honest
|
|
50
|
+
* surface, but the parameter must not CONTEXTUALLY TYPE literal arguments
|
|
51
|
+
* as `any` (an any-typed slot is the island boundary; `JSON.stringify([1,
|
|
52
|
+
* 2])` must keep building a static array and serializing it
|
|
53
|
+
* type-directedly). */
|
|
54
|
+
interface JSON {
|
|
55
|
+
parse(text: string): unknown;
|
|
56
|
+
stringify(value: unknown): string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* The supported Promise construction shape: an executor whose resolve takes
|
|
60
|
+
* the plain value. Preferred over the lib signature at inference time, so
|
|
61
|
+
* `new Promise<T>((resolve) => ...)` types resolve as `(value: T) => void`
|
|
62
|
+
* — no PromiseLike union. The reject parameter is a real closure rejecting
|
|
63
|
+
* the promise; its reason is pinned to Error (the lib says `reason?: any`)
|
|
64
|
+
* because rejection payloads ride the same representation as thrown values
|
|
65
|
+
* and the idiomatic reason IS an Error — reject(nonError) and bare
|
|
66
|
+
* reject() typecheck only in the project world and meet the lowerer's
|
|
67
|
+
* honest coercion fences instead. First settle wins, exactly JS: a reject
|
|
68
|
+
* after resolve (or a second reject) is a no-op, and an executor throw
|
|
69
|
+
* after any settle is swallowed. Executors that use the lib signature's
|
|
70
|
+
* other extras (resolving with a thenable) still typecheck and fail
|
|
71
|
+
* lowering on their types. */
|
|
72
|
+
interface PromiseConstructor {
|
|
73
|
+
new <T>(
|
|
74
|
+
executor: (resolve: (value: T) => void, reject: (reason: Error) => void) => void,
|
|
75
|
+
): Promise<T>;
|
|
76
|
+
/* ES2024's Promise.withResolvers, in the executor's own scriptc shape:
|
|
77
|
+
* resolve takes the plain value (no PromiseLike union; the conditional
|
|
78
|
+
* collapses Promise<void>'s resolve to () => void so the record's
|
|
79
|
+
* field types map exactly), reject is the executor's Error-pinned
|
|
80
|
+
* rejection closure. The lib's own declaration would otherwise be
|
|
81
|
+
* unrepresentable field-by-field. */
|
|
82
|
+
withResolvers<T>(): {
|
|
83
|
+
promise: Promise<T>;
|
|
84
|
+
// `0 extends 1 & T` detects any (untyped JS: Promise.withResolvers()
|
|
85
|
+
// infers it) — its settled value rides the dyn arm like unknown's,
|
|
86
|
+
// so resolve takes one unknown; a naked conditional over any would
|
|
87
|
+
// otherwise union BOTH branches, which no field can map.
|
|
88
|
+
resolve: 0 extends 1 & T
|
|
89
|
+
? (value: unknown) => void
|
|
90
|
+
: [T] extends [void]
|
|
91
|
+
? () => void
|
|
92
|
+
: (value: T) => void;
|
|
93
|
+
reject: (reason: Error) => void;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* scriptc's shipped declarations — the ALWAYS-SHIPPED CORE. Programs
|
|
2
|
+
* compile against the REAL TypeScript standard library (lib.es2023, no
|
|
3
|
+
* DOM, no @types): the checker sees the full standard surface, and the
|
|
4
|
+
* LOWERER is the scope fence — any reached use of standard-library surface
|
|
5
|
+
* without a lowering is a SC2020 diagnostic at its use site. This file
|
|
6
|
+
* declares only what the es2023 lib does not:
|
|
7
|
+
*
|
|
8
|
+
* 1. scriptc's own primitives (comptime, __island_eval).
|
|
9
|
+
* 2. setTimeout/clearTimeout and the Timeout handle (Node/DOM territory the
|
|
10
|
+
* lib files don't cover; plain declarations, so with @types/node present
|
|
11
|
+
* they MERGE as overloads instead of colliding — the Timeout handle maps
|
|
12
|
+
* to the numeric timer id either way, and .unref()/.ref()/.hasRef() are
|
|
13
|
+
* loop-liveness bookkeeping).
|
|
14
|
+
*
|
|
15
|
+
* This file ships to EVERY program scriptc builds — the lowering program
|
|
16
|
+
* and preflight's project-world second-chance program alike (a project
|
|
17
|
+
* using comptime must typecheck in both). The divergence/precision
|
|
18
|
+
* overrides (JSON.parse(): unknown, pop(): T, the Promise executor shape,
|
|
19
|
+
* ...) live in scriptc-overrides.d.ts, which joins the LOWERING program only.
|
|
20
|
+
*
|
|
21
|
+
* console, process, and the "node:fs" module live in scriptc-node-fallback.d.ts,
|
|
22
|
+
* shipped ONLY when the target project has no @types/node — with it, the
|
|
23
|
+
* project's real Node types are the type surface and the fallback stands
|
|
24
|
+
* down (its `declare const`/`declare module` forms would collide). The
|
|
25
|
+
* lowering tables recognize the same members either way, by name +
|
|
26
|
+
* provenance. */
|
|
27
|
+
|
|
28
|
+
/* The timer handle — setTimeout's return, mapped to the numeric timer id.
|
|
29
|
+
* unref() drops it from the event loop's keep-alive set (the process may
|
|
30
|
+
* exit with the timer still armed — it never fires then, exactly Node);
|
|
31
|
+
* ref() restores it; hasRef() reports the state. The methods return the
|
|
32
|
+
* handle for chaining. Under @types/node this MERGES with NodeJS.Timeout
|
|
33
|
+
* (both map to the same numeric handle). */
|
|
34
|
+
interface Timeout {
|
|
35
|
+
ref(): Timeout;
|
|
36
|
+
unref(): Timeout;
|
|
37
|
+
hasRef(): boolean;
|
|
38
|
+
/* Re-arms the timer to fire at now + the original delay (Node's
|
|
39
|
+
* Timeout.refresh). Chaining like ref/unref. */
|
|
40
|
+
refresh(): Timeout;
|
|
41
|
+
}
|
|
42
|
+
/* The callback is invoked with NO arguments; the second overload admits a
|
|
43
|
+
* callback declared with one parameter for the sleep idiom —
|
|
44
|
+
* `setTimeout(resolve, ms)` with Promise<unknown>'s resolve — where the
|
|
45
|
+
* zero-argument invocation delivers undefined (@types/node's generic
|
|
46
|
+
* signature admits the same shape and MERGES with these). Promise<void>'s
|
|
47
|
+
* resolve keeps matching the first overload (void params accept absence). */
|
|
48
|
+
declare function setTimeout(callback: () => void, ms?: number): Timeout;
|
|
49
|
+
declare function setTimeout(callback: (value?: unknown) => void, ms?: number): Timeout;
|
|
50
|
+
/* The trailing-argument form: Node passes the extras to the callback
|
|
51
|
+
* (`setTimeout(cb, 0, 'foo')` fires cb('foo')). The callback slot accepts
|
|
52
|
+
* any function shape (never[] rest — parameter-contravariance's bottom);
|
|
53
|
+
* the delivered call rides the checked-dynamic boundary, so each argument
|
|
54
|
+
* is validated against the callback's real signature at fire time. */
|
|
55
|
+
declare function setTimeout(callback: (...args: never[]) => void, ms?: number, ...args: unknown[]): Timeout;
|
|
56
|
+
declare function clearTimeout(handle?: Timeout | number | null | undefined): void;
|
|
57
|
+
|
|
58
|
+
/* Compile-time evaluation. The callback must be an inline arrow/function
|
|
59
|
+
* expression with NO references to outer bindings (it is extracted
|
|
60
|
+
* source-textually and executed in an isolated node:vm context inside the
|
|
61
|
+
* COMPILER's Node process); the returned value is baked into the binary as a
|
|
62
|
+
* literal — numbers (finite), strings, booleans, arrays, and records,
|
|
63
|
+
* nested. What type-checks runs with real JavaScript semantics, so the
|
|
64
|
+
* baked result is exactly what Node would compute at runtime (the
|
|
65
|
+
* differential harness verifies this with a `comptime = (f) => f()` shim). */
|
|
66
|
+
declare function comptime<T>(compute: () => T): T;
|
|
67
|
+
|
|
68
|
+
/* INTERNAL TESTING HOOK — not part of the supported surface, deliberately
|
|
69
|
+
* undocumented. Evaluates `code` in the embedded dynamic-island engine and
|
|
70
|
+
* returns String(result); island exceptions arrive as catchable errors.
|
|
71
|
+
* Requires --dynamic (a clean diagnostic otherwise). This exists to prove
|
|
72
|
+
* the engine embed end-to-end in tests; user-facing constructs will lower
|
|
73
|
+
* to the island through their own paths, not through this. */
|
|
74
|
+
declare function __island_eval(code: string): string;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export interface CcOptions {
|
|
2
|
+
/** Path of the generated (or hand-written) program TU: a .c file, or the
|
|
3
|
+
* LLVM backend's .ll — clang compiles IR text natively on the same
|
|
4
|
+
* command line, so both ride this one seat. */
|
|
5
|
+
cPath: string;
|
|
6
|
+
/** Path of the native executable to produce. */
|
|
7
|
+
outPath: string;
|
|
8
|
+
/** Build with ASan + the runtime RC audit (test/debug lane). */
|
|
9
|
+
sanitize?: boolean;
|
|
10
|
+
/** Embed the dynamic-island engine (--dynamic): compiles scr_island.c,
|
|
11
|
+
* defines SCR_DYNAMIC, and links the cached libqjs.a. Off = the static
|
|
12
|
+
* default, byte-identical to builds predating the flag. */
|
|
13
|
+
dynamic?: boolean;
|
|
14
|
+
/** The program contains a regex construct (index.ts detects it on the
|
|
15
|
+
* IR): compiles scr_regex.c and links the vendored libregexp — as cached
|
|
16
|
+
* standalone objects in static builds, from the engine archive under
|
|
17
|
+
* --dynamic (one libregexp per binary; its host hooks want the island's
|
|
18
|
+
* JSContext there). Off = regex-free: the command line is exactly the
|
|
19
|
+
* historical one, so regex-free binaries cannot change by a byte. */
|
|
20
|
+
regex?: boolean;
|
|
21
|
+
/** The embedded npm graph references fetch (index.ts detects it on the
|
|
22
|
+
* IR): compiles the NATIVE fetch bridge (scr_fetch.c over scr_net +
|
|
23
|
+
* scr_tls + scr_http's client parser + zlib — the socket units join
|
|
24
|
+
* the link implicitly, no libcurl anywhere), which builds for every
|
|
25
|
+
* target the socket units reach: hosts, linux cross, win32 cross. Only
|
|
26
|
+
* meaningful under `dynamic`; fetch-free builds keep their exact link
|
|
27
|
+
* line. SCRIPTC_FETCH_CURL=1 selects the retired curl reference instead
|
|
28
|
+
* (scr_fetch_curl.c + system libcurl on hosts / the generated soname
|
|
29
|
+
* stub on linux cross targets — ensureCurlStub), kept compilable for
|
|
30
|
+
* one release as the flip's reference. */
|
|
31
|
+
fetch?: boolean;
|
|
32
|
+
/** The embedded npm graph imports node:http or node:https (index.ts
|
|
33
|
+
* detects it on the IR): compiles the island's http/https client
|
|
34
|
+
* bridge (scr_net_island.c) and implies the socket units into the
|
|
35
|
+
* link, exactly like fetch. The emitted main calls
|
|
36
|
+
* scr_net_island_install on the same predicate (native-fetch builds
|
|
37
|
+
* also register it from scr_fetch_install). */
|
|
38
|
+
netIsland?: boolean;
|
|
39
|
+
/** The program uses zlib (index.ts detects zlib.* libCalls on the IR):
|
|
40
|
+
* compiles scr_zlib.c — the regex/curl gating precedent, so zlib-free
|
|
41
|
+
* binaries keep their exact link line. Host builds link the SYSTEM libz
|
|
42
|
+
* (macOS ships it), byte-identical to the historical line; cross targets
|
|
43
|
+
* compile the vendored zlib per target instead (ensureZlibObjects — zig
|
|
44
|
+
* has no libz in its sysroots). Compressed bytes may differ between the
|
|
45
|
+
* system and vendored libraries, which is why the corpus only ever
|
|
46
|
+
* compares round-trips and fixed-blob inflation, never raw deflate
|
|
47
|
+
* output. */
|
|
48
|
+
zlib?: boolean;
|
|
49
|
+
/** The program uses node:assert (index.ts detects assert.* libCalls on
|
|
50
|
+
* the IR): compiles scr_assert.c — the zlib gating precedent, so
|
|
51
|
+
* assert-free binaries keep their exact size class. scr_regex.c calls
|
|
52
|
+
* the assert throw/inspect helpers (assert.match lives there) and
|
|
53
|
+
* scr_symbol.c calls the equality message assemblers (assert.eqSym
|
|
54
|
+
* lives there), so the regex and symbol switches also pull this
|
|
55
|
+
* file. */
|
|
56
|
+
assert?: boolean;
|
|
57
|
+
/** The program uses util.inspect/format (index.ts detects insp.*
|
|
58
|
+
* libCalls on the IR): compiles scr_inspect.c — the assert gating
|
|
59
|
+
* precedent, so inspect-free binaries keep their exact size class. */
|
|
60
|
+
inspect?: boolean;
|
|
61
|
+
/** The program dispatches prototype methods on dyn receivers (index.ts
|
|
62
|
+
* detects dynInvoke nodes / dyn.defineProps libCalls on the IR):
|
|
63
|
+
* compiles scr_dyn_invoke.c — the assert gating precedent, so
|
|
64
|
+
* dispatch-free binaries keep their exact size class. */
|
|
65
|
+
dynInvoke?: boolean;
|
|
66
|
+
/** The program uses the diagnostics_channel surface (index.ts detects
|
|
67
|
+
* dc.* libCalls on the IR): compiles scr_dc.c — pure data structure
|
|
68
|
+
* over the DOM (no loop hooks, no install), cross-compiles everywhere.
|
|
69
|
+
* Channel-free binaries keep their exact size class. */
|
|
70
|
+
dc?: boolean;
|
|
71
|
+
/** The program uses the checked-dynamic async surfaces
|
|
72
|
+
* (moduleUsesDynAsync on the IR, or the dynInvoke/dc gates — their TUs
|
|
73
|
+
* call into this one): compiles scr_async_dyn.c — DOM-promise
|
|
74
|
+
* reactions, AsyncLocalStorage, the unhandledRejection/warning
|
|
75
|
+
* process events. */
|
|
76
|
+
dynAsync?: boolean;
|
|
77
|
+
/** The program uses the process-events surface (signal/exit listeners,
|
|
78
|
+
* stdin events, for-await over stdin — moduleUsesProcessEvents on the
|
|
79
|
+
* IR): compiles scr_events.c into the binary. Event-free binaries keep
|
|
80
|
+
* their exact link line and size class. */
|
|
81
|
+
events?: boolean;
|
|
82
|
+
/** The program uses the node:events EventEmitter surface
|
|
83
|
+
* (moduleUsesEmitter on the IR): compiles scr_events_emitter.c into the
|
|
84
|
+
* binary — the events gating precedent, but pure data structure (no
|
|
85
|
+
* loop hooks, no install), so it cross-compiles everywhere win32
|
|
86
|
+
* included. Emitter-free binaries keep their exact link line. */
|
|
87
|
+
emitter?: boolean;
|
|
88
|
+
/** The program uses ES Symbol values (moduleUsesSymbol on the IR):
|
|
89
|
+
* compiles scr_symbol.c into the binary — the emitter gating precedent:
|
|
90
|
+
* pure data structure (no loop hooks, no install; the Symbol.for
|
|
91
|
+
* registry initializes lazily), so it cross-compiles everywhere.
|
|
92
|
+
* Symbol-free binaries keep their exact link line. */
|
|
93
|
+
symbol?: boolean;
|
|
94
|
+
/** The program uses the URLSearchParams surface (moduleUsesSearchParams
|
|
95
|
+
* on the IR): compiles scr_url_params.c into the binary — the symbol
|
|
96
|
+
* gating precedent: pure data structure (no loop hooks, no install),
|
|
97
|
+
* cross-compiles everywhere. sp-free binaries keep their exact link
|
|
98
|
+
* line (scr_url.c never references the unit). */
|
|
99
|
+
searchParams?: boolean;
|
|
100
|
+
/** The program uses the node:stream class surface (moduleUsesStream on
|
|
101
|
+
* the IR): compiles scr_stream.c into the binary — always alongside
|
|
102
|
+
* scr_events_emitter.c, which moduleUsesEmitter answers true for
|
|
103
|
+
* whenever this does (the stream classes root at the emitter). Pure
|
|
104
|
+
* data structure plus the loop's deferred-tick hook — no poller, so it
|
|
105
|
+
* cross-compiles everywhere win32 included. */
|
|
106
|
+
stream?: boolean;
|
|
107
|
+
/** The program uses the node:net surface (moduleUsesNet on the IR):
|
|
108
|
+
* compiles scr_net.c into the binary — the events gating precedent, so
|
|
109
|
+
* net-free binaries keep their exact link line. */
|
|
110
|
+
net?: boolean;
|
|
111
|
+
/** The program uses the node:http server surface (moduleUsesHttpServer
|
|
112
|
+
* on the IR): compiles scr_http.c — always alongside scr_net.c, which
|
|
113
|
+
* moduleUsesNet answers true for whenever this does. */
|
|
114
|
+
http?: boolean;
|
|
115
|
+
/** The program uses the REAL node:http2 surface (moduleUsesHttp2 on
|
|
116
|
+
* the IR): compiles scr_http2.c — always alongside scr_net.c, which
|
|
117
|
+
* moduleUsesNet answers true for whenever this does. */
|
|
118
|
+
http2?: boolean;
|
|
119
|
+
/** The program uses the node:dgram or node:dns surface (moduleUsesDgram
|
|
120
|
+
* on the IR): compiles scr_dgram.c into the binary — the net gating
|
|
121
|
+
* precedent, so dgram-free binaries keep their exact link line. */
|
|
122
|
+
dgram?: boolean;
|
|
123
|
+
/** The program uses fs.watch (moduleUsesFsWatch on the IR): compiles
|
|
124
|
+
* scr_watch.c into the binary — the net gating precedent, so watch-free
|
|
125
|
+
* binaries keep their exact link line. */
|
|
126
|
+
watch?: boolean;
|
|
127
|
+
/** The program uses node:test (moduleUsesNodeTest on the IR): compiles
|
|
128
|
+
* scr_test.c into the binary — the net gating precedent, so test-free
|
|
129
|
+
* binaries keep their exact link line. */
|
|
130
|
+
nodeTest?: boolean;
|
|
131
|
+
/** The program uses the node:tls or node:https surface (moduleUsesTls on
|
|
132
|
+
* the IR): compiles scr_tls.c and links the vendored mbedTLS archive
|
|
133
|
+
* (built lazily like the engine archive, cached per flavor). Always
|
|
134
|
+
* alongside scr_net.c and scr_http.c, which moduleUsesNet /
|
|
135
|
+
* moduleUsesHttpServer answer true for whenever this does. TLS-free
|
|
136
|
+
* binaries keep their exact link line and never compile mbedTLS. */
|
|
137
|
+
tls?: boolean;
|
|
138
|
+
}
|
|
139
|
+
export declare function runtimeSrcDir(): string;
|
|
140
|
+
export interface CcDriver {
|
|
141
|
+
/** The compiler argv prefix: ["clang"] (default) or ["zig", "cc"]. */
|
|
142
|
+
argv: string[];
|
|
143
|
+
/** The SCRIPTC_TARGET triple, or null for a host-native build. */
|
|
144
|
+
target: string | null;
|
|
145
|
+
/** Extra compile args the target demands; ALWAYS [] on the default path. */
|
|
146
|
+
targetArgs: string[];
|
|
147
|
+
}
|
|
148
|
+
export declare function resolveCc(env?: NodeJS.ProcessEnv): CcDriver;
|
|
149
|
+
/** The OS the produced binary runs on: the triple's OS under SCRIPTC_TARGET,
|
|
150
|
+
* the host's otherwise — so platform-conditional link flags follow the
|
|
151
|
+
* TARGET, not the machine running the compiler. Exported for compile()/
|
|
152
|
+
* analyze(): the FRONTEND consults it too (path.sep / os.EOL literals and
|
|
153
|
+
* the path-module binding follow the target — a win32 triple compiles
|
|
154
|
+
* Node-on-Windows semantics, path.win32 backing the bare module). */
|
|
155
|
+
export declare function targetPlatform(driver: CcDriver): string;
|
|
156
|
+
/** Compiles one C program together with the runtime sources.
|
|
157
|
+
* Without a cache dir (the production default), the runtime (a dozen small
|
|
158
|
+
* files) is recompiled on every build in one historical clang invocation —
|
|
159
|
+
* no cached-archive staleness bugs. --dynamic additionally compiles
|
|
160
|
+
* scr_island.c under SCR_DYNAMIC and links the cached engine archive (built
|
|
161
|
+
* lazily, see above); regex-using programs additionally compile scr_regex.c
|
|
162
|
+
* and link libregexp (the cached objects, or the archive's own copy under
|
|
163
|
+
* --dynamic). Without either, the command line is exactly the historical
|
|
164
|
+
* one — regex-free static builds must stay byte-identical.
|
|
165
|
+
*
|
|
166
|
+
* With SCRIPTC_CACHE_DIR set (the test lanes; see the cache block above),
|
|
167
|
+
* unchanged programs skip clang via the binary cache, and misses link the
|
|
168
|
+
* program's own TU against cached per-flavor runtime objects. */
|
|
169
|
+
export declare function compileC(opts: CcOptions): Promise<void>;
|