@scriptc/compiler 0.0.10 → 0.0.11
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 +54 -9
- package/dist/backend/emission/emit-exprs.js +34 -2
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emitter.js +25 -1
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.js +59 -4
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/coverage/surface-manifest.js +16 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +20 -7
- package/dist/diagnostics/diagnostic.js +44 -11
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +56 -0
- package/dist/frontend/lowering/lower-builtins.js +235 -4
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +38 -4
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +7 -0
- package/dist/frontend/lowering/lower-classes.js +51 -1
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +4 -0
- package/dist/frontend/lowering/lower-containers.js +69 -7
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-emitter.d.ts +70 -3
- package/dist/frontend/lowering/lower-emitter.js +436 -29
- package/dist/frontend/lowering/lower-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +80 -5
- package/dist/frontend/lowering/lower-exprs.js +472 -13
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +8 -5
- package/dist/frontend/lowering/lower-modules.js +141 -47
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +14 -0
- package/dist/frontend/lowering/lower-namespaces.js +122 -15
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +80 -6
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +113 -6
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +17 -0
- package/dist/frontend/lowering/lowerer.js +105 -17
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +44 -0
- package/dist/frontend/lowering/surfaces.js +234 -3
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm.d.ts +12 -0
- package/dist/frontend/npm.js +30 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/program.d.ts +25 -0
- package/dist/frontend/program.js +144 -135
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/shared.d.ts +1 -1
- package/dist/frontend/shared.js +1 -1
- package/dist/frontend/shared.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +137 -4
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +64 -8
- package/dist/ir/nodes.js +21 -3
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +11 -2
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.js +12 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.d.ts +119 -0
- package/dist/library/int-infer.js +1301 -0
- package/dist/library/int-infer.js.map +1 -0
- package/dist/library/int-infer.test.d.ts +1 -0
- package/dist/library/int-infer.test.js +279 -0
- package/dist/library/int-infer.test.js.map +1 -0
- package/dist/library/profile.d.ts +32 -5
- package/dist/library/profile.js +77 -13
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar.d.ts +23 -0
- package/dist/library/sidecar.js +150 -16
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +208 -10
|
@@ -447,7 +447,10 @@ interface Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends
|
|
|
447
447
|
}
|
|
448
448
|
interface BufferConstructor {
|
|
449
449
|
from(data: string, encoding?: BufferEncoding): Buffer;
|
|
450
|
-
|
|
450
|
+
/* The ArrayBuffer form is the VIEW construction: x.buffer with an
|
|
451
|
+
* optional byte offset/length shares x's storage (the subarray rule). */
|
|
452
|
+
from(data: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
|
453
|
+
from(data: Uint8Array | readonly number[]): Buffer;
|
|
451
454
|
alloc(size: number, fill?: string | number | Uint8Array, encoding?: BufferEncoding): Buffer;
|
|
452
455
|
compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
|
453
456
|
/* alloc without the zero-fill guarantee — the lowering zero-fills
|
|
@@ -798,16 +801,38 @@ declare module "perf_hooks" {
|
|
|
798
801
|
* performance.now() either way. */
|
|
799
802
|
declare var performance: import("node:perf_hooks").Performance;
|
|
800
803
|
|
|
801
|
-
/* node:module
|
|
802
|
-
*
|
|
803
|
-
* createRequire
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
804
|
+
/* node:module. createRequire's lowered shape is the version/config-
|
|
805
|
+
* reading pattern real CLIs ship: a const binding over
|
|
806
|
+
* createRequire(import.meta.url) (or __filename) whose require calls
|
|
807
|
+
* take STATIC string literals — the indirection erases at compile time.
|
|
808
|
+
* A builtin spec makes the binding a namespace import in const clothing;
|
|
809
|
+
* a relative .json document bakes and parses (JSON.parse's `unknown`
|
|
810
|
+
* stance — validate with a checked cast); an installed npm package loads
|
|
811
|
+
* through the island's require-condition entry under --dynamic; a bare
|
|
812
|
+
* name nothing installed resolves compiles to Node's catchable
|
|
813
|
+
* MODULE_NOT_FOUND throw (the optional-dependency try/require pattern).
|
|
814
|
+
* Dynamic specifiers fence: a compiled binary's module graph is fixed at
|
|
815
|
+
* build time. builtinModules is the baked Node v24 list (a fresh
|
|
816
|
+
* mutable array per read where Node ships one frozen singleton);
|
|
817
|
+
* isBuiltin and syncBuiltinESMExports fence per site. Bare "module"
|
|
818
|
+
* stays a package specifier (an npm package by that name exists); only
|
|
819
|
+
* the node: spelling names the builtin. */
|
|
809
820
|
declare module "node:module" {
|
|
810
821
|
export function createRequire(filename: string | URL): (id: string) => unknown;
|
|
822
|
+
export const builtinModules: string[];
|
|
823
|
+
export function isBuiltin(moduleName: string): boolean;
|
|
824
|
+
export function syncBuiltinESMExports(): void;
|
|
825
|
+
}
|
|
826
|
+
/* import.meta: module-loader metadata with no value representation —
|
|
827
|
+
* every read fences (SC1090) EXCEPT as createRequire's base, where it
|
|
828
|
+
* only NAMES the containing file (import.meta.url, import.meta.filename,
|
|
829
|
+
* and __filename all mean "this file" there). Declared so the pattern
|
|
830
|
+
* typechecks under the fallback surface; @types/node's own augmentation
|
|
831
|
+
* stands in when adopted. */
|
|
832
|
+
interface ImportMeta {
|
|
833
|
+
url: string;
|
|
834
|
+
filename: string;
|
|
835
|
+
dirname: string;
|
|
811
836
|
}
|
|
812
837
|
|
|
813
838
|
/* The synchronous node:fs surface — utf8-only, no options objects, no
|
|
@@ -3148,3 +3173,23 @@ declare module "node:stream/promises" {
|
|
|
3148
3173
|
import streamPromises = require("stream/promises");
|
|
3149
3174
|
export = streamPromises;
|
|
3150
3175
|
}
|
|
3176
|
+
declare module "stream/consumers" {
|
|
3177
|
+
/* The promise consumers over a readable: accumulate every chunk and
|
|
3178
|
+
* settle — text (the utf8 decode), json (the text through JSON.parse:
|
|
3179
|
+
* `unknown`, validated with a checked cast; malformed input rejects
|
|
3180
|
+
* with the parse's SyntaxError), buffer (the concatenated bytes;
|
|
3181
|
+
* string chunks contribute their utf8 bytes, Node's Blob rule).
|
|
3182
|
+
* Stream errors reject; an early close rejects with
|
|
3183
|
+
* ERR_STREAM_PREMATURE_CLOSE. arrayBuffer and blob fence per site:
|
|
3184
|
+
* neither value has a representation in a compiled binary. */
|
|
3185
|
+
function text(stream: unknown): Promise<string>;
|
|
3186
|
+
function json(stream: unknown): Promise<unknown>;
|
|
3187
|
+
function buffer(stream: unknown): Promise<Buffer>;
|
|
3188
|
+
function arrayBuffer(stream: unknown): Promise<ArrayBuffer>;
|
|
3189
|
+
function blob(stream: unknown): Promise<unknown>;
|
|
3190
|
+
export { arrayBuffer, blob, buffer, json, text };
|
|
3191
|
+
}
|
|
3192
|
+
declare module "node:stream/consumers" {
|
|
3193
|
+
import streamConsumers = require("stream/consumers");
|
|
3194
|
+
export = streamConsumers;
|
|
3195
|
+
}
|
|
@@ -1008,6 +1008,10 @@ export function emitExpr(E, e) {
|
|
|
1008
1008
|
// Omitted relative indices default like string slice: start 0,
|
|
1009
1009
|
// end +Infinity (math.h is always included). Fresh copy, +1.
|
|
1010
1010
|
return E.newTemp(e.type, `scr_bytes_slice(${r.name}, ${args[0]?.name ?? "0"}, ${args[1]?.name ?? "INFINITY"})`);
|
|
1011
|
+
case "subarray":
|
|
1012
|
+
// Same defaults; the result is a +1 VIEW aliasing the
|
|
1013
|
+
// receiver's storage (subarray / Buffer's slice).
|
|
1014
|
+
return E.newTemp(e.type, `scr_bytes_subarray(${r.name}, ${args[0]?.name ?? "0"}, ${args[1]?.name ?? "INFINITY"})`);
|
|
1011
1015
|
case "setFrom": {
|
|
1012
1016
|
// dst.set(src, offset?) — void; throws Node's RangeError on
|
|
1013
1017
|
// overflow (may-throw seed).
|
|
@@ -1063,6 +1067,10 @@ export function emitExpr(E, e) {
|
|
|
1063
1067
|
E.emitPendingCheck();
|
|
1064
1068
|
return t;
|
|
1065
1069
|
}
|
|
1070
|
+
case "fillElem":
|
|
1071
|
+
// Per-element TypedArray fill (non-u8): slice-style index
|
|
1072
|
+
// defaults, never throws; the receiver comes back +1.
|
|
1073
|
+
return E.newTemp(e.type, `scr_bytes_fill_elem(${r.name}, ${args[0].name}, ${args[1]?.name ?? "0"}, ${args[2]?.name ?? "INFINITY"})`);
|
|
1066
1074
|
case "fillStr": {
|
|
1067
1075
|
const n = e.args.length - 2;
|
|
1068
1076
|
const t = E.newTemp(e.type, `scr_bytes_fill_str(${r.name}, ${args[0].name}, ${args[1].name}, ${n}, ` +
|
|
@@ -2477,10 +2485,14 @@ export function emitExpr(E, e) {
|
|
|
2477
2485
|
return finish(`scr_math_max_arr(${arg(0)})`);
|
|
2478
2486
|
case "math.minArr":
|
|
2479
2487
|
return finish(`scr_math_min_arr(${arg(0)})`);
|
|
2480
|
-
// Math.floor — C
|
|
2481
|
-
// included).
|
|
2488
|
+
// Math.floor/trunc/ceil — the C functions ARE the JS operations
|
|
2489
|
+
// (math.h is always included). Borrow nothing; no throw.
|
|
2482
2490
|
case "math.floor":
|
|
2483
2491
|
return finish(`floor(${arg(0)})`);
|
|
2492
|
+
case "math.trunc":
|
|
2493
|
+
return finish(`trunc(${arg(0)})`);
|
|
2494
|
+
case "math.ceil":
|
|
2495
|
+
return finish(`ceil(${arg(0)})`);
|
|
2484
2496
|
// Math.abs — C fabs IS the JS operation. Math.round — the JS
|
|
2485
2497
|
// half-toward-+Infinity rule (scr_lib.c; C round() differs on
|
|
2486
2498
|
// halves and naive floor(x+0.5) drifts at the epsilon boundary).
|
|
@@ -5097,6 +5109,18 @@ export function emitExpr(E, e) {
|
|
|
5097
5109
|
const list = Array.from({ length: n }, (_, i) => `(ScrStream *)${arg(1 + i)}`).join(", ");
|
|
5098
5110
|
return finish(`scr_sp_pipeline(${n}, (ScrStream *[]){ ${list} })`);
|
|
5099
5111
|
}
|
|
5112
|
+
case "sc.text":
|
|
5113
|
+
// stream/consumers: +1 pending promises the accumulate-and-
|
|
5114
|
+
// settle machinery resolves or rejects (the stream's
|
|
5115
|
+
// error / premature close / json's SyntaxError).
|
|
5116
|
+
E.usesTimers = true;
|
|
5117
|
+
return finish(`scr_sc_text((ScrStream *)${arg(0)})`);
|
|
5118
|
+
case "sc.json":
|
|
5119
|
+
E.usesTimers = true;
|
|
5120
|
+
return finish(`scr_sc_json((ScrStream *)${arg(0)})`);
|
|
5121
|
+
case "sc.buffer":
|
|
5122
|
+
E.usesTimers = true;
|
|
5123
|
+
return finish(`scr_sc_buffer((ScrStream *)${arg(0)})`);
|
|
5100
5124
|
case "readable.newDyn":
|
|
5101
5125
|
case "writable.newDyn":
|
|
5102
5126
|
case "duplex.newDyn":
|
|
@@ -5152,6 +5176,14 @@ export function emitExpr(E, e) {
|
|
|
5152
5176
|
case "readable.pushStr":
|
|
5153
5177
|
E.usesTimers = true;
|
|
5154
5178
|
return finish(`scr_stream_push_str((ScrStream *)${arg(0)}, ${arg(1)})`);
|
|
5179
|
+
case "readable.pushStrEnc":
|
|
5180
|
+
// push(chunk, enc) with a literal non-utf8 encoding.
|
|
5181
|
+
E.usesTimers = true;
|
|
5182
|
+
return finish(`scr_stream_push_str_enc((ScrStream *)${arg(0)}, ${arg(1)}, ${arg(2)})`);
|
|
5183
|
+
case "readable.pushEncoding":
|
|
5184
|
+
// The defaultEncoding option's push side (chaining, +1).
|
|
5185
|
+
E.usesTimers = true;
|
|
5186
|
+
return finish(`(${cType(e.type).trim()})scr_stream_set_push_encoding((ScrStream *)${arg(0)}, ${arg(1)})`);
|
|
5155
5187
|
case "readable.pushNull":
|
|
5156
5188
|
E.usesTimers = true;
|
|
5157
5189
|
return finish(`scr_stream_push_null((ScrStream *)${arg(0)})`);
|