@scriptc/compiler 0.0.11 → 0.0.13
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 +153 -24
- package/ambient/scriptc.d.ts +2 -2
- package/dist/backend/cc.d.ts +10 -2
- package/dist/backend/cc.js +12 -0
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-async.js +1 -1
- package/dist/backend/emission/emit-exprs.js +235 -64
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-island.js +1 -1
- package/dist/backend/emission/emit-shapes.js +1 -1
- package/dist/backend/emission/emit-walkers.d.ts +14 -14
- package/dist/backend/emission/emit-walkers.js +44 -44
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +3 -3
- package/dist/backend/emission/emitter.js +8 -8
- package/dist/backend/emission/may-throw.js +1 -1
- package/dist/backend/llvm/dyn.d.ts +10 -10
- package/dist/backend/llvm/dyn.js +26 -26
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +140 -49
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +1 -1
- package/dist/backend/llvm/walkers.js +2 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.js +4 -3
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +7 -0
- package/dist/frontend/lowering/crypto-tables.js +139 -0
- package/dist/frontend/lowering/crypto-tables.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.js +5 -5
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +12 -12
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +45 -27
- package/dist/frontend/lowering/lower-builtins.js +203 -70
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +4 -4
- package/dist/frontend/lowering/lower-calls.js +74 -66
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +41 -7
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +5 -5
- package/dist/frontend/lowering/lower-containers.js +19 -19
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-emitter.js +2 -2
- package/dist/frontend/lowering/lower-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +7 -7
- package/dist/frontend/lowering/lower-exprs.js +227 -119
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +5 -5
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +12 -3
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +17 -17
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +11 -1
- package/dist/frontend/lowering/lower-namespaces.js +41 -6
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +21 -0
- package/dist/frontend/lowering/lower-server.js +278 -23
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +1 -1
- package/dist/frontend/lowering/lower-stmts.js +195 -34
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +67 -23
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +31 -13
- package/dist/frontend/lowering/lowerer.js +99 -45
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -0
- package/dist/frontend/lowering/surfaces.js +78 -2
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/program.js +1 -1
- package/dist/frontend/shared.js +7 -7
- package/dist/frontend/shared.js.map +1 -1
- package/dist/frontend/types.d.ts +2 -2
- package/dist/frontend/types.js +27 -15
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +44 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +208 -106
- package/dist/ir/nodes.js +100 -22
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +96 -38
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/int-infer.js +13 -0
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/profile.d.ts +8 -6
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar-validate.js +1 -1
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +1 -1
- package/dist/library/sidecar.js +20 -7
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +289 -4
package/dist/backend/llvm/dyn.js
CHANGED
|
@@ -55,8 +55,8 @@ export class LlDyn {
|
|
|
55
55
|
valTy(t) {
|
|
56
56
|
return t.kind === "f64" ? "double" : t.kind === "bool" ? "i1" : "ptr";
|
|
57
57
|
}
|
|
58
|
-
/* ──
|
|
59
|
-
/** Loads a
|
|
58
|
+
/* ── dyn node plumbing ─────────────────────────────────────────────── */
|
|
59
|
+
/** Loads a dyn node's kind tag (i32 at +8). */
|
|
60
60
|
kindOf(B, d) {
|
|
61
61
|
const p = B.tmp();
|
|
62
62
|
const k = B.tmp();
|
|
@@ -143,7 +143,7 @@ export class LlDyn {
|
|
|
143
143
|
B.line(`${t} = call ptr @scr_dyn_retain_v(ptr ${x})`);
|
|
144
144
|
return t;
|
|
145
145
|
}
|
|
146
|
-
/** THE immortal undefined
|
|
146
|
+
/** THE immortal undefined dyn value (borrowed — retain to own). */
|
|
147
147
|
undef(B) {
|
|
148
148
|
this.host.declare(`declare ptr @scr_dyn_undefined()`);
|
|
149
149
|
const t = B.tmp();
|
|
@@ -273,7 +273,7 @@ export class LlDyn {
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
/* ── dynMatchHelper (emit-walkers.ts, ported) ──────────────────────── */
|
|
276
|
-
/** `sc_dm_<n>(ptr d) -> i1` — does this
|
|
276
|
+
/** `sc_dm_<n>(ptr d) -> i1` — does this dyn fit T? Never throws. */
|
|
277
277
|
dynMatchHelper(t) {
|
|
278
278
|
const key = typeKey(t);
|
|
279
279
|
const existing = this.dynMatchers.get(key);
|
|
@@ -305,7 +305,7 @@ export class LlDyn {
|
|
|
305
305
|
kindIs(DK.UNDEF);
|
|
306
306
|
break;
|
|
307
307
|
case "dyn":
|
|
308
|
-
// An `unknown` target: every
|
|
308
|
+
// An `unknown` target: every dyn value fits, undefined included.
|
|
309
309
|
B.terminate(`ret i1 true`);
|
|
310
310
|
break;
|
|
311
311
|
case "bytes":
|
|
@@ -466,7 +466,7 @@ export class LlDyn {
|
|
|
466
466
|
return name;
|
|
467
467
|
}
|
|
468
468
|
/* ── dynCheckHelper (emit-walkers.ts, ported) ──────────────────────── */
|
|
469
|
-
/** `sc_dc_<n>(ptr d, ptr path) -> T` — validate the
|
|
469
|
+
/** `sc_dc_<n>(ptr d, ptr path) -> T` — validate the checked-dynamic tree against T and
|
|
470
470
|
* BUILD the typed value (+1), or throw the catchable path-annotated
|
|
471
471
|
* TypeError and return a dummy with the pending flag set. */
|
|
472
472
|
dynCheckHelper(t) {
|
|
@@ -518,7 +518,7 @@ export class LlDyn {
|
|
|
518
518
|
break;
|
|
519
519
|
}
|
|
520
520
|
case "dyn": {
|
|
521
|
-
// An `unknown` slot: the
|
|
521
|
+
// An `unknown` slot: the checked-dynamic tree subtree passes through as-is.
|
|
522
522
|
const r = this.retainDyn(B, "%d");
|
|
523
523
|
B.terminate(`ret ptr ${r}`);
|
|
524
524
|
break;
|
|
@@ -536,15 +536,15 @@ export class LlDyn {
|
|
|
536
536
|
}
|
|
537
537
|
case "object": {
|
|
538
538
|
// The %Error extraction (an instanceof-Error narrow on unknown):
|
|
539
|
-
// validate the
|
|
539
|
+
// validate the checked-dynamic tree's error encoding — the reserved "%error" marker
|
|
540
540
|
// caughtToDyn builds — and extract through the runtime's IDENTITY
|
|
541
|
-
// CACHE (scr_error_from_dyn): a
|
|
541
|
+
// CACHE (scr_error_from_dyn): a dyn error that came from a runtime
|
|
542
542
|
// ScrError answers that very instance, so out-and-back crossings
|
|
543
543
|
// compare reference-equal (the tracing suite's shape); alien
|
|
544
544
|
// %error objects rebuild once and cache the pair. The C walker's
|
|
545
545
|
// arm exactly.
|
|
546
546
|
if (t.className !== "%Error") {
|
|
547
|
-
throw new Error(`llvm emitter bug: dynCheck of class ${t.className} (only %Error extracts from the
|
|
547
|
+
throw new Error(`llvm emitter bug: dynCheck of class ${t.className} (only %Error extracts from the checked-dynamic tree)`);
|
|
548
548
|
}
|
|
549
549
|
const kd = this.kindOf(B, "%d");
|
|
550
550
|
const isObj = B.tmp();
|
|
@@ -652,7 +652,7 @@ export class LlDyn {
|
|
|
652
652
|
const m = this.objGetLit(B, "%d", f.name);
|
|
653
653
|
if (f.type.kind === "dyn") {
|
|
654
654
|
// An `unknown` field: a present key passes through, a missing
|
|
655
|
-
// one IS the undefined
|
|
655
|
+
// one IS the undefined dyn value.
|
|
656
656
|
const has = B.tmp();
|
|
657
657
|
B.line(`${has} = icmp ne ptr ${m}, null`);
|
|
658
658
|
const sel = B.tmp();
|
|
@@ -917,7 +917,7 @@ export class LlDyn {
|
|
|
917
917
|
return name;
|
|
918
918
|
}
|
|
919
919
|
/* ── toDynHelper (emit-walkers.ts, ported) ─────────────────────────── */
|
|
920
|
-
/** `sc_td_<n>(<T> v) -> ptr` — build a fresh dyn
|
|
920
|
+
/** `sc_td_<n>(<T> v) -> ptr` — build a fresh dyn value from a
|
|
921
921
|
* static one (+1), DEEP-COPYING composites. Borrows the operand.
|
|
922
922
|
* Never throws. */
|
|
923
923
|
toDynHelper(t) {
|
|
@@ -952,7 +952,7 @@ export class LlDyn {
|
|
|
952
952
|
break;
|
|
953
953
|
}
|
|
954
954
|
case "object": {
|
|
955
|
-
// %Error only (canConvertToDyn's gate): the
|
|
955
|
+
// %Error only (canConvertToDyn's gate): the checked-dynamic tree's error encoding.
|
|
956
956
|
if (t.className !== "%Error") {
|
|
957
957
|
throw new Error(`llvm emitter bug: to-dyn of class ${t.className}`);
|
|
958
958
|
}
|
|
@@ -995,7 +995,7 @@ export class LlDyn {
|
|
|
995
995
|
};
|
|
996
996
|
host.declare(`declare void @scr_dyn_obj_set(ptr, ptr, i64, ptr)`);
|
|
997
997
|
// CYCLE-CAPABLE shapes guard the deep copy: enter TRAPS on a value
|
|
998
|
-
// already being converted (a cyclic value has no finite
|
|
998
|
+
// already being converted (a cyclic value has no finite dyn copy —
|
|
999
999
|
// SEMANTICS.md; the C emitter's contract exactly).
|
|
1000
1000
|
const cyclicRec = traceAdapter(host, t) !== null;
|
|
1001
1001
|
if (cyclicRec) {
|
|
@@ -1265,7 +1265,7 @@ export class LlDyn {
|
|
|
1265
1265
|
case "promise": {
|
|
1266
1266
|
// Promises box by REFERENCE (SCR_DYN_PROMISE — identity is the
|
|
1267
1267
|
// promise): promise<dyn> carries its ScrPromise directly (the
|
|
1268
|
-
// payload is already a
|
|
1268
|
+
// payload is already a dyn value); any other inner boxes an
|
|
1269
1269
|
// ADAPTER promise whose settle callback converts the payload
|
|
1270
1270
|
// (rejections copy raw inside the runtime's cb-waiter machinery).
|
|
1271
1271
|
if (t.inner.kind === "dyn") {
|
|
@@ -1300,10 +1300,10 @@ export class LlDyn {
|
|
|
1300
1300
|
this.defs.push(`define internal ptr @${name}(${this.valTy(t)} %v) ${FN_ATTRS} { ; to-dyn ${key}`, B.render(), `}`, ``);
|
|
1301
1301
|
return name;
|
|
1302
1302
|
}
|
|
1303
|
-
/** The
|
|
1303
|
+
/** The checked-dynamic tree-promise settle adapter for one fulfillment payload type —
|
|
1304
1304
|
* promiseDynAdapterHelper (emit-walkers.ts), ported:
|
|
1305
1305
|
* `void sc_pda_<n>(ptr %dst, ptr %src)` reads src's fulfilled payload
|
|
1306
|
-
* by its compile-time kind, converts it to a
|
|
1306
|
+
* by its compile-time kind, converts it to a dyn value, and fulfills
|
|
1307
1307
|
* dst with it (scr_dyn_new_promise_adapting's callback; rejections
|
|
1308
1308
|
* never reach an adapter — the runtime copies them raw). Interned per
|
|
1309
1309
|
* inner typeKey. */
|
|
@@ -1387,7 +1387,7 @@ export class LlDyn {
|
|
|
1387
1387
|
return name;
|
|
1388
1388
|
}
|
|
1389
1389
|
/* ── the dyn ToString pair (dynToStrHelper, ported) ────────────────── */
|
|
1390
|
-
/** Node's String() over a
|
|
1390
|
+
/** Node's String() over a dyn value — sc_ds (+1 result) over the
|
|
1391
1391
|
* recursive sc_ds_buf walker. Borrowed operand; never throws. */
|
|
1392
1392
|
dynToStrHelper() {
|
|
1393
1393
|
if (this.dynToStrFn)
|
|
@@ -1485,7 +1485,7 @@ export class LlDyn {
|
|
|
1485
1485
|
}
|
|
1486
1486
|
B.startBlock(labels.get(DK.OBJ));
|
|
1487
1487
|
{
|
|
1488
|
-
// The
|
|
1488
|
+
// The checked-dynamic tree's error encoding renders Error.prototype.toString;
|
|
1489
1489
|
// plain objects are "[object Object]".
|
|
1490
1490
|
const marker = this.objGetLit(B, "%d", "%error");
|
|
1491
1491
|
const isErr = B.tmp();
|
|
@@ -1757,14 +1757,14 @@ export class LlDyn {
|
|
|
1757
1757
|
B.condBr(isErr, lErr, lDef);
|
|
1758
1758
|
B.startBlock(lErr);
|
|
1759
1759
|
// The identity-cached crossing (scr_json.c): one error instance,
|
|
1760
|
-
// one
|
|
1760
|
+
// one dyn node — the C walker's arm exactly.
|
|
1761
1761
|
host.declare(`declare ptr @scr_dyn_from_error(ptr)`);
|
|
1762
1762
|
const r = B.tmp();
|
|
1763
1763
|
B.line(`${r} = call ptr @scr_dyn_from_error(ptr ${p})`);
|
|
1764
1764
|
B.terminate(`ret ptr ${r}`);
|
|
1765
1765
|
}
|
|
1766
1766
|
B.startBlock(lDef);
|
|
1767
|
-
// SCR_EXC_REF: a thrown
|
|
1767
|
+
// SCR_EXC_REF: a thrown dyn value passes back BY REFERENCE (identity
|
|
1768
1768
|
// with every other holder — the dyn adapters discriminate); non-dyn
|
|
1769
1769
|
// REF and non-Error objects keep the "[object Object]" approximation
|
|
1770
1770
|
// — truthy, typeof "object", fields unreadable.
|
|
@@ -1797,7 +1797,7 @@ export class LlDyn {
|
|
|
1797
1797
|
return name;
|
|
1798
1798
|
}
|
|
1799
1799
|
/* ── the keyed read (dynKeyGetHelper, ported) ──────────────────────── */
|
|
1800
|
-
/** `sc_dyn_key_get(ptr d, ptr k, i1 opt) -> ptr` — d[k] on a
|
|
1800
|
+
/** `sc_dyn_key_get(ptr d, ptr k, i1 opt) -> ptr` — d[k] on a dyn value.
|
|
1801
1801
|
* Result +1; throws on non-optional nullish receivers. */
|
|
1802
1802
|
dynKeyGetHelper() {
|
|
1803
1803
|
const memoKey = "%dynKeyGet";
|
|
@@ -2488,7 +2488,7 @@ export class LlDyn {
|
|
|
2488
2488
|
}
|
|
2489
2489
|
/** The call thunk for one closure signature: validate each dyn arg
|
|
2490
2490
|
* into the declared param type, call through the closure, convert the
|
|
2491
|
-
* result back to a
|
|
2491
|
+
* result back to a dyn value (+1). */
|
|
2492
2492
|
dynFuncThunkHelper(t) {
|
|
2493
2493
|
const key = typeKey(t);
|
|
2494
2494
|
const existing = this.dynFuncThunks.get(key);
|
|
@@ -2500,7 +2500,7 @@ export class LlDyn {
|
|
|
2500
2500
|
const B = new BlockBuilder();
|
|
2501
2501
|
const argNames = [];
|
|
2502
2502
|
t.params.forEach((p, i) => {
|
|
2503
|
-
// JS arity: a missing argument IS the undefined
|
|
2503
|
+
// JS arity: a missing argument IS the undefined dyn value.
|
|
2504
2504
|
const adSlot = B.slot();
|
|
2505
2505
|
B.entryAllocas.push(`${adSlot} = alloca ptr`);
|
|
2506
2506
|
const has = B.tmp();
|
|
@@ -2527,7 +2527,7 @@ export class LlDyn {
|
|
|
2527
2527
|
argNames.push(this.retainDyn(B, ad));
|
|
2528
2528
|
}
|
|
2529
2529
|
else if (p.kind === "jsval") {
|
|
2530
|
-
// A checker-'any' param: the
|
|
2530
|
+
// A checker-'any' param: the dyn argument enters the island —
|
|
2531
2531
|
// wrapped cells unwrap by reference, data deep-copies, boxed
|
|
2532
2532
|
// functions cross through the host shim; a kind with no crossing
|
|
2533
2533
|
// throws the catchable TypeError (null + pending).
|
|
@@ -2571,7 +2571,7 @@ export class LlDyn {
|
|
|
2571
2571
|
argNames.push(a);
|
|
2572
2572
|
}
|
|
2573
2573
|
});
|
|
2574
|
-
// VARIADIC (rest-marked) signatures: one extra trailing
|
|
2574
|
+
// VARIADIC (rest-marked) signatures: one extra trailing dyn-array
|
|
2575
2575
|
// param carries the call's arguments from index params.length on.
|
|
2576
2576
|
let rest = null;
|
|
2577
2577
|
if (t.rest) {
|