@scriptc/compiler 0.2.9 → 0.3.0
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 +2 -36
- package/ambient/scriptc-overrides.d.ts +1 -25
- package/ambient/scriptc.d.ts +1 -9
- package/dist/backend/cycle-analysis.d.ts +56 -0
- package/dist/backend/cycle-analysis.js +175 -14
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +95 -2
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +3 -7
- package/dist/backend/cycle-mutability.js +4 -30
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.d.ts +1 -1
- package/dist/backend/executable-features.js +3 -8
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +57 -0
- package/dist/backend/immutability.js +178 -0
- package/dist/backend/immutability.js.map +1 -0
- package/dist/backend/immutability.test.js +131 -0
- package/dist/backend/immutability.test.js.map +1 -0
- package/dist/backend/library-pack.js +0 -2
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/llvm/borrowed-inputs.d.ts +9 -2
- package/dist/backend/llvm/borrowed-inputs.js +31 -3
- package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/classes.d.ts +28 -0
- package/dist/backend/llvm/classes.js +48 -14
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +134 -6
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +13 -0
- package/dist/backend/llvm/common.js +13 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +1 -1
- package/dist/backend/llvm/constant-callbacks.js +3 -3
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +1 -1
- package/dist/backend/llvm/dense-array-access.js +5 -4
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +10 -2
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +2 -1
- package/dist/backend/llvm/dyn.js +3 -76
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +67 -19
- package/dist/backend/llvm/emitter.js +443 -226
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +21 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-calls.js +14 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +41 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +4 -107
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -2
- package/dist/backend/llvm/expr-dispatch.js +0 -41
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.d.ts +1 -1
- package/dist/backend/llvm/expr-dynamic.js +13 -27
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +30 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/lib-dispatch.js +0 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +0 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +0 -8
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +3 -3
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +5 -2
- package/dist/backend/llvm/loop-array-borrows.js +27 -8
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +14 -0
- package/dist/backend/llvm/map-number-lookup.js +33 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/map-read-lifetimes.js +20 -4
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +25 -3
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +124 -0
- package/dist/backend/llvm/reference-writes.js +1090 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +8 -5
- package/dist/backend/llvm/shapes.js +37 -13
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -3
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +40 -11
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +3 -0
- package/dist/backend/llvm/string-reads.js +31 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.d.ts +2 -2
- package/dist/backend/llvm/switch-dispatch.js +35 -22
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +29 -11
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +8 -1
- package/dist/backend/llvm/walk-borrows.js +15 -4
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/may-throw.d.ts +36 -2
- package/dist/backend/may-throw.js +308 -21
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +147 -2
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/artifact-stamps.js +0 -2
- package/dist/backend/native/artifact-stamps.js.map +1 -1
- package/dist/backend/native/cache-warm.d.ts +1 -1
- package/dist/backend/native/cache-warm.js +2 -3
- package/dist/backend/native/cache-warm.js.map +1 -1
- package/dist/backend/native/compiler-fingerprint.d.ts +1 -1
- package/dist/backend/native/compiler-fingerprint.js +4 -7
- package/dist/backend/native/compiler-fingerprint.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +3 -28
- package/dist/backend/native/driver.js +1 -3
- package/dist/backend/native/driver.js.map +1 -1
- package/dist/backend/native/executable.d.ts +0 -15
- package/dist/backend/native/executable.js +17 -172
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/tool-identity.js +0 -1
- package/dist/backend/native/tool-identity.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +0 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +23 -33
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/publication.d.ts +5 -0
- package/dist/backend/publication.js +10 -0
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/publication.test.js +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -2
- package/dist/backend/runtime-pack-core.js +5 -14
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -8
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +22 -19
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +0 -5
- package/dist/backend/target-diagnostics.js +1 -11
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/vendor-archives.d.ts +1 -7
- package/dist/backend/vendor-archives.js +9 -189
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +0 -1
- package/dist/backend/vendor-inputs.js +0 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -5
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +4 -8
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +1 -1
- package/dist/cli/usage.d.ts +1 -5
- package/dist/cli/usage.js +4 -9
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +2 -2
- package/dist/compat/fetch-profile.js +16 -25
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +2 -17
- package/dist/contracts/check.d.ts +8 -0
- package/dist/contracts/check.js +1573 -0
- package/dist/contracts/check.js.map +1 -0
- package/dist/coverage/report.d.ts +5 -22
- package/dist/coverage/report.js +12 -76
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.d.ts +3 -3
- package/dist/coverage/surface-manifest.js +22 -27
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +1 -3
- package/dist/coverage/verdict-cache.js +2 -7
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -60
- package/dist/diagnostics/diagnostic.js +39 -118
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -4
- package/dist/diagnostics/envelope.js +0 -9
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/envelope.test.js +1 -1
- package/dist/diagnostics/envelope.test.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +0 -3
- package/dist/executable/executable-cache.js +2 -4
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +0 -4
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +14 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +10 -10
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +0 -88
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/contract-types.d.ts +50 -0
- package/dist/frontend/contract-types.js +232 -0
- package/dist/frontend/contract-types.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +1 -1
- package/dist/frontend/dts-paths.js +1 -1
- package/dist/frontend/lowering/abstract-equality.js +1 -4
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +4 -11
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.js +0 -13
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +0 -4
- package/dist/frontend/lowering/builtins/crypto.js +0 -4
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +1 -39
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +0 -15
- package/dist/frontend/lowering/builtins/module-resolution.js +5 -44
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +0 -6
- package/dist/frontend/lowering/builtins/numbers.js +6 -57
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +4 -67
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.js +1 -1
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +1 -37
- package/dist/frontend/lowering/call-arguments.js +11 -94
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +1 -6
- package/dist/frontend/lowering/call-signatures.js +16 -68
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +19 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.js +168 -98
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +44 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +0 -2
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +1 -1
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +5 -35
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +0 -1
- package/dist/frontend/lowering/coercions/state.js +0 -1
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -4
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +2 -12
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +12 -0
- package/dist/frontend/lowering/coercions/unions.js +63 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +9 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +2 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +10 -54
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +0 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +2 -10
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +1 -6
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +0 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +0 -6
- package/dist/frontend/lowering/containers/string-and-regexp.js +2 -10
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +0 -3
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +0 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -8
- package/dist/frontend/lowering/expressions/object-literals.js +8 -35
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +0 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +7 -67
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +0 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +0 -1
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +10 -77
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.js +1 -10
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +2 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -3
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +2 -27
- package/dist/frontend/lowering/lower-calls.js +56 -465
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +11 -49
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.js +2 -3
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -8
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +3 -4
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +3 -5
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +0 -8
- package/dist/frontend/lowering/lower-exprs.js +133 -908
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -5
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +1 -50
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +0 -43
- package/dist/frontend/lowering/lower-modules.js +25 -329
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +5 -5
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +0 -30
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +98 -0
- package/dist/frontend/lowering/{lower-island.js → lower-stdlib.js} +97 -1160
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +0 -16
- package/dist/frontend/lowering/lower-stmts.js +58 -1016
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -3
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +26 -151
- package/dist/frontend/lowering/lowerer.js +120 -770
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +4 -51
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.d.ts +100 -0
- package/dist/frontend/lowering/narrowing-stability.js +1174 -0
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -0
- package/dist/frontend/lowering/narrowing-stability.test.js +150 -0
- package/dist/frontend/lowering/narrowing-stability.test.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +0 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/strict-equality.js +1 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -45
- package/dist/frontend/lowering/surfaces.js +5 -65
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-syntax.d.ts +0 -3
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/npm-node.d.ts +0 -7
- package/dist/frontend/npm-node.js +0 -7
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +6 -82
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +1 -1
- package/dist/frontend/npm-static.js +6 -71
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +3 -319
- package/dist/frontend/npm.js +6 -1007
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -197
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js +1 -2
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +3 -11
- package/dist/frontend/pipeline.js +37 -56
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +12 -6
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +0 -34
- package/dist/frontend/program.js +13 -98
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +0 -4
- package/dist/frontend/provenance-core.js +4 -37
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -4
- package/dist/frontend/provenance-registry.js +0 -20
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.d.ts +0 -12
- package/dist/frontend/resolve.js +0 -34
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +2 -2
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/services-node.js +2 -3
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services.d.ts +1 -8
- package/dist/frontend/services.js +2 -22
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +0 -38
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +0 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +2 -27
- package/dist/frontend/type-mapper.js +85 -153
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/builtin-effects.js +0 -5
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +1 -55
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-globals.test.js +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/final-fields.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +29 -3
- package/dist/ir/int32-slots.js +152 -66
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +1 -1
- package/dist/ir/integer-loops.js +3 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +26 -1
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +20 -0
- package/dist/ir/integer-ranges.js +178 -21
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +148 -3
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +44 -284
- package/dist/ir/ir.js +10 -259
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +2 -7
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +3 -30
- package/dist/ir/runtime-features.js +5 -41
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +6 -2
- package/dist/ir/serialize.js +11 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +0 -21
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/unshare.d.ts +14 -0
- package/dist/ir/unshare.js +60 -0
- package/dist/ir/unshare.js.map +1 -0
- package/dist/ir/unshare.test.js +115 -0
- package/dist/ir/unshare.test.js.map +1 -0
- package/dist/ir/validate.js +9 -207
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +6 -6
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/prepare.js +14 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +0 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.test.js +2 -4
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.js +2 -4
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +2 -16
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +0 -3
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/startup-cache.js +0 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +80 -88
- package/dist/backend/llvm/expr-island.d.ts +0 -15
- package/dist/backend/llvm/expr-island.js +0 -709
- package/dist/backend/llvm/expr-island.js.map +0 -1
- package/dist/frontend/lowering/coercions/island.d.ts +0 -37
- package/dist/frontend/lowering/coercions/island.js +0 -350
- package/dist/frontend/lowering/coercions/island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.d.ts +0 -229
- package/dist/frontend/lowering/lower-island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.test.js +0 -56
- package/dist/frontend/lowering/lower-island.test.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.d.ts +0 -17
- package/dist/frontend/npm-fetch-analysis.js +0 -109
- package/dist/frontend/npm-fetch-analysis.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.test.js +0 -130
- package/dist/frontend/npm-fetch-analysis.test.js.map +0 -1
- package/dist/frontend/npm-fetch-node.d.ts +0 -2
- package/dist/frontend/npm-fetch-node.js +0 -12
- package/dist/frontend/npm-fetch-node.js.map +0 -1
- package/dist/frontend/npm-fetch-syntax.d.ts +0 -6
- package/dist/frontend/npm-fetch-syntax.js +0 -202
- package/dist/frontend/npm-fetch-syntax.js.map +0 -1
- package/dist/native/runtime-typescript.d.ts +0 -4
- package/dist/native/runtime-typescript.js +0 -74
- package/dist/native/runtime-typescript.js.map +0 -1
- package/dist/native/runtime-typescript.test.js +0 -41
- package/dist/native/runtime-typescript.test.js.map +0 -1
- /package/dist/{frontend/lowering/lower-island.test.d.ts → backend/immutability.test.d.ts} +0 -0
- /package/dist/frontend/{npm-fetch-analysis.test.d.ts → lowering/narrowing-stability.test.d.ts} +0 -0
- /package/dist/{native/runtime-typescript.test.d.ts → ir/unshare.test.d.ts} +0 -0
|
@@ -8,17 +8,17 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
8
8
|
* the module artifacts (globals, embedded npm tables) the IR module carries. */
|
|
9
9
|
import * as ts from "../ts7/adapter.js";
|
|
10
10
|
import { bindingSource } from "../binding-source.js";
|
|
11
|
-
import { dirname as dirnamePath,
|
|
12
|
-
import {
|
|
11
|
+
import { dirname as dirnamePath, resolve as resolvePath } from "node:path";
|
|
12
|
+
import { packageNameOfPath, probeNodeImportRefusal } from "../npm.js";
|
|
13
13
|
import { isNpmStaticPackage } from "../npm-static.js";
|
|
14
14
|
import { isJsSourceFileName } from "../tsc-codes.js";
|
|
15
15
|
import { isRelativeSpecifier } from "../workspace-registry.js";
|
|
16
16
|
import { canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, entryPackageFilePredicate, isCjsJsFile, isJsSourceFile, isRequireStatement, locOf, makeCycleAdmission, orderedImportsOf, resolveImport, resolveNpmImport, } from "../program.js";
|
|
17
17
|
import { markCycleEarlyBindings, withCycleInitFlags } from "./cycle-initialization.js";
|
|
18
|
-
import { invalidJsonModuleDiag,
|
|
19
|
-
import { BOOL, CAUGHT, DYN, F64,
|
|
20
|
-
import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType,
|
|
21
|
-
import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl,
|
|
18
|
+
import { invalidJsonModuleDiag, unsupportedPackageImportDiag, } from "../../diagnostics/diagnostic.js";
|
|
19
|
+
import { BOOL, CAUGHT, DYN, F64, RUNTIME_ERROR_CLASSES, STRING, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, isUnitType, } from "../../ir/ir.js";
|
|
20
|
+
import { ENTRY_NAME, PoisonError, boundIdentifiersOf, dynFallbackType, newFnCtx, staticImportNamespaceType, } from "./lowerer.js";
|
|
21
|
+
import { isNativeFfiRequire, builtinMemberRequireDecl, builtinNamespaceDestructureModuleOf, createRequireBindingDecl, createRequireNamespaceDecl, createRequireProgramModuleDecl, } from "./builtins/module-bindings.js";
|
|
22
22
|
import { isPromisifyCall, registerBuiltinCallableAlias } from "./builtins/callable-aliases.js";
|
|
23
23
|
import { stripTypeCasts } from "./builtins/arguments.js";
|
|
24
24
|
import { bindingContextualGenericFnNodeOf, bindingGenericFnAliasInfoOf, bindingGenericFnInfoOf, bindingGenericFnNodeOf, implicitLocalFnInfoOf, implicitLocalFnNodeOf, } from "./generic-functions.js";
|
|
@@ -170,22 +170,6 @@ function dynamicProgramImportsOf(program, sf) {
|
|
|
170
170
|
});
|
|
171
171
|
return out;
|
|
172
172
|
}
|
|
173
|
-
/** --dynamic builds: program modules reachable ONLY through dynamic
|
|
174
|
-
* `import()` join the compiled module graph — appended to `order` (before
|
|
175
|
-
* the entry, which stays last) in depth-first postorder over their own
|
|
176
|
-
* static import edges, exactly like preflight ordered the static graph.
|
|
177
|
-
* NOTHING calls their %init at startup (%main runs only the entry's init,
|
|
178
|
-
* and no static import header names these), so a dynamic-only module
|
|
179
|
-
* still evaluates exactly when Node evaluates it: the import() site's
|
|
180
|
-
* namespace builder calls the guarded init on the engine microtask.
|
|
181
|
-
* Fixpoint: an added module's own import() sites are scanned too. Static
|
|
182
|
-
* cycles inside the added subgraph ride preflight's own admission engine
|
|
183
|
-
* (makeCycleAdmission — preflight only walked the entry's static graph,
|
|
184
|
-
* so it never judged these): benign back edges are Node cache hits the
|
|
185
|
-
* run-once init guards reproduce, and inadmissible ones get preflight's
|
|
186
|
-
* SC1016 with the same narrowed reason via `onCycle`. Idempotent —
|
|
187
|
-
* re-running on an already-extended order adds nothing (both lowering
|
|
188
|
-
* passes share one array). */
|
|
189
173
|
export function appendDynamicImportModules(program, order, onCycle) {
|
|
190
174
|
if (order.length === 0)
|
|
191
175
|
return; // no preflight order — sites keep their fences
|
|
@@ -390,33 +374,12 @@ export function collectProgram(lowerer, parts) {
|
|
|
390
374
|
}
|
|
391
375
|
markCycleEarlyBindings(lowerer);
|
|
392
376
|
}
|
|
393
|
-
/** The npm-import chokepoint, run once per pass during collection (so
|
|
394
|
-
* bodies lowered in ANY pass resolve the bindings). In a static build
|
|
395
|
-
* every value-importing npm import reports the requires-dynamic
|
|
396
|
-
* diagnostic naming the package — the package's shipped JS has exactly
|
|
397
|
-
* one execution home, the embedded engine. Under --dynamic each value
|
|
398
|
-
* binding becomes a jsval GLOBAL, registered by ALIASED symbol (modules
|
|
399
|
-
* importing the same export share one global) and initialized at the
|
|
400
|
-
* top of the importing module's %init by island.import — the engine's
|
|
401
|
-
* module registry caches, so re-imports are lookups, not re-evaluations.
|
|
402
|
-
* The runtime graph (the package entry plus everything it reaches)
|
|
403
|
-
* builds here too; its failures are ordinary diagnostics at the import
|
|
404
|
-
* site. Type-only imports are free either way: the .d.ts is a type
|
|
405
|
-
* surface, not code. */
|
|
406
377
|
export function collectNpmImports(lowerer, parts) {
|
|
407
|
-
const services = lowerer.frontendServices;
|
|
408
|
-
if (lowerer.dynamic && services === undefined)
|
|
409
|
-
throw new Error("dynamic lowering requires frontend services");
|
|
410
|
-
const builder = lowerer.dynamic && services !== undefined ? new NpmGraphBuilder(services) : null;
|
|
411
378
|
const entryPackageFile = entryPackageFilePredicate(lowerer.entry.fileName);
|
|
412
379
|
for (const fp of parts) {
|
|
413
380
|
for (const stmt of fp.sf.statements) {
|
|
414
381
|
// NAMED re-exports from npm packages (`export { isUrl } from
|
|
415
|
-
// "url-or-path"`
|
|
416
|
-
// plumbing — the island load registers at this statement's
|
|
417
|
-
// position, and each binding keys the same aliased symbol a
|
|
418
|
-
// direct import would, so consumers' alias chains land on the
|
|
419
|
-
// same storage.
|
|
382
|
+
// "url-or-path"`): use the same package bindings as direct imports.
|
|
420
383
|
const reexport = ts.isExportDeclaration(stmt) &&
|
|
421
384
|
!stmt.isTypeOnly &&
|
|
422
385
|
stmt.moduleSpecifier !== undefined &&
|
|
@@ -447,16 +410,13 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
447
410
|
const spec = specNode.text;
|
|
448
411
|
// --external-types owns this exact module interpretation. Even when
|
|
449
412
|
// an install happens to resolve the same name (or --npm-static auto
|
|
450
|
-
// selects its package), the declaration mapping
|
|
451
|
-
// island runtime implementation; the preflight/import-use SC1010
|
|
452
|
-
// fences are the whole story.
|
|
413
|
+
// selects its package), the declaration mapping owns this boundary.
|
|
453
414
|
if (lowerer.externalTypes.has(spec))
|
|
454
415
|
continue;
|
|
455
416
|
// A source-only workspace package is part of the program module
|
|
456
417
|
// graph: resolveImport follows its node_modules link to the loaded
|
|
457
418
|
// TypeScript entry. Its internal `.js` spellings have already been
|
|
458
|
-
// resolved to `.ts` by that graph
|
|
459
|
-
// the JavaScript island.
|
|
419
|
+
// resolved to `.ts` by that graph.
|
|
460
420
|
if (!isRelativeSpecifier(spec) && resolveImport(lowerer.program, fp.sf, spec) !== null) {
|
|
461
421
|
continue;
|
|
462
422
|
}
|
|
@@ -465,7 +425,6 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
465
425
|
// is a PROGRAM-MODULE dependency — its entry sits in the module
|
|
466
426
|
// order, orderedImportsOf answers it for the %init header, and the
|
|
467
427
|
// checker's alias chains bind the imports to its own exports. The
|
|
468
|
-
// island owns nothing here, in static and --dynamic builds alike.
|
|
469
428
|
if (npm !== null &&
|
|
470
429
|
isNpmStaticPackage(npm.packageName) &&
|
|
471
430
|
isJsSourceFileName(npm.typesFile) &&
|
|
@@ -474,12 +433,8 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
474
433
|
}
|
|
475
434
|
// A RELATIVE specifier resolving INTO node_modules (the e2e driver
|
|
476
435
|
// shape: `import "../node_modules/vercel/dist/index.js"`) is
|
|
477
|
-
// package code too
|
|
478
|
-
//
|
|
479
|
-
// embedded engine, so it takes the same island path as a bare
|
|
480
|
-
// specifier (previously it lowered to NOTHING: not an npm import,
|
|
481
|
-
// and node_modules files never lower as program modules — the
|
|
482
|
-
// import silently dropped).
|
|
436
|
+
// package code too. Attribute it to the package so unselected source
|
|
437
|
+
// receives a diagnostic instead of silently dropping the import.
|
|
483
438
|
const relPkg = npm === null && isRelativeSpecifier(spec)
|
|
484
439
|
? packageNameOfPath(resolvePath(dirnamePath(fp.sf.fileName), spec))
|
|
485
440
|
: null;
|
|
@@ -491,7 +446,6 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
491
446
|
if (relIsJs) {
|
|
492
447
|
// An explicitly selected installed entry owns its package's
|
|
493
448
|
// source graph. Preflight included these modules for native
|
|
494
|
-
// initialization; do not also embed them in the island.
|
|
495
449
|
const dep = resolveImport(lowerer.program, fp.sf, spec);
|
|
496
450
|
if (dep !== null && entryPackageFile(dep.fileName) && lowerer.fileTag.has(dep))
|
|
497
451
|
continue;
|
|
@@ -506,105 +460,16 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
506
460
|
// resolved, but the exports target ships no JS — the types-only
|
|
507
461
|
// package shape): preflight registered Node's startup crash for
|
|
508
462
|
// it, %main throws before any init runs, and the bindings never
|
|
509
|
-
// link — nothing to embed, no island requirement, in EITHER mode.
|
|
510
463
|
if (npm !== null && probeNodeImportRefusal(fp.sf.fileName, spec) !== null)
|
|
511
464
|
continue;
|
|
512
|
-
|
|
513
|
-
lowerer.pushDiag(
|
|
514
|
-
continue;
|
|
515
|
-
}
|
|
516
|
-
const before = builder.errors.length;
|
|
517
|
-
const entryKey = npm
|
|
518
|
-
? (builder.addImport(fp.sf.fileName, spec), builder.entryOf(fp.sf.fileName, spec))
|
|
519
|
-
: builder.addFileImport(fp.sf.fileName, spec);
|
|
520
|
-
for (const err of builder.errors.slice(before)) {
|
|
521
|
-
lowerer.pushDiag(npmEmbedFailedDiag(err.message, locOf(stmt)));
|
|
522
|
-
}
|
|
523
|
-
if (entryKey === null)
|
|
524
|
-
continue; // resolution failed — reported above
|
|
525
|
-
const loc = locOf(stmt);
|
|
526
|
-
const byStmt = lowerer.npmInitActions.get(fp.sf) ?? new Map();
|
|
527
|
-
lowerer.npmInitActions.set(fp.sf, byStmt);
|
|
528
|
-
const actions = byStmt.get(stmt) ?? [];
|
|
529
|
-
byStmt.set(stmt, actions);
|
|
530
|
-
const importExpr = (exportName) => ({
|
|
531
|
-
kind: "libCall",
|
|
532
|
-
fn: "island.import",
|
|
533
|
-
args: [
|
|
534
|
-
{ kind: "strLit", value: entryKey, type: STRING, loc },
|
|
535
|
-
{ kind: "strLit", value: exportName, type: STRING, loc },
|
|
536
|
-
// The specifier as WRITTEN — Node's missing-export SyntaxError
|
|
537
|
-
// names it ("The requested module 'x' does not provide an
|
|
538
|
-
// export named 'y'"), and the runtime check reproduces that
|
|
539
|
-
// message exactly (scr_jsval_import).
|
|
540
|
-
{ kind: "strLit", value: spec, type: STRING, loc },
|
|
541
|
-
],
|
|
542
|
-
type: JSVAL,
|
|
543
|
-
loc,
|
|
544
|
-
});
|
|
545
|
-
const bind = (nameNode, exportName) => {
|
|
546
|
-
let symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
547
|
-
if (symbol && symbol.flags & ts.SymbolFlags.Alias) {
|
|
548
|
-
symbol = lowerer.checker.getAliasedSymbol(symbol);
|
|
549
|
-
}
|
|
550
|
-
if (!symbol)
|
|
551
|
-
return;
|
|
552
|
-
let g = lowerer.globalsBySymbol.get(symbol);
|
|
553
|
-
if (!g) {
|
|
554
|
-
g = {
|
|
555
|
-
id: `%g.npm.${lowerer.globalsList.length}`,
|
|
556
|
-
name: nameNode.text,
|
|
557
|
-
type: JSVAL,
|
|
558
|
-
mutable: false,
|
|
559
|
-
};
|
|
560
|
-
lowerer.globalsBySymbol.set(symbol, g);
|
|
561
|
-
lowerer.globalsList.push(g);
|
|
562
|
-
}
|
|
563
|
-
actions.push({ kind: "assign", localId: g.id, value: importExpr(exportName), loc });
|
|
564
|
-
};
|
|
565
|
-
if (reexport !== null) {
|
|
566
|
-
for (const el of reexport.elements) {
|
|
567
|
-
if (el.isTypeOnly)
|
|
568
|
-
continue;
|
|
569
|
-
bind(el.name, el.propertyName?.text ?? el.name.text);
|
|
570
|
-
}
|
|
571
|
-
continue;
|
|
572
|
-
}
|
|
573
|
-
if (!clause) {
|
|
574
|
-
// Side-effect import: load for its top-level effects, keep nothing.
|
|
575
|
-
actions.push({ kind: "exprStmt", expr: importExpr("*"), loc });
|
|
465
|
+
{
|
|
466
|
+
lowerer.pushDiag(unsupportedPackageImportDiag(npm?.packageName ?? relPkg, locOf(stmt)));
|
|
576
467
|
continue;
|
|
577
468
|
}
|
|
578
|
-
if (clause.name)
|
|
579
|
-
bind(clause.name, "default");
|
|
580
|
-
if (clause.namedBindings) {
|
|
581
|
-
if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
582
|
-
bind(clause.namedBindings.name, "*");
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
for (const el of clause.namedBindings.elements) {
|
|
586
|
-
if (el.isTypeOnly)
|
|
587
|
-
continue;
|
|
588
|
-
bind(el.name, el.propertyName?.text ?? el.name.text);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
469
|
}
|
|
593
470
|
}
|
|
594
471
|
for (const fp of parts)
|
|
595
|
-
collectDynamicImports(lowerer,
|
|
596
|
-
if (builder) {
|
|
597
|
-
for (const fp of parts)
|
|
598
|
-
collectCreateRequires(lowerer, builder, fp.sf);
|
|
599
|
-
const graph = builder.finish();
|
|
600
|
-
if (graph.modules.length > 0) {
|
|
601
|
-
lowerer.npmEmbedded = { modules: graph.modules, edges: graph.edges };
|
|
602
|
-
}
|
|
603
|
-
if (graph.builtins.length > 0)
|
|
604
|
-
lowerer.npmBuiltins = graph.builtins;
|
|
605
|
-
if (graph.lazyTraps.length > 0)
|
|
606
|
-
lowerer.npmLazyTraps = graph.lazyTraps;
|
|
607
|
-
}
|
|
472
|
+
collectDynamicImports(lowerer, fp.sf);
|
|
608
473
|
}
|
|
609
474
|
/** Literal dynamic-import collection: every
|
|
610
475
|
* `import("literal")` in the file — whatever body it sits in — resolves
|
|
@@ -619,7 +484,7 @@ export function collectNpmImports(lowerer, parts) {
|
|
|
619
484
|
* specifiers are skipped — the lowering owns that fence (the module
|
|
620
485
|
* graph is a build-time artifact; there is nothing to embed for a
|
|
621
486
|
* runtime-computed name). */
|
|
622
|
-
function collectDynamicImports(lowerer,
|
|
487
|
+
function collectDynamicImports(lowerer, sf) {
|
|
623
488
|
ts.walkPreorder(sf, (node) => {
|
|
624
489
|
if (ts.isCallExpression(node) &&
|
|
625
490
|
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
|
|
@@ -645,65 +510,18 @@ function collectDynamicImports(lowerer, builder, sf) {
|
|
|
645
510
|
const builtin = canonicalBuiltinModule(spec);
|
|
646
511
|
const res = ownModule
|
|
647
512
|
? { kind: "program-module" }
|
|
648
|
-
:
|
|
513
|
+
: builtin !== null
|
|
649
514
|
? { kind: "static-builtin", module: builtin }
|
|
650
|
-
:
|
|
515
|
+
: undefined;
|
|
651
516
|
if (res === undefined) {
|
|
652
517
|
return undefined;
|
|
653
518
|
}
|
|
654
519
|
lowerer.dynImports.set(mapKey, res);
|
|
655
|
-
if (res.kind === "unsupported-builtin") {
|
|
656
|
-
lowerer.pushDiag(npmEmbedFailedDiag(`'${spec}' is a Node builtin the island does not provide a shim for`, locOf(node)));
|
|
657
|
-
}
|
|
658
|
-
else if (res.kind === "unresolved") {
|
|
659
|
-
lowerer.pushDiag(npmEmbedFailedDiag(res.message, locOf(node)));
|
|
660
|
-
}
|
|
661
520
|
}
|
|
662
521
|
}
|
|
663
522
|
return undefined;
|
|
664
523
|
});
|
|
665
524
|
}
|
|
666
|
-
/** The createRequire half of the npm chokepoint (--dynamic only): every
|
|
667
|
-
* `require("bare-literal")` through a createRequire binding — whatever
|
|
668
|
-
* body it sits in — resolves under Node's "require" condition and
|
|
669
|
-
* embeds AT COLLECTION time, so the per-site lowering later just looks
|
|
670
|
-
* its entry up (lowerCreateRequireCall). Builtins, relative documents,
|
|
671
|
-
* "#" specifiers, --npm-static opt-ins, and Node-refused bare names
|
|
672
|
-
* are the lowering's own arms — only resolvable installed packages
|
|
673
|
-
* register here; resolution failures are diagnostics at the call
|
|
674
|
-
* expression, exactly like static npm imports at their statements. */
|
|
675
|
-
function collectCreateRequires(lowerer, builder, sf) {
|
|
676
|
-
const visit = (node) => {
|
|
677
|
-
if (ts.isCallExpression(node)) {
|
|
678
|
-
const cr = createRequireSpecOf(lowerer, node);
|
|
679
|
-
const spec = cr?.spec ?? null;
|
|
680
|
-
if (cr !== null &&
|
|
681
|
-
spec !== null &&
|
|
682
|
-
canonicalBuiltinModule(spec) === null &&
|
|
683
|
-
!isRelativeSpecifier(spec) &&
|
|
684
|
-
!isAbsolute(spec) &&
|
|
685
|
-
!spec.startsWith("#") &&
|
|
686
|
-
probeNodeRequireRefusal(cr.baseFile.fileName, spec) === null) {
|
|
687
|
-
const pkgName = spec.startsWith("@")
|
|
688
|
-
? spec.split("/").slice(0, 2).join("/")
|
|
689
|
-
: spec.split("/")[0];
|
|
690
|
-
const mapKey = `${cr.baseFile.fileName}\u0000${spec}`;
|
|
691
|
-
if (!lowerer.createRequireImports.has(mapKey) && !isNpmStaticPackage(pkgName)) {
|
|
692
|
-
const before = builder.errors.length;
|
|
693
|
-
const entryKey = builder.addRequire(cr.baseFile.fileName, spec);
|
|
694
|
-
for (const err of builder.errors.slice(before)) {
|
|
695
|
-
lowerer.pushDiag(npmEmbedFailedDiag(err.message, locOf(node)));
|
|
696
|
-
}
|
|
697
|
-
lowerer.createRequireImports.set(mapKey, entryKey === null
|
|
698
|
-
? ""
|
|
699
|
-
: { entryKey, format: builder.moduleFormatOf(entryKey) ?? "cjs" });
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
ts.forEachChild(node, visit);
|
|
704
|
-
};
|
|
705
|
-
visit(sf);
|
|
706
|
-
}
|
|
707
525
|
/** JSON module default imports (`import pkg from "../package.json"`):
|
|
708
526
|
* the document is DATA known at build time, so the binding bakes into a
|
|
709
527
|
* record global — the checker's structural type for the module (thanks
|
|
@@ -1866,7 +1684,7 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1866
1684
|
(!decl.type &&
|
|
1867
1685
|
!hasJsTypeAnnotation(decl) &&
|
|
1868
1686
|
checkedGlobalReference(lowerer, initializer)) ||
|
|
1869
|
-
|
|
1687
|
+
stdlibGlobalNameOf(lowerer, initializer) === "globalThis")) {
|
|
1870
1688
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1871
1689
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1872
1690
|
const g = {
|
|
@@ -2030,35 +1848,6 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2030
1848
|
}
|
|
2031
1849
|
continue;
|
|
2032
1850
|
}
|
|
2033
|
-
// A JS file-scope object literal carrying GET accessors whose
|
|
2034
|
-
// strict type has no mapping (the doc-printer root-indent
|
|
2035
|
-
// shape — a self-referential getter): the literal builds
|
|
2036
|
-
// ISLAND-NATIVE (the getter defines through the engine), so
|
|
2037
|
-
// the binding holds the HANDLE — a jsval global, so exports
|
|
2038
|
-
// and separately-declared functions reach the same engine
|
|
2039
|
-
// object.
|
|
2040
|
-
if (lowerer.dynamic &&
|
|
2041
|
-
isJsSourceFile(sf) &&
|
|
2042
|
-
!lowerer.mapTypeOf(lowerer.typeOf(nameNode)) &&
|
|
2043
|
-
ts.isIdentifier(decl.name) &&
|
|
2044
|
-
nameNode === decl.name &&
|
|
2045
|
-
decl.initializer !== undefined &&
|
|
2046
|
-
ts.isObjectLiteralExpression(decl.initializer) &&
|
|
2047
|
-
decl.initializer.properties.some((p) => ts.isGetAccessorDeclaration(p))) {
|
|
2048
|
-
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
2049
|
-
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
2050
|
-
const g = {
|
|
2051
|
-
id: `%g.${tag}${nsPrefix}${nameNode.text}`,
|
|
2052
|
-
name: nameNode.text,
|
|
2053
|
-
type: JSVAL,
|
|
2054
|
-
mutable: isLet,
|
|
2055
|
-
source: bindingSource(nameNode),
|
|
2056
|
-
};
|
|
2057
|
-
lowerer.globalsBySymbol.set(symbol, g);
|
|
2058
|
-
lowerer.globalsList.push(g);
|
|
2059
|
-
}
|
|
2060
|
-
continue;
|
|
2061
|
-
}
|
|
2062
1851
|
// A function initializer can have a native calling convention
|
|
2063
1852
|
// even when its inferred return/parameter pieces need DYN. Keep
|
|
2064
1853
|
// that closure in a checked-value global so class methods and
|
|
@@ -2122,23 +1911,12 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2122
1911
|
ts.isNewExpression(decl.initializer)
|
|
2123
1912
|
? (objectFactoryGlobalType(lowerer, decl.initializer) ?? undefined)
|
|
2124
1913
|
: undefined;
|
|
2125
|
-
//
|
|
2126
|
-
//
|
|
2127
|
-
// production — whatever the checker's namespace type mapped to
|
|
2128
|
-
// (lowerVarDecl's rule at module scope; the init body assigns
|
|
2129
|
-
// it).
|
|
1914
|
+
// Prefer the initializer's native namespace or proxy storage
|
|
1915
|
+
// where it is more precise than the declaration's checker type.
|
|
2130
1916
|
const handleT = ts.isIdentifier(decl.name) && nameNode === decl.name
|
|
2131
1917
|
? ((isNativeProxyInitializer(lowerer, decl.initializer) ? DYN : null) ??
|
|
2132
|
-
(lowerer.
|
|
2133
|
-
|
|
2134
|
-
: staticImportNamespaceType(lowerer, decl.initializer)) ??
|
|
2135
|
-
(lowerer.dynamic
|
|
2136
|
-
? // An unchecked-overload call result stores the handle,
|
|
2137
|
-
// exactly the local rule (uncheckedOverloadHandleCall).
|
|
2138
|
-
uncheckedOverloadHandleCall(lowerer, decl.initializer)
|
|
2139
|
-
? JSVAL
|
|
2140
|
-
: null
|
|
2141
|
-
: null))
|
|
1918
|
+
staticImportNamespaceType(lowerer, decl.initializer) ??
|
|
1919
|
+
null)
|
|
2142
1920
|
: null;
|
|
2143
1921
|
// JavaScript factory results with unmappable annotations still
|
|
2144
1922
|
// need shared storage. Unannotated callable unions also use a
|
|
@@ -2257,8 +2035,7 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2257
2035
|
decl.initializer &&
|
|
2258
2036
|
ts.isCallExpression(decl.initializer))
|
|
2259
2037
|
type = DYN;
|
|
2260
|
-
if (
|
|
2261
|
-
isJsSourceFile(sf) &&
|
|
2038
|
+
if (isJsSourceFile(sf) &&
|
|
2262
2039
|
!decl.type &&
|
|
2263
2040
|
!hasJsTypeAnnotation(decl) &&
|
|
2264
2041
|
decl.initializer &&
|
|
@@ -2291,26 +2068,6 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2291
2068
|
!hasJsTypeAnnotation(decl)) {
|
|
2292
2069
|
type = DYN;
|
|
2293
2070
|
}
|
|
2294
|
-
// An evolving-`any` array's DERIVED file-scope binding under
|
|
2295
|
-
// --dynamic (`const kept = fns.filter(...)` where `fns`
|
|
2296
|
-
// registered array<jsval> at its `any[]` declaration): the
|
|
2297
|
-
// receiver-type-preserving methods answer the receiver's
|
|
2298
|
-
// handle-element array, while tsc's evolving-array analysis
|
|
2299
|
-
// spells the pushed element type here — the value's element
|
|
2300
|
-
// type is the truth, so the global slot takes the handle-
|
|
2301
|
-
// element array (lowerVarDecl's adoption, the file-scope
|
|
2302
|
-
// face). Annotated declarations keep the validated-boundary
|
|
2303
|
-
// fence.
|
|
2304
|
-
if (lowerer.dynamic &&
|
|
2305
|
-
ts.isIdentifier(decl.name) &&
|
|
2306
|
-
nameNode === decl.name &&
|
|
2307
|
-
decl.type === undefined &&
|
|
2308
|
-
decl.initializer !== undefined &&
|
|
2309
|
-
type.kind === "array" &&
|
|
2310
|
-
type.elem.kind !== "jsval" &&
|
|
2311
|
-
handleArrayPreservingCall(lowerer, decl.initializer)) {
|
|
2312
|
-
type = arrayOf(JSVAL);
|
|
2313
|
-
}
|
|
2314
2071
|
// An exact class behind a generic interface keeps its native
|
|
2315
2072
|
// representation so generic calls can specialize against its body.
|
|
2316
2073
|
if ((type.kind === "record" || type.kind === "dyn") &&
|
|
@@ -2321,25 +2078,6 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2321
2078
|
if (initT?.kind === "object")
|
|
2322
2079
|
type = initT;
|
|
2323
2080
|
}
|
|
2324
|
-
// A file-scope PATTERN over an ISLAND-bound source (`export
|
|
2325
|
-
// let { toString } = 1;` — the engine reads the wrapper's
|
|
2326
|
-
// prototype member): the bound value follows the island
|
|
2327
|
-
// property-read rule, so the global slot must too — declared
|
|
2328
|
-
// primitives exit eagerly to their static type, everything
|
|
2329
|
-
// else stores the HANDLE (a func-typed slot could never take
|
|
2330
|
-
// the engine value the desugar assigns).
|
|
2331
|
-
if (lowerer.dynamic && !ts.isIdentifier(decl.name) && decl.initializer !== undefined) {
|
|
2332
|
-
const srcT = lowerer.mapTypeOf(lowerer.typeOf(decl.initializer));
|
|
2333
|
-
const island = srcT !== null &&
|
|
2334
|
-
(srcT.kind === "jsval" ||
|
|
2335
|
-
srcT.kind === "f64" ||
|
|
2336
|
-
srcT.kind === "bool" ||
|
|
2337
|
-
srcT.kind === "string" ||
|
|
2338
|
-
isUnitType(srcT));
|
|
2339
|
-
if (island && type.kind !== "f64" && type.kind !== "bool" && type.kind !== "string") {
|
|
2340
|
-
type = JSVAL;
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
2081
|
// File-scope unit-only bindings (`var x: undefined`, `const
|
|
2344
2082
|
// y: void = undefined`) ride the unit-only union, exactly
|
|
2345
2083
|
// like function-scope locals (lowerVarDecl's rule).
|
|
@@ -2437,33 +2175,6 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
2437
2175
|
}
|
|
2438
2176
|
}
|
|
2439
2177
|
}
|
|
2440
|
-
/** True iff this initializer's VALUE is a jsval-element array from a
|
|
2441
|
-
* module global already registered as one (the evolving-`any` binding
|
|
2442
|
-
* under --dynamic): the global itself, or a receiver-TYPE-PRESERVING
|
|
2443
|
-
* array-method call chain over it (filter/slice/splice/concat — each
|
|
2444
|
-
* answers the receiver's own array type). Registration runs in source
|
|
2445
|
-
* order, so the root's global — declared above, TDZ-guaranteed — is
|
|
2446
|
-
* already in the table. */
|
|
2447
|
-
function handleArrayPreservingCall(lowerer, e) {
|
|
2448
|
-
const PRESERVING = new Set(["filter", "slice", "splice", "concat"]);
|
|
2449
|
-
let cur = e;
|
|
2450
|
-
for (;;) {
|
|
2451
|
-
while (ts.isParenthesizedExpression(cur))
|
|
2452
|
-
cur = cur.expression;
|
|
2453
|
-
if (ts.isCallExpression(cur) &&
|
|
2454
|
-
ts.isPropertyAccessExpression(cur.expression) &&
|
|
2455
|
-
PRESERVING.has(cur.expression.name.text)) {
|
|
2456
|
-
cur = cur.expression.expression;
|
|
2457
|
-
continue;
|
|
2458
|
-
}
|
|
2459
|
-
break;
|
|
2460
|
-
}
|
|
2461
|
-
if (!ts.isIdentifier(cur))
|
|
2462
|
-
return false;
|
|
2463
|
-
const sym = lowerer.checker.getSymbolAtLocation(cur);
|
|
2464
|
-
const g = sym ? lowerer.globalsBySymbol.get(sym) : undefined;
|
|
2465
|
-
return g?.type.kind === "array" && g.type.elem.kind === "jsval";
|
|
2466
|
-
}
|
|
2467
2178
|
/** Registers the entry-init note for a `var` module global: JS hoists
|
|
2468
2179
|
* module vars to `undefined` at module entry, so an undefined-armed slot
|
|
2469
2180
|
* must hold the interned undefined arm BEFORE the body runs (a function
|
|
@@ -2476,11 +2187,10 @@ function handleArrayPreservingCall(lowerer, e) {
|
|
|
2476
2187
|
function noteVarGlobalEntryInit(lowerer, sf, g) {
|
|
2477
2188
|
// 'any' globals need the entry init exactly like undefined-armed
|
|
2478
2189
|
// unions: tsc never guards `any` reads, so `var x: any;` is readable
|
|
2479
|
-
// before any assignment and its slot must hold
|
|
2480
|
-
// — the ENGINE's for jsval (--dynamic), the checked-dynamic tree's for dyn (static) —
|
|
2190
|
+
// before any assignment and its slot must hold native undefined
|
|
2481
2191
|
// rather than a C-level NULL (an op or validated exit on NULL is
|
|
2482
2192
|
// memory-unsafe, not a TypeError).
|
|
2483
|
-
if (g.type.kind !== "union" && g.type.kind !== "
|
|
2193
|
+
if (g.type.kind !== "union" && g.type.kind !== "dyn")
|
|
2484
2194
|
return;
|
|
2485
2195
|
const inits = lowerer.varGlobalEntryInits.get(sf) ?? [];
|
|
2486
2196
|
inits.push(g);
|
|
@@ -2638,20 +2348,6 @@ export function lowerDefaultExport(lowerer, stmt) {
|
|
|
2638
2348
|
const value = lowerer.lowerExprExpecting(stmt.expression, g.type);
|
|
2639
2349
|
return { kind: "assign", localId: g.id, value, loc: locOf(stmt) };
|
|
2640
2350
|
}
|
|
2641
|
-
/** One file's top-level statements as its init function — RUN-ONCE like a
|
|
2642
|
-
* Node module body: non-entry inits open with a guard flag test (already
|
|
2643
|
-
* ran → return) and set the flag before anything else, so every caller —
|
|
2644
|
-
* hoisted import headers, inline require statements, diamonds, cache-hit
|
|
2645
|
-
* re-requires — gets Node's module-cache semantics from the same call.
|
|
2646
|
-
* After the guard comes the file's HOISTED module-edge header: one
|
|
2647
|
-
* guarded %init call per imported user module and the island loads for
|
|
2648
|
-
* npm imports, in import order (Node evaluates every imported module
|
|
2649
|
-
* before the importer's body — depth-first postorder falls out of the
|
|
2650
|
-
* nesting). CommonJS requires are NOT in the header: Node runs them at
|
|
2651
|
-
* their statements, so the statement lowering emits their %init calls
|
|
2652
|
-
* inline in the body. JSON-import bindings (pure data) load next; then
|
|
2653
|
-
* the body. Top-level var statements assign the pre-registered globals
|
|
2654
|
-
* instead of declaring locals. */
|
|
2655
2351
|
export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
2656
2352
|
const isAsync = lowerer.asyncInitFiles.has(sf);
|
|
2657
2353
|
const ctx = newFnCtx(false, null, null, VOID);
|