@scriptc/compiler 0.0.21 → 0.0.23
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 +117 -37
- package/dist/backend/cc-cache.test.d.ts +1 -0
- package/dist/backend/cc-cache.test.js +2507 -0
- package/dist/backend/cc-cache.test.js.map +1 -0
- package/dist/backend/cc.d.ts +69 -11
- package/dist/backend/cc.js +1937 -222
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-async.js +3 -1
- package/dist/backend/emission/emit-async.js.map +1 -1
- package/dist/backend/emission/emit-exprs.d.ts +10 -0
- package/dist/backend/emission/emit-exprs.js +482 -18
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +13 -5
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-types.js +4 -1
- package/dist/backend/emission/emit-types.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +108 -7
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +27 -1
- package/dist/backend/emission/emitter.js +84 -3
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +1 -0
- package/dist/backend/llvm/dyn.js +305 -8
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +831 -23
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +3 -2
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +118 -0
- package/dist/compat/fetch-profile.js +531 -0
- package/dist/compat/fetch-profile.js.map +1 -0
- package/dist/coverage/surface-manifest.js +69 -0
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +10 -0
- package/dist/diagnostics/diagnostic.js +27 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +24 -15
- package/dist/frontend/lowering/lower-builtins.js +217 -69
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +41 -0
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +32 -11
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +3 -3
- package/dist/frontend/lowering/lower-exprs.js +87 -15
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +7 -1
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +123 -7
- package/dist/frontend/lowering/lower-island.js +1976 -26
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +17 -1
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +33 -9
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +40 -0
- package/dist/frontend/lowering/lowerer.js +290 -18
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +55 -12
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/program.d.ts +20 -4
- package/dist/frontend/program.js +391 -49
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.d.ts +10 -0
- package/dist/frontend/resolve.js +37 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/ts7/enums.d.ts +9 -0
- package/dist/frontend/ts7/enums.js +8 -6
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/program.js +4 -1
- package/dist/frontend/ts7/program.js.map +1 -1
- package/dist/frontend/types.d.ts +16 -9
- package/dist/frontend/types.js +119 -38
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +70 -14
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +55 -26
- package/dist/ir/nodes.js +42 -29
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +106 -9
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/int-infer.js +7 -1
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +80 -0
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/sidecar-validate.js +5 -0
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +3 -0
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1097 -130
|
@@ -232,9 +232,9 @@ export declare function foldedStringKeyOf(L: Lowerer, expr: ts.Expression): stri
|
|
|
232
232
|
* dyn's String() for dyn operands — `{ [field]: v }` where field is a
|
|
233
233
|
* checked-dynamic param). Values convert through the usual dyn boundary
|
|
234
234
|
* (dynFrom's domain, functions box); a value with no dyn representation
|
|
235
|
-
* fences per property. Spreads
|
|
236
|
-
*
|
|
237
|
-
export declare function lowerDynObjectLiteral(L: Lowerer, expr: ts.ObjectLiteralExpression): IrExpr;
|
|
235
|
+
* fences per property. Spreads copy through dyn.assign in source order;
|
|
236
|
+
* accessors stay fenced. */
|
|
237
|
+
export declare function lowerDynObjectLiteral(L: Lowerer, expr: ts.ObjectLiteralExpression, boxValue?: (node: ts.Expression, value: IrExpr) => IrExpr): IrExpr;
|
|
238
238
|
export declare function lowerObjectLiteral(L: Lowerer, expr: ts.ObjectLiteralExpression): IrExpr;
|
|
239
239
|
/** A conditional spread's carrier property: `name: value` or shorthand,
|
|
240
240
|
* with an identifier/string-literal name. */
|
|
@@ -82,6 +82,15 @@ function lowerExprInner(L, expr) {
|
|
|
82
82
|
const chainRecv = L.chainRecvByNode.get(expr);
|
|
83
83
|
if (chainRecv)
|
|
84
84
|
return { ...chainRecv, loc };
|
|
85
|
+
// --external-types supplies CHECKER truth only. A value rooted in one
|
|
86
|
+
// of those declarations has no runtime implementation in scriptc, so
|
|
87
|
+
// every use fences at its expression instead of accidentally lowering
|
|
88
|
+
// as an ambient ReferenceError or a structural value. This keeps the
|
|
89
|
+
// rest of coverage measurable without overstating the host boundary.
|
|
90
|
+
const externalTypeSpecifier = L.externalTypeSpecifierOf(expr);
|
|
91
|
+
if (externalTypeSpecifier !== null) {
|
|
92
|
+
L.externalHostFence(externalTypeSpecifier, expr);
|
|
93
|
+
}
|
|
85
94
|
if (ts.isNumericLiteral(expr)) {
|
|
86
95
|
const value = Number(expr.text.replace(/_/g, ""));
|
|
87
96
|
// Ask 4's representability input: a DECIMAL INTEGER source spelling
|
|
@@ -1605,6 +1614,10 @@ function lowerExprInner(L, expr) {
|
|
|
1605
1614
|
// The lib fence's PROPERTY chokepoint: a stdlib-declared member that
|
|
1606
1615
|
// no lowering above claimed ([1,2].entries, Math.SQRT2, Promise.all,
|
|
1607
1616
|
// re.exec as a value, ...) reports SC2020 here.
|
|
1617
|
+
L.fenceStaticAbortControllerMemberRead(expr);
|
|
1618
|
+
L.fenceStaticResponseMember(expr, "read");
|
|
1619
|
+
L.fenceStaticHeadersMember(expr, "read");
|
|
1620
|
+
L.fenceStaticReadableStreamMember(expr, "read");
|
|
1608
1621
|
L.stdlibMemberFence(expr);
|
|
1609
1622
|
// The npm chokepoint: a member on a package-typed receiver in a
|
|
1610
1623
|
// static build — attributed to the package, like every other site.
|
|
@@ -2899,7 +2912,7 @@ export function lowerIntrinsicProperty(L, expr) {
|
|
|
2899
2912
|
if (probe.type.kind === "array")
|
|
2900
2913
|
kind = "array";
|
|
2901
2914
|
}
|
|
2902
|
-
if (kind !== "string" && kind !== "array" && kind !== "map" && kind !== "set" && kind !== "f64" && kind !== "regex" && kind !== "url" && kind !== "searchParams" && kind !== "stats" && kind !== "spawnRes" && kind !== "child" && kind !== "bytes" && kind !== "symbol") {
|
|
2915
|
+
if (kind !== "string" && kind !== "array" && kind !== "map" && kind !== "set" && kind !== "f64" && kind !== "date" && kind !== "regex" && kind !== "url" && kind !== "searchParams" && kind !== "stats" && kind !== "spawnRes" && kind !== "child" && kind !== "bytes" && kind !== "symbol") {
|
|
2903
2916
|
return null;
|
|
2904
2917
|
}
|
|
2905
2918
|
// child receivers also admit the user's own child-shaped interface
|
|
@@ -2994,6 +3007,20 @@ export function lowerIntrinsicProperty(L, expr) {
|
|
|
2994
3007
|
}
|
|
2995
3008
|
L.noLowering(`Stats.${name}`, expr, "isFile(), isDirectory(), and size are the supported Stats members", L.checker.getSymbolAtLocation(expr.name));
|
|
2996
3009
|
}
|
|
3010
|
+
if (kind === "date") {
|
|
3011
|
+
const methods = new Set([
|
|
3012
|
+
"getTime", "valueOf", "toISOString",
|
|
3013
|
+
"getFullYear", "getUTCFullYear", "getMonth", "getUTCMonth",
|
|
3014
|
+
"getDate", "getUTCDate", "getDay", "getUTCDay", "getHours",
|
|
3015
|
+
"getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds",
|
|
3016
|
+
"getUTCSeconds", "getMilliseconds", "getUTCMilliseconds",
|
|
3017
|
+
"getTimezoneOffset",
|
|
3018
|
+
]);
|
|
3019
|
+
if (methods.has(name)) {
|
|
3020
|
+
L.unsupported("SC1090", expr, `Date methods as values (call '${name}' directly)`);
|
|
3021
|
+
}
|
|
3022
|
+
L.noLowering(`Date.prototype.${name}`, expr, "getTime(), valueOf(), toISOString(), the local/UTC calendar getters, and getTimezoneOffset() are supported; Date setters and locale/string formatters have no lowering", L.checker.getSymbolAtLocation(expr.name));
|
|
3023
|
+
}
|
|
2997
3024
|
if (kind === "symbol") {
|
|
2998
3025
|
const loc = locOf(expr);
|
|
2999
3026
|
// `.description`: the checker's `string | undefined` — undefined
|
|
@@ -3360,9 +3387,11 @@ export function lowerArrayLiteral(L, expr, expected) {
|
|
|
3360
3387
|
let srcNode = el.expression;
|
|
3361
3388
|
while (ts.isParenthesizedExpression(srcNode))
|
|
3362
3389
|
srcNode = srcNode.expression;
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3390
|
+
L.fenceStaticHeadersIteration(el.expression);
|
|
3391
|
+
let src = L.lowerDynamicHeadersSpread(el.expression, type) ??
|
|
3392
|
+
(ts.isConditionalExpression(srcNode)
|
|
3393
|
+
? lowerTernary(L, srcNode, type)
|
|
3394
|
+
: L.lowerExpr(el.expression));
|
|
3366
3395
|
// `[...someSet]`: a same-element Set drains into a fresh array in
|
|
3367
3396
|
// insertion order (setIntrinsic toArray); the spread machinery
|
|
3368
3397
|
// then copies like any array source.
|
|
@@ -3639,14 +3668,39 @@ function propNameText(L, name) {
|
|
|
3639
3668
|
* dyn's String() for dyn operands — `{ [field]: v }` where field is a
|
|
3640
3669
|
* checked-dynamic param). Values convert through the usual dyn boundary
|
|
3641
3670
|
* (dynFrom's domain, functions box); a value with no dyn representation
|
|
3642
|
-
* fences per property. Spreads
|
|
3643
|
-
*
|
|
3644
|
-
export function lowerDynObjectLiteral(L, expr) {
|
|
3671
|
+
* fences per property. Spreads copy through dyn.assign in source order;
|
|
3672
|
+
* accessors stay fenced. */
|
|
3673
|
+
export function lowerDynObjectLiteral(L, expr, boxValue) {
|
|
3645
3674
|
const loc = locOf(expr);
|
|
3646
|
-
|
|
3675
|
+
let fields = [];
|
|
3676
|
+
let acc = null;
|
|
3677
|
+
const flushFields = () => {
|
|
3678
|
+
if (fields.length === 0)
|
|
3679
|
+
return;
|
|
3680
|
+
const chunk = { kind: "dynObjLit", fields, type: DYN, loc };
|
|
3681
|
+
acc = acc === null
|
|
3682
|
+
? chunk
|
|
3683
|
+
: { kind: "libCall", fn: "dyn.assign", args: [acc, chunk], type: DYN, loc };
|
|
3684
|
+
fields = [];
|
|
3685
|
+
};
|
|
3647
3686
|
for (const prop of expr.properties) {
|
|
3648
|
-
if (
|
|
3649
|
-
|
|
3687
|
+
if (ts.isSpreadAssignment(prop)) {
|
|
3688
|
+
flushFields();
|
|
3689
|
+
const raw = L.lowerExpr(prop.expression);
|
|
3690
|
+
const source = boxValue
|
|
3691
|
+
? boxValue(prop.expression, raw)
|
|
3692
|
+
: L.coerceToExpected(raw, DYN);
|
|
3693
|
+
if (source.type.kind !== "dyn") {
|
|
3694
|
+
L.unsupported("SC1101", prop.expression, `spreading '${L.fmt(source.type)}' into a checked-dynamic object literal`);
|
|
3695
|
+
}
|
|
3696
|
+
acc ??= { kind: "dynObjLit", fields: [], type: DYN, loc };
|
|
3697
|
+
acc = { kind: "libCall", fn: "dyn.assign", args: [acc, source], type: DYN, loc: locOf(prop) };
|
|
3698
|
+
continue;
|
|
3699
|
+
}
|
|
3700
|
+
if (!ts.isPropertyAssignment(prop) &&
|
|
3701
|
+
!ts.isShorthandPropertyAssignment(prop) &&
|
|
3702
|
+
!ts.isMethodDeclaration(prop)) {
|
|
3703
|
+
L.unsupported("SC1090", prop, "accessors in a runtime-keyed (computed-key) object literal");
|
|
3650
3704
|
}
|
|
3651
3705
|
const name = prop.name;
|
|
3652
3706
|
let key;
|
|
@@ -3675,16 +3729,23 @@ export function lowerDynObjectLiteral(L, expr) {
|
|
|
3675
3729
|
else {
|
|
3676
3730
|
L.unsupported("SC1090", prop, "non-identifier property names");
|
|
3677
3731
|
}
|
|
3678
|
-
const valueExpr = ts.
|
|
3732
|
+
const valueExpr = ts.isMethodDeclaration(prop)
|
|
3733
|
+
? prop
|
|
3734
|
+
: ts.isShorthandPropertyAssignment(prop)
|
|
3735
|
+
? prop.name
|
|
3736
|
+
: prop.initializer;
|
|
3679
3737
|
// Lambda values that fail to lower become trap closures (the
|
|
3680
3738
|
// per-call fence granularity — fenceClosureProbe) so the object
|
|
3681
3739
|
// still builds; everything else keeps the per-property fence below.
|
|
3682
3740
|
let raw;
|
|
3683
3741
|
const propDiagsBefore = L.diags.length;
|
|
3684
3742
|
try {
|
|
3743
|
+
const lowerValue = () => ts.isMethodDeclaration(prop)
|
|
3744
|
+
? (L.rejectThisInObjectMethod(prop.body ?? prop), L.lowerLambda(prop))
|
|
3745
|
+
: L.lowerExpr(valueExpr);
|
|
3685
3746
|
raw =
|
|
3686
|
-
fenceClosureProbe(L, valueExpr, undefined,
|
|
3687
|
-
|
|
3747
|
+
fenceClosureProbe(L, valueExpr, undefined, lowerValue) ??
|
|
3748
|
+
lowerValue();
|
|
3688
3749
|
}
|
|
3689
3750
|
catch (err) {
|
|
3690
3751
|
// A PURE member read a JS file cannot lower (a namespace object
|
|
@@ -3722,7 +3783,9 @@ export function lowerDynObjectLiteral(L, expr) {
|
|
|
3722
3783
|
});
|
|
3723
3784
|
raw = { kind: "closure", fnName, captures: [], type: funcOf([], VOID), loc: locOf(prop) };
|
|
3724
3785
|
}
|
|
3725
|
-
let v =
|
|
3786
|
+
let v = boxValue
|
|
3787
|
+
? boxValue(valueExpr, raw)
|
|
3788
|
+
: L.coerceToExpected(raw, DYN);
|
|
3726
3789
|
if (v.type.kind !== "dyn") {
|
|
3727
3790
|
const convDiagsBefore = L.diags.length;
|
|
3728
3791
|
try {
|
|
@@ -3768,7 +3831,8 @@ export function lowerDynObjectLiteral(L, expr) {
|
|
|
3768
3831
|
}
|
|
3769
3832
|
fields.push({ key, value: v });
|
|
3770
3833
|
}
|
|
3771
|
-
|
|
3834
|
+
flushFields();
|
|
3835
|
+
return acc ?? { kind: "dynObjLit", fields: [], type: DYN, loc };
|
|
3772
3836
|
}
|
|
3773
3837
|
/** Spreading a source whose shape carries accessor slots: Node's copy
|
|
3774
3838
|
* invokes each getter exactly once in insertion order — even for keys a
|
|
@@ -5185,6 +5249,14 @@ export function lowerElementAccess(L, expr) {
|
|
|
5185
5249
|
if (en)
|
|
5186
5250
|
return en;
|
|
5187
5251
|
}
|
|
5252
|
+
// Native Web handles use the same supported surface for bracket and dot
|
|
5253
|
+
// spellings. Fence a statically-known unsupported key before the generic
|
|
5254
|
+
// checked-dynamic element-read path can turn it into a runtime missing
|
|
5255
|
+
// member.
|
|
5256
|
+
L.fenceStaticAbortControllerMemberRead(expr);
|
|
5257
|
+
L.fenceStaticResponseMember(expr, "read");
|
|
5258
|
+
L.fenceStaticHeadersMember(expr, "read");
|
|
5259
|
+
L.fenceStaticReadableStreamMember(expr, "read");
|
|
5188
5260
|
// `globalThis[<expr>]` — the dynamic global probe (the harness's
|
|
5189
5261
|
// conditional-globals sweep): a compiled binary's globals are
|
|
5190
5262
|
// compile-time bindings, not runtime properties, and none of the
|