@scriptc/compiler 0.0.34 → 0.0.35

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 (66) hide show
  1. package/dist/backend/cc-cache.test.js +969 -7
  2. package/dist/backend/cc-cache.test.js.map +1 -1
  3. package/dist/backend/cc.d.ts +90 -18
  4. package/dist/backend/cc.js +953 -276
  5. package/dist/backend/cc.js.map +1 -1
  6. package/dist/backend/llvm/split.d.ts +43 -0
  7. package/dist/backend/llvm/split.js +227 -0
  8. package/dist/backend/llvm/split.js.map +1 -0
  9. package/dist/backend/llvm/split.test.d.ts +1 -0
  10. package/dist/backend/llvm/split.test.js +102 -0
  11. package/dist/backend/llvm/split.test.js.map +1 -0
  12. package/dist/backend/object-localize.test.js +20 -0
  13. package/dist/backend/object-localize.test.js.map +1 -1
  14. package/dist/executable/early-cache.d.ts +86 -0
  15. package/dist/executable/early-cache.js +460 -0
  16. package/dist/executable/early-cache.js.map +1 -0
  17. package/dist/executable/early-cache.test.d.ts +1 -0
  18. package/dist/executable/early-cache.test.js +300 -0
  19. package/dist/executable/early-cache.test.js.map +1 -0
  20. package/dist/ffi/profile.d.ts +7 -2
  21. package/dist/ffi/profile.js +1 -0
  22. package/dist/ffi/profile.js.map +1 -1
  23. package/dist/frontend/lowering/lower-builtins.js +2 -2
  24. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  25. package/dist/frontend/lowering/lower-calls.js +14 -4
  26. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  27. package/dist/frontend/lowering/lower-containers.js +18 -23
  28. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  29. package/dist/frontend/lowering/lower-exprs.js +22 -10
  30. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  31. package/dist/frontend/lowering/lower-island.js +3 -3
  32. package/dist/frontend/lowering/lower-island.js.map +1 -1
  33. package/dist/frontend/lowering/lower-mixins.js +1 -1
  34. package/dist/frontend/lowering/lower-mixins.js.map +1 -1
  35. package/dist/frontend/lowering/lower-stmts.js +1 -1
  36. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  37. package/dist/frontend/lowering/lowerer.d.ts +6 -0
  38. package/dist/frontend/lowering/lowerer.js +230 -81
  39. package/dist/frontend/lowering/lowerer.js.map +1 -1
  40. package/dist/frontend/lowering/surfaces.js +1 -1
  41. package/dist/frontend/lowering/surfaces.js.map +1 -1
  42. package/dist/frontend/program.js +42 -13
  43. package/dist/frontend/program.js.map +1 -1
  44. package/dist/frontend/ts7/checker.d.ts +40 -2
  45. package/dist/frontend/ts7/checker.js +194 -32
  46. package/dist/frontend/ts7/checker.js.map +1 -1
  47. package/dist/frontend/types.js +20 -42
  48. package/dist/frontend/types.js.map +1 -1
  49. package/dist/index.d.ts +4 -1
  50. package/dist/index.js +219 -101
  51. package/dist/index.js.map +1 -1
  52. package/dist/ir/nodes.d.ts +6 -0
  53. package/dist/ir/nodes.js +28 -0
  54. package/dist/ir/nodes.js.map +1 -1
  55. package/dist/ir/validate.js +7 -1
  56. package/dist/ir/validate.js.map +1 -1
  57. package/dist/library/early-cache.js +4 -23
  58. package/dist/library/early-cache.js.map +1 -1
  59. package/dist/library/implementation-identity.d.ts +23 -0
  60. package/dist/library/implementation-identity.js +84 -0
  61. package/dist/library/implementation-identity.js.map +1 -0
  62. package/dist/startup-cache.d.ts +6 -0
  63. package/dist/startup-cache.js +6 -0
  64. package/dist/startup-cache.js.map +1 -0
  65. package/package.json +3 -2
  66. package/surface-manifest.json +1 -1
@@ -3,7 +3,7 @@
3
3
  * methods with Node-exact forEach desugaring, and the string and regex
4
4
  * method surfaces. */
5
5
  import * as ts from "../ts7/adapter.js";
6
- import { BOOL, BYTES_U8, CAUGHT, DYN, F64, JSVAL, STRING, UNDEFINED_T, VOID, arrayOf, bytesOf, funcOf, isRefCounted, isSupportedIndexValue, isUnitType, typeEquals } from "../../ir/nodes.js";
6
+ import { BOOL, BYTES_U8, CAUGHT, DYN, F64, JSVAL, STRING, UNDEFINED_T, VOID, arrayOf, bytesOf, funcOf, isRefCounted, isSupportedArrayElem, isSupportedIndexValue, isUnitType, typeEquals } from "../../ir/nodes.js";
7
7
  import { ARRAY_METHODS, MAP_METHODS, SET_COMBINE_METHODS, SET_METHODS, STR_METHODS } from "./surfaces.js";
8
8
  import { droppableStatic, isRequireMainFilename, lowerDynObjectLiteral, probeLower, pureReemittable } from "./lower-exprs.js";
9
9
  import { forOfVarTarget, lowerDestructuringAssign } from "./lower-stmts.js";
@@ -91,6 +91,18 @@ function lowerSplitLimitArg(L, node, loc) {
91
91
  const defaultValue = { kind: "numLit", value: 4294967295, type: F64, loc };
92
92
  return node ? lowerOptionalDefaultArg(L, node, F64, defaultValue) : defaultValue;
93
93
  }
94
+ /** Callback-driven array producers bypass mapType's ordinary T[] mapping:
95
+ * the callback is lowered first, then the helper's result array is built
96
+ * directly from its IR return type. Fence element kinds ScrArr cannot hold
97
+ * before constructing that array type. */
98
+ function fenceProducedArrayElem(L, node, producer, elem) {
99
+ if (elem.kind === "dyn") {
100
+ L.unsupported("SC1090", node, `${producer} with a callback returning 'unknown'-typed values (the result array has no static element type — annotate the callback's return)`);
101
+ }
102
+ if (!isSupportedArrayElem(elem)) {
103
+ L.unsupported("SC1090", node, `${producer} with a callback returning '${L.fmt(elem)}' values (arrays of this element kind have no representation — store the values individually)`);
104
+ }
105
+ }
94
106
  /** Ambient array method calls. `push`/`unshift`/`pop`/`reverse`/
95
107
  * `indexOf`/`includes`/`join`
96
108
  * lower to arrIntrinsic; the HOF family — `map`/`filter`/`forEach`/
@@ -566,28 +578,8 @@ export function lowerArrayHofCall(L, call, access, method, elem) {
566
578
  // story yet).
567
579
  L.badType(call, L.typeOf(call));
568
580
  }
569
- if (method === "map" &&
570
- (fnRet.kind === "map" || fnRet.kind === "set" || fnRet.kind === "url" ||
571
- fnRet.kind === "searchParams" || fnRet.kind === "generator" || fnRet.kind === "caught" ||
572
- fnRet.kind === "stats" || fnRet.kind === "fileHandle" || fnRet.kind === "spawnRes" || fnRet.kind === "netSocket" ||
573
- fnRet.kind === "dgramSocket" || fnRet.kind === "testCtx" || fnRet.kind === "httpReq" ||
574
- fnRet.kind === "httpRes" || fnRet.kind === "httpClientReq" || fnRet.kind === "secureCtx" ||
575
- fnRet.kind === "fsWatcher" || fnRet.kind === "childStream" || fnRet.kind === "procStream" ||
576
- isUnitType(fnRet))) {
577
- // The result would be an array of an element kind ScrArr has no
578
- // home for (mapTypeOf's own array exclusions) — the callback return
579
- // type bypasses that gate, so it is enforced here: a named fence,
580
- // never a mistyped array into the backends.
581
- L.unsupported("SC1090", call, `'.map()' with a callback returning '${L.fmt(fnRet)}' values (arrays of this element kind have no representation — store the values individually)`);
582
- }
583
- if (method === "map" && fnRet.kind === "dyn") {
584
- // A checked-dynamic callback return would make the result a
585
- // dyn-element STATIC array, which has no backend representation
586
- // (dynFallbackType's rule: an unmappable element makes the WHOLE
587
- // value dyn — but map's fresh array is built here, not by a
588
- // declaration, so the honest answer is the fence).
589
- L.unsupported("SC1090", call, "'.map()' with a callback returning 'unknown'-typed values (the result array has no static element type — annotate the callback's return)");
590
- }
581
+ if (method === "map")
582
+ fenceProducedArrayElem(L, call, "'.map()'", fnRet);
591
583
  // JS applies ToBoolean to whatever the predicate answers, so a non-bool
592
584
  // result is not an error — the filter loop wraps the call in the same
593
585
  // toBool an `if` statement would apply. The island/dyn shapes, whose
@@ -753,6 +745,7 @@ export function lowerTupleReadMethodCall(L, call, access) {
753
745
  const fnRet = fnArg.type.ret;
754
746
  if (fnRet.kind === "void" || fnRet.kind === "func")
755
747
  L.badType(call, L.typeOf(call));
748
+ fenceProducedArrayElem(L, call, "'.map()'", fnRet);
756
749
  const helper = arrayHofHelper(L, "map", snapshotElem, fnRet, arity, loc);
757
750
  return { kind: "call", callee: helper, args: [snapshot, fnArg], type: arrayOf(fnRet), loc };
758
751
  }
@@ -1270,6 +1263,7 @@ export function lowerArrayFlatMapCall(L, call, access, elem) {
1270
1263
  // No flatten happens: exactly map's loop, map's helper.
1271
1264
  if (fnRet.kind === "void" || fnRet.kind === "func")
1272
1265
  L.badType(call, L.typeOf(call));
1266
+ fenceProducedArrayElem(L, call, "'.flatMap()'", fnRet);
1273
1267
  const helper = arrayHofHelper(L, "map", elem, fnRet, arity, loc);
1274
1268
  return { kind: "call", callee: helper, args: [receiver, fnArg], type: arrayOf(fnRet), loc };
1275
1269
  }
@@ -2356,6 +2350,7 @@ export function lowerArrayFromCall(L, call, access) {
2356
2350
  const fnRet = fnT.ret;
2357
2351
  if (fnRet.kind === "void" || fnRet.kind === "func")
2358
2352
  L.badType(call, L.typeOf(call));
2353
+ fenceProducedArrayElem(L, call, "'Array.from({ length }, mapper)'", fnRet);
2359
2354
  const arity = fnT.params.length;
2360
2355
  const key = `fromLen:${typeKey(fnRet)}:${arity}`;
2361
2356
  let helper = L.arrHofHelpers.get(key);