@scriptc/compiler 0.0.23 → 0.0.24
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/ambient/scriptc-node-fallback.d.ts +100 -11
- package/dist/backend/cc.d.ts +13 -0
- package/dist/backend/cc.js +11 -0
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-async.d.ts +4 -0
- package/dist/backend/emission/emit-async.js +31 -1
- package/dist/backend/emission/emit-async.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +147 -14
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-shapes.js +1 -0
- package/dist/backend/emission/emit-shapes.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +24 -5
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-types.js +10 -0
- package/dist/backend/emission/emit-types.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +10 -2
- package/dist/backend/emission/emitter.js +49 -30
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.js +284 -25
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +9 -1
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/mangle.d.ts +3 -0
- package/dist/backend/mangle.js +5 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +14 -9
- package/dist/frontend/lowering/lower-builtins.js +737 -62
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +2 -1
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +2 -1
- package/dist/frontend/lowering/lower-containers.js +99 -32
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +53 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +59 -1
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +5 -0
- package/dist/frontend/lowering/lower-server.js +1 -1
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +6 -2
- package/dist/frontend/lowering/lower-stmts.js +45 -10
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +2 -2
- package/dist/frontend/lowering/lowerer.js +11 -6
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +65 -13
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/types.d.ts +3 -0
- package/dist/frontend/types.js +78 -0
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +23 -0
- package/dist/ir/integer-loops.js +82 -0
- package/dist/ir/integer-loops.js.map +1 -0
- package/dist/ir/nodes.d.ts +84 -21
- package/dist/ir/nodes.js +84 -1
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +92 -18
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.js +4 -3
- package/dist/library/fence-eval.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +50 -2
|
@@ -205,12 +205,18 @@ declare var process: {
|
|
|
205
205
|
/* The raw byte writes — no newline, no formatting. stdout shares
|
|
206
206
|
* console.log's stream, each call is submitted promptly, and ordering is
|
|
207
207
|
* preserved. The boolean is Node's backpressure signal — these synchronous
|
|
208
|
-
* writes always return true.
|
|
209
|
-
*
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
* writes always return true. Static BufferEncoding arguments and the
|
|
209
|
+
* completion callback overloads match Node's WritableStream surface. */
|
|
210
|
+
stdout: {
|
|
211
|
+
write(data: string | Uint8Array, callback?: (error?: Error | null) => void): boolean;
|
|
212
|
+
write(data: string | Uint8Array, encoding: BufferEncoding, callback?: (error?: Error | null) => void): boolean;
|
|
213
|
+
readonly isTTY: boolean;
|
|
214
|
+
};
|
|
215
|
+
stderr: {
|
|
216
|
+
write(data: string | Uint8Array, callback?: (error?: Error | null) => void): boolean;
|
|
217
|
+
write(data: string | Uint8Array, encoding: BufferEncoding, callback?: (error?: Error | null) => void): boolean;
|
|
218
|
+
readonly isTTY: boolean;
|
|
219
|
+
};
|
|
214
220
|
/* The stdin stream, the piped-input slice: the TTY probe, the
|
|
215
221
|
* data/end/error events (on and once — a 'data' listener keeps the
|
|
216
222
|
* event loop alive until EOF, like Node's flowing stdin), destroy()
|
|
@@ -475,8 +481,8 @@ declare var Buffer: BufferConstructor;
|
|
|
475
481
|
|
|
476
482
|
/* The WHATWG encoders (Node globals). The COMPOSED forms lower —
|
|
477
483
|
* `new TextEncoder().encode(s)` and `new TextDecoder().decode(bytes)` —
|
|
478
|
-
* as do same-scope const store-then-call forms.
|
|
479
|
-
*
|
|
484
|
+
* as do same-scope const store-then-call forms. Recognized literal WHATWG
|
|
485
|
+
* labels compile statically; runtime-valued/unknown labels and the
|
|
480
486
|
* fatal/ignoreBOM options fence at the use site). */
|
|
481
487
|
interface TextEncoder {
|
|
482
488
|
encode(input?: string): Uint8Array;
|
|
@@ -485,7 +491,7 @@ declare var TextEncoder: { new (): TextEncoder };
|
|
|
485
491
|
interface TextDecoder {
|
|
486
492
|
decode(input?: ArrayBufferView | ArrayBuffer): string;
|
|
487
493
|
}
|
|
488
|
-
declare var TextDecoder: { new (label?:
|
|
494
|
+
declare var TextDecoder: { new (label?: string): TextDecoder };
|
|
489
495
|
|
|
490
496
|
/* The WHATWG event surface (Node globals since v15): declared so the
|
|
491
497
|
* suite's event-plumbing tests typecheck and fence per SITE with the
|
|
@@ -975,6 +981,8 @@ declare module "node:fs" {
|
|
|
975
981
|
/* The 2-argument form only (Node's mode flags have no lowering). The
|
|
976
982
|
* destination is created or truncated carrying the SOURCE's mode. */
|
|
977
983
|
export function copyFileSync(src: string, dest: string): void;
|
|
984
|
+
export function rename(oldPath: string, newPath: string, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
985
|
+
export function renameSync(oldPath: string, newPath: string): void;
|
|
978
986
|
export function rmSync(path: string): void;
|
|
979
987
|
/* maxRetries/retryDelay are accepted no-ops (Node retries around
|
|
980
988
|
* EBUSY-class races; the synchronous lowering has no re-entrancy that
|
|
@@ -1010,12 +1018,16 @@ declare module "node:fs" {
|
|
|
1010
1018
|
};
|
|
1011
1019
|
/* A stat(2) snapshot (statSync follows symlinks, lstatSync does not —
|
|
1012
1020
|
* Node's split) — immutable; the supported surface is exactly these
|
|
1013
|
-
* members.
|
|
1021
|
+
* members. blocks is the allocated size in 512-byte units; the time
|
|
1022
|
+
* fields are milliseconds with their sub-second fractions. */
|
|
1014
1023
|
export interface Stats {
|
|
1015
1024
|
isFile(): boolean;
|
|
1016
1025
|
isDirectory(): boolean;
|
|
1017
1026
|
isSymbolicLink(): boolean;
|
|
1018
1027
|
readonly size: number;
|
|
1028
|
+
readonly blocks: number;
|
|
1029
|
+
readonly nlink: number;
|
|
1030
|
+
readonly atimeMs: number;
|
|
1019
1031
|
readonly mtimeMs: number;
|
|
1020
1032
|
}
|
|
1021
1033
|
export function statSync(path: string): Stats;
|
|
@@ -1029,6 +1041,11 @@ declare module "node:fs" {
|
|
|
1029
1041
|
* is omitted/null, or from a numeric byte position without advancing the
|
|
1030
1042
|
* fd. Answers the byte count, 0 at EOF. */
|
|
1031
1043
|
export function readSync(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number | null): number;
|
|
1044
|
+
/* Write a caller-buffer window, or a utf8 string, at the fd's current
|
|
1045
|
+
* position when position is omitted/null (advancing it), or at a numeric
|
|
1046
|
+
* byte position without advancing it. Answers the byte count. */
|
|
1047
|
+
export function writeSync(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number | null): number;
|
|
1048
|
+
export function writeSync(fd: number, string: string, position?: number | null, encoding?: "utf8" | "utf-8"): number;
|
|
1032
1049
|
/* statSync over an open fd — the same Stats snapshot. */
|
|
1033
1050
|
export function fstatSync(fd: number): Stats;
|
|
1034
1051
|
/* realpath(3) — resolves symlinks, `.`/`..`, throwing Node's fs error
|
|
@@ -1090,15 +1107,52 @@ declare module "fs" {
|
|
|
1090
1107
|
* interleaves with timers or other fibers — observable only in concurrent
|
|
1091
1108
|
* code. readFile is utf8-only, like readFileSync. */
|
|
1092
1109
|
declare module "fs/promises" {
|
|
1110
|
+
export interface FileReadResult<T extends Uint8Array> {
|
|
1111
|
+
bytesRead: number;
|
|
1112
|
+
buffer: T;
|
|
1113
|
+
}
|
|
1114
|
+
export interface FileWriteResult<T> {
|
|
1115
|
+
bytesWritten: number;
|
|
1116
|
+
buffer: T;
|
|
1117
|
+
}
|
|
1118
|
+
export interface FileHandle {
|
|
1119
|
+
readonly fd: number;
|
|
1120
|
+
close(): Promise<void>;
|
|
1121
|
+
read<T extends Uint8Array>(
|
|
1122
|
+
buffer: T,
|
|
1123
|
+
offset?: number | null,
|
|
1124
|
+
length?: number | null,
|
|
1125
|
+
position?: number | null,
|
|
1126
|
+
): Promise<FileReadResult<T>>;
|
|
1127
|
+
write<T extends Uint8Array>(
|
|
1128
|
+
buffer: T,
|
|
1129
|
+
offset?: number | null,
|
|
1130
|
+
length?: number | null,
|
|
1131
|
+
position?: number | null,
|
|
1132
|
+
): Promise<FileWriteResult<T>>;
|
|
1133
|
+
write(data: string, position?: number | null, encoding?: "utf8" | "utf-8" | null): Promise<FileWriteResult<string>>;
|
|
1134
|
+
readFile(options?: null): Promise<Buffer>;
|
|
1135
|
+
readFile(encoding: "utf8" | "utf-8"): Promise<string>;
|
|
1136
|
+
writeFile(data: string | Uint8Array, encoding?: "utf8" | "utf-8" | null): Promise<void>;
|
|
1137
|
+
appendFile(data: string | Uint8Array, encoding?: "utf8" | "utf-8" | null): Promise<void>;
|
|
1138
|
+
stat(): Promise<import("node:fs").Stats>;
|
|
1139
|
+
}
|
|
1140
|
+
export function open(path: string, flags?: string, mode?: number): Promise<FileHandle>;
|
|
1093
1141
|
export function readFile(path: string, encoding: "utf8" | "utf-8"): Promise<string>;
|
|
1094
1142
|
export function readFile(path: string): Promise<Buffer>;
|
|
1095
|
-
export function writeFile(
|
|
1143
|
+
export function writeFile(
|
|
1144
|
+
path: string,
|
|
1145
|
+
data: string,
|
|
1146
|
+
options?: { mode?: number; encoding?: "utf8" | "utf-8"; flag?: string; [option: string]: unknown },
|
|
1147
|
+
): Promise<void>;
|
|
1148
|
+
export function writeFile(path: string, data: string, encoding: "utf8" | "utf-8"): Promise<void>;
|
|
1096
1149
|
export function mkdir(path: string, options?: { recursive?: boolean; mode?: number }): Promise<void>;
|
|
1097
1150
|
export function readdir(path: string): Promise<string[]>;
|
|
1098
1151
|
export function rm(path: string): Promise<void>;
|
|
1099
1152
|
export function stat(path: string): Promise<import("node:fs").Stats>;
|
|
1100
1153
|
export function unlink(path: string): Promise<void>;
|
|
1101
1154
|
export function chmod(path: string, mode: number): Promise<void>;
|
|
1155
|
+
export function rename(oldPath: string, newPath: string): Promise<void>;
|
|
1102
1156
|
}
|
|
1103
1157
|
declare module "node:fs/promises" {
|
|
1104
1158
|
export * from "fs/promises";
|
|
@@ -1584,6 +1638,41 @@ declare module "util" {
|
|
|
1584
1638
|
format?: unknown,
|
|
1585
1639
|
...args: unknown[]
|
|
1586
1640
|
): string;
|
|
1641
|
+
export type ParseArgsOptionsType = "boolean" | "string";
|
|
1642
|
+
export interface ParseArgsOptionDescriptor {
|
|
1643
|
+
type: ParseArgsOptionsType;
|
|
1644
|
+
multiple?: boolean;
|
|
1645
|
+
short?: string;
|
|
1646
|
+
default?: string | boolean | string[] | boolean[];
|
|
1647
|
+
}
|
|
1648
|
+
export interface ParseArgsOptionsConfig {
|
|
1649
|
+
[longOption: string]: ParseArgsOptionDescriptor;
|
|
1650
|
+
}
|
|
1651
|
+
export interface ParseArgsConfig {
|
|
1652
|
+
args?: readonly string[];
|
|
1653
|
+
options?: ParseArgsOptionsConfig;
|
|
1654
|
+
strict?: boolean;
|
|
1655
|
+
allowPositionals?: boolean;
|
|
1656
|
+
allowNegative?: boolean;
|
|
1657
|
+
tokens?: boolean;
|
|
1658
|
+
}
|
|
1659
|
+
export type ParseArgsToken =
|
|
1660
|
+
| {
|
|
1661
|
+
kind: "option";
|
|
1662
|
+
index: number;
|
|
1663
|
+
name: string;
|
|
1664
|
+
rawName: string;
|
|
1665
|
+
value: string | undefined;
|
|
1666
|
+
inlineValue: boolean | undefined;
|
|
1667
|
+
}
|
|
1668
|
+
| { kind: "positional"; index: number; value: string }
|
|
1669
|
+
| { kind: "option-terminator"; index: number };
|
|
1670
|
+
export interface ParseArgsResult {
|
|
1671
|
+
values: { [longOption: string]: undefined | string | boolean | Array<string | boolean> };
|
|
1672
|
+
positionals: string[];
|
|
1673
|
+
tokens?: ParseArgsToken[];
|
|
1674
|
+
}
|
|
1675
|
+
export function parseArgs(config?: ParseArgsConfig): ParseArgsResult;
|
|
1587
1676
|
/* util.getCallSites (Node ≥22.9): the captured-frame slice harness
|
|
1588
1677
|
* code reads. No stack bookkeeping exists in a compiled binary — every
|
|
1589
1678
|
* reached call fences per site. */
|
package/dist/backend/cc.d.ts
CHANGED
|
@@ -46,6 +46,15 @@ export interface CcOptions {
|
|
|
46
46
|
* implemented in scr_copying.c (index.ts detects them on the IR).
|
|
47
47
|
* Off keeps that optional TU out of unrelated binaries. */
|
|
48
48
|
copying?: boolean;
|
|
49
|
+
/** The program uses a statically-labelled non-UTF-8 TextDecoder. Its
|
|
50
|
+
* generated mapping tables live behind SCR_TEXT_DECODER_LEGACY so the
|
|
51
|
+
* always-compiled bytes TU stays in the historical size class otherwise. */
|
|
52
|
+
textDecoderLegacy?: boolean;
|
|
53
|
+
/** The program uses fs/promises.open or a FileHandle value
|
|
54
|
+
* (moduleUsesFileHandle on the IR): compiles scr_file_handle.c. Keeping
|
|
55
|
+
* the descriptor object and promise adapters in their own unit preserves
|
|
56
|
+
* the base runtime's size class for programs that never open a handle. */
|
|
57
|
+
fileHandle?: boolean;
|
|
49
58
|
/** The embedded npm graph references fetch (index.ts detects it on the
|
|
50
59
|
* IR): compiles the NATIVE fetch bridge (scr_fetch.c over scr_net +
|
|
51
60
|
* scr_tls + scr_http's client parser + zlib — the socket units join
|
|
@@ -134,6 +143,9 @@ export interface CcOptions {
|
|
|
134
143
|
* line (escape-only programs ride the always-linked component encoder
|
|
135
144
|
* and never flip this). */
|
|
136
145
|
qs?: boolean;
|
|
146
|
+
/** The program uses static util.parseArgs (index.ts detects its libCall):
|
|
147
|
+
* compiles scr_util.c, a pure checked-dynamic data transform. */
|
|
148
|
+
parseArgs?: boolean;
|
|
137
149
|
/** The program uses the node:stream class surface (moduleUsesStream on
|
|
138
150
|
* the IR): compiles scr_stream.c into the binary — always alongside
|
|
139
151
|
* scr_events_emitter.c, which moduleUsesEmitter answers true for
|
|
@@ -242,6 +254,7 @@ export interface LibArchiveOptions {
|
|
|
242
254
|
emitter?: boolean;
|
|
243
255
|
zlib?: boolean;
|
|
244
256
|
copying?: boolean;
|
|
257
|
+
textDecoderLegacy?: boolean;
|
|
245
258
|
}
|
|
246
259
|
export declare function compileLibArchive(opts: LibArchiveOptions): Promise<void>;
|
|
247
260
|
/** Resolve the build cache without touching the filesystem. Exported from this
|
package/dist/backend/cc.js
CHANGED
|
@@ -732,6 +732,7 @@ export async function compileLibArchive(opts) {
|
|
|
732
732
|
"-fno-strict-aliasing", // the emitted object model type-puns — see compileC's buildArgs
|
|
733
733
|
"-Wno-deprecated-declarations",
|
|
734
734
|
"-DSCR_LIB",
|
|
735
|
+
...(opts.textDecoderLegacy ? ["-DSCR_TEXT_DECODER_LEGACY"] : []),
|
|
735
736
|
"-I", rtDir,
|
|
736
737
|
...(regex ? ["-I", vendorEngineDir()] : []),
|
|
737
738
|
...(opts.zlib ? ["-I", vendorZlibDir()] : []),
|
|
@@ -2166,6 +2167,9 @@ export async function compileC(opts) {
|
|
|
2166
2167
|
const http = (opts.http ?? false) || nativeFetch || netIsland;
|
|
2167
2168
|
const tls = (opts.tls ?? false) || nativeFetch || netIsland;
|
|
2168
2169
|
const driver = resolveCc();
|
|
2170
|
+
// scr_async.c submits callback-style filesystem work to a native worker.
|
|
2171
|
+
// POSIX drivers need the thread compile/link mode; win32 uses CreateThread.
|
|
2172
|
+
const threadArgs = targetPlatform(driver) === "win32" ? [] : ["-pthread"];
|
|
2169
2173
|
if (driver.target !== null) {
|
|
2170
2174
|
// See the resolveCc block: these inputs are built on and for the HOST
|
|
2171
2175
|
// (vendored archives, system libs). Regex, zlib, and the engine archive
|
|
@@ -2290,9 +2294,11 @@ export async function compileC(opts) {
|
|
|
2290
2294
|
const buildArgs = (rt, build = {}) => [
|
|
2291
2295
|
"-std=c11",
|
|
2292
2296
|
...driver.targetArgs,
|
|
2297
|
+
...threadArgs,
|
|
2293
2298
|
...(sanitize
|
|
2294
2299
|
? ["-O1", "-fsanitize=address", "-DSCR_RC_AUDIT"]
|
|
2295
2300
|
: ["-O2"]),
|
|
2301
|
+
...(opts.textDecoderLegacy ? ["-DSCR_TEXT_DECODER_LEGACY"] : []),
|
|
2296
2302
|
"-fno-math-errno",
|
|
2297
2303
|
// The emitted object model is deliberately type-punned C: a hierarchy
|
|
2298
2304
|
// upcast is a raw pointer cast, so one object's header (rc, vt) and
|
|
@@ -2310,6 +2316,7 @@ export async function compileC(opts) {
|
|
|
2310
2316
|
"-I", rtDir,
|
|
2311
2317
|
...RUNTIME_SOURCES.map((f) => rt(join(rtDir, f))),
|
|
2312
2318
|
...(opts.copying ? [rt(join(rtDir, "scr_copying.c"))] : []),
|
|
2319
|
+
...(opts.fileHandle ? [rt(join(rtDir, "scr_file_handle.c"))] : []),
|
|
2313
2320
|
// win32 targets compile the libc-shim TU (stpcpy, arc4random_buf,
|
|
2314
2321
|
// gmtime_r, strcasestr — the _WIN32 block in scr_runtime.h declares
|
|
2315
2322
|
// them) and link advapi32 (the CSPRNG RtlGenRandom/SystemFunction036,
|
|
@@ -2354,6 +2361,7 @@ export async function compileC(opts) {
|
|
|
2354
2361
|
...(opts.symbol ? [rt(join(rtDir, "scr_symbol.c"))] : []),
|
|
2355
2362
|
...(opts.searchParams ? [rt(join(rtDir, "scr_url_params.c"))] : []),
|
|
2356
2363
|
...(opts.qs ? [rt(join(rtDir, "scr_qs.c"))] : []),
|
|
2364
|
+
...(opts.parseArgs ? [rt(join(rtDir, "scr_util.c"))] : []),
|
|
2357
2365
|
...(opts.stream ? [rt(join(rtDir, "scr_stream.c"))] : []),
|
|
2358
2366
|
// The readiness-poller backends (scr_platform.h): kqueue on macOS/BSD,
|
|
2359
2367
|
// epoll on Linux, WSAPoll on Windows — each TU is empty off its
|
|
@@ -2472,9 +2480,11 @@ export async function compileC(opts) {
|
|
|
2472
2480
|
const cflags = [
|
|
2473
2481
|
"-std=c11",
|
|
2474
2482
|
...driver.targetArgs,
|
|
2483
|
+
...threadArgs,
|
|
2475
2484
|
...(sanitize
|
|
2476
2485
|
? ["-O1", "-fsanitize=address", "-DSCR_RC_AUDIT"]
|
|
2477
2486
|
: ["-O2"]),
|
|
2487
|
+
...(opts.textDecoderLegacy ? ["-DSCR_TEXT_DECODER_LEGACY"] : []),
|
|
2478
2488
|
"-fno-math-errno",
|
|
2479
2489
|
"-fno-strict-aliasing", // the emitted object model type-puns — see buildArgs
|
|
2480
2490
|
"-Wno-deprecated-declarations",
|
|
@@ -2573,6 +2583,7 @@ export async function compileC(opts) {
|
|
|
2573
2583
|
}
|
|
2574
2584
|
const linkProbeArgs = [
|
|
2575
2585
|
...(sanitize ? ["-fsanitize=address"] : []),
|
|
2586
|
+
...threadArgs,
|
|
2576
2587
|
...(targetPlatform(driver) === "win32"
|
|
2577
2588
|
? ["-ladvapi32", "-liphlpapi", "-lws2_32"]
|
|
2578
2589
|
: []),
|