@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
|
@@ -14,12 +14,11 @@ import { lowerGenMethodCall } from "./lower-generators.js";
|
|
|
14
14
|
import { lowerClassSymbolMethodCall } from "./symbol-methods.js";
|
|
15
15
|
import { errorToStringCall } from "./error-methods.js";
|
|
16
16
|
import { lowerClassPrototypeAssign, lowerClassPrototypeDescriptors } from "./class-prototypes.js";
|
|
17
|
-
import { BYTES_ELEMENT_NAME, BIGINT_T, BOOL, CAUGHT, DYN, F64,
|
|
17
|
+
import { BYTES_ELEMENT_NAME, BIGINT_T, BOOL, CAUGHT, DYN, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
|
|
18
18
|
import { isJsSourceFile, locOf, requireSpecOf } from "../program.js";
|
|
19
19
|
import { isGenericCallableMemberType, typeKey } from "../type-mapper.js";
|
|
20
|
-
import {
|
|
20
|
+
import { dynFallbackType, jsFuncNameOf, newFnCtx, staticImportNamespaceType } from "./lowerer.js";
|
|
21
21
|
import { NARROW_FIRST, STRING_INDEX_METHODS, STR_METHODS, stdlibGlobalNameOf } from "./surfaces.js";
|
|
22
|
-
import { requiresDynamicDiag } from "../../diagnostics/diagnostic.js";
|
|
23
22
|
import { dynStringReceiver } from "./containers/dynamic-receivers.js";
|
|
24
23
|
import { lowerArrayConstructor, lowerArrayFromCall, lowerArrayOfCall, } from "./containers/array-construction.js";
|
|
25
24
|
import { lowerDynArrayFilterCall, lowerDynArrayFlatMapCall } from "./containers/array-callbacks.js";
|
|
@@ -57,27 +56,10 @@ import { lowerClassDataDescriptor, lowerClassDescriptorRead } from "./class-desc
|
|
|
57
56
|
import { classStaticDataFor } from "./class-static-data.js";
|
|
58
57
|
import { lowerUrlFactory } from "./lower-url.js";
|
|
59
58
|
import { nullishValueUnitOf } from "./binding-analysis.js";
|
|
60
|
-
import { spreadNeedsRuntimeArity, completeFuncValueArgs, lowerSpreadArgsCall,
|
|
59
|
+
import { spreadNeedsRuntimeArity, completeFuncValueArgs, lowerSpreadArgsCall, completeArgs, } from "./call-arguments.js";
|
|
61
60
|
import { isThisParameter } from "./call-signatures.js";
|
|
61
|
+
import { checkedArmExtraction } from "./coercions/unions.js";
|
|
62
62
|
import { requireObjLitGenericReceiver, objLitGenericFnNodeOf, objLitGenericFnInfoOf, genericCallInstance, } from "./generic-functions.js";
|
|
63
|
-
/** An island call result the .d.ts DECLARES as a primitive exits eagerly
|
|
64
|
-
* to that static type — the member-read rule's call sibling (see the
|
|
65
|
-
* getProp lowering in lower-exprs.ts): primitives copy by value, every
|
|
66
|
-
* static consumer works on the result, and a lying declaration throws the
|
|
67
|
-
* catchable TypeError. Chain-handled forms stay jsval (the optChain's
|
|
68
|
-
* unit path is the engine's undefined). */
|
|
69
|
-
export function islandPrimitiveExit(lowerer, call, result) {
|
|
70
|
-
if (call.questionDotToken)
|
|
71
|
-
return result;
|
|
72
|
-
if (ts.isPropertyAccessExpression(call.expression) && call.expression.questionDotToken)
|
|
73
|
-
return result;
|
|
74
|
-
const declared = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
75
|
-
if (declared &&
|
|
76
|
-
(declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string")) {
|
|
77
|
-
return { kind: "jsExit", value: result, type: declared, loc: result.loc };
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
63
|
export function lowerCall(lowerer, expr) {
|
|
82
64
|
const loc = locOf(expr);
|
|
83
65
|
// Object's checker return type is `any`. Claim known object inputs
|
|
@@ -279,12 +261,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
279
261
|
}
|
|
280
262
|
const args = expr.arguments.map((a) => {
|
|
281
263
|
const lowered = lowerer.lowerExpr(a);
|
|
282
|
-
if (lowered.type.kind === "jsval") {
|
|
283
|
-
// Node prints objects with util.inspect formatting, which
|
|
284
|
-
// String() cannot match — silent divergence is banned. Templates
|
|
285
|
-
// are ToString (Node-exact), casts are validated: both honest.
|
|
286
|
-
lowerer.unsupported("SC1090", a, `${surface} of 'any' values (wrap it: ${surface}(\`\${v}\`), or validate with 'as <type>' first)`);
|
|
287
|
-
}
|
|
288
264
|
// Checked-dynamic values carry their own shape, so the runtime
|
|
289
265
|
// renders them exactly like Node's console formatter renders a
|
|
290
266
|
// non-format argument: strings VERBATIM, everything else through
|
|
@@ -579,20 +555,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
579
555
|
if (name === "String")
|
|
580
556
|
return lowerer.ensureString(arg, argNode);
|
|
581
557
|
}
|
|
582
|
-
// __island_eval: the internal island testing hook (eval in the embedded
|
|
583
|
-
// engine, String(result) back). Provenance-checked like setTimeout.
|
|
584
|
-
// Only meaningful when the engine is linked: without --dynamic it is a
|
|
585
|
-
// clean requires-dynamic diagnostic, never an ICE or a link error.
|
|
586
|
-
if (ts.isIdentifier(expr.expression) &&
|
|
587
|
-
expr.expression.text === "__island_eval" &&
|
|
588
|
-
lowerer.isStdlibSymbol(lowerer.resolveValueSymbol(expr.expression) ?? undefined)) {
|
|
589
|
-
if (!lowerer.dynamic) {
|
|
590
|
-
lowerer.pushDiag(requiresDynamicDiag("'__island_eval'", loc));
|
|
591
|
-
throw new PoisonError();
|
|
592
|
-
}
|
|
593
|
-
const code = lowerer.lowerExprExpecting(expr.arguments[0], STRING);
|
|
594
|
-
return { kind: "libCall", fn: "island.eval", args: [code], type: STRING, loc };
|
|
595
|
-
}
|
|
596
558
|
// Computed calls preserve their evaluated receiver just like dotted
|
|
597
559
|
// calls, including when the property is keyed by a native symbol.
|
|
598
560
|
if (ts.isElementAccessExpression(expr.expression) &&
|
|
@@ -639,129 +601,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
639
601
|
};
|
|
640
602
|
}
|
|
641
603
|
}
|
|
642
|
-
// Island calls. A property-access callee whose receiver is an 'any'
|
|
643
|
-
// value is an engine method call (this = receiver, JS-exact); any other
|
|
644
|
-
// 'any'-typed callee is an engine function call. Arguments marshal in;
|
|
645
|
-
// results stay island values.
|
|
646
|
-
// A questionDotToken here is always chain-handled (the gate at the top
|
|
647
|
-
// of lowerCall routed unhandled ones to the chain lowering), so
|
|
648
|
-
// `x?.y(...)` re-dispatches into this same method-call form with the
|
|
649
|
-
// receiver reading back as the chain's bound handle.
|
|
650
|
-
if (ts.isPropertyAccessExpression(expr.expression) &&
|
|
651
|
-
lowerer.isIslandExpr(expr.expression.expression)) {
|
|
652
|
-
// Typed fetch/Web Streams handles map to island values under
|
|
653
|
-
// --dynamic, but their inventory still owns which methods exist.
|
|
654
|
-
// Reject unsupported rows before the universal jsval method path.
|
|
655
|
-
lowerer.fenceStaticResponseMember(expr.expression, "call");
|
|
656
|
-
lowerer.fenceStaticHeadersMember(expr.expression, "call");
|
|
657
|
-
lowerer.fenceStaticReadableStreamMember(expr.expression, "call");
|
|
658
|
-
const receiver = lowerer.lowerExpr(expr.expression.expression);
|
|
659
|
-
// A checker-`any` receiver whose VALUE lives in the checked-dynamic tree (a
|
|
660
|
-
// checked-dynamic local behind the any-typed spelling — the JS
|
|
661
|
-
// WeakSet placeholder, rest-args arrays): the checked-dynamic
|
|
662
|
-
// method machinery owns it — receiver-kind dispatch, stored-member
|
|
663
|
-
// calls, honest fences — never an engine op over a dyn value.
|
|
664
|
-
if (receiver.type.kind === "dyn") {
|
|
665
|
-
const served = lowerDynReceiverMethodCall(lowerer, expr, expr.expression);
|
|
666
|
-
if (served)
|
|
667
|
-
return served;
|
|
668
|
-
lowerer.unsupported("SC1100", expr, `'.${expr.expression.name.text}()' calls through 'unknown'-valued receivers in dynamically-executed positions`);
|
|
669
|
-
}
|
|
670
|
-
const args = expr.arguments.map((a) => lowerer.jsvalIn(lowerer.lowerExpr(a), a));
|
|
671
|
-
const result = {
|
|
672
|
-
kind: "jsOp",
|
|
673
|
-
op: "callMethod",
|
|
674
|
-
name: expr.expression.name.text,
|
|
675
|
-
args: [receiver, ...args],
|
|
676
|
-
type: JSVAL,
|
|
677
|
-
loc,
|
|
678
|
-
};
|
|
679
|
-
return islandPrimitiveExit(lowerer, expr, result);
|
|
680
|
-
}
|
|
681
|
-
if (lowerer.isIslandExpr(expr.expression)) {
|
|
682
|
-
// `o.m(...)` where o LOWERS checked-dynamic and the checker types
|
|
683
|
-
// `o.m` 'any' (a member read behind an 'object'/'unknown'-typed
|
|
684
|
-
// bag): METHOD-CALL semantics — receiver-kind dispatch (dynInvoke),
|
|
685
|
-
// so `this` binds and a WRAPPED island receiver runs the ENGINE's
|
|
686
|
-
// own method (the routed-ops lane). A stored-member dynCall would
|
|
687
|
-
// call engine prototype methods receiverless — the this-less
|
|
688
|
-
// `list.slice()` ToObject TypeError. Spread arguments keep the
|
|
689
|
-
// stored-member path below (the runtime-arity lane owns them).
|
|
690
|
-
if (ts.isPropertyAccessExpression(expr.expression) &&
|
|
691
|
-
!expr.expression.questionDotToken &&
|
|
692
|
-
!expr.questionDotToken &&
|
|
693
|
-
!expr.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
694
|
-
const recvProbe = tryLowerExpression(lowerer, expr.expression.expression);
|
|
695
|
-
if (recvProbe?.type.kind === "dyn") {
|
|
696
|
-
const args = expr.arguments.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
697
|
-
return {
|
|
698
|
-
kind: "dynInvoke",
|
|
699
|
-
recv: recvProbe,
|
|
700
|
-
method: expr.expression.name.text,
|
|
701
|
-
calleeName: expr.expression.getText(),
|
|
702
|
-
args,
|
|
703
|
-
type: DYN,
|
|
704
|
-
loc,
|
|
705
|
-
};
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
const callee = lowerer.lowerExpr(expr.expression);
|
|
709
|
-
// A checker-`any` callee that LOWERED checked-dynamic (a dyn member
|
|
710
|
-
// chain's stored function): the checked-dynamic tree's own call — dynCall reads and
|
|
711
|
-
// calls the stored member with Node's is-not-a-function TypeError
|
|
712
|
-
// on refusal.
|
|
713
|
-
if (callee.type.kind === "dyn") {
|
|
714
|
-
const args = expr.arguments.map((a) => lowerer.lowerExprExpecting(a, DYN));
|
|
715
|
-
const calleeName = ts.isPropertyAccessExpression(expr.expression)
|
|
716
|
-
? expr.expression.getText()
|
|
717
|
-
: ts.isIdentifier(expr.expression)
|
|
718
|
-
? expr.expression.text
|
|
719
|
-
: "value";
|
|
720
|
-
return { kind: "dynCall", callee, calleeName, args, type: DYN, loc };
|
|
721
|
-
}
|
|
722
|
-
// `fn(...args)` — a TRAILING spread into an island call: the
|
|
723
|
-
// engine's own apply (`fn.apply(undefined, argsArray)`); leading
|
|
724
|
-
// plain arguments prepend through `[l1, l2].concat(argsArray)`
|
|
725
|
-
// (concat flattens the array argument one level — exactly the
|
|
726
|
-
// spread). Other spread shapes keep the syntax fence.
|
|
727
|
-
if (expr.arguments.length > 0 &&
|
|
728
|
-
ts.isSpreadElement(expr.arguments[expr.arguments.length - 1]) &&
|
|
729
|
-
expr.arguments.slice(0, -1).every((a) => !ts.isSpreadElement(a))) {
|
|
730
|
-
const spread = expr.arguments[expr.arguments.length - 1];
|
|
731
|
-
const spreadV = lowerer.jsvalIn(lowerer.lowerExpr(spread.expression), spread.expression);
|
|
732
|
-
const leading = expr.arguments
|
|
733
|
-
.slice(0, -1)
|
|
734
|
-
.map((a) => lowerer.jsvalIn(lowerer.lowerExpr(a), a));
|
|
735
|
-
const argsArr = leading.length === 0
|
|
736
|
-
? spreadV
|
|
737
|
-
: {
|
|
738
|
-
kind: "jsOp",
|
|
739
|
-
op: "callMethod",
|
|
740
|
-
name: "concat",
|
|
741
|
-
args: [{ kind: "jsOp", op: "arrLit", args: leading, type: JSVAL, loc }, spreadV],
|
|
742
|
-
type: JSVAL,
|
|
743
|
-
loc,
|
|
744
|
-
};
|
|
745
|
-
const result = {
|
|
746
|
-
kind: "jsOp",
|
|
747
|
-
op: "callMethod",
|
|
748
|
-
name: "apply",
|
|
749
|
-
args: [callee, { kind: "jsOp", op: "undefLit", args: [], type: JSVAL, loc }, argsArr],
|
|
750
|
-
type: JSVAL,
|
|
751
|
-
loc,
|
|
752
|
-
};
|
|
753
|
-
return islandPrimitiveExit(lowerer, expr, result);
|
|
754
|
-
}
|
|
755
|
-
const args = expr.arguments.map((a) => lowerer.jsvalIn(lowerer.lowerExpr(a), a));
|
|
756
|
-
const result = {
|
|
757
|
-
kind: "jsOp",
|
|
758
|
-
op: "callFn",
|
|
759
|
-
args: [callee, ...args],
|
|
760
|
-
type: JSVAL,
|
|
761
|
-
loc,
|
|
762
|
-
};
|
|
763
|
-
return islandPrimitiveExit(lowerer, expr, result);
|
|
764
|
-
}
|
|
765
604
|
// Builtin-module functions (fs, path, os, ...): named imports whose
|
|
766
605
|
// binding resolves to a supported builtin specifier lower to `libCall`.
|
|
767
606
|
// A user local shadowing an import has a different symbol and never
|
|
@@ -850,9 +689,8 @@ export function lowerCall(lowerer, expr) {
|
|
|
850
689
|
}
|
|
851
690
|
// STATIC parseInt/parseFloat/isNaN/isFinite (num.parseInt /
|
|
852
691
|
// num.parseFloat / num.isNaN / number.isFinite — scr_string.c,
|
|
853
|
-
// scr_lib.c; ECMA-exact, Node is the oracle).
|
|
854
|
-
//
|
|
855
|
-
// different, non-stdlib symbol. parseInt's omitted radix completes
|
|
692
|
+
// scr_lib.c; ECMA-exact, Node is the oracle). Declaration provenance
|
|
693
|
+
// excludes shadowed names. parseInt's omitted radix completes
|
|
856
694
|
// to 0 — the spec's "undefined" (base 10 with the 0x hex escape);
|
|
857
695
|
// parseFloat lowers the STRING form only (Node would ToString other
|
|
858
696
|
// values — no static story); isNaN/isFinite's arguments are
|
|
@@ -934,8 +772,7 @@ export function lowerCall(lowerer, expr) {
|
|
|
934
772
|
if (v.type.kind === "dyn") {
|
|
935
773
|
data = v;
|
|
936
774
|
}
|
|
937
|
-
else if (v.kind === "unitLit" ||
|
|
938
|
-
(v.type.kind !== "jsval" && lowerer.dynConvertible(v.type))) {
|
|
775
|
+
else if (v.kind === "unitLit" || lowerer.dynConvertible(v.type)) {
|
|
939
776
|
data = { kind: "dynFrom", value: v, type: DYN, loc };
|
|
940
777
|
}
|
|
941
778
|
else {
|
|
@@ -949,11 +786,10 @@ export function lowerCall(lowerer, expr) {
|
|
|
949
786
|
loc,
|
|
950
787
|
};
|
|
951
788
|
}
|
|
952
|
-
// Island-backed globals (parseFloat, isFinite): the engine's own
|
|
953
789
|
// global function executes — callFn(globalGet(name)) — and the
|
|
954
790
|
// result exits to the declared static type. A user function
|
|
955
791
|
// shadowing the name has a different, non-stdlib symbol.
|
|
956
|
-
const islFn = lowerer.
|
|
792
|
+
const islFn = lowerer.stdlibGlobalFnOf(expr.expression);
|
|
957
793
|
if (islFn && expr.arguments.length !== islFn.args.length) {
|
|
958
794
|
const name = expr.expression.text;
|
|
959
795
|
lowerer.noLowering(`${name} with ${expr.arguments.length} argument${expr.arguments.length === 1 ? "" : "s"}`, expr);
|
|
@@ -961,31 +797,14 @@ export function lowerCall(lowerer, expr) {
|
|
|
961
797
|
if (islFn && expr.arguments.length === islFn.args.length) {
|
|
962
798
|
// The static forms above already took the exactly-typed argument
|
|
963
799
|
// (a string for parseFloat, a number for isFinite): name the
|
|
964
|
-
// argument type that
|
|
965
|
-
//
|
|
966
|
-
//
|
|
967
|
-
const argText =
|
|
800
|
+
// argument type that refused the call, so the message states the
|
|
801
|
+
// condition rather than reading as if the global itself were
|
|
802
|
+
// unsupported.
|
|
803
|
+
const argText = loweredArgumentText(lowerer, expr.arguments[0]);
|
|
968
804
|
const exact = expr.expression.text === "isFinite" ? "number" : "string";
|
|
969
|
-
lowerer.
|
|
970
|
-
? "convert the argument explicitly first (for example String(x), or narrow the union)
|
|
971
|
-
: "
|
|
972
|
-
const callee = {
|
|
973
|
-
kind: "jsOp",
|
|
974
|
-
op: "globalGet",
|
|
975
|
-
name: expr.expression.text,
|
|
976
|
-
args: [],
|
|
977
|
-
type: JSVAL,
|
|
978
|
-
loc,
|
|
979
|
-
};
|
|
980
|
-
const args = expr.arguments.map((a) => lowerer.jsvalIn(lowerer.lowerExpr(a), a));
|
|
981
|
-
const result = {
|
|
982
|
-
kind: "jsOp",
|
|
983
|
-
op: "callFn",
|
|
984
|
-
args: [callee, ...args],
|
|
985
|
-
type: JSVAL,
|
|
986
|
-
loc,
|
|
987
|
-
};
|
|
988
|
-
return { kind: "jsExit", value: result, type: islFn.ret, loc };
|
|
805
|
+
lowerer.refuseUnsupportedApi(`'${expr.expression.text}' with a '${argText}' argument`, expr, exact === "string"
|
|
806
|
+
? "only a string argument compiles statically: convert the argument explicitly first (for example String(x), or narrow the union)"
|
|
807
|
+
: "only a number argument compiles statically: narrow the argument to a number first");
|
|
989
808
|
}
|
|
990
809
|
}
|
|
991
810
|
// A TYPE-GUARD call on a catch binding (`isErrnoException(err)` —
|
|
@@ -1253,8 +1072,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
1253
1072
|
lowerPromiseAllTupleCall(lowerer, expr, expr.expression) ??
|
|
1254
1073
|
lowerer.lowerPromiseStaticCall(expr, expr.expression) ??
|
|
1255
1074
|
lowerPromiseRejectCall(lowerer, expr, expr.expression) ??
|
|
1256
|
-
// Before the island path: regex-argument replace/replaceAll/split
|
|
1257
|
-
// lower STATICALLY; only the string-pattern overloads are island.
|
|
1258
1075
|
lowerRegexMethodCallWithOptionalArg(lowerer, expr, expr.expression) ??
|
|
1259
1076
|
lowerUrlStaticCall(lowerer, expr, expr.expression) ??
|
|
1260
1077
|
lowerer.lowerUrlMethodCall(expr, expr.expression) ??
|
|
@@ -1303,7 +1120,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
1303
1120
|
lowerStringPrototypeCall(lowerer, expr, expr.expression) ??
|
|
1304
1121
|
lowerStringMethodCallWithOptionalArgs(lowerer, expr, expr.expression) ??
|
|
1305
1122
|
// Typed-array/Buffer receivers and the Buffer statics — before the
|
|
1306
|
-
// island path (bytes never cross the boundary).
|
|
1307
1123
|
lowerer.lowerBytesMethodCall(expr, expr.expression) ??
|
|
1308
1124
|
lowerBytesStaticCall(lowerer, expr, expr.expression) ??
|
|
1309
1125
|
lowerBufferStaticCallWithNarrowedArg(lowerer, expr, expr.expression) ??
|
|
@@ -1311,7 +1127,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
1311
1127
|
// stdlib chokepoint claims the member).
|
|
1312
1128
|
lowerStreamStaticCall(lowerer, expr, expr.expression) ??
|
|
1313
1129
|
// Primitive toString calls, including numeric radices, use the
|
|
1314
|
-
// native formatters before the island method path.
|
|
1315
1130
|
lowerNumberToStringCall(lowerer, expr, expr.expression) ??
|
|
1316
1131
|
// Union receivers whose every arm has a text — the ngrok
|
|
1317
1132
|
// `(chunk: Buffer | string) => chunk.toString()` idiom.
|
|
@@ -1320,31 +1135,23 @@ export function lowerCall(lowerer, expr) {
|
|
|
1320
1135
|
// override-free program classes — "[object Object]", folded.
|
|
1321
1136
|
lowerDefaultToStringCall(lowerer, expr, expr.expression) ??
|
|
1322
1137
|
// The remaining primitive prototype statics — toExponential(),
|
|
1323
|
-
// both toFixed() forms, hasOwnProperty over literal keys.
|
|
1324
|
-
// the island path. Optional-chain spellings first enter the chain
|
|
1325
|
-
// machinery above, then re-enter here with a narrowed chainRecv.
|
|
1138
|
+
// both toFixed() forms, hasOwnProperty over literal keys.
|
|
1326
1139
|
lowerPrimitiveProtoCall(lowerer, expr, expr.expression.expression, expr.expression.name.text, lowerer.checker.getSymbolAtLocation(expr.expression.name)) ??
|
|
1327
1140
|
// hasOwnProperty on a program class CONSTRUCTOR — own statics are
|
|
1328
1141
|
// compile-time-known, so a literal key folds to a constant.
|
|
1329
1142
|
lowerClassHasOwnPropertyCall(lowerer, expr, expr.expression) ??
|
|
1330
1143
|
lowerObjectOwnMethodCall(lowerer, expr, expr.expression) ??
|
|
1331
|
-
// Response constructor
|
|
1332
|
-
//
|
|
1333
|
-
// and generic-call fallbacks (Response.json otherwise reports the
|
|
1334
|
-
// generic SC1090 fence).
|
|
1144
|
+
// Refuse Response constructor operations before generic-call
|
|
1145
|
+
// fallbacks can report an unrelated SC1090 diagnostic.
|
|
1335
1146
|
lowerer.fenceUnsupportedFetchConstructorMember(expr.expression) ??
|
|
1336
1147
|
// Static fetch responses are checked-dynamic handles, but the
|
|
1337
1148
|
// adopted undici declaration exposes a wider API than that handle.
|
|
1338
|
-
//
|
|
1339
|
-
// dyn receiver path can compile them into a runtime missing-method
|
|
1340
|
-
// failure. Dynamic-only rows pass through these checks unchanged.
|
|
1149
|
+
// Refuse unsupported members before generic checked-value dispatch.
|
|
1341
1150
|
lowerer.fenceStaticResponseMember(expr.expression, "call") ??
|
|
1342
1151
|
lowerer.fenceStaticHeadersMember(expr.expression, "call") ??
|
|
1343
1152
|
lowerer.fenceStaticReadableStreamMember(expr.expression, "call") ??
|
|
1344
|
-
lowerer.
|
|
1153
|
+
lowerer.lowerStdlibMethodCall(expr, expr.expression) ??
|
|
1345
1154
|
// Dyn receivers (JSON.parse-derived `unknown`/`any` values) —
|
|
1346
|
-
// validated-extract, then the static machinery. After the island
|
|
1347
|
-
// path (jsval receivers belong there), before the fences.
|
|
1348
1155
|
lowerDynReceiverMethodCall(lowerer, expr, expr.expression) ??
|
|
1349
1156
|
// Narrowing filters (inferred predicates, filter(Boolean)) claim
|
|
1350
1157
|
// their calls before the generic array HOF path types the result
|
|
@@ -1471,9 +1278,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
1471
1278
|
const symbolMethod = lowerClassSymbolMethodCall(lowerer, expr);
|
|
1472
1279
|
if (symbolMethod)
|
|
1473
1280
|
return symbolMethod;
|
|
1474
|
-
const headersIterator = lowerer.lowerDynamicHeadersIteratorCall(expr, expr.expression);
|
|
1475
|
-
if (headersIterator)
|
|
1476
|
-
return headersIterator;
|
|
1477
1281
|
lowerer.fenceUnsupportedFetchConstructorMember(expr.expression);
|
|
1478
1282
|
lowerer.fenceStaticResponseMember(expr.expression, "call");
|
|
1479
1283
|
lowerer.fenceStaticHeadersMember(expr.expression, "call");
|
|
@@ -1662,34 +1466,6 @@ export function lowerCall(lowerer, expr) {
|
|
|
1662
1466
|
if (spreadServed)
|
|
1663
1467
|
return spreadServed;
|
|
1664
1468
|
}
|
|
1665
|
-
// An ISLAND-REST func value called directly (`f(1, 2)` where f is the
|
|
1666
|
-
// --dynamic `(...args) =>` lambda): the type SPELLS its trailing
|
|
1667
|
-
// engine-array param — complete the call exactly like completeArgs'
|
|
1668
|
-
// island pack (fixed slots positionally, missing ones with the
|
|
1669
|
-
// engine's undefined, the surplus marshaled into one fresh engine
|
|
1670
|
-
// array). JS arity, no runtime machinery.
|
|
1671
|
-
if (callee.type.rest === true &&
|
|
1672
|
-
callee.type.restAbi === "jsval" &&
|
|
1673
|
-
callee.type.params.length >= 1 &&
|
|
1674
|
-
callee.type.params[callee.type.params.length - 1].kind === "jsval" &&
|
|
1675
|
-
!expr.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
1676
|
-
const fixed = callee.type.params.slice(0, -1);
|
|
1677
|
-
const args = fixed.map((p, i) => {
|
|
1678
|
-
const a = expr.arguments[i];
|
|
1679
|
-
if (a)
|
|
1680
|
-
return lowerer.lowerExprExpecting(a, p);
|
|
1681
|
-
const absent = omittedArgFor(lowerer, p, loc);
|
|
1682
|
-
if (!absent) {
|
|
1683
|
-
lowerer.unsupported("SC1090", expr, "calls omitting a non-optional parameter of the callee's type");
|
|
1684
|
-
}
|
|
1685
|
-
return absent;
|
|
1686
|
-
});
|
|
1687
|
-
const restArgs = expr.arguments
|
|
1688
|
-
.slice(fixed.length)
|
|
1689
|
-
.map((a) => lowerer.lowerExprExpecting(a, JSVAL));
|
|
1690
|
-
args.push({ kind: "jsOp", op: "arrLit", args: restArgs, type: JSVAL, loc });
|
|
1691
|
-
return { kind: "callValue", callee, args, type: callee.type.ret, loc };
|
|
1692
|
-
}
|
|
1693
1469
|
// A JS call with MORE arguments than the callee's lowered signature
|
|
1694
1470
|
// (`cb(1, 'x')` where the mustCall wrapper's inferred type declared
|
|
1695
1471
|
// fewer params — tsc's JS world doesn't police arity): ride the
|
|
@@ -2203,8 +1979,7 @@ const ARRAY_BORROW_METHODS = new Set([
|
|
|
2203
1979
|
"some",
|
|
2204
1980
|
]);
|
|
2205
1981
|
function lowerArrayPrototypeBorrowCall(lowerer, call, access) {
|
|
2206
|
-
if (
|
|
2207
|
-
!isJsSourceFile(call.getSourceFile()) ||
|
|
1982
|
+
if (!isJsSourceFile(call.getSourceFile()) ||
|
|
2208
1983
|
call.questionDotToken ||
|
|
2209
1984
|
access.questionDotToken ||
|
|
2210
1985
|
access.name.text !== "call" ||
|
|
@@ -2238,9 +2013,7 @@ function lowerArrayPrototypeBorrowCall(lowerer, call, access) {
|
|
|
2238
2013
|
};
|
|
2239
2014
|
}
|
|
2240
2015
|
function lowerObjectOwnPrototypeCall(lowerer, call, access) {
|
|
2241
|
-
if (
|
|
2242
|
-
access.name.text !== "call" ||
|
|
2243
|
-
!ts.isPropertyAccessExpression(access.expression))
|
|
2016
|
+
if (access.name.text !== "call" || !ts.isPropertyAccessExpression(access.expression))
|
|
2244
2017
|
return null;
|
|
2245
2018
|
const method = access.expression;
|
|
2246
2019
|
const enumerable = method.name.text === "propertyIsEnumerable";
|
|
@@ -2257,8 +2030,7 @@ function lowerObjectOwnPrototypeCall(lowerer, call, access) {
|
|
|
2257
2030
|
}
|
|
2258
2031
|
function lowerObjectOwnMethodCall(lowerer, call, access) {
|
|
2259
2032
|
const method = access.name.text;
|
|
2260
|
-
if (
|
|
2261
|
-
call.questionDotToken ||
|
|
2033
|
+
if (call.questionDotToken ||
|
|
2262
2034
|
access.questionDotToken ||
|
|
2263
2035
|
(method !== "hasOwnProperty" && method !== "propertyIsEnumerable") ||
|
|
2264
2036
|
call.arguments.some(ts.isSpreadElement))
|
|
@@ -2476,9 +2248,7 @@ function lowerObjectOwnCall(lowerer, call, receiverNode, keyNode, extraNodes, me
|
|
|
2476
2248
|
return { kind: "seqExpr", stmts, result, type: BOOL, loc };
|
|
2477
2249
|
}
|
|
2478
2250
|
function lowerObjectPrototypeCall(lowerer, call, access) {
|
|
2479
|
-
if (
|
|
2480
|
-
access.name.text !== "call" ||
|
|
2481
|
-
!ts.isPropertyAccessExpression(access.expression))
|
|
2251
|
+
if (access.name.text !== "call" || !ts.isPropertyAccessExpression(access.expression))
|
|
2482
2252
|
return null;
|
|
2483
2253
|
const method = access.expression;
|
|
2484
2254
|
const prototype = method.expression;
|
|
@@ -3577,12 +3347,11 @@ function lowerArrayIsArrayCall(lowerer, call, access) {
|
|
|
3577
3347
|
// (`Array.isArray(tlds)` on `string | readonly string[]` — the
|
|
3578
3348
|
// narrowing test tsc's control flow then builds on); several array
|
|
3579
3349
|
// arms OR their tag tests, and zero arms fold to false — both only
|
|
3580
|
-
// over side-effect-free reads
|
|
3581
|
-
//
|
|
3582
|
-
// static tag answer and keep the narrow-first fence.
|
|
3350
|
+
// over side-effect-free reads. Opaque arms have no static tag answer
|
|
3351
|
+
// and keep the narrow-first fence.
|
|
3583
3352
|
const unionId = arg.type.unionId;
|
|
3584
3353
|
const def = lowerer.unions.get(unionId);
|
|
3585
|
-
const opaque = !def || def.arms.some((a) => a.kind === "dyn" || a.kind === "caught"
|
|
3354
|
+
const opaque = !def || def.arms.some((a) => a.kind === "dyn" || a.kind === "caught");
|
|
3586
3355
|
const arrayTags = lowerer.arrayValueTags(arg.type.unionId);
|
|
3587
3356
|
const freeRead = arg.kind === "varRef" || arg.kind === "recordGet" || arg.kind === "fieldGet";
|
|
3588
3357
|
if (!opaque && arrayTags.length === 1) {
|
|
@@ -3614,7 +3383,7 @@ function lowerArrayIsArrayCall(lowerer, call, access) {
|
|
|
3614
3383
|
}
|
|
3615
3384
|
lowerer.unsupported("SC1090", argNode, `Array.isArray on '${lowerer.fmt(arg.type)}' values (narrow first: check a discriminant field, or compare with '!== undefined'/'!== null' for unit arms)`);
|
|
3616
3385
|
}
|
|
3617
|
-
if (arg.type.kind === "
|
|
3386
|
+
if (arg.type.kind === "caught")
|
|
3618
3387
|
return null;
|
|
3619
3388
|
if (arg.kind === "varRef" || arg.kind === "recordGet" || arg.kind === "fieldGet") {
|
|
3620
3389
|
return { kind: "boolLit", value: lowerer.isArrayValueType(arg.type), type: BOOL, loc };
|
|
@@ -4151,24 +3920,13 @@ function reconcileOverloadReturn(lowerer, expr, call) {
|
|
|
4151
3920
|
// follows maybeNarrow's stance — a unit arm has no payload to extract.
|
|
4152
3921
|
if (!rt || rt.kind === "void" || isUnitType(rt) || typeEquals(rt, call.type))
|
|
4153
3922
|
return call;
|
|
4154
|
-
// An ISLAND-valued implementation return (`any` under --dynamic): the
|
|
4155
3923
|
// resolved overload's return type is a claim tsc never checked against
|
|
4156
3924
|
// the body — extracting it HERE would throw the boundary TypeError
|
|
4157
3925
|
// where Node just lets the value flow (functionOverloads35: the
|
|
4158
3926
|
// implementation returns its object argument under a number-returning
|
|
4159
3927
|
// overload signature; Node exits clean). The checker-trust trap keeps
|
|
4160
3928
|
// governing edges the checker actually vouches for; this edge it never
|
|
4161
|
-
// did. The
|
|
4162
|
-
// (uncheckedOverloadHandleCall's rule at the declaration sites), and
|
|
4163
|
-
// uses dispatch to engine ops like any island value.
|
|
4164
|
-
if (call.type.kind === "jsval")
|
|
4165
|
-
return call;
|
|
4166
|
-
// The CHECKED-DYNAMIC twin of the island rule: an `any`-returning
|
|
4167
|
-
// implementation under a typed overload signature is the same
|
|
4168
|
-
// never-vouched-for edge (functionOverloads35's shape without
|
|
4169
|
-
// --dynamic) — extracting the resolved type HERE would throw the
|
|
4170
|
-
// boundary TypeError where Node lets the value flow. Uses stay
|
|
4171
|
-
// checked per read like every any-origin value.
|
|
3929
|
+
// did. The checked value stays in bindings and is validated per use.
|
|
4172
3930
|
if (call.type.kind === "dyn")
|
|
4173
3931
|
return call;
|
|
4174
3932
|
if (call.type.kind === "union" && rt.kind !== "union") {
|
|
@@ -4223,24 +3981,6 @@ function templateEscapesValid(raw) {
|
|
|
4223
3981
|
}
|
|
4224
3982
|
return true;
|
|
4225
3983
|
}
|
|
4226
|
-
/** Tagged templates `tag\`a${x}b\`` — ES's call: tag(strings, ...values).
|
|
4227
|
-
* The strings object is a per-SITE lazily initialized hidden array global,
|
|
4228
|
-
* so the spec's identity contract holds — the same site evaluated twice
|
|
4229
|
-
* hands the tag the SAME array; two sites never share. TemplateStringsArray
|
|
4230
|
-
* maps to string[] (type-mapper.ts), so the array rides the ordinary
|
|
4231
|
-
* slot-directed coercion into whatever the tag's first parameter wants
|
|
4232
|
-
* — string[] exactly, an `any` slot through the dyn boundary, a rest
|
|
4233
|
-
* pack's first element. Checked tags receive frozen cooked and raw
|
|
4234
|
-
* arrays with the standard nonenumerable `.raw` descriptor. Typed direct
|
|
4235
|
-
* tags retain the string-array representation.
|
|
4236
|
-
*
|
|
4237
|
-
* Tag forms: a top-level declared function (the direct-call fast path —
|
|
4238
|
-
* overload sets reconcile through the resolved signature exactly like
|
|
4239
|
-
* plain calls), an island value under --dynamic (engine method/function
|
|
4240
|
-
* call with the engine's cooked/raw template object), and
|
|
4241
|
-
* a checked-dynamic value (the dynCall boundary — a non-function tag
|
|
4242
|
-
* throws Node's catchable TypeError). Everything else — generic tags,
|
|
4243
|
-
* method tags, function-value bindings — fences by name. */
|
|
4244
3984
|
export function lowerTaggedTemplate(lowerer, expr) {
|
|
4245
3985
|
const loc = locOf(expr);
|
|
4246
3986
|
const pieces = ts.isNoSubstitutionTemplateLiteral(expr.template)
|
|
@@ -4255,51 +3995,6 @@ export function lowerTaggedTemplate(lowerer, expr) {
|
|
|
4255
3995
|
const values = ts.isNoSubstitutionTemplateLiteral(expr.template)
|
|
4256
3996
|
? []
|
|
4257
3997
|
: expr.template.templateSpans.map((s) => s.expression);
|
|
4258
|
-
// Island tags (--dynamic): the engine call forms, mirroring lowerCall's
|
|
4259
|
-
// island paths — a property-access tag is a method call (this = the
|
|
4260
|
-
// receiver, JS-exact), any other island tag a function call. The
|
|
4261
|
-
// strings argument builds ENGINE-NATIVE with its `.raw` property (the
|
|
4262
|
-
// tplStrings op): a JSON marshal would drop `.raw`, and tags dispatch
|
|
4263
|
-
// on it (the outdent idiom treats a raw-less argument as its OPTIONS
|
|
4264
|
-
// form and answers a function). A fresh array per evaluation — tags
|
|
4265
|
-
// caching by strings identity re-compute per call (SEMANTICS.md).
|
|
4266
|
-
const islandStrings = () => ({
|
|
4267
|
-
kind: "jsOp",
|
|
4268
|
-
op: "tplStrings",
|
|
4269
|
-
args: [
|
|
4270
|
-
...pieces.map((p) => ({
|
|
4271
|
-
kind: "jsMarshal",
|
|
4272
|
-
value: { kind: "strLit", value: p.text, type: STRING, loc },
|
|
4273
|
-
type: JSVAL,
|
|
4274
|
-
loc,
|
|
4275
|
-
})),
|
|
4276
|
-
...pieces.map((p) => ({
|
|
4277
|
-
kind: "jsMarshal",
|
|
4278
|
-
value: { kind: "strLit", value: templateRawTextOf(p), type: STRING, loc },
|
|
4279
|
-
type: JSVAL,
|
|
4280
|
-
loc,
|
|
4281
|
-
})),
|
|
4282
|
-
],
|
|
4283
|
-
type: JSVAL,
|
|
4284
|
-
loc,
|
|
4285
|
-
});
|
|
4286
|
-
if (ts.isPropertyAccessExpression(expr.tag) && lowerer.isIslandExpr(expr.tag.expression)) {
|
|
4287
|
-
const receiver = lowerer.lowerExpr(expr.tag.expression);
|
|
4288
|
-
const args = [islandStrings(), ...values.map((a) => lowerer.jsvalIn(lowerer.lowerExpr(a), a))];
|
|
4289
|
-
return {
|
|
4290
|
-
kind: "jsOp",
|
|
4291
|
-
op: "callMethod",
|
|
4292
|
-
name: expr.tag.name.text,
|
|
4293
|
-
args: [receiver, ...args],
|
|
4294
|
-
type: JSVAL,
|
|
4295
|
-
loc,
|
|
4296
|
-
};
|
|
4297
|
-
}
|
|
4298
|
-
if (lowerer.isIslandExpr(expr.tag)) {
|
|
4299
|
-
const callee = lowerer.lowerExpr(expr.tag);
|
|
4300
|
-
const args = [islandStrings(), ...values.map((a) => lowerer.jsvalIn(lowerer.lowerExpr(a), a))];
|
|
4301
|
-
return { kind: "jsOp", op: "callFn", args: [callee, ...args], type: JSVAL, loc };
|
|
4302
|
-
}
|
|
4303
3998
|
// Direct call of a top-level declared function — the plain-call fast
|
|
4304
3999
|
// path with the strings array as the leading completed argument.
|
|
4305
4000
|
if (ts.isIdentifier(expr.tag) && !lowerer.isSelfReference(expr.tag)) {
|
|
@@ -4493,20 +4188,14 @@ function loweredTemplateStrings(lowerer, expr, cooked, loc, raw) {
|
|
|
4493
4188
|
* wrapper's await re-throws it), and a handler throw rejects the
|
|
4494
4189
|
* result — the spec's onFulfilled rules by construction. Null for
|
|
4495
4190
|
* non-promise receivers and other members. */
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
* `import("...")` call is the island promise itself; an identifier bound
|
|
4499
|
-
* to a promise-of-jsval local or module global answers the binding's
|
|
4500
|
-
* type. Null everywhere else. */
|
|
4501
|
-
function islandPromiseStorageTypeOf(lowerer, e) {
|
|
4502
|
-
const direct = lowerer.dynamic ? importCallHandleType(e) : staticImportNamespaceType(lowerer, e);
|
|
4191
|
+
function modulePromiseStorageTypeOf(lowerer, e) {
|
|
4192
|
+
const direct = staticImportNamespaceType(lowerer, e);
|
|
4503
4193
|
if (direct?.kind === "promise")
|
|
4504
4194
|
return direct;
|
|
4505
4195
|
if (!ts.isIdentifier(e))
|
|
4506
4196
|
return null;
|
|
4507
4197
|
const local = lowerer.resolveLocal(e);
|
|
4508
|
-
if (local?.type.kind === "promise" &&
|
|
4509
|
-
(local.type.inner.kind === "jsval" || local.type.inner.kind === "moduleNs"))
|
|
4198
|
+
if (local?.type.kind === "promise" && local.type.inner.kind === "moduleNs")
|
|
4510
4199
|
return local.type;
|
|
4511
4200
|
if (local)
|
|
4512
4201
|
return null;
|
|
@@ -4514,27 +4203,10 @@ function islandPromiseStorageTypeOf(lowerer, e) {
|
|
|
4514
4203
|
if (sym && sym.flags & ts.SymbolFlags.Alias)
|
|
4515
4204
|
sym = lowerer.checker.getAliasedSymbol(sym);
|
|
4516
4205
|
const g = sym ? lowerer.globalsBySymbol.get(sym) : undefined;
|
|
4517
|
-
if (g?.type.kind === "promise" &&
|
|
4518
|
-
(g.type.inner.kind === "jsval" || g.type.inner.kind === "moduleNs"))
|
|
4206
|
+
if (g?.type.kind === "promise" && g.type.inner.kind === "moduleNs")
|
|
4519
4207
|
return g.type;
|
|
4520
4208
|
return null;
|
|
4521
4209
|
}
|
|
4522
|
-
/** Marks an INLINE then-handler's unannotated identifier parameters for
|
|
4523
|
-
* the island-handle (jsval) binding type — paramShape's early-out. Only
|
|
4524
|
-
* the inline arrow/function forms qualify: a handler VALUE keeps its own
|
|
4525
|
-
* declared signature (and the settled-type equality check below). */
|
|
4526
|
-
function markJsvalHandlerParams(lowerer, handler) {
|
|
4527
|
-
let e = handler;
|
|
4528
|
-
while (ts.isParenthesizedExpression(e))
|
|
4529
|
-
e = e.expression;
|
|
4530
|
-
if (!ts.isArrowFunction(e) && !ts.isFunctionExpression(e))
|
|
4531
|
-
return;
|
|
4532
|
-
for (const p of e.parameters) {
|
|
4533
|
-
if (ts.isIdentifier(p.name) && p.type === undefined && !p.dotDotDotToken && !p.initializer) {
|
|
4534
|
-
lowerer.jsvalParamOverrides.add(p);
|
|
4535
|
-
}
|
|
4536
|
-
}
|
|
4537
|
-
}
|
|
4538
4210
|
function markModuleNsHandlerParams(lowerer, handler, type) {
|
|
4539
4211
|
let e = handler;
|
|
4540
4212
|
while (ts.isParenthesizedExpression(e))
|
|
@@ -4556,13 +4228,10 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4556
4228
|
let recvT = lowerer.mapTypeOf(lowerer.typeOf(access.expression)) ??
|
|
4557
4229
|
dynFallbackType(lowerer, access.expression, lowerer.typeOf(access.expression));
|
|
4558
4230
|
// A dynamic-import promise under an unmappable checker type
|
|
4559
|
-
// (`Promise<typeof import("./m")>`
|
|
4560
|
-
//
|
|
4561
|
-
// (importCallHandleType / the island-HANDLE var rules), so the storage
|
|
4562
|
-
// type is the receiver's truth. Direct `import("./m").then(...)`
|
|
4563
|
-
// spells the same promise with no binding at all.
|
|
4231
|
+
// (`Promise<typeof import("./m")>`) uses the module promise's native
|
|
4232
|
+
// storage type. Direct `import("./m").then(...)` needs no binding.
|
|
4564
4233
|
if (!recvT)
|
|
4565
|
-
recvT =
|
|
4234
|
+
recvT = modulePromiseStorageTypeOf(lowerer, access.expression);
|
|
4566
4235
|
if (recvT?.kind !== "promise")
|
|
4567
4236
|
return null;
|
|
4568
4237
|
if (!lowerer.isStdlibMember(access))
|
|
@@ -4596,20 +4265,6 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4596
4265
|
}
|
|
4597
4266
|
// The receiver evaluates FIRST, in the enclosing function, like JS.
|
|
4598
4267
|
let receiver = lowerer.lowerExpr(access.expression);
|
|
4599
|
-
// A PACKAGE-returned promise lowers as an island value (jsval): the
|
|
4600
|
-
// promise lives in the engine, so bridge it — a static promise the
|
|
4601
|
-
// engine promise settles (fulfillment = the retained handle or void,
|
|
4602
|
-
// rejection = the bridged reason) — and desugar over the BRIDGE
|
|
4603
|
-
// exactly like a native receiver. This is the classic CLI entry line,
|
|
4604
|
-
// `program.parseAsync(process.argv).catch(handler)`.
|
|
4605
|
-
if (receiver.type.kind === "jsval") {
|
|
4606
|
-
receiver = {
|
|
4607
|
-
kind: "jsBridgePromise",
|
|
4608
|
-
value: receiver,
|
|
4609
|
-
type: { kind: "promise", inner: recvT.inner.kind === "void" ? VOID : JSVAL },
|
|
4610
|
-
loc,
|
|
4611
|
-
};
|
|
4612
|
-
}
|
|
4613
4268
|
if (receiver.type.kind === "dyn" && lowerer.dynConvertible(recvT))
|
|
4614
4269
|
receiver = lowerer.coerceInto(access.expression, receiver, recvT);
|
|
4615
4270
|
if (receiver.type.kind !== "promise") {
|
|
@@ -4617,9 +4272,8 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4617
4272
|
// a lowering gap, named rather than ICEd on.
|
|
4618
4273
|
lowerer.unsupported("SC1090", call, `'.${member}' on this receiver`);
|
|
4619
4274
|
}
|
|
4620
|
-
//
|
|
4621
|
-
//
|
|
4622
|
-
// typed uses of the settled value exit through coerceInto below.
|
|
4275
|
+
// Wrapper types follow the receiver's promise type; typed uses of the
|
|
4276
|
+
// settled value convert through coerceInto below.
|
|
4623
4277
|
const promT = receiver.type;
|
|
4624
4278
|
const inner = promT.inner;
|
|
4625
4279
|
if (passthrough) {
|
|
@@ -4684,8 +4338,6 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4684
4338
|
lowerer.noLowering("then with these handlers", call, "the result must be a representable promise");
|
|
4685
4339
|
}
|
|
4686
4340
|
const R = resultT.inner;
|
|
4687
|
-
if (!fulfilledAbsent && inner.kind === "jsval")
|
|
4688
|
-
markJsvalHandlerParams(lowerer, fulfilledNode);
|
|
4689
4341
|
if (!fulfilledAbsent && inner.kind === "moduleNs")
|
|
4690
4342
|
markModuleNsHandlerParams(lowerer, fulfilledNode, inner);
|
|
4691
4343
|
const boxHandler = (node, allowDirect) => {
|
|
@@ -4863,12 +4515,8 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
4863
4515
|
lowerer.fnStack.pop();
|
|
4864
4516
|
}
|
|
4865
4517
|
}
|
|
4866
|
-
// The settled value is an island HANDLE: an inline handler's
|
|
4867
|
-
// unannotated parameter binds it as jsval, whatever the checker's
|
|
4868
4518
|
// contextual type spelled (a module-namespace type has no mapping —
|
|
4869
4519
|
// the handle is the value's only story, isIslandExpr's local rule).
|
|
4870
|
-
if (inner.kind === "jsval")
|
|
4871
|
-
markJsvalHandlerParams(lowerer, call.arguments[0]);
|
|
4872
4520
|
if (inner.kind === "moduleNs")
|
|
4873
4521
|
markModuleNsHandlerParams(lowerer, call.arguments[0], inner);
|
|
4874
4522
|
let cb = lowerer.lowerExpr(call.arguments[0]);
|
|
@@ -5388,18 +5036,6 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
5388
5036
|
// with the dyn undefined.
|
|
5389
5037
|
catchBody.push({ kind: "return", value: dynUndefinedExpr(loc), loc });
|
|
5390
5038
|
}
|
|
5391
|
-
else if (R.kind === "jsval") {
|
|
5392
|
-
// A package-typed result (Promise<Command> — the parseAsync().catch
|
|
5393
|
-
// entry line): falling off the handler's end resolves with
|
|
5394
|
-
// undefined, which on the island side is the engine's own
|
|
5395
|
-
// undefined. Also what makes a never-returning handler (ending in
|
|
5396
|
-
// process.exit) satisfy the always-returns analysis.
|
|
5397
|
-
catchBody.push({
|
|
5398
|
-
kind: "return",
|
|
5399
|
-
value: { kind: "jsOp", op: "globalGet", name: "undefined", args: [], type: JSVAL, loc },
|
|
5400
|
-
loc,
|
|
5401
|
-
});
|
|
5402
|
-
}
|
|
5403
5039
|
const ctx = lowerer.ctx;
|
|
5404
5040
|
const lifted = {
|
|
5405
5041
|
name: fnName,
|
|
@@ -5497,7 +5133,7 @@ export function lowerFilterNarrowCall(lowerer, call, access) {
|
|
|
5497
5133
|
// ToBoolean must be answerable per element (dyn/caught arms are not).
|
|
5498
5134
|
if (elem.kind === "union")
|
|
5499
5135
|
lowerer.requireTruthyUnion(elem.unionId, argNode);
|
|
5500
|
-
if (elem.kind === "dyn" || elem.kind === "
|
|
5136
|
+
if (elem.kind === "dyn" || elem.kind === "void" || isUnitType(elem)) {
|
|
5501
5137
|
lowerer.badType(argNode, lowerer.typeOf(argNode));
|
|
5502
5138
|
}
|
|
5503
5139
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
@@ -6055,8 +5691,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6055
5691
|
member === "getOwnPropertySymbols" ||
|
|
6056
5692
|
member === "getOwnPropertyDescriptors") &&
|
|
6057
5693
|
call.arguments.length === 1 &&
|
|
6058
|
-
!call.arguments.some(ts.isSpreadElement)
|
|
6059
|
-
!lowerer.dynamic) {
|
|
5694
|
+
!call.arguments.some(ts.isSpreadElement)) {
|
|
6060
5695
|
let object = lowerer.lowerExpr(call.arguments[0]);
|
|
6061
5696
|
if (object.type.kind === "string" ||
|
|
6062
5697
|
object.type.kind === "f64" ||
|
|
@@ -6078,8 +5713,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6078
5713
|
}
|
|
6079
5714
|
if ((member === "getPrototypeOf" || member === "setPrototypeOf") &&
|
|
6080
5715
|
call.arguments.length === (member === "getPrototypeOf" ? 1 : 2) &&
|
|
6081
|
-
!call.arguments.some(ts.isSpreadElement)
|
|
6082
|
-
!lowerer.dynamic) {
|
|
5716
|
+
!call.arguments.some(ts.isSpreadElement)) {
|
|
6083
5717
|
let object = lowerer.lowerExpr(call.arguments[0]);
|
|
6084
5718
|
if (object.type.kind === "func") {
|
|
6085
5719
|
const fnName = jsFuncNameOf(call.arguments[0], lowerer);
|
|
@@ -6159,7 +5793,6 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6159
5793
|
// identity. Statically DISJOINT kind pairs answer the constant false
|
|
6160
5794
|
// with the operands still evaluated (tsc admits any pair — Object.is
|
|
6161
5795
|
// is (any, any) — and JS evaluates the arguments either way).
|
|
6162
|
-
// dyn/jsval operands keep strict equality's stance: validate first.
|
|
6163
5796
|
if (member === "is") {
|
|
6164
5797
|
if (call.arguments.length !== 2 || call.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
6165
5798
|
lowerer.noLowering(`Object.is with ${call.arguments.length} arguments`, call, "exactly two arguments are the lowered form (JS treats a missing one as undefined — pass it explicitly)");
|
|
@@ -6183,7 +5816,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6183
5816
|
const unitTest = lowerer.lowerUnitComparison(left, right, false, loc);
|
|
6184
5817
|
if (unitTest)
|
|
6185
5818
|
return unitTest;
|
|
6186
|
-
if (lk === "dyn" || rk === "dyn"
|
|
5819
|
+
if (lk === "dyn" || rk === "dyn") {
|
|
6187
5820
|
return {
|
|
6188
5821
|
kind: "libCall",
|
|
6189
5822
|
fn: "dyn.sameValue",
|
|
@@ -6270,8 +5903,7 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6270
5903
|
lowerer.noLowering(`Object.is over '${lowerer.fmt(left.type)}' and '${lowerer.fmt(right.type)}' operands`, call, "the operands must share one comparable kind (numbers, strings, booleans, units, one union shape, or one reference type)");
|
|
6271
5904
|
}
|
|
6272
5905
|
// Native checked objects retain a live prototype and can install an
|
|
6273
|
-
// own-property descriptor table during creation.
|
|
6274
|
-
// use the engine's Object.create path below.
|
|
5906
|
+
// own-property descriptor table during creation.
|
|
6275
5907
|
if (member === "create") {
|
|
6276
5908
|
if (call.arguments.some((a) => ts.isSpreadElement(a))) {
|
|
6277
5909
|
lowerer.noLowering("Object.create with spread arguments", call);
|
|
@@ -6284,50 +5916,6 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6284
5916
|
while (ts.isParenthesizedExpression(protoNode))
|
|
6285
5917
|
protoNode = protoNode.expression;
|
|
6286
5918
|
const nullProto = protoNode.kind === ts.SyntaxKind.NullKeyword;
|
|
6287
|
-
if (lowerer.dynamic) {
|
|
6288
|
-
if (call.arguments.length === 2)
|
|
6289
|
-
lowerer.noLowering("Object.create with properties under --dynamic", call);
|
|
6290
|
-
// The checker types the result `any` — an ENGINE value under
|
|
6291
|
-
// --dynamic — and the engine's own Object.create answers with
|
|
6292
|
-
// REAL prototype semantics: reads delegate LIVE, writes shadow,
|
|
6293
|
-
// and inspect renders Node's exact shapes ("[Object: null
|
|
6294
|
-
// prototype]" included). null and engine-held (jsval) prototypes
|
|
6295
|
-
// route; checked-dynamic (dyn) prototypes keep the named fence —
|
|
6296
|
-
// their marshal into the engine is a DEEP COPY, so a later
|
|
6297
|
-
// prototype mutation would be invisible through the created
|
|
6298
|
-
// object where Node delegates live.
|
|
6299
|
-
const objectGlobal = () => ({
|
|
6300
|
-
kind: "jsOp",
|
|
6301
|
-
op: "globalGet",
|
|
6302
|
-
name: "Object",
|
|
6303
|
-
args: [],
|
|
6304
|
-
type: JSVAL,
|
|
6305
|
-
loc,
|
|
6306
|
-
});
|
|
6307
|
-
if (nullProto) {
|
|
6308
|
-
const nullIn = { kind: "jsOp", op: "nullLit", args: [], type: JSVAL, loc };
|
|
6309
|
-
return {
|
|
6310
|
-
kind: "jsOp",
|
|
6311
|
-
op: "callMethod",
|
|
6312
|
-
name: "create",
|
|
6313
|
-
args: [objectGlobal(), nullIn],
|
|
6314
|
-
type: JSVAL,
|
|
6315
|
-
loc,
|
|
6316
|
-
};
|
|
6317
|
-
}
|
|
6318
|
-
const proto = lowerer.lowerExpr(protoNode);
|
|
6319
|
-
if (proto.type.kind === "jsval") {
|
|
6320
|
-
return {
|
|
6321
|
-
kind: "jsOp",
|
|
6322
|
-
op: "callMethod",
|
|
6323
|
-
name: "create",
|
|
6324
|
-
args: [objectGlobal(), proto],
|
|
6325
|
-
type: JSVAL,
|
|
6326
|
-
loc,
|
|
6327
|
-
};
|
|
6328
|
-
}
|
|
6329
|
-
lowerer.noLowering(`Object.create over '${lowerer.fmt(proto.type)}' prototypes`, call, "prototype reads delegate LIVE in Node (mutating the prototype shows through the created object), which the boundary's deep copy cannot honor — only null and engine-held ('any') prototypes lower");
|
|
6330
|
-
}
|
|
6331
5919
|
if (nullProto && call.arguments.length === 1) {
|
|
6332
5920
|
return { kind: "libCall", fn: "dyn.objCreateNullProto", args: [], type: DYN, loc };
|
|
6333
5921
|
}
|
|
@@ -6978,7 +6566,6 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
6978
6566
|
}
|
|
6979
6567
|
// unknown[] uses the checked-dynamic array representation. Enumerate
|
|
6980
6568
|
// a live view of the record so values retain their identities and the
|
|
6981
|
-
// result never pretends to be a native vector or an island array.
|
|
6982
6569
|
const enumerationType = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
6983
6570
|
if ((member === "values" || member === "entries") &&
|
|
6984
6571
|
(enumerationType?.kind === "dyn" ||
|
|
@@ -7682,7 +7269,6 @@ function lowerObjLitGenericMethodCall(lowerer, call, access) {
|
|
|
7682
7269
|
const provablyNot = thisT !== null &&
|
|
7683
7270
|
thisT.kind !== "searchParams" &&
|
|
7684
7271
|
thisT.kind !== "dyn" &&
|
|
7685
|
-
thisT.kind !== "jsval" &&
|
|
7686
7272
|
(!thisArg ||
|
|
7687
7273
|
ts.isIdentifier(thisArg) ||
|
|
7688
7274
|
ts.isLiteralExpression(thisArg) ||
|
|
@@ -7938,8 +7524,14 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
7938
7524
|
});
|
|
7939
7525
|
let callee = target ? lowerer.fieldGetExpr(target, locOf(access), access) : null;
|
|
7940
7526
|
if (callee?.type.kind === "union" && callableType !== null) {
|
|
7941
|
-
|
|
7942
|
-
|
|
7527
|
+
// Calling a cleared callback field throws Node's call TypeError.
|
|
7528
|
+
const inPlace = checkedArmExtraction(lowerer, callee, lowerer.armTag(callee.type.unionId, callableType), callableType, () => `${access.getText()} is not a function`);
|
|
7529
|
+
const helper = inPlace
|
|
7530
|
+
? null
|
|
7531
|
+
: lowerer.narrowedArmHelper(callee.type.unionId, callableType, locOf(access));
|
|
7532
|
+
if (inPlace)
|
|
7533
|
+
callee = inPlace;
|
|
7534
|
+
else if (helper !== null) {
|
|
7943
7535
|
callee = lowerer.checkedNarrowCall(helper, callee, callableType, locOf(access));
|
|
7944
7536
|
}
|
|
7945
7537
|
}
|
|
@@ -8389,8 +7981,8 @@ function loweredArgumentText(lowerer, arg) {
|
|
|
8389
7981
|
}
|
|
8390
7982
|
/** The static global number parsers (parseInt/parseFloat/isNaN/isFinite),
|
|
8391
7983
|
* shared by the globals and their Number.* aliases. `call` blames arity
|
|
8392
|
-
* fences; null when the argument shape
|
|
8393
|
-
*
|
|
7984
|
+
* fences; null when the argument shape has no static form (the caller
|
|
7985
|
+
* reports the SC2012 refusal). */
|
|
8394
7986
|
export function lowerStaticNumberGlobal(lowerer, name, call, args, loc) {
|
|
8395
7987
|
if (name === "parseInt" || name === "isNaN") {
|
|
8396
7988
|
const maxArgs = name === "parseInt" ? 2 : 1;
|
|
@@ -8491,10 +8083,9 @@ export function lowerStaticNumberGlobal(lowerer, name, call, args, loc) {
|
|
|
8491
8083
|
// parseInt's siblings (num.parseFloat is ECMA 19.2.4's decimal-
|
|
8492
8084
|
// literal prefix parse in scr_string.c; a number-typed isFinite IS
|
|
8493
8085
|
// Number.isFinite — the global's ToNumber coercion is the identity
|
|
8494
|
-
// there, ms's `isFinite(val)` guard). Other argument types
|
|
8495
|
-
//
|
|
8496
|
-
//
|
|
8497
|
-
// territory. The probe never emits — lowering is IR construction.
|
|
8086
|
+
// there, ms's `isFinite(val)` guard). Other argument types retain
|
|
8087
|
+
// their native coercion checks or the SC2012 refusal. The probe never
|
|
8088
|
+
// emits — lowering is IR construction.
|
|
8498
8089
|
if ((name === "parseFloat" || name === "isFinite") && args.length === 1) {
|
|
8499
8090
|
if (name === "parseFloat") {
|
|
8500
8091
|
const optional = optionalCallValue(lowerer, args[0]);
|