@scriptc/compiler 0.0.12 → 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 +141 -15
- package/dist/backend/cc.d.ts +8 -0
- package/dist/backend/cc.js +12 -0
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +138 -12
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/llvm/emitter.js +43 -6
- package/dist/backend/llvm/emitter.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/lower-builtins.d.ts +38 -20
- package/dist/frontend/lowering/lower-builtins.js +111 -39
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +8 -0
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +10 -2
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +69 -7
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +1 -1
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +21 -0
- package/dist/frontend/lowering/lower-server.js +267 -12
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +4 -4
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -1
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +21 -3
- package/dist/frontend/lowering/lowerer.js +48 -8
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -0
- package/dist/frontend/lowering/surfaces.js +76 -0
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/types.js +12 -0
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +99 -9
- package/dist/ir/nodes.js +52 -1
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +52 -4
- package/dist/ir/validate.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +286 -1
|
@@ -17,7 +17,7 @@ import { unsupportedModuleFeatureOf } from "../shared.js";
|
|
|
17
17
|
import { fenceEnumObjectValue, lowerEnumAccess } from "./lower-enums.js";
|
|
18
18
|
import { ambientNsRootOf, ambientUndefReadType, ambientUndefVarRootOf, ambientUndefinedFnSymbolOf, contextualUndefReadType, fenceEarlyAliasUse, fenceEarlyNsMemberRef, lowerNsIdentifierValue, nsMemberIdentOf, nsUndefRead, nsWritableTarget } from "./lower-namespaces.js";
|
|
19
19
|
import { expandoMemberRead, expandoWritableTarget } from "./lower-expando.js";
|
|
20
|
-
import { lowerSocketInstanceOf } from "./lower-server.js";
|
|
20
|
+
import { lowerSocketInstanceOf, lowerTlsRootCertificates } from "./lower-server.js";
|
|
21
21
|
import { findGenericMethodOn, lowerStaticFieldRead } from "./lower-classes.js";
|
|
22
22
|
import { bindingNeverReassigned, implicitMonoFile, lowerTaggedTemplate, nullishGenericBindingUnitOf, objLitGenericFnInfoOf, objLitGenericFnNodeOf, requireObjLitGenericReceiver } from "./lower-calls.js";
|
|
23
23
|
import { mixinFnOfCallee } from "./lower-mixins.js";
|
|
@@ -693,10 +693,11 @@ function lowerExprInner(L, expr) {
|
|
|
693
693
|
if (acc)
|
|
694
694
|
return acc;
|
|
695
695
|
}
|
|
696
|
-
// A binding destructured from
|
|
697
|
-
// (
|
|
696
|
+
// A binding destructured from a baked constants object
|
|
697
|
+
// (http2.constants / crypto.constants): the literal — the
|
|
698
|
+
// declaration emitted nothing (builtinConstantsDestructureDecl).
|
|
698
699
|
{
|
|
699
|
-
const h2c = L.
|
|
700
|
+
const h2c = L.builtinConstantBindingOf(expr);
|
|
700
701
|
if (h2c)
|
|
701
702
|
return h2c;
|
|
702
703
|
}
|
|
@@ -715,6 +716,14 @@ function lowerExprInner(L, expr) {
|
|
|
715
716
|
if (bi.module === "module" && bi.member === "builtinModules") {
|
|
716
717
|
return builtinModulesArrayLit(loc);
|
|
717
718
|
}
|
|
719
|
+
// tls.rootCertificates: a runtime-valued module constant (the
|
|
720
|
+
// cached bundled-CA array) — the one member read that lowers
|
|
721
|
+
// to a libCall instead of a baked literal.
|
|
722
|
+
{
|
|
723
|
+
const roots = lowerTlsRootCertificates(L, bi, loc);
|
|
724
|
+
if (roots)
|
|
725
|
+
return roots;
|
|
726
|
+
}
|
|
718
727
|
// JavaScript sources: a builtin member taken as a bare VALUE is
|
|
719
728
|
// the same identity-token story as stdlib globals above (the
|
|
720
729
|
// harness adds worker_threads.Worker to its identity Set).
|
|
@@ -1447,7 +1456,7 @@ function lowerExprInner(L, expr) {
|
|
|
1447
1456
|
L.lowerFsConstantsProperty(expr) ??
|
|
1448
1457
|
// http2.constants.NGHTTP2_CANCEL (any constants-object spelling):
|
|
1449
1458
|
// the baked-literal table.
|
|
1450
|
-
L.
|
|
1459
|
+
L.lowerBuiltinConstantsProperty(expr) ??
|
|
1451
1460
|
// Builtin namespace imports (`path.sep`, `os.EOL`,
|
|
1452
1461
|
// `fs.constants.R_OK` where the root is `import * as ...`): the
|
|
1453
1462
|
// same constants and per-member fences as named builtin imports.
|
|
@@ -1858,7 +1867,8 @@ export function lowerTernary(L, expr, expected) {
|
|
|
1858
1867
|
// tagged element type the checker's own type doesn't spell).
|
|
1859
1868
|
const own = L.mapTypeOf(L.typeOf(expr));
|
|
1860
1869
|
const useCtx = (ctxMapped?.kind === "record" || ctxMapped?.kind === "union" || ctxMapped?.kind === "object") &&
|
|
1861
|
-
(own === null ||
|
|
1870
|
+
(own === null ||
|
|
1871
|
+
(own.kind === "union" && !typeEquals(own, ctxMapped) && !L.inLogicalLeftPosition(expr)));
|
|
1862
1872
|
// Mixed dyn/unit arms under an unmappable own type (`typeof pkg.name
|
|
1863
1873
|
// === "string" ? pkg.name : null` — the lowering world types the
|
|
1864
1874
|
// unknown-receiver read `any`, which a static build cannot hold):
|
|
@@ -5518,7 +5528,10 @@ export function lowerRecordKeyRead(L, expr, shapeId, shape) {
|
|
|
5518
5528
|
let dk = litKey !== null
|
|
5519
5529
|
? { kind: "strLit", value: litKey, type: STRING, loc: locOf(keyNode) }
|
|
5520
5530
|
: L.lowerExpr(keyNode);
|
|
5521
|
-
|
|
5531
|
+
// Number AND checked-dynamic keys ride the JS-exact formatter —
|
|
5532
|
+
// property keys ARE strings (o[k] is o[String(k)] in JS), and a dyn
|
|
5533
|
+
// key (agent.sockets[agent.getName(...)]) stringifies the same way.
|
|
5534
|
+
if (dk.type.kind === "f64" || dk.type.kind === "dyn")
|
|
5522
5535
|
dk = L.ensureString(dk, keyNode);
|
|
5523
5536
|
if (dk.type.kind !== "string") {
|
|
5524
5537
|
L.unsupported("SC1090", keyNode, "indexing records with non-string or non-number keys");
|
|
@@ -6612,6 +6625,30 @@ export function lowerBinary(L, expr) {
|
|
|
6612
6625
|
// shapes lower through lowerCondition's bool descent instead.
|
|
6613
6626
|
const target = L.mapTypeOf(L.typeOf(expr));
|
|
6614
6627
|
if (target?.kind === "union") {
|
|
6628
|
+
// `||` whose left does NOT fit the result union: the checker built
|
|
6629
|
+
// that result by DROPPING the left's falsy arms (`process.env.X ||
|
|
6630
|
+
// null` is `string | null`, `|| 3000` is `string | number` — the
|
|
6631
|
+
// `undefined` is gone from both), so coercing the left eagerly, as
|
|
6632
|
+
// the shared shape below does, retags an arm the test is about to
|
|
6633
|
+
// rule out and throws where Node yields the default. Single-eval
|
|
6634
|
+
// instead: test the left in its OWN union and retag only on the
|
|
6635
|
+
// truthy side, where the dropped arms are unreachable. `&&` keeps
|
|
6636
|
+
// the eager shape — there the falsy left IS the result, so the
|
|
6637
|
+
// checker keeps those arms in the target and they must coerce.
|
|
6638
|
+
if (op === ts.SyntaxKind.BarBarToken && left.type.kind === "union" && !typeEquals(left.type, target)) {
|
|
6639
|
+
const retag = L.unionRetagHelper(left.type.unionId, target.unionId, loc);
|
|
6640
|
+
if (retag) {
|
|
6641
|
+
L.requireTruthyUnion(left.type.unionId, expr);
|
|
6642
|
+
return {
|
|
6643
|
+
kind: "orDefault",
|
|
6644
|
+
left,
|
|
6645
|
+
right: L.coerceInto(expr.right, right, target),
|
|
6646
|
+
retag,
|
|
6647
|
+
type: target,
|
|
6648
|
+
loc,
|
|
6649
|
+
};
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6615
6652
|
L.requireTruthyUnion(target.unionId, expr);
|
|
6616
6653
|
return {
|
|
6617
6654
|
kind: "logical",
|
|
@@ -6978,6 +7015,12 @@ export function lowerBinary(L, expr) {
|
|
|
6978
7015
|
typeEquals(idLeft.type, idRight.type)) {
|
|
6979
7016
|
return { kind: "bin", op: negated ? "!==" : "===", left: idLeft, right: idRight, type: BOOL, loc };
|
|
6980
7017
|
}
|
|
7018
|
+
// Runtime HANDLES are objects to === too: one handle per socket/
|
|
7019
|
+
// request/response, so pointer identity IS JS's object equality
|
|
7020
|
+
// (`c.pause() === c` — Node's chaining assertions). */
|
|
7021
|
+
if (DYN_HANDLE_KINDS.has(idLeft.type.kind) && typeEquals(idLeft.type, idRight.type)) {
|
|
7022
|
+
return { kind: "bin", op: negated ? "!==" : "===", left: idLeft, right: idRight, type: BOOL, loc };
|
|
7023
|
+
}
|
|
6981
7024
|
L.unsupported("SC1043", expr);
|
|
6982
7025
|
break;
|
|
6983
7026
|
}
|
|
@@ -8077,6 +8120,25 @@ export function lowerInExpression(L, expr, loc) {
|
|
|
8077
8120
|
const rIn = lowerRuntimeKeyIn(L, expr, loc);
|
|
8078
8121
|
if (rIn)
|
|
8079
8122
|
return rIn;
|
|
8123
|
+
// A runtime key over a CHECKED-DYNAMIC receiver (`name in
|
|
8124
|
+
// agent.sockets` — both sides computed; the checker may type the
|
|
8125
|
+
// receiver as a Dict while the VALUE lives in the checked-dynamic tree, so the
|
|
8126
|
+
// LOWERED type decides): the dyn presence answer, with the key
|
|
8127
|
+
// stringified like every property key (o[k] is o[String(k)] in JS;
|
|
8128
|
+
// `in` shares the coercion).
|
|
8129
|
+
{
|
|
8130
|
+
const probed = probeLower(L, expr.right);
|
|
8131
|
+
if (probed?.type.kind === "dyn") {
|
|
8132
|
+
let k = L.lowerExpr(expr.left); // JS order: the key evaluates first
|
|
8133
|
+
if (k.type.kind === "f64" || k.type.kind === "string" || k.type.kind === "dyn") {
|
|
8134
|
+
k = L.ensureString(k, expr.left);
|
|
8135
|
+
const recvD = L.lowerExpr(expr.right);
|
|
8136
|
+
if (recvD.type.kind === "dyn") {
|
|
8137
|
+
return { kind: "libCall", fn: "dyn.hasKey", args: [recvD, k], type: BOOL, loc };
|
|
8138
|
+
}
|
|
8139
|
+
}
|
|
8140
|
+
}
|
|
8141
|
+
}
|
|
8080
8142
|
L.unsupported("SC1090", expr.left, "'in' with computed (non-literal) keys (a const whose type is one string literal folds; a string-typed key answers over index-signature record receivers)");
|
|
8081
8143
|
}
|
|
8082
8144
|
// A receiver re-read (the static folds below) is safe for plain reads
|