@scriptc/compiler 0.0.29 → 0.0.31
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 +5 -13
- package/dist/backend/emission/emit-async.d.ts +1 -0
- package/dist/backend/emission/emit-async.js +27 -1
- package/dist/backend/emission/emit-async.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +109 -18
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +1 -0
- package/dist/backend/emission/emitter.js +25 -3
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.js +152 -0
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/mangle.d.ts +1 -0
- package/dist/backend/mangle.js +3 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +23 -1
- package/dist/diagnostics/diagnostic.js +34 -0
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +3 -1
- package/dist/frontend/lowering/lower-calls.js +201 -37
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +6 -5
- package/dist/frontend/lowering/lower-containers.js +27 -13
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +11 -1
- package/dist/frontend/lowering/lower-exprs.js +398 -49
- 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 +105 -55
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +74 -11
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +50 -12
- package/dist/frontend/lowering/lowerer.js +84 -15
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +52 -19
- package/dist/ir/nodes.js +2 -2
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +67 -9
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/profile.d.ts +33 -0
- package/dist/library/profile.js +161 -3
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar.d.ts +3 -2
- package/dist/library/sidecar.js +7 -3
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1 -1
|
@@ -35,21 +35,22 @@ export declare function arrayHofHelper(L: Lowerer, method: "map" | "filter" | "f
|
|
|
35
35
|
* parameter type). Null when this isn't a tuple slice/map — writers and
|
|
36
36
|
* the rest of the surface keep their fences. */
|
|
37
37
|
export declare function lowerTupleReadMethodCall(L: Lowerer, call: ts.CallExpression, access: ts.PropertyAccessExpression): IrExpr | null;
|
|
38
|
-
/**
|
|
38
|
+
/** An OOB-SAFE indexed read: `xs[i]`
|
|
39
39
|
* answers the interned `elem | undefined` union — the element when `i`
|
|
40
40
|
* is an integer in [0, len), JS's property-miss undefined otherwise —
|
|
41
41
|
* instead of the trap divergence 4 documents for program code.
|
|
42
42
|
* Package JS is inference-typed, guard-style code (`registeredArguments
|
|
43
43
|
* .slice(-1)[0]`, commander's last-element probe), and the trap would
|
|
44
44
|
* fire on working Node idioms; program files keep the documented trap
|
|
45
|
-
* (their annotations can prove bounds).
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
export declare function lowerNpmStaticSafeIndexRead(L: Lowerer, arr: IrExpr & {
|
|
45
|
+
* (their annotations can prove bounds). Existing element unions retag
|
|
46
|
+
* into the canonical union with an added undefined arm. */
|
|
47
|
+
export declare function lowerSafeIndexRead(L: Lowerer, arr: IrExpr & {
|
|
49
48
|
type: {
|
|
50
49
|
kind: "array";
|
|
51
50
|
};
|
|
52
51
|
}, index: IrExpr, loc: SrcLoc): IrExpr | null;
|
|
52
|
+
/** Backward-compatible name for the npm-static probe path. */
|
|
53
|
+
export declare const lowerNpmStaticSafeIndexRead: typeof lowerSafeIndexRead;
|
|
53
54
|
/** Interned synthetic function for one (elem, argument-shape) concat —
|
|
54
55
|
* `%arr.concat.<n>(a, x0, x1, ...)`: a fresh array takes a's elements
|
|
55
56
|
* (pushSpread), then each argument pushes (element) or spreads (array)
|
|
@@ -633,13 +633,23 @@ export function lowerTupleReadMethodCall(L, call, access) {
|
|
|
633
633
|
return null;
|
|
634
634
|
if (!L.isStdlibMember(access))
|
|
635
635
|
return null;
|
|
636
|
-
|
|
636
|
+
let receiverIr = L.mapTypeOf(L.typeOf(access.expression));
|
|
637
|
+
let receiver = null;
|
|
638
|
+
// A readonly tuple union under Array.isArray is checker-typed as an
|
|
639
|
+
// unmappable intersection with any[], while maybeNarrow still extracts
|
|
640
|
+
// its one tuple arm. Dispatch the supported tuple read methods from
|
|
641
|
+
// that lowered representation, like tuple indexing and `.length`.
|
|
642
|
+
const checkerArray = L.checkerArrayValue(access.expression);
|
|
643
|
+
if (checkerArray?.type.kind === "record") {
|
|
644
|
+
receiverIr = checkerArray.type;
|
|
645
|
+
receiver = checkerArray;
|
|
646
|
+
}
|
|
637
647
|
if (receiverIr?.kind !== "record")
|
|
638
648
|
return null;
|
|
639
649
|
const shape = L.shapes.get(receiverIr.shapeId);
|
|
640
650
|
if (!shape?.tuple)
|
|
641
651
|
return null;
|
|
642
|
-
|
|
652
|
+
receiver ??= L.lowerExpr(access.expression);
|
|
643
653
|
if (receiver.type.kind !== "record")
|
|
644
654
|
return null;
|
|
645
655
|
if (!pureReemittable(receiver)) {
|
|
@@ -702,26 +712,25 @@ export function lowerTupleReadMethodCall(L, call, access) {
|
|
|
702
712
|
const helper = arrayHofHelper(L, "map", snapshotElem, fnRet, arity, loc);
|
|
703
713
|
return { kind: "call", callee: helper, args: [snapshot, fnArg], type: arrayOf(fnRet), loc };
|
|
704
714
|
}
|
|
705
|
-
/**
|
|
715
|
+
/** An OOB-SAFE indexed read: `xs[i]`
|
|
706
716
|
* answers the interned `elem | undefined` union — the element when `i`
|
|
707
717
|
* is an integer in [0, len), JS's property-miss undefined otherwise —
|
|
708
718
|
* instead of the trap divergence 4 documents for program code.
|
|
709
719
|
* Package JS is inference-typed, guard-style code (`registeredArguments
|
|
710
720
|
* .slice(-1)[0]`, commander's last-element probe), and the trap would
|
|
711
721
|
* fire on working Node idioms; program files keep the documented trap
|
|
712
|
-
* (their annotations can prove bounds).
|
|
713
|
-
*
|
|
714
|
-
|
|
715
|
-
export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
722
|
+
* (their annotations can prove bounds). Existing element unions retag
|
|
723
|
+
* into the canonical union with an added undefined arm. */
|
|
724
|
+
export function lowerSafeIndexRead(L, arr, index, loc) {
|
|
716
725
|
const elem = arr.type.elem;
|
|
717
|
-
if (elem.kind === "
|
|
726
|
+
if (elem.kind === "void" || elem.kind === "dyn")
|
|
718
727
|
return null;
|
|
719
|
-
const resultT = L.withUndefinedArm(elem);
|
|
720
|
-
if (resultT.kind !== "union")
|
|
728
|
+
const resultT = elem.kind === "union" ? L.withUndefinedArmOf(elem) : L.withUndefinedArm(elem);
|
|
729
|
+
if (!resultT || resultT.kind !== "union")
|
|
721
730
|
return null;
|
|
722
731
|
const undefTag = L.armTag(resultT.unionId, UNDEFINED_T);
|
|
723
|
-
const foundTag = L.armTag(resultT.unionId, elem);
|
|
724
|
-
if (undefTag < 0 || foundTag < 0)
|
|
732
|
+
const foundTag = elem.kind === "union" ? -1 : L.armTag(resultT.unionId, elem);
|
|
733
|
+
if (undefTag < 0 || (elem.kind !== "union" && foundTag < 0))
|
|
725
734
|
return null;
|
|
726
735
|
const arrT = arr.type;
|
|
727
736
|
const key = `idxOr:${typeKey(elem)}`;
|
|
@@ -745,6 +754,7 @@ export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
|
745
754
|
};
|
|
746
755
|
const body = [
|
|
747
756
|
readLenStmt(arrT, loc),
|
|
757
|
+
{ kind: "if", cond: { kind: "bin", op: "!==", left: i, right: i, type: BOOL, loc }, then: [{ kind: "return", value: miss, loc }], else_: null, loc },
|
|
748
758
|
{ kind: "if", cond: lt(i, num(0)), then: [{ kind: "return", value: miss, loc }], else_: null, loc },
|
|
749
759
|
{ kind: "if", cond: { kind: "bin", op: ">=", left: i, right: n, type: BOOL, loc }, then: [{ kind: "return", value: miss, loc }], else_: null, loc },
|
|
750
760
|
// A fractional index is a property miss too (floor(i) < i exactly
|
|
@@ -759,7 +769,9 @@ export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
|
759
769
|
{ kind: "varDecl", localId: "v.0", init: { kind: "arrayGet", arr: ref("a.0", arrT), index: i, type: elem, loc }, loc },
|
|
760
770
|
{
|
|
761
771
|
kind: "return",
|
|
762
|
-
value:
|
|
772
|
+
value: elem.kind === "union"
|
|
773
|
+
? L.coerceToExpected(v, resultT)
|
|
774
|
+
: { kind: "unionWrap", unionId: resultT.unionId, tag: foundTag, value: v, type: resultT, loc },
|
|
763
775
|
loc,
|
|
764
776
|
},
|
|
765
777
|
];
|
|
@@ -782,6 +794,8 @@ export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
|
782
794
|
}
|
|
783
795
|
return { kind: "call", callee: name, args: [arr, index], type: resultT, loc };
|
|
784
796
|
}
|
|
797
|
+
/** Backward-compatible name for the npm-static probe path. */
|
|
798
|
+
export const lowerNpmStaticSafeIndexRead = lowerSafeIndexRead;
|
|
785
799
|
/** Interned synthetic function for one (elem, argument-shape) concat —
|
|
786
800
|
* `%arr.concat.<n>(a, x0, x1, ...)`: a fresh array takes a's elements
|
|
787
801
|
* (pushSpread), then each argument pushes (element) or spreads (array)
|