@scriptc/compiler 0.0.31 → 0.0.33

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 +1 -1
  2. package/dist/backend/cc-cache.test.js +308 -1
  3. package/dist/backend/cc-cache.test.js.map +1 -1
  4. package/dist/backend/cc.d.ts +17 -5
  5. package/dist/backend/cc.js +745 -75
  6. package/dist/backend/cc.js.map +1 -1
  7. package/dist/backend/emission/emit-exprs.js +53 -2
  8. package/dist/backend/emission/emit-exprs.js.map +1 -1
  9. package/dist/backend/emission/emitter.d.ts +12 -5
  10. package/dist/backend/emission/emitter.js +160 -22
  11. package/dist/backend/emission/emitter.js.map +1 -1
  12. package/dist/backend/emission/may-throw.js +7 -4
  13. package/dist/backend/emission/may-throw.js.map +1 -1
  14. package/dist/backend/ffi-callbacks.d.ts +38 -1
  15. package/dist/backend/ffi-callbacks.js +76 -3
  16. package/dist/backend/ffi-callbacks.js.map +1 -1
  17. package/dist/backend/llvm/emitter.js +243 -12
  18. package/dist/backend/llvm/emitter.js.map +1 -1
  19. package/dist/diagnostics/diagnostic.js +2 -0
  20. package/dist/diagnostics/diagnostic.js.map +1 -1
  21. package/dist/ffi/profile.d.ts +17 -5
  22. package/dist/ffi/profile.js +169 -22
  23. package/dist/ffi/profile.js.map +1 -1
  24. package/dist/frontend/lowering/lower-calls.d.ts +1 -0
  25. package/dist/frontend/lowering/lower-calls.js +89 -23
  26. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  27. package/dist/frontend/lowering/lower-containers.js +65 -19
  28. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  29. package/dist/frontend/lowering/lowerer.d.ts +12 -0
  30. package/dist/frontend/lowering/lowerer.js +20 -1
  31. package/dist/frontend/lowering/lowerer.js.map +1 -1
  32. package/dist/frontend/ts7/checker.d.ts +2 -0
  33. package/dist/frontend/ts7/checker.js +20 -3
  34. package/dist/frontend/ts7/checker.js.map +1 -1
  35. package/dist/frontend/types.d.ts +8 -0
  36. package/dist/frontend/types.js +33 -5
  37. package/dist/frontend/types.js.map +1 -1
  38. package/dist/index.js +35 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/ir/nodes.d.ts +22 -9
  41. package/dist/ir/nodes.js +7 -1
  42. package/dist/ir/nodes.js.map +1 -1
  43. package/dist/ir/serialize.d.ts +1 -1
  44. package/dist/ir/serialize.js +1 -1
  45. package/dist/ir/validate.js +74 -1
  46. package/dist/ir/validate.js.map +1 -1
  47. package/dist/library/int-infer.js +7 -1
  48. package/dist/library/int-infer.js.map +1 -1
  49. package/dist/library/int-infer.test.js +73 -4
  50. package/dist/library/int-infer.test.js.map +1 -1
  51. package/dist/library/profile.d.ts +3 -0
  52. package/dist/library/profile.js +9 -1
  53. package/dist/library/profile.js.map +1 -1
  54. package/package.json +2 -2
  55. package/surface-manifest.json +1 -1
@@ -511,6 +511,16 @@ export declare class Lowerer {
511
511
  /** Union re-tag helpers (%union.retag.N), interned per (from, to)
512
512
  * unionId pair — see unionRetagHelper. */
513
513
  readonly retagHelpers: Map<string, string>;
514
+ /** Callee names of every interned coercion helper whose CALL mints a
515
+ * FRESH closure per evaluation (%fn.width.*, %fn.adapt.*,
516
+ * %fnval.spawnres.*). Registered at the mint site — NOT recovered by
517
+ * name-prefix matching — because retained-FFI release identity is the
518
+ * runtime closure pointer: a coercion adapter allocates a different
519
+ * closure at the registration and release sites, so lowerFfiCall must
520
+ * refuse these forms at compile time (SC5003). Any new closure-minting
521
+ * adapter helper MUST add its name here, or the identity guard silently
522
+ * reopens and the mismatch surfaces as a runtime release trap instead. */
523
+ readonly freshClosureAdapters: Set<string>;
514
524
  /** Symbols bound by `const x = promisify(execFile)` — the one lowered
515
525
  * util.promisify shape. Declarations register here and emit nothing;
516
526
  * calls through the binding lower (lowerExecFileAsyncCall) and value
@@ -706,6 +716,8 @@ export declare class Lowerer {
706
716
  * IrModule.unions. An arm's index in the canonical list is its runtime
707
717
  * tag. */
708
718
  readonly unions: UnionRegistry;
719
+ /** Context-free successful type mappings. See TypeMapperCtx.typeMemo. */
720
+ readonly typeMemo: Map<string, IrType>;
709
721
  readonly ambient: string;
710
722
  readonly overridesAmbient: string;
711
723
  readonly fallbackAmbient: string;
@@ -700,6 +700,16 @@ export class Lowerer {
700
700
  /** Union re-tag helpers (%union.retag.N), interned per (from, to)
701
701
  * unionId pair — see unionRetagHelper. */
702
702
  retagHelpers = new Map();
703
+ /** Callee names of every interned coercion helper whose CALL mints a
704
+ * FRESH closure per evaluation (%fn.width.*, %fn.adapt.*,
705
+ * %fnval.spawnres.*). Registered at the mint site — NOT recovered by
706
+ * name-prefix matching — because retained-FFI release identity is the
707
+ * runtime closure pointer: a coercion adapter allocates a different
708
+ * closure at the registration and release sites, so lowerFfiCall must
709
+ * refuse these forms at compile time (SC5003). Any new closure-minting
710
+ * adapter helper MUST add its name here, or the identity guard silently
711
+ * reopens and the mismatch surfaces as a runtime release trap instead. */
712
+ freshClosureAdapters = new Set();
703
713
  /** Symbols bound by `const x = promisify(execFile)` — the one lowered
704
714
  * util.promisify shape. Declarations register here and emit nothing;
705
715
  * calls through the binding lower (lowerExecFileAsyncCall) and value
@@ -875,6 +885,8 @@ export class Lowerer {
875
885
  * IrModule.unions. An arm's index in the canonical list is its runtime
876
886
  * tag. */
877
887
  unions = new UnionRegistry();
888
+ /** Context-free successful type mappings. See TypeMapperCtx.typeMemo. */
889
+ typeMemo = new Map();
878
890
  ambient = ambientDtsPath();
879
891
  overridesAmbient = overridesDtsPath();
880
892
  fallbackAmbient = fallbackDtsPath();
@@ -1038,6 +1050,10 @@ export class Lowerer {
1038
1050
  isNpmFile: this.isNpmFile,
1039
1051
  isExternalTypeFile: (sf) => this.externalTypeSpecifiersByFile.has(tsgoPath(resolve(sf.fileName))),
1040
1052
  dynamic: this.dynamic,
1053
+ typeMemo: this.typeMemo,
1054
+ canMemoizeType: () => this.typeParamBindings === null &&
1055
+ this.typeParamTsBindings === null &&
1056
+ this.mixinTypeContext === null,
1041
1057
  // fileTag is filled just below; the hook is only ever CALLED during
1042
1058
  // lowering, long after the constructor completes.
1043
1059
  isProgramFile: (sf) => this.fileTag.has(sf),
@@ -2000,7 +2016,7 @@ export class Lowerer {
2000
2016
  const module = this.diags.length > 0
2001
2017
  ? null
2002
2018
  : {
2003
- irVersion: 3,
2019
+ irVersion: 5,
2004
2020
  sourceFile: this.entry.fileName,
2005
2021
  functions,
2006
2022
  classes: artifacts.classes,
@@ -4368,6 +4384,7 @@ export class Lowerer {
4368
4384
  return existing;
4369
4385
  const name = `%fn.width.${this.widthHelpers.size}`;
4370
4386
  this.widthHelpers.set(key, name);
4387
+ this.freshClosureAdapters.add(name); // wraps `f` in a new closure per call
4371
4388
  const impl = `${name}.impl`;
4372
4389
  // The returned closure's body: call the captured original, width-map.
4373
4390
  this.liftedFns.push({
@@ -4545,6 +4562,7 @@ export class Lowerer {
4545
4562
  return existing;
4546
4563
  const name = `%fn.adapt.${this.retagHelpers.size}`;
4547
4564
  this.retagHelpers.set(key, name);
4565
+ this.freshClosureAdapters.add(name); // wraps `f` in a new closure per call
4548
4566
  const impl = `${name}.impl`;
4549
4567
  const params = toT.params.map((t, i) => ({ localId: `a.${i}`, name: `a${i}`, type: t }));
4550
4568
  const strandThrow = (why) => ({
@@ -4715,6 +4733,7 @@ export class Lowerer {
4715
4733
  return existing;
4716
4734
  const name = `%fnval.spawnres.${this.widthHelpers.size}`;
4717
4735
  this.widthHelpers.set(key, name);
4736
+ this.freshClosureAdapters.add(name); // wraps `f` in a new closure per call
4718
4737
  const impl = `${name}.impl`;
4719
4738
  const params = toT.params.map((p, i) => ({ localId: `p${i}.0`, name: `p${i}`, type: p }));
4720
4739
  const rRef = { kind: "varRef", localId: "r.0", type: fromT.ret, loc };