@scriptc/compiler 0.0.28 → 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.
Files changed (55) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +5 -13
  2. package/dist/backend/cc.d.ts +23 -2
  3. package/dist/backend/cc.js +250 -9
  4. package/dist/backend/cc.js.map +1 -1
  5. package/dist/backend/emission/emit-async.d.ts +1 -0
  6. package/dist/backend/emission/emit-async.js +27 -1
  7. package/dist/backend/emission/emit-async.js.map +1 -1
  8. package/dist/backend/emission/emit-exprs.js +109 -18
  9. package/dist/backend/emission/emit-exprs.js.map +1 -1
  10. package/dist/backend/emission/emitter.d.ts +1 -0
  11. package/dist/backend/emission/emitter.js +25 -3
  12. package/dist/backend/emission/emitter.js.map +1 -1
  13. package/dist/backend/llvm/emitter.js +152 -0
  14. package/dist/backend/llvm/emitter.js.map +1 -1
  15. package/dist/backend/mangle.d.ts +1 -0
  16. package/dist/backend/mangle.js +3 -0
  17. package/dist/backend/mangle.js.map +1 -1
  18. package/dist/coverage/surface-manifest.js +1 -0
  19. package/dist/coverage/surface-manifest.js.map +1 -1
  20. package/dist/diagnostics/diagnostic.d.ts +23 -1
  21. package/dist/diagnostics/diagnostic.js +34 -0
  22. package/dist/diagnostics/diagnostic.js.map +1 -1
  23. package/dist/frontend/lowering/lower-calls.d.ts +3 -1
  24. package/dist/frontend/lowering/lower-calls.js +196 -33
  25. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  26. package/dist/frontend/lowering/lower-containers.d.ts +6 -5
  27. package/dist/frontend/lowering/lower-containers.js +15 -11
  28. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  29. package/dist/frontend/lowering/lower-exprs.d.ts +11 -1
  30. package/dist/frontend/lowering/lower-exprs.js +366 -25
  31. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  32. package/dist/frontend/lowering/lower-server.d.ts +5 -0
  33. package/dist/frontend/lowering/lower-server.js +105 -55
  34. package/dist/frontend/lowering/lower-server.js.map +1 -1
  35. package/dist/frontend/lowering/lower-stmts.js +71 -9
  36. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  37. package/dist/frontend/lowering/lowerer.d.ts +24 -5
  38. package/dist/frontend/lowering/lowerer.js +28 -4
  39. package/dist/frontend/lowering/lowerer.js.map +1 -1
  40. package/dist/index.d.ts +1 -0
  41. package/dist/index.js +84 -5
  42. package/dist/index.js.map +1 -1
  43. package/dist/ir/nodes.d.ts +52 -19
  44. package/dist/ir/nodes.js +2 -2
  45. package/dist/ir/nodes.js.map +1 -1
  46. package/dist/ir/validate.js +67 -9
  47. package/dist/ir/validate.js.map +1 -1
  48. package/dist/library/profile.d.ts +33 -0
  49. package/dist/library/profile.js +178 -4
  50. package/dist/library/profile.js.map +1 -1
  51. package/dist/library/sidecar.d.ts +3 -2
  52. package/dist/library/sidecar.js +7 -3
  53. package/dist/library/sidecar.js.map +1 -1
  54. package/package.json +2 -2
  55. package/surface-manifest.json +2 -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
- /** The OOB-SAFE indexed read for --npm-static package files: `xs[i]`
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). Null when the element is
46
- * union-typed (the re-tag has no story here) — the caller keeps the
47
- * ordinary read. */
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
- /** The OOB-SAFE indexed read for --npm-static package files: `xs[i]`
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). Null when the element is
713
- * union-typed (the re-tag has no story here) — the caller keeps the
714
- * ordinary read. */
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 === "union" || elem.kind === "void" || elem.kind === "dyn")
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: { kind: "unionWrap", unionId: resultT.unionId, tag: foundTag, value: v, type: resultT, loc },
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)