@scriptc/compiler 0.0.29 → 0.0.30
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 +196 -33
- 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 +15 -11
- 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 +366 -25
- 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 +71 -9
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +24 -5
- package/dist/frontend/lowering/lowerer.js +28 -4
- 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)
|
|
@@ -702,26 +702,25 @@ export function lowerTupleReadMethodCall(L, call, access) {
|
|
|
702
702
|
const helper = arrayHofHelper(L, "map", snapshotElem, fnRet, arity, loc);
|
|
703
703
|
return { kind: "call", callee: helper, args: [snapshot, fnArg], type: arrayOf(fnRet), loc };
|
|
704
704
|
}
|
|
705
|
-
/**
|
|
705
|
+
/** An OOB-SAFE indexed read: `xs[i]`
|
|
706
706
|
* answers the interned `elem | undefined` union — the element when `i`
|
|
707
707
|
* is an integer in [0, len), JS's property-miss undefined otherwise —
|
|
708
708
|
* instead of the trap divergence 4 documents for program code.
|
|
709
709
|
* Package JS is inference-typed, guard-style code (`registeredArguments
|
|
710
710
|
* .slice(-1)[0]`, commander's last-element probe), and the trap would
|
|
711
711
|
* 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) {
|
|
712
|
+
* (their annotations can prove bounds). Existing element unions retag
|
|
713
|
+
* into the canonical union with an added undefined arm. */
|
|
714
|
+
export function lowerSafeIndexRead(L, arr, index, loc) {
|
|
716
715
|
const elem = arr.type.elem;
|
|
717
|
-
if (elem.kind === "
|
|
716
|
+
if (elem.kind === "void" || elem.kind === "dyn")
|
|
718
717
|
return null;
|
|
719
|
-
const resultT = L.withUndefinedArm(elem);
|
|
720
|
-
if (resultT.kind !== "union")
|
|
718
|
+
const resultT = elem.kind === "union" ? L.withUndefinedArmOf(elem) : L.withUndefinedArm(elem);
|
|
719
|
+
if (!resultT || resultT.kind !== "union")
|
|
721
720
|
return null;
|
|
722
721
|
const undefTag = L.armTag(resultT.unionId, UNDEFINED_T);
|
|
723
|
-
const foundTag = L.armTag(resultT.unionId, elem);
|
|
724
|
-
if (undefTag < 0 || foundTag < 0)
|
|
722
|
+
const foundTag = elem.kind === "union" ? -1 : L.armTag(resultT.unionId, elem);
|
|
723
|
+
if (undefTag < 0 || (elem.kind !== "union" && foundTag < 0))
|
|
725
724
|
return null;
|
|
726
725
|
const arrT = arr.type;
|
|
727
726
|
const key = `idxOr:${typeKey(elem)}`;
|
|
@@ -745,6 +744,7 @@ export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
|
745
744
|
};
|
|
746
745
|
const body = [
|
|
747
746
|
readLenStmt(arrT, loc),
|
|
747
|
+
{ kind: "if", cond: { kind: "bin", op: "!==", left: i, right: i, type: BOOL, loc }, then: [{ kind: "return", value: miss, loc }], else_: null, loc },
|
|
748
748
|
{ kind: "if", cond: lt(i, num(0)), then: [{ kind: "return", value: miss, loc }], else_: null, loc },
|
|
749
749
|
{ kind: "if", cond: { kind: "bin", op: ">=", left: i, right: n, type: BOOL, loc }, then: [{ kind: "return", value: miss, loc }], else_: null, loc },
|
|
750
750
|
// A fractional index is a property miss too (floor(i) < i exactly
|
|
@@ -759,7 +759,9 @@ export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
|
759
759
|
{ kind: "varDecl", localId: "v.0", init: { kind: "arrayGet", arr: ref("a.0", arrT), index: i, type: elem, loc }, loc },
|
|
760
760
|
{
|
|
761
761
|
kind: "return",
|
|
762
|
-
value:
|
|
762
|
+
value: elem.kind === "union"
|
|
763
|
+
? L.coerceToExpected(v, resultT)
|
|
764
|
+
: { kind: "unionWrap", unionId: resultT.unionId, tag: foundTag, value: v, type: resultT, loc },
|
|
763
765
|
loc,
|
|
764
766
|
},
|
|
765
767
|
];
|
|
@@ -782,6 +784,8 @@ export function lowerNpmStaticSafeIndexRead(L, arr, index, loc) {
|
|
|
782
784
|
}
|
|
783
785
|
return { kind: "call", callee: name, args: [arr, index], type: resultT, loc };
|
|
784
786
|
}
|
|
787
|
+
/** Backward-compatible name for the npm-static probe path. */
|
|
788
|
+
export const lowerNpmStaticSafeIndexRead = lowerSafeIndexRead;
|
|
785
789
|
/** Interned synthetic function for one (elem, argument-shape) concat —
|
|
786
790
|
* `%arr.concat.<n>(a, x0, x1, ...)`: a fresh array takes a's elements
|
|
787
791
|
* (pushSpread), then each argument pushes (element) or spreads (array)
|