@scriptc/compiler 0.0.10 → 0.0.11

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 (78) hide show
  1. package/ambient/scriptc-node-fallback.d.ts +54 -9
  2. package/dist/backend/emission/emit-exprs.js +34 -2
  3. package/dist/backend/emission/emit-exprs.js.map +1 -1
  4. package/dist/backend/emission/emitter.js +25 -1
  5. package/dist/backend/emission/emitter.js.map +1 -1
  6. package/dist/backend/llvm/emitter.js +59 -4
  7. package/dist/backend/llvm/emitter.js.map +1 -1
  8. package/dist/coverage/surface-manifest.js +16 -2
  9. package/dist/coverage/surface-manifest.js.map +1 -1
  10. package/dist/diagnostics/diagnostic.d.ts +20 -7
  11. package/dist/diagnostics/diagnostic.js +44 -11
  12. package/dist/diagnostics/diagnostic.js.map +1 -1
  13. package/dist/frontend/lowering/lower-builtins.d.ts +56 -0
  14. package/dist/frontend/lowering/lower-builtins.js +235 -4
  15. package/dist/frontend/lowering/lower-builtins.js.map +1 -1
  16. package/dist/frontend/lowering/lower-calls.js +38 -4
  17. package/dist/frontend/lowering/lower-calls.js.map +1 -1
  18. package/dist/frontend/lowering/lower-classes.d.ts +7 -0
  19. package/dist/frontend/lowering/lower-classes.js +51 -1
  20. package/dist/frontend/lowering/lower-classes.js.map +1 -1
  21. package/dist/frontend/lowering/lower-containers.d.ts +4 -0
  22. package/dist/frontend/lowering/lower-containers.js +69 -7
  23. package/dist/frontend/lowering/lower-containers.js.map +1 -1
  24. package/dist/frontend/lowering/lower-emitter.d.ts +70 -3
  25. package/dist/frontend/lowering/lower-emitter.js +436 -29
  26. package/dist/frontend/lowering/lower-emitter.js.map +1 -1
  27. package/dist/frontend/lowering/lower-exprs.d.ts +80 -5
  28. package/dist/frontend/lowering/lower-exprs.js +472 -13
  29. package/dist/frontend/lowering/lower-exprs.js.map +1 -1
  30. package/dist/frontend/lowering/lower-modules.d.ts +8 -5
  31. package/dist/frontend/lowering/lower-modules.js +141 -47
  32. package/dist/frontend/lowering/lower-modules.js.map +1 -1
  33. package/dist/frontend/lowering/lower-namespaces.d.ts +14 -0
  34. package/dist/frontend/lowering/lower-namespaces.js +122 -15
  35. package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
  36. package/dist/frontend/lowering/lower-stmts.js +80 -6
  37. package/dist/frontend/lowering/lower-stmts.js.map +1 -1
  38. package/dist/frontend/lowering/lower-stream.js +113 -6
  39. package/dist/frontend/lowering/lower-stream.js.map +1 -1
  40. package/dist/frontend/lowering/lowerer.d.ts +17 -0
  41. package/dist/frontend/lowering/lowerer.js +105 -17
  42. package/dist/frontend/lowering/lowerer.js.map +1 -1
  43. package/dist/frontend/lowering/surfaces.d.ts +44 -0
  44. package/dist/frontend/lowering/surfaces.js +234 -3
  45. package/dist/frontend/lowering/surfaces.js.map +1 -1
  46. package/dist/frontend/npm.d.ts +12 -0
  47. package/dist/frontend/npm.js +30 -0
  48. package/dist/frontend/npm.js.map +1 -1
  49. package/dist/frontend/program.d.ts +25 -0
  50. package/dist/frontend/program.js +144 -135
  51. package/dist/frontend/program.js.map +1 -1
  52. package/dist/frontend/shared.d.ts +1 -1
  53. package/dist/frontend/shared.js +1 -1
  54. package/dist/frontend/shared.js.map +1 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.js +137 -4
  57. package/dist/index.js.map +1 -1
  58. package/dist/ir/nodes.d.ts +64 -8
  59. package/dist/ir/nodes.js +21 -3
  60. package/dist/ir/nodes.js.map +1 -1
  61. package/dist/ir/validate.js +11 -2
  62. package/dist/ir/validate.js.map +1 -1
  63. package/dist/library/fence-eval.js +12 -2
  64. package/dist/library/fence-eval.js.map +1 -1
  65. package/dist/library/int-infer.d.ts +119 -0
  66. package/dist/library/int-infer.js +1301 -0
  67. package/dist/library/int-infer.js.map +1 -0
  68. package/dist/library/int-infer.test.d.ts +1 -0
  69. package/dist/library/int-infer.test.js +279 -0
  70. package/dist/library/int-infer.test.js.map +1 -0
  71. package/dist/library/profile.d.ts +32 -5
  72. package/dist/library/profile.js +77 -13
  73. package/dist/library/profile.js.map +1 -1
  74. package/dist/library/sidecar.d.ts +23 -0
  75. package/dist/library/sidecar.js +150 -16
  76. package/dist/library/sidecar.js.map +1 -1
  77. package/package.json +2 -2
  78. package/surface-manifest.json +208 -10
@@ -13,7 +13,7 @@ import { NARROW_FIRST, builtinFenceHintOf, builtinModuleFnOf } from "./surfaces.
13
13
  import { requiresDynamicDiag } from "../../diagnostics/diagnostic.js";
14
14
  import { mixinFnShapeOf } from "./lower-mixins.js";
15
15
  import { bufEncoding, dynStringReceiver, lowerArrayFromCall, lowerDynArrayFilterCall, lowerDynArrayFlatMapCall, lowerGroupByStaticCall, lowerIteratorHelperCall, lowerObjectAssignIndexShape, lowerObjectFromEntriesCall, lowerObjectIterOverIndexShape, lowerRegexMethodCall, lowerStringMethodCall, lowerTupleReadMethodCall } from "./lower-containers.js";
16
- import { lowerChildStreamMethodCall, lowerDirentMethodCall, lowerPerfHooksCall, lowerProcStreamMethodCall, lowerReflectApplyCall, lowerWatcherMethodCall } from "./lower-builtins.js";
16
+ import { lowerChildStreamMethodCall, lowerCreateRequireCall, lowerDirentMethodCall, lowerPerfHooksCall, lowerProcStreamMethodCall, lowerReflectApplyCall, lowerWatcherMethodCall } from "./lower-builtins.js";
17
17
  import { droppableStatic, lowerPromiseAllTupleCall, lowerPromiseRejectCall, probeLower, templateRawTextOf } from "./lower-exprs.js";
18
18
  import { httpClientFnBindingOf, isStreamUndefCallExpr, lowerHttpClientFnCall } from "./lower-server.js";
19
19
  import { EMITTER_API_MEMBERS, exactInstanceClassOf, findGenericMethodOn, lowerClassGenericMethodCall, lowerStaticMethodCall } from "./lower-classes.js";
@@ -2316,6 +2316,15 @@ export function lowerCall(L, expr) {
2316
2316
  }
2317
2317
  }
2318
2318
  }
2319
+ // `require("spec")` through a createRequire binding (and the inline
2320
+ // `createRequire(import.meta.url)("spec")` spelling — a CallExpression
2321
+ // callee no other dispatch path serves): the static erasure —
2322
+ // builtins/json/npm per lowerCreateRequireCall's arms.
2323
+ {
2324
+ const crServed = lowerCreateRequireCall(L, expr, loc);
2325
+ if (crServed)
2326
+ return crServed;
2327
+ }
2319
2328
  // `process.getuid?.()` — intercepted BEFORE the optional-chain
2320
2329
  // machinery (the member always exists on a POSIX target, so the
2321
2330
  // optional call IS the call; `process.getuid` itself has no value
@@ -7128,8 +7137,13 @@ export function nullishValueUnitOf(L, sym) {
7128
7137
  return cached;
7129
7138
  L.nullishBindings.set(sym, null); // cycle guard: self-referential probes answer non-qualifying
7130
7139
  const decl = L.checker.valueDeclarationOf(sym);
7140
+ // Statement-position declarators only: a for-loop head (`for (let x =
7141
+ // null as any; ...)`) declares a LOCAL with per-iteration semantics —
7142
+ // lowerVarDeclList's contract requires a lowered statement for it, so
7143
+ // the no-storage family never claims it.
7131
7144
  if (!decl || !ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name) ||
7132
- decl.getSourceFile().isDeclarationFile || decl.initializer === undefined) {
7145
+ decl.getSourceFile().isDeclarationFile || decl.initializer === undefined ||
7146
+ !ts.isVariableStatement(decl.parent.parent)) {
7133
7147
  return null;
7134
7148
  }
7135
7149
  const unit = nullishExprUnitOf(L, decl.initializer);
@@ -7204,8 +7218,21 @@ export function nullishGenericBindingUnitOf(L, sym) {
7204
7218
  if (unit === null)
7205
7219
  return null;
7206
7220
  const mapped = L.mapTypeOf(L.checker.getTypeOfSymbol(sym));
7207
- if (mapped !== null && mapped.kind !== "record")
7208
- return null;
7221
+ if (mapped !== null) {
7222
+ // Only the EMPTY interned shape qualifies among record mappings —
7223
+ // the all-generic-signature interface (`I<A & B>`) whose struct has
7224
+ // no slot at all. A record with DATA fields (`const value: { inner:
7225
+ // number | string } = null as any`) keeps its real storage and
7226
+ // every ordinary lowering: its reads flow through positions (comma
7227
+ // chains, call arguments) the no-storage read paths never claim,
7228
+ // so claiming the binding would fence working programs.
7229
+ if (mapped.kind !== "record")
7230
+ return null;
7231
+ const shape = L.shapes.get(mapped.shapeId);
7232
+ if (!shape || shape.fields.length > 0 || shape.tuple !== undefined || shape.indexValue !== undefined) {
7233
+ return null;
7234
+ }
7235
+ }
7209
7236
  return unit;
7210
7237
  }
7211
7238
  /** True when every write of `sym` in its declaring file is a plain `x =
@@ -7297,6 +7324,13 @@ export function deadUnmappableBinding(L, sym, decl) {
7297
7324
  return true;
7298
7325
  if (!ts.isIdentifier(decl.name))
7299
7326
  return false;
7327
+ // Statement-position declarators only: a for-loop head (`for (let x;
7328
+ // false;) {}`) declares a LOCAL with per-iteration semantics —
7329
+ // lowerVarDeclList's contract requires a lowered statement for it, so
7330
+ // the no-storage family never claims it (catch bindings sit outside a
7331
+ // variable statement too and stay out the same way).
7332
+ if (!ts.isVariableStatement(decl.parent.parent))
7333
+ return false;
7300
7334
  const sf = decl.getSourceFile();
7301
7335
  if (sf.isDeclarationFile || isJsSourceFile(sf))
7302
7336
  return false;