@scriptc/compiler 0.0.24 → 0.0.26
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 +15 -7
- package/dist/backend/cc.d.ts +3 -0
- package/dist/backend/cc.js +37 -4
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +81 -10
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +14 -1
- package/dist/backend/emission/emitter.js +117 -11
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +11 -1
- package/dist/backend/emission/may-throw.js.map +1 -1
- package/dist/backend/ffi-callbacks.d.ts +11 -0
- package/dist/backend/ffi-callbacks.js +33 -0
- package/dist/backend/ffi-callbacks.js.map +1 -0
- package/dist/backend/llvm/classes.js +21 -21
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +7 -4
- package/dist/backend/llvm/dyn.js +145 -141
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +7 -1
- package/dist/backend/llvm/emitter.js +950 -300
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +4 -0
- package/dist/backend/llvm/shapes.js +26 -24
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/unsupported.js +1 -1
- package/dist/backend/llvm/unsupported.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -0
- package/dist/backend/llvm/walkers.js +50 -46
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.js +3 -2
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/ffi/profile.d.ts +20 -2
- package/dist/ffi/profile.js +130 -6
- package/dist/ffi/profile.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +58 -22
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +17 -7
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +5 -0
- package/dist/frontend/lowering/lower-server.js +129 -37
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +8 -1
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +3 -2
- package/dist/frontend/lowering/surfaces.js +4 -3
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm.d.ts +16 -0
- package/dist/frontend/npm.js +257 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +152 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +48 -13
- package/dist/ir/nodes.js +49 -7
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +10 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/wasi-paths.d.ts +5 -0
- package/dist/wasi-paths.js +22 -0
- package/dist/wasi-paths.js.map +1 -0
- package/package.json +2 -2
- package/surface-manifest.json +2 -2
|
@@ -2118,25 +2118,33 @@ declare module "node:net" {
|
|
|
2118
2118
|
* connection per call (no agent pooling) with Node's exact wire head. */
|
|
2119
2119
|
declare module "http" {
|
|
2120
2120
|
import { Server as NetServer, Socket } from "net";
|
|
2121
|
-
export
|
|
2121
|
+
export interface Server extends NetServer {
|
|
2122
|
+
timeout: number;
|
|
2123
|
+
keepAliveTimeout: number;
|
|
2124
|
+
keepAliveTimeoutBuffer: number;
|
|
2125
|
+
headersTimeout: number;
|
|
2126
|
+
requestTimeout: number;
|
|
2127
|
+
}
|
|
2122
2128
|
export type RequestListener =
|
|
2123
2129
|
(req: IncomingMessage, res: ServerResponse) => void;
|
|
2124
2130
|
/* The Server VALUE — Node's constructor works with and without `new`
|
|
2125
2131
|
* (test/parallel's http.Server(fn) spelling); both route to the
|
|
2126
2132
|
* createServer lowering. */
|
|
2127
2133
|
export const Server: {
|
|
2128
|
-
new (requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2129
|
-
new (options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2130
|
-
(requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2131
|
-
(options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void):
|
|
2134
|
+
new (requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2135
|
+
new (options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2136
|
+
(requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2137
|
+
(options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
|
|
2132
2138
|
};
|
|
2133
2139
|
/* The options-record stance (the RequestOptions precedent): every
|
|
2134
2140
|
* documented key typechecks; the lowering's option walk decides per
|
|
2135
|
-
* key — requireHostHeader: false
|
|
2141
|
+
* key — requireHostHeader: false, joinDuplicateHeaders, and
|
|
2142
|
+
* keepAliveTimeoutBuffer lower,
|
|
2136
2143
|
* documented-but-unlowered keys fence by name, unknown keys drop. */
|
|
2137
2144
|
export interface ServerOptions {
|
|
2138
2145
|
requireHostHeader?: boolean;
|
|
2139
2146
|
joinDuplicateHeaders?: boolean;
|
|
2147
|
+
keepAliveTimeoutBuffer?: number;
|
|
2140
2148
|
[option: string]: unknown;
|
|
2141
2149
|
}
|
|
2142
2150
|
/* The outgoing-header shape, @types/node's matrix: numbers format via
|
|
@@ -2392,7 +2400,7 @@ declare module "node:tls" {
|
|
|
2392
2400
|
* self-signed probe shape). With neither, /etc/ssl/cert.pem stands in
|
|
2393
2401
|
* for Node's bundled roots. */
|
|
2394
2402
|
declare module "https" {
|
|
2395
|
-
import { Server } from "
|
|
2403
|
+
import { Server } from "http";
|
|
2396
2404
|
import { Agent, ClientRequest, IncomingMessage, ServerResponse } from "http";
|
|
2397
2405
|
export { Agent, Server };
|
|
2398
2406
|
export interface ServerOptions {
|
package/dist/backend/cc.d.ts
CHANGED
|
@@ -214,6 +214,9 @@ export interface CcDriver {
|
|
|
214
214
|
linkArgs: string[];
|
|
215
215
|
}
|
|
216
216
|
export declare function resolveCc(env?: NodeJS.ProcessEnv, hostPlatform?: NodeJS.Platform): CcDriver;
|
|
217
|
+
/** Musl intentionally has no predefined libc macro. The explicit Zig target
|
|
218
|
+
* is therefore the source of truth for selecting its small runtime shim. */
|
|
219
|
+
export declare function isMuslTarget(driver: Pick<CcDriver, "target">): boolean;
|
|
217
220
|
/** The OS the produced binary runs on: the triple's OS under SCRIPTC_TARGET,
|
|
218
221
|
* the host's otherwise — so platform-conditional link flags follow the
|
|
219
222
|
* TARGET, not the machine running the compiler. Exported for compile()/
|
package/dist/backend/cc.js
CHANGED
|
@@ -197,14 +197,34 @@ export function resolveCc(env = process.env, hostPlatform = process.platform) {
|
|
|
197
197
|
}
|
|
198
198
|
if (target === "")
|
|
199
199
|
return { argv: ["zig", "cc"], target: null, ...hostArgs };
|
|
200
|
+
if (target.includes("wasi") && target !== "wasm32-wasi") {
|
|
201
|
+
throw new Error(`unsupported WASI target '${target}' (supported: wasm32-wasi)`);
|
|
202
|
+
}
|
|
200
203
|
const linux = target.includes("linux");
|
|
204
|
+
const wasi = target.includes("wasi");
|
|
205
|
+
const musl = target.includes("linux-musl");
|
|
201
206
|
return {
|
|
202
207
|
argv: ["zig", "cc"],
|
|
203
208
|
target,
|
|
204
|
-
targetArgs: [
|
|
205
|
-
|
|
209
|
+
targetArgs: [
|
|
210
|
+
"-target",
|
|
211
|
+
target,
|
|
212
|
+
...(linux || wasi ? ["-D_GNU_SOURCE"] : []),
|
|
213
|
+
...(musl ? ["-DSCR_MUSL"] : []),
|
|
214
|
+
...(wasi ? ["-D_WASI_EMULATED_SIGNAL", "-D_WASI_EMULATED_PROCESS_CLOCKS"] : []),
|
|
215
|
+
],
|
|
216
|
+
linkArgs: linux
|
|
217
|
+
? ["-lm"]
|
|
218
|
+
: wasi
|
|
219
|
+
? ["-lwasi-emulated-signal", "-lwasi-emulated-process-clocks"]
|
|
220
|
+
: [],
|
|
206
221
|
};
|
|
207
222
|
}
|
|
223
|
+
/** Musl intentionally has no predefined libc macro. The explicit Zig target
|
|
224
|
+
* is therefore the source of truth for selecting its small runtime shim. */
|
|
225
|
+
export function isMuslTarget(driver) {
|
|
226
|
+
return driver.target?.includes("linux-musl") ?? false;
|
|
227
|
+
}
|
|
208
228
|
/** The OS the produced binary runs on: the triple's OS under SCRIPTC_TARGET,
|
|
209
229
|
* the host's otherwise — so platform-conditional link flags follow the
|
|
210
230
|
* TARGET, not the machine running the compiler. Exported for compile()/
|
|
@@ -214,6 +234,8 @@ export function resolveCc(env = process.env, hostPlatform = process.platform) {
|
|
|
214
234
|
export function targetPlatform(driver) {
|
|
215
235
|
if (driver.target === null)
|
|
216
236
|
return process.platform;
|
|
237
|
+
if (driver.target.includes("wasi"))
|
|
238
|
+
return "wasi";
|
|
217
239
|
if (driver.target.includes("linux"))
|
|
218
240
|
return "linux";
|
|
219
241
|
if (driver.target.includes("windows"))
|
|
@@ -715,6 +737,9 @@ export async function compileLibArchive(opts) {
|
|
|
715
737
|
// carries no -l flags. Never present off win32, so host archives
|
|
716
738
|
// cannot change by a byte.
|
|
717
739
|
...(targetPlatform(driver) === "win32" ? ["scr_win.c"] : []),
|
|
740
|
+
// Zig's musl sysroot does not provide arc4random_buf. Keep the fallback
|
|
741
|
+
// inside the archive so library embedders need no extra system library.
|
|
742
|
+
...(isMuslTarget(driver) ? ["scr_musl.c"] : []),
|
|
718
743
|
...(regex ? ["scr_regex.c"] : []),
|
|
719
744
|
...(opts.assert || regex || opts.symbol ? ["scr_assert.c"] : []),
|
|
720
745
|
...(opts.inspect ? ["scr_inspect.c"] : []),
|
|
@@ -2167,9 +2192,14 @@ export async function compileC(opts) {
|
|
|
2167
2192
|
const http = (opts.http ?? false) || nativeFetch || netIsland;
|
|
2168
2193
|
const tls = (opts.tls ?? false) || nativeFetch || netIsland;
|
|
2169
2194
|
const driver = resolveCc();
|
|
2195
|
+
const runtimeSources = targetPlatform(driver) === "wasi"
|
|
2196
|
+
? RUNTIME_SOURCES.filter((source) => source !== "scr_child.c")
|
|
2197
|
+
: RUNTIME_SOURCES;
|
|
2170
2198
|
// scr_async.c submits callback-style filesystem work to a native worker.
|
|
2171
2199
|
// POSIX drivers need the thread compile/link mode; win32 uses CreateThread.
|
|
2172
|
-
const threadArgs = targetPlatform(driver) === "win32"
|
|
2200
|
+
const threadArgs = targetPlatform(driver) === "win32" || targetPlatform(driver) === "wasi"
|
|
2201
|
+
? []
|
|
2202
|
+
: ["-pthread"];
|
|
2173
2203
|
if (driver.target !== null) {
|
|
2174
2204
|
// See the resolveCc block: these inputs are built on and for the HOST
|
|
2175
2205
|
// (vendored archives, system libs). Regex, zlib, and the engine archive
|
|
@@ -2314,7 +2344,7 @@ export async function compileC(opts) {
|
|
|
2314
2344
|
"-fno-strict-aliasing",
|
|
2315
2345
|
"-Wno-deprecated-declarations", // ucontext fibers (scr_async.c)
|
|
2316
2346
|
"-I", rtDir,
|
|
2317
|
-
...
|
|
2347
|
+
...runtimeSources.map((f) => rt(join(rtDir, f))),
|
|
2318
2348
|
...(opts.copying ? [rt(join(rtDir, "scr_copying.c"))] : []),
|
|
2319
2349
|
...(opts.fileHandle ? [rt(join(rtDir, "scr_file_handle.c"))] : []),
|
|
2320
2350
|
// win32 targets compile the libc-shim TU (stpcpy, arc4random_buf,
|
|
@@ -2327,6 +2357,9 @@ export async function compileC(opts) {
|
|
|
2327
2357
|
...(targetPlatform(driver) === "win32"
|
|
2328
2358
|
? [rt(join(rtDir, "scr_win.c")), "-ladvapi32", "-liphlpapi", "-lws2_32"]
|
|
2329
2359
|
: []),
|
|
2360
|
+
// musl deliberately has no libc-identification predefine; resolveCc's
|
|
2361
|
+
// SCR_MUSL flag and this target-selected TU travel together.
|
|
2362
|
+
...(isMuslTarget(driver) ? [rt(join(rtDir, "scr_musl.c"))] : []),
|
|
2330
2363
|
...(regex
|
|
2331
2364
|
? ["-I", vendorEngineDir(), rt(join(rtDir, "scr_regex.c")), ...lreObjects]
|
|
2332
2365
|
: []),
|