@scriptc/compiler 0.4.2 → 0.4.3
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 +397 -37
- package/dist/backend/cycle-analysis.d.ts +4 -1
- package/dist/backend/cycle-analysis.js +6 -4
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +55 -0
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +7 -0
- package/dist/backend/cycle-mutability.js +19 -1
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.js +2 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +6 -3
- package/dist/backend/immutability.js +33 -29
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/library-pack.js +1 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +16 -1
- package/dist/backend/llvm/alloc.js +54 -4
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.d.ts +2 -1
- package/dist/backend/llvm/appended-array-literals.js +44 -36
- package/dist/backend/llvm/appended-array-literals.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.test.js +4 -3
- package/dist/backend/llvm/appended-array-literals.test.js.map +1 -1
- package/dist/backend/llvm/array-search.d.ts +4 -3
- package/dist/backend/llvm/array-search.js +21 -9
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/blocks.d.ts +1 -1
- package/dist/backend/llvm/blocks.js +2 -2
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/byte-windows.js +2 -0
- package/dist/backend/llvm/byte-windows.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.d.ts +6 -1
- package/dist/backend/llvm/bytes-alias.js +8 -2
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.d.ts +47 -5
- package/dist/backend/llvm/bytes-loop-versions.js +473 -32
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +258 -2
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/checked-value-lifetimes.js +2 -0
- package/dist/backend/llvm/checked-value-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +7 -5
- package/dist/backend/llvm/classes.js +44 -20
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +167 -7
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +9 -3
- package/dist/backend/llvm/common.js +9 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +2 -1
- package/dist/backend/llvm/constant-callbacks.js +83 -52
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/counted-loops.d.ts +7 -0
- package/dist/backend/llvm/counted-loops.js +18 -0
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +39 -8
- package/dist/backend/llvm/dense-array-access.js +222 -52
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +36 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.d.ts +17 -1
- package/dist/backend/llvm/dense-array-loops.js +194 -5
- package/dist/backend/llvm/dense-array-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.test.js +90 -1
- package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
- package/dist/backend/llvm/dyn-handle-tags.test.js +6 -1
- package/dist/backend/llvm/dyn-handle-tags.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +26 -0
- package/dist/backend/llvm/dyn.js +352 -61
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +11 -20
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-journal.d.ts +93 -0
- package/dist/backend/llvm/emit-journal.js +170 -0
- package/dist/backend/llvm/emit-journal.js.map +1 -0
- package/dist/backend/llvm/emit-module.js +195 -27
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +0 -4
- package/dist/backend/llvm/emit-statements.js +268 -84
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter-state.d.ts +7 -0
- package/dist/backend/llvm/emitter-state.js +14 -0
- package/dist/backend/llvm/emitter-state.js.map +1 -0
- package/dist/backend/llvm/emitter.d.ts +176 -37
- package/dist/backend/llvm/emitter.js +724 -85
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +54 -5
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +34 -12
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +47 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +28 -14
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +14 -2
- package/dist/backend/llvm/expr-containers.js +129 -37
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +14 -0
- package/dist/backend/llvm/expr-dynamic.js +18 -11
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +100 -28
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +11 -6
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +12 -0
- package/dist/backend/llvm/expr-records.js +106 -0
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +2 -2
- package/dist/backend/llvm/expr-stream-bridges.js +194 -65
- 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/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +2 -2
- package/dist/backend/llvm/expr-stream-callbacks.js +74 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/int32-kind-loops.d.ts +39 -0
- package/dist/backend/llvm/int32-kind-loops.js +106 -0
- package/dist/backend/llvm/int32-kind-loops.js.map +1 -0
- package/dist/backend/llvm/integer-or-nan-indexes.test.d.ts +1 -0
- package/dist/backend/llvm/integer-or-nan-indexes.test.js +118 -0
- package/dist/backend/llvm/integer-or-nan-indexes.test.js.map +1 -0
- package/dist/backend/llvm/integer-values.d.ts +20 -1
- package/dist/backend/llvm/integer-values.js +71 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +1 -1
- package/dist/backend/llvm/js-ic.js +1 -1
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/key-orders.d.ts +7 -0
- package/dist/backend/llvm/key-orders.js +33 -0
- package/dist/backend/llvm/key-orders.js.map +1 -0
- package/dist/backend/llvm/lib-connect.js +4 -0
- package/dist/backend/llvm/lib-connect.js.map +1 -1
- package/dist/backend/llvm/lib-datagram.js +11 -0
- package/dist/backend/llvm/lib-datagram.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +80 -2
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +4 -4
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.js +4 -0
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-lookup.js +16 -6
- package/dist/backend/llvm/lib-lookup.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +73 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +35 -5
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +115 -19
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +14 -0
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +33 -0
- package/dist/backend/llvm/loop-state.js +42 -0
- package/dist/backend/llvm/loop-state.js.map +1 -0
- package/dist/backend/llvm/map-number-lookup.d.ts +26 -8
- package/dist/backend/llvm/map-number-lookup.js +91 -31
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +55 -0
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.js +4 -2
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.d.ts +2 -1
- package/dist/backend/llvm/nullable-unions.js +15 -3
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +10 -0
- package/dist/backend/llvm/publish.js +12 -0
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/receivers.js +6 -1
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +1 -9
- package/dist/backend/llvm/record-results.js +2 -11
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +7 -2
- package/dist/backend/llvm/reference-writes.js +89 -72
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/running-extrema.d.ts +11 -0
- package/dist/backend/llvm/running-extrema.js +115 -0
- package/dist/backend/llvm/running-extrema.js.map +1 -0
- package/dist/backend/llvm/running-extrema.test.d.ts +1 -0
- package/dist/backend/llvm/running-extrema.test.js +89 -0
- package/dist/backend/llvm/running-extrema.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +71 -15
- package/dist/backend/llvm/shapes.js +222 -33
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +53 -7
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +6 -0
- package/dist/backend/llvm/speculative-integers.js +2 -2
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +3 -2
- package/dist/backend/llvm/stack-objects.js +5 -2
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +12 -0
- package/dist/backend/llvm/string-reads.js +44 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +3 -0
- package/dist/backend/llvm/walk-borrows.js +46 -41
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +3 -0
- package/dist/backend/llvm/walkers.js +88 -65
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/llvm/wrapping-sums.d.ts +16 -1
- package/dist/backend/llvm/wrapping-sums.js +126 -0
- package/dist/backend/llvm/wrapping-sums.js.map +1 -1
- package/dist/backend/may-throw.d.ts +8 -10
- package/dist/backend/may-throw.js +14 -10
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +5 -0
- package/dist/backend/native/executable.js +7 -0
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +4 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/publication.d.ts +12 -1
- package/dist/backend/publication.js +37 -14
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/publication.test.js +30 -0
- package/dist/backend/publication.test.js.map +1 -1
- package/dist/backend/result-slots.d.ts +16 -0
- package/dist/backend/result-slots.js +23 -0
- package/dist/backend/result-slots.js.map +1 -0
- 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 -0
- package/dist/backend/runtime-pack-core.js +1 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +2 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +2 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/stack-observations.d.ts +2 -1
- package/dist/backend/stack-observations.js +67 -42
- package/dist/backend/stack-observations.js.map +1 -1
- package/dist/backend/target-diagnostics.js +5 -3
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +1 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/usage.d.ts +1 -1
- package/dist/cli/usage.js +3 -3
- package/dist/compat/fetch-profile.js +1 -1
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/contracts/check.js +4 -3
- package/dist/contracts/check.js.map +1 -1
- package/dist/contracts/int32-elements.js +10 -2
- package/dist/contracts/int32-elements.js.map +1 -1
- package/dist/coverage/report.js +12 -3
- package/dist/coverage/report.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +4 -0
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -0
- package/dist/diagnostics/envelope.js +1 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +2 -0
- package/dist/executable/executable-cache.js +1 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +1 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/decl-projection.d.ts +41 -0
- package/dist/frontend/decl-projection.js +854 -0
- package/dist/frontend/decl-projection.js.map +1 -0
- package/dist/frontend/decl-projection.test.d.ts +1 -0
- package/dist/frontend/decl-projection.test.js +30 -0
- package/dist/frontend/decl-projection.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +15 -0
- package/dist/frontend/dts-paths.js +25 -0
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +6 -0
- package/dist/frontend/input-tracker.js +51 -28
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +19 -0
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +100 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js +46 -15
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.js +13 -2
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +84 -9
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/global-namespace-keys.d.ts +3 -0
- package/dist/frontend/lowering/builtins/global-namespace-keys.js +122 -0
- package/dist/frontend/lowering/builtins/global-namespace-keys.js.map +1 -0
- package/dist/frontend/lowering/builtins/numbers.js +9 -1
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.d.ts +6 -0
- package/dist/frontend/lowering/builtins/promises.js +88 -2
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +5 -1
- package/dist/frontend/lowering/builtins/readline.js +35 -3
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +24 -1
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +6 -3
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/class-callbacks.d.ts +5 -2
- package/dist/frontend/lowering/class-callbacks.js +82 -12
- package/dist/frontend/lowering/class-callbacks.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +4 -1
- package/dist/frontend/lowering/class-construction.js +17 -3
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +39 -2
- package/dist/frontend/lowering/class-dynamic-dispatch.js +766 -108
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +47 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-iterables.d.ts +2 -1
- package/dist/frontend/lowering/class-iterables.js +9 -1
- package/dist/frontend/lowering/class-iterables.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +32 -9
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +31 -2
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +9 -3
- package/dist/frontend/lowering/class-runtime-statics.js +29 -4
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +48 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +91 -1
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callback-call.js +2 -2
- package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +338 -18
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-concat.js +10 -0
- package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +15 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js +19 -8
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +2 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +3 -0
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +7 -2
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +6 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +205 -0
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -0
- package/dist/frontend/lowering/containers/indexed-objects.d.ts +0 -12
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -7
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +55 -9
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js +43 -19
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/dispatch-sites.js +15 -1
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.js +9 -1
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/error-methods.js +47 -2
- package/dist/frontend/lowering/error-methods.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.js +47 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +36 -2
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +90 -13
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +33 -4
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +95 -1
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +3 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +10 -0
- package/dist/frontend/lowering/expressions/object-literals.js +138 -51
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +12 -0
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.js +113 -11
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +212 -33
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.js +4 -0
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +22 -3
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +28 -0
- package/dist/frontend/lowering/frozen-records.js +322 -0
- package/dist/frontend/lowering/frozen-records.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +49 -0
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +7 -2
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/iterable-values.d.ts +49 -0
- package/dist/frontend/lowering/iterable-values.js +297 -0
- package/dist/frontend/lowering/iterable-values.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.js +186 -1
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/js-class-fields.d.ts +8 -0
- package/dist/frontend/lowering/js-class-fields.js +45 -10
- package/dist/frontend/lowering/js-class-fields.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.d.ts +18 -3
- package/dist/frontend/lowering/key-order-witness.js +770 -22
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +428 -8
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +4 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +7 -0
- package/dist/frontend/lowering/lower-calls.js +443 -41
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +11 -2
- package/dist/frontend/lowering/lower-classes.js +302 -22
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +3 -1
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +10 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.d.ts +11 -0
- package/dist/frontend/lowering/lower-functions.js +83 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +41 -31
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.js +6 -3
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +18 -6
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +32 -0
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +5 -1
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +2 -2
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +5 -0
- package/dist/frontend/lowering/lower-stdlib.js +30 -0
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +23 -0
- package/dist/frontend/lowering/lower-stmts.js +454 -48
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +20 -2
- package/dist/frontend/lowering/lower-stream.js +1483 -156
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +77 -6
- package/dist/frontend/lowering/lowerer.js +313 -29
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/module-namespace-elements.d.ts +11 -1
- package/dist/frontend/lowering/module-namespace-elements.js +82 -5
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/new-target.d.ts +12 -0
- package/dist/frontend/lowering/new-target.js +280 -0
- package/dist/frontend/lowering/new-target.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -0
- package/dist/frontend/lowering/surfaces.js +18 -6
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/undefined-index.d.ts +27 -0
- package/dist/frontend/lowering/undefined-index.js +82 -0
- package/dist/frontend/lowering/undefined-index.js.map +1 -0
- package/dist/frontend/lowering/var-hoisting.js +29 -13
- package/dist/frontend/lowering/var-hoisting.js.map +1 -1
- package/dist/frontend/lowering/width-lift.d.ts +18 -0
- package/dist/frontend/npm-static-bundled-chunks.js +9 -11
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
- package/dist/frontend/npm-static-bundled-chunks.test.js +6 -5
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +9 -1
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.js +4 -20
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +3 -0
- package/dist/frontend/package-shims.js +71 -8
- package/dist/frontend/package-shims.js.map +1 -1
- package/dist/frontend/pipeline.js +18 -10
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/process-fork.d.ts +25 -0
- package/dist/frontend/process-fork.js +2 -0
- package/dist/frontend/process-fork.js.map +1 -0
- package/dist/frontend/program.d.ts +8 -1
- package/dist/frontend/program.js +484 -69
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +43 -3
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/token-equivalence.d.ts +3 -0
- package/dist/frontend/token-equivalence.js +409 -0
- package/dist/frontend/token-equivalence.js.map +1 -0
- package/dist/frontend/token-equivalence.test.d.ts +1 -0
- package/dist/frontend/token-equivalence.test.js +67 -0
- package/dist/frontend/token-equivalence.test.js.map +1 -0
- package/dist/frontend/ts7/ast-node.d.ts +22 -0
- package/dist/frontend/ts7/ast-node.js +1048 -103
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +24 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +4 -3
- package/dist/frontend/ts7/ast-wire.js +34 -24
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.test.js +23 -0
- package/dist/frontend/ts7/ast-wire.test.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +3 -4
- package/dist/frontend/ts7/checker-backend.js +2 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +5 -9
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +4 -0
- package/dist/frontend/ts7/checker.js +7 -0
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/lib-diagnostics.d.ts +24 -0
- package/dist/frontend/ts7/lib-diagnostics.js +307 -0
- package/dist/frontend/ts7/lib-diagnostics.js.map +1 -0
- package/dist/frontend/ts7/lib-diagnostics.test.d.ts +1 -0
- package/dist/frontend/ts7/lib-diagnostics.test.js +199 -0
- package/dist/frontend/ts7/lib-diagnostics.test.js.map +1 -0
- package/dist/frontend/ts7/program-host.d.ts +7 -0
- package/dist/frontend/ts7/program-host.js +25 -2
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +14 -1
- package/dist/frontend/ts7/session.js +22 -0
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +13 -1
- package/dist/frontend/type-mapper.js +191 -11
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +5 -3
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +4 -0
- package/dist/ir/array-length-stability.js +19 -6
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +24 -0
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.d.ts +7 -0
- package/dist/ir/builtin-effects.js +52 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +6 -4
- package/dist/ir/builtin-signatures.js +166 -13
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +2 -1
- package/dist/ir/callback-specialization.js +23 -18
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +19 -0
- package/dist/ir/char-unit-locals.js +185 -0
- package/dist/ir/char-unit-locals.js.map +1 -0
- package/dist/ir/char-unit-locals.test.d.ts +1 -0
- package/dist/ir/char-unit-locals.test.js +94 -0
- package/dist/ir/char-unit-locals.test.js.map +1 -0
- package/dist/ir/final-fields.d.ts +2 -1
- package/dist/ir/final-fields.js +14 -16
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +2 -0
- package/dist/ir/function-references.js +2 -0
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +3 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/initializer-bindings.d.ts +2 -1
- package/dist/ir/initializer-bindings.js +27 -20
- package/dist/ir/initializer-bindings.js.map +1 -1
- package/dist/ir/int32-arrays.d.ts +108 -0
- package/dist/ir/int32-arrays.js +831 -0
- package/dist/ir/int32-arrays.js.map +1 -0
- package/dist/ir/int32-slots.d.ts +24 -2
- package/dist/ir/int32-slots.js +259 -57
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +3 -3
- package/dist/ir/integer-loops.js +14 -6
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +10 -0
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +5 -0
- package/dist/ir/integer-ranges.js +125 -12
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +30 -0
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +70 -7
- package/dist/ir/ir.js +58 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +21 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-ic.d.ts +19 -2
- package/dist/ir/js-ic.js +95 -11
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +188 -0
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +57 -0
- package/dist/ir/node-index.js +215 -0
- package/dist/ir/node-index.js.map +1 -0
- package/dist/ir/paired-while-loops.d.ts +25 -0
- package/dist/ir/paired-while-loops.js +335 -0
- package/dist/ir/paired-while-loops.js.map +1 -0
- package/dist/ir/paired-while-loops.test.d.ts +1 -0
- package/dist/ir/paired-while-loops.test.js +163 -0
- package/dist/ir/paired-while-loops.test.js.map +1 -0
- package/dist/ir/parameter-versions.d.ts +25 -0
- package/dist/ir/parameter-versions.js +300 -0
- package/dist/ir/parameter-versions.js.map +1 -0
- package/dist/ir/runtime-features.d.ts +34 -13
- package/dist/ir/runtime-features.js +152 -38
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/serialize.d.ts +12 -2
- package/dist/ir/serialize.js +16 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +17 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/traverse.js +18 -6
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +122 -36
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/ir-policy.js +2 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/cache.d.ts +6 -1
- package/dist/native/cache.js +28 -5
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +16 -2
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +21 -1
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +8 -6
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache.d.ts +1 -1
- package/dist/native/executable-cache.js +2 -2
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -1
- package/dist/native/prepare.js +119 -31
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +78 -18
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.test.js +2 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/text-file.d.ts +13 -3
- package/dist/native/text-file.js +63 -9
- package/dist/native/text-file.js.map +1 -1
- package/dist/native/text-file.test.d.ts +1 -0
- package/dist/native/text-file.test.js +49 -0
- package/dist/native/text-file.test.js.map +1 -0
- package/dist/native/toolchain.js +4 -4
- package/dist/native/toolchain.js.map +1 -1
- package/dist/native/toolchain.test.js +3 -3
- package/dist/native/toolchain.test.js.map +1 -1
- package/package.json +21 -21
- package/shims/chalk/v5.ts +688 -0
- package/shims/hono-node-server/v2.ts +645 -0
- package/shims/hot-shots/client.ts +1126 -0
- package/shims/hot-shots/v8-unix-dgram.ts +8 -0
- package/shims/hot-shots/v8.ts +8 -0
- package/surface-manifest.json +26 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { keyedHelperName } from "./stable-names.js";
|
|
2
|
+
import { perKeyOrder } from "./key-order-witness.js";
|
|
2
3
|
import { isForwardedTupleSpread, lowerForwardingApply } from "./typed-arguments.js";
|
|
3
4
|
import { guardNullProto, nullProtoRecordShape } from "./null-prototype.js";
|
|
4
5
|
import { lowerDynStreamMemberCall } from "./dyn-streams.js";
|
|
@@ -29,9 +30,10 @@ import { lowerClassSymbolMethodCall } from "./symbol-methods.js";
|
|
|
29
30
|
import { lowerReadlineDisposeCall } from "./builtins/readline.js";
|
|
30
31
|
import { errorToStringCall } from "./error-methods.js";
|
|
31
32
|
import { lowerClassPrototypeAssign, lowerClassPrototypeDescriptors } from "./class-prototypes.js";
|
|
32
|
-
import { BYTES_ELEMENT_NAME, BIGINT_T, BOOL, CAUGHT, DYN, DYN_HANDLE_KINDS, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, RUNTIME_EMITTER_CLASS, } from "../../ir/ir.js";
|
|
33
|
+
import { BYTES_ELEMENT_NAME, BYTES_U8, BIGINT_T, BOOL, CAUGHT, DYN, DYN_HANDLE_KINDS, F64, NULL_T, STRING, SYMBOL_T, UNDEFINED_T, VOID, arrayOf, canBoxFuncIntoDyn, canConvertToDyn, canDynCheckTo, funcOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, shapeKeyOrders, typeEquals, RUNTIME_EMITTER_CLASS, } from "../../ir/ir.js";
|
|
33
34
|
import { lowerProtocolMethodCall } from "./class-protocol-dispatch.js";
|
|
34
35
|
import { isJsSourceFile, locOf, requireSpecOf } from "../program.js";
|
|
36
|
+
import { isPackageShimFile, isShimIntrinsicName } from "../package-shims.js";
|
|
35
37
|
import { lowerJsonRequireCall } from "./json-require.js";
|
|
36
38
|
import { lowerAssertInstanceCall } from "./assert-instances.js";
|
|
37
39
|
import { isGenericCallableMemberType, isOverloadedCallableMemberType, typeKey, } from "../type-mapper.js";
|
|
@@ -82,6 +84,7 @@ import { defaultAfterUndefined, lowerOptionalArgument, lowerStaticallyUndefinedA
|
|
|
82
84
|
import { fenceSymbolFieldCopy } from "./symbol-fields.js";
|
|
83
85
|
import { lowerClassDataDescriptor, lowerClassDescriptorRead } from "./class-descriptors.js";
|
|
84
86
|
import { lowerClassFieldDefine, lowerClassIntegrity } from "./class-attributes.js";
|
|
87
|
+
import { freezableRecordType, lowerNativeFreeze } from "./frozen-records.js";
|
|
85
88
|
import { classStaticDataFor } from "./class-static-data.js";
|
|
86
89
|
import { lowerUrlFactory } from "./lower-url.js";
|
|
87
90
|
import { nullishValueUnitOf } from "./binding-analysis.js";
|
|
@@ -93,8 +96,59 @@ import { maybePromiseReturnStmt, promiseArmedUnionOf } from "./maybe-promise.js"
|
|
|
93
96
|
import { requireObjLitGenericReceiver, objLitGenericFnNodeOf, objLitGenericFnInfoOf, genericCallInstance, } from "./generic-functions.js";
|
|
94
97
|
import { codeGenerationCalleeOf, lowerCodeGenerationCall } from "./code-generation.js";
|
|
95
98
|
const ZLIB_STREAM_METHODS = new Set(["flush", "params", "close", "reset"]);
|
|
99
|
+
/** `Object.defineProperty(target, ...)`, `Object.defineProperties`,
|
|
100
|
+
* `Reflect.defineProperty`, and `target.__defineGetter__/__defineSetter__`
|
|
101
|
+
* over a target that may hold an Error can install an accessor over an
|
|
102
|
+
* error's `name` or `message` (error-methods.ts). */
|
|
103
|
+
function noteErrorAccessorReflection(lowerer, expr) {
|
|
104
|
+
const callee = expr.expression;
|
|
105
|
+
if (!ts.isPropertyAccessExpression(callee))
|
|
106
|
+
return;
|
|
107
|
+
const member = callee.name.text;
|
|
108
|
+
const target = member === "defineProperty" || member === "defineProperties"
|
|
109
|
+
? expr.arguments.nodes[0]
|
|
110
|
+
: member === "__defineGetter__" || member === "__defineSetter__"
|
|
111
|
+
? callee.expression
|
|
112
|
+
: undefined;
|
|
113
|
+
if (!target)
|
|
114
|
+
return;
|
|
115
|
+
const error = lowerer.checker.resolveName("Error", ts.SymbolFlags.Type, target, false);
|
|
116
|
+
const errorType = error ? lowerer.checker.getDeclaredTypeOfSymbol(error) : null;
|
|
117
|
+
if (mayHoldError(lowerer, lowerer.checker.getTypeAtLocation(target), errorType))
|
|
118
|
+
lowerer.errorAccessorReflection = locOf(expr);
|
|
119
|
+
}
|
|
120
|
+
/** An untyped or generic type, a type Error is assignable to (`object`,
|
|
121
|
+
* `{}`, `Object`, `{ message?: string }`), or
|
|
122
|
+
* an Error-shaped type with both `name` and `message`, alone or in a
|
|
123
|
+
* union or intersection. */
|
|
124
|
+
function mayHoldError(lowerer, type, errorType) {
|
|
125
|
+
if (type.flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.Instantiable))
|
|
126
|
+
return true;
|
|
127
|
+
if (type.flags & (ts.TypeFlags.Union | ts.TypeFlags.Intersection))
|
|
128
|
+
return ts.constituentTypes(type).some((part) => mayHoldError(lowerer, part, errorType));
|
|
129
|
+
return ((lowerer.checker.getPropertyOfType(type, "message") !== undefined &&
|
|
130
|
+
lowerer.checker.getPropertyOfType(type, "name") !== undefined) ||
|
|
131
|
+
(errorType !== null && lowerer.checker.isTypeAssignableTo(errorType, type)));
|
|
132
|
+
}
|
|
133
|
+
/** The `f` of a `(0, f)` callee (a numeric left operand, so dropping it
|
|
134
|
+
* changes only the call's receiver), or null. */
|
|
135
|
+
function receiverlessCalleeOf(callee) {
|
|
136
|
+
let e = callee;
|
|
137
|
+
while (ts.isParenthesizedExpression(e))
|
|
138
|
+
e = e.expression;
|
|
139
|
+
if (!ts.isBinaryExpression(e) ||
|
|
140
|
+
e.operatorToken.kind !== ts.SyntaxKind.CommaToken ||
|
|
141
|
+
!ts.isNumericLiteral(e.left))
|
|
142
|
+
return null;
|
|
143
|
+
let right = e.right;
|
|
144
|
+
while (ts.isParenthesizedExpression(right))
|
|
145
|
+
right = right.expression;
|
|
146
|
+
return right;
|
|
147
|
+
}
|
|
96
148
|
export function lowerCall(lowerer, expr) {
|
|
97
149
|
const loc = locOf(expr);
|
|
150
|
+
if (lowerer.errorAccessorReflection === null)
|
|
151
|
+
noteErrorAccessorReflection(lowerer, expr);
|
|
98
152
|
// Object's checker return type is `any`. Claim known object inputs
|
|
99
153
|
// before generic checked-dynamic dispatch tries to load the constructor.
|
|
100
154
|
if (ts.isIdentifier(expr.expression) &&
|
|
@@ -113,6 +167,17 @@ export function lowerCall(lowerer, expr) {
|
|
|
113
167
|
const json = lowerJsonRequireCall(lowerer, expr);
|
|
114
168
|
if (json)
|
|
115
169
|
return json;
|
|
170
|
+
// `(0, ns.member)(...)` over a builtin module (tsc's and esbuild's call
|
|
171
|
+
// without a receiver): Node's module functions do not read `this`, so it
|
|
172
|
+
// is the member call.
|
|
173
|
+
{
|
|
174
|
+
const member = receiverlessCalleeOf(expr.expression);
|
|
175
|
+
if (member !== null && ts.isPropertyAccessExpression(member)) {
|
|
176
|
+
const builtin = lowerer.lowerNamespaceBuiltinCall(expr, member);
|
|
177
|
+
if (builtin)
|
|
178
|
+
return builtin;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
116
181
|
// eval(...) and Function(...): Node's EvalError under
|
|
117
182
|
// --disallow-code-generation-from-strings (code-generation.ts).
|
|
118
183
|
{
|
|
@@ -120,6 +185,13 @@ export function lowerCall(lowerer, expr) {
|
|
|
120
185
|
if (codeGeneration !== null)
|
|
121
186
|
return lowerCodeGenerationCall(lowerer, expr, codeGeneration);
|
|
122
187
|
}
|
|
188
|
+
// A package shim's runtime intrinsic (a bodiless `declare function`
|
|
189
|
+
// named scriptcUnixDgram* in a shipped shim): a direct runtime call.
|
|
190
|
+
if (ts.isIdentifier(expr.expression) && isShimIntrinsicName(expr.expression.text)) {
|
|
191
|
+
const intrinsic = lowerShimIntrinsicCall(lowerer, expr, expr.expression, loc);
|
|
192
|
+
if (intrinsic)
|
|
193
|
+
return intrinsic;
|
|
194
|
+
}
|
|
123
195
|
// Inline require() of a program module (cjs-inline-require.ts): a
|
|
124
196
|
// member call over its export table resolves like a binding's member
|
|
125
197
|
// call after the module's %init at this position; the require itself
|
|
@@ -1305,7 +1377,17 @@ export function lowerCall(lowerer, expr) {
|
|
|
1305
1377
|
}
|
|
1306
1378
|
const accessorTarget = lowerer.fieldTarget(expr.expression);
|
|
1307
1379
|
if (accessorTarget?.container === "accessor") {
|
|
1308
|
-
|
|
1380
|
+
let callee = lowerer.fieldGetExpr(accessorTarget, locOf(expr.expression), expr.expression);
|
|
1381
|
+
// A getter returning a callable class instance (chalk's
|
|
1382
|
+
// `chalk.red("x")`): call through its `%call` field.
|
|
1383
|
+
if (callee.type.kind === "object") {
|
|
1384
|
+
const direct = callableInstanceStringCall(lowerer, expr, callee, locOf(expr));
|
|
1385
|
+
if (direct)
|
|
1386
|
+
return direct;
|
|
1387
|
+
callee = lowerer.hybridCallUnwrap(callee);
|
|
1388
|
+
if (callee.type.kind === "func")
|
|
1389
|
+
return lowerCallThroughValue(lowerer, expr, callee, locOf(expr));
|
|
1390
|
+
}
|
|
1309
1391
|
if (callee.type.kind === "func") {
|
|
1310
1392
|
const args = completeFuncValueArgs(lowerer, expr, callee.type, locOf(expr));
|
|
1311
1393
|
return { kind: "callValue", callee, args, type: callee.type.ret, loc: locOf(expr) };
|
|
@@ -1522,8 +1604,47 @@ export function lowerCall(lowerer, expr) {
|
|
|
1522
1604
|
// a non-func IR type was already rejected while lowering the callee.
|
|
1523
1605
|
// HYBRID (function-with-properties) values call through their %call slot.
|
|
1524
1606
|
let callee = lowerer.lowerExpr(expr.expression);
|
|
1525
|
-
|
|
1607
|
+
{
|
|
1608
|
+
const direct = callableInstanceStringCall(lowerer, expr, callee, loc);
|
|
1609
|
+
if (direct)
|
|
1610
|
+
return direct;
|
|
1611
|
+
}
|
|
1612
|
+
if (callee.type.kind === "record" || callee.type.kind === "object")
|
|
1526
1613
|
callee = lowerer.hybridCallUnwrap(callee);
|
|
1614
|
+
return lowerCallThroughValue(lowerer, expr, callee, loc);
|
|
1615
|
+
}
|
|
1616
|
+
/** A callable class instance called with one string: its `%call1` method
|
|
1617
|
+
* when the class has one (the chalk shim's typed fast path), skipping the
|
|
1618
|
+
* variadic closure's checked-dynamic arguments. */
|
|
1619
|
+
function callableInstanceStringCall(lowerer, expr, callee, loc) {
|
|
1620
|
+
if (callee.type.kind !== "object" || expr.arguments.nodes.length !== 1)
|
|
1621
|
+
return null;
|
|
1622
|
+
const arg = expr.arguments.nodes[0];
|
|
1623
|
+
if (ts.isSpreadElement(arg))
|
|
1624
|
+
return null;
|
|
1625
|
+
const info = lowerer.classes.get(callee.type.className);
|
|
1626
|
+
if (info === undefined || !info.fields.has("%call") || !lowerer.findMethodOn(info, "%call1"))
|
|
1627
|
+
return null;
|
|
1628
|
+
const value = lowerer.lowerExpr(arg);
|
|
1629
|
+
if (value.type.kind === "string")
|
|
1630
|
+
return lowerer.accessorCall(callee.type.className, "%call1", callee, [value], STRING, loc);
|
|
1631
|
+
// Any other argument (a number behind a cast): the variadic closure,
|
|
1632
|
+
// through the checked-dynamic call as lowerCallThroughValue would.
|
|
1633
|
+
const closure = lowerer.hybridCallUnwrap(callee);
|
|
1634
|
+
if (closure.type.kind !== "func")
|
|
1635
|
+
return null;
|
|
1636
|
+
return {
|
|
1637
|
+
kind: "dynCall",
|
|
1638
|
+
callee: { kind: "dynFrom", value: closure, type: DYN, loc },
|
|
1639
|
+
calleeName: ts.isIdentifier(expr.expression) ? expr.expression.text : "value",
|
|
1640
|
+
args: [lowerer.coerceToExpected(value, DYN)],
|
|
1641
|
+
type: DYN,
|
|
1642
|
+
loc,
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
/** A call through an evaluated callee value: checked-dynamic callees,
|
|
1646
|
+
* function unions, typed-rest and runtime-arity closures. */
|
|
1647
|
+
function lowerCallThroughValue(lowerer, expr, callee, loc) {
|
|
1527
1648
|
// A CHECKED-DYNAMIC callee — `fn(a, b)` where fn is an implicit-any
|
|
1528
1649
|
// JS binding (the mustCall body's `fn(...args)`), a dyn capture, or a
|
|
1529
1650
|
// keyed read off a dyn value: the dynCall boundary. Arguments convert
|
|
@@ -1917,6 +2038,20 @@ function lowerBigIntConstructorValue(lowerer, arg, loc) {
|
|
|
1917
2038
|
return { kind: "libCall", fn: "bigint.parse", args: [arg], type: BIGINT_T, loc };
|
|
1918
2039
|
if (arg.type.kind === "f64")
|
|
1919
2040
|
return { kind: "libCall", fn: "bigint.fromF64", args: [arg], type: BIGINT_T, loc };
|
|
2041
|
+
// Byte storage converts through ToPrimitive, which BigInt then parses: a
|
|
2042
|
+
// typed array's text is its elements joined with "," (one element reads
|
|
2043
|
+
// as that element, none as 0n, several throw the SyntaxError for the
|
|
2044
|
+
// joined text), a Buffer's is its UTF-8 decoding and a DataView's is
|
|
2045
|
+
// "[object DataView]". The runtime value tells them apart, as for String.
|
|
2046
|
+
if (arg.type.kind === "bytes") {
|
|
2047
|
+
const text = {
|
|
2048
|
+
kind: "toString",
|
|
2049
|
+
operand: { kind: "dynFrom", value: arg, type: DYN, loc },
|
|
2050
|
+
type: STRING,
|
|
2051
|
+
loc,
|
|
2052
|
+
};
|
|
2053
|
+
return { kind: "libCall", fn: "bigint.parse", args: [text], type: BIGINT_T, loc };
|
|
2054
|
+
}
|
|
1920
2055
|
if (arg.type.kind === "bool") {
|
|
1921
2056
|
return {
|
|
1922
2057
|
kind: "ternary",
|
|
@@ -1952,6 +2087,7 @@ function lowerBigIntConstructorValue(lowerer, arg, loc) {
|
|
|
1952
2087
|
arm.kind === "string" ||
|
|
1953
2088
|
arm.kind === "f64" ||
|
|
1954
2089
|
arm.kind === "bool" ||
|
|
2090
|
+
arm.kind === "bytes" ||
|
|
1955
2091
|
isUnitType(arm)))
|
|
1956
2092
|
return null;
|
|
1957
2093
|
const key = `bigint.scalar:${unionId}`;
|
|
@@ -2989,6 +3125,15 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
|
|
|
2989
3125
|
// 'unknown' slot does.
|
|
2990
3126
|
if (checkerUntyped && DYN_HANDLE_KINDS.has(recv.type.kind))
|
|
2991
3127
|
recv = lowerer.coerceToExpected(recv, DYN);
|
|
3128
|
+
// A typed array whose checker type collapsed to `any` (a JS binding
|
|
3129
|
+
// referenced in its own initializer's inference — hono's etag digest
|
|
3130
|
+
// `const nextChunk = new Uint8Array(new ArrayBuffer(f(chunk)))` beside
|
|
3131
|
+
// `chunk = nextChunk`) still lowered to its native bytes. The typed
|
|
3132
|
+
// lowerings key on the checker type and decline it, so it boxes by
|
|
3133
|
+
// reference (the box shares the native storage, so writes through the
|
|
3134
|
+
// call stay visible) and the call dispatches on the runtime kind.
|
|
3135
|
+
if (checkerUntyped && recv.type.kind === "bytes")
|
|
3136
|
+
recv = lowerer.coerceToExpected(recv, DYN);
|
|
2992
3137
|
// The last-resort retry (boxTypedTemporary — every other lowering
|
|
2993
3138
|
// already declined): a checker-`any` receiver whose value is a FRESH
|
|
2994
3139
|
// typed result of an earlier step in the chain (`out.split("\n")`
|
|
@@ -3108,17 +3253,21 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
|
|
|
3108
3253
|
if (access.name.text === "flatMap")
|
|
3109
3254
|
return lowerDynArrayFlatMapCall(lowerer, call, access, recv);
|
|
3110
3255
|
// String methods claim only names NO other dyn-representable kind's
|
|
3111
|
-
// prototype declares (Array carries includes/indexOf/slice too)
|
|
3112
|
-
//
|
|
3113
|
-
//
|
|
3114
|
-
// need a receiver-kind dispatch — they keep the fence.
|
|
3256
|
+
// prototype declares (Array carries includes/indexOf/slice too), so no
|
|
3257
|
+
// other kind inherits them. Shared names would need a receiver-kind
|
|
3258
|
+
// dispatch — they keep the fence.
|
|
3115
3259
|
if (DYN_STRING_ONLY_METHODS.has(access.name.text) && !ownCallable) {
|
|
3116
|
-
//
|
|
3117
|
-
//
|
|
3118
|
-
// `
|
|
3119
|
-
//
|
|
3120
|
-
|
|
3121
|
-
|
|
3260
|
+
// A checked-dynamic object can still carry its OWN member of that
|
|
3261
|
+
// name: zod's schemas assign `trim`, `toLowerCase` and `startsWith`
|
|
3262
|
+
// in their constructors (`z.string().trim().min(1)`), an object's
|
|
3263
|
+
// prototype can define `trim`, and a JavaScript module object can
|
|
3264
|
+
// assign `repeat` in a function body (`common.repeat(" ", n)`, an
|
|
3265
|
+
// object-typed receiver the member is missing from). An untyped
|
|
3266
|
+
// receiver, or a member the checker cannot type, dispatches on the
|
|
3267
|
+
// receiver's runtime kind: a string runs the string lowering, anything
|
|
3268
|
+
// else calls its member as Node does.
|
|
3269
|
+
if ((checkerUntyped ||
|
|
3270
|
+
(lowerer.typeOf(access).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0) &&
|
|
3122
3271
|
!call.questionDotToken &&
|
|
3123
3272
|
!access.questionDotToken &&
|
|
3124
3273
|
!call.arguments.nodes.some(ts.isSpreadElement))
|
|
@@ -3142,7 +3291,12 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
|
|
|
3142
3291
|
}
|
|
3143
3292
|
// The argument is a radix for bigint and an encoding for Buffer.
|
|
3144
3293
|
// Preserve its runtime value so receiver dispatch can choose correctly.
|
|
3145
|
-
|
|
3294
|
+
// An authored own `toString` member (zod's `errorUtil.toString`, which
|
|
3295
|
+
// answers string | undefined) is an ordinary method call instead.
|
|
3296
|
+
if (access.name.text === "toString" &&
|
|
3297
|
+
call.arguments.nodes.length <= 1 &&
|
|
3298
|
+
!ownCallable &&
|
|
3299
|
+
!(checkerUntyped && jsAssignsOwnToString(lowerer, access.expression))) {
|
|
3146
3300
|
const argument = call.arguments.nodes[0];
|
|
3147
3301
|
return {
|
|
3148
3302
|
kind: "libCall",
|
|
@@ -3244,11 +3398,17 @@ function lowerDynReceiverMethodCall(lowerer, call, access, boxTypedTemporary = f
|
|
|
3244
3398
|
// The same holds when only the MEMBER is checker-untyped: TypeScript
|
|
3245
3399
|
// importing chalk's JavaScript source types the default export as a
|
|
3246
3400
|
// plain function, so `chalk.bold` reads as `any` on a typed receiver.
|
|
3401
|
+
const ownToString = access.name.text === "toString" &&
|
|
3402
|
+
checkerUntyped &&
|
|
3403
|
+
jsAssignsOwnToString(lowerer, access.expression);
|
|
3247
3404
|
const stringOnlyName = (checkerUntyped ||
|
|
3248
3405
|
(lowerer.typeOf(access).flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) !== 0) &&
|
|
3249
3406
|
!ownCallable &&
|
|
3250
3407
|
DYN_STRING_PROTO_ONLY_NAMES.has(access.name.text);
|
|
3251
|
-
if (DYN_PROTO_METHOD_NAMES.has(access.name.text) &&
|
|
3408
|
+
if (DYN_PROTO_METHOD_NAMES.has(access.name.text) &&
|
|
3409
|
+
!ownCallable &&
|
|
3410
|
+
!ownToString &&
|
|
3411
|
+
!stringOnlyName)
|
|
3252
3412
|
return null;
|
|
3253
3413
|
// Optional forms (`obj.cb?.()`, `obj?.cb()`) belong to the chain
|
|
3254
3414
|
// machinery's short-circuit semantics — not modeled here yet.
|
|
@@ -3509,6 +3669,7 @@ const DYN_DISPATCH_METHODS = new Set([
|
|
|
3509
3669
|
"shift",
|
|
3510
3670
|
"unshift",
|
|
3511
3671
|
"slice",
|
|
3672
|
+
"splice",
|
|
3512
3673
|
"at",
|
|
3513
3674
|
"indexOf",
|
|
3514
3675
|
"lastIndexOf",
|
|
@@ -3650,6 +3811,9 @@ const DYN_DISPATCH_METHODS = new Set([
|
|
|
3650
3811
|
"additionalHeaders",
|
|
3651
3812
|
"altsvc",
|
|
3652
3813
|
"origin",
|
|
3814
|
+
// FinalizationRegistry's methods (scr_finalization_registry_new).
|
|
3815
|
+
"register",
|
|
3816
|
+
"unregister",
|
|
3653
3817
|
// Worker and MessagePort methods use the owning context's handle adapter.
|
|
3654
3818
|
"postMessage",
|
|
3655
3819
|
"terminate",
|
|
@@ -3661,6 +3825,15 @@ export function lowerDynDispatchMethodCall(lowerer, call, access, recv, arrayRec
|
|
|
3661
3825
|
if ((!DYN_DISPATCH_METHODS.has(method) && !isJsSourceFile(ts.getSourceFileOfNode(call))) ||
|
|
3662
3826
|
lowerer.chainBlocked(call, access))
|
|
3663
3827
|
return null;
|
|
3828
|
+
// readable.compose lowers its stages from their syntax, so it needs the
|
|
3829
|
+
// stream's class: a stream a JavaScript function returns untyped has none.
|
|
3830
|
+
if (method === "compose") {
|
|
3831
|
+
const recvT = lowerer.mapTypeOf(lowerer.typeOf(access.expression));
|
|
3832
|
+
if (recvT?.kind === "object" &&
|
|
3833
|
+
streamSidesOf(lowerer, lowerer.classes.get(recvT.className)) !== null) {
|
|
3834
|
+
lowerer.noLowering("readable.compose on a stream held as a checked-dynamic value", call, "type the stream where it comes from, such as a JSDoc @returns {Readable} on the function that returns it");
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3664
3837
|
if (call.arguments.nodes.some((arg) => ts.isSpreadElement(arg))) {
|
|
3665
3838
|
const loc = locOf(call);
|
|
3666
3839
|
const local = lowerer.declareHiddenLocal("%spreadReceiver", DYN);
|
|
@@ -5315,7 +5488,19 @@ export function lowerPromiseMethodCall(lowerer, call, access) {
|
|
|
5315
5488
|
!(param.kind === "dyn" && (inner.kind === "void" || lowerer.dynConvertible(inner)))) {
|
|
5316
5489
|
lowerer.unsupported("SC1090", call.arguments.nodes[0], `then handlers whose parameter is not the settled value's type (expected '${lowerer.fmt(inner)}', got '${lowerer.fmt(param)}')`);
|
|
5317
5490
|
}
|
|
5318
|
-
|
|
5491
|
+
let resultT = lowerer.mapTypeOf(lowerer.typeOf(call));
|
|
5492
|
+
// JavaScript whose declared result type has no mapping (zod's
|
|
5493
|
+
// `Promise.all(items).then((r) => ParseStatus.mergeArray(status, r))`,
|
|
5494
|
+
// typed by a .d.ts union): the handler's value settles the promise as
|
|
5495
|
+
// a checked-dynamic value, checked where it is used.
|
|
5496
|
+
if (resultT?.kind !== "promise" &&
|
|
5497
|
+
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
5498
|
+
cb.type.kind === "func" &&
|
|
5499
|
+
cb.type.ret.kind !== "promise" &&
|
|
5500
|
+
cb.type.ret.kind !== "void" &&
|
|
5501
|
+
(cb.type.ret.kind === "dyn" || lowerer.dynConvertible(cb.type.ret))) {
|
|
5502
|
+
resultT = { kind: "promise", inner: DYN };
|
|
5503
|
+
}
|
|
5319
5504
|
if (resultT?.kind !== "promise") {
|
|
5320
5505
|
lowerer.noLowering("then with this handler's result type", call, "the combined result must be a representable promise");
|
|
5321
5506
|
}
|
|
@@ -5790,6 +5975,13 @@ export function lowerFilterNarrowCall(lowerer, call, access) {
|
|
|
5790
5975
|
const narrowed = outElem !== null && !typeEquals(outElem, elem);
|
|
5791
5976
|
if (!narrowed && !isBooleanArg)
|
|
5792
5977
|
return null;
|
|
5978
|
+
// A written predicate (`(p): p is Cat => ...`, a guard function value)
|
|
5979
|
+
// proves nothing at run time: the generic array HOF path filters the
|
|
5980
|
+
// receiver's elements and converts the kept ones checked
|
|
5981
|
+
// (filterResultElem).
|
|
5982
|
+
if (!isBooleanArg &&
|
|
5983
|
+
((!ts.isArrowFunction(argNode) && !ts.isFunctionExpression(argNode)) || argNode.type))
|
|
5984
|
+
return null;
|
|
5793
5985
|
const annotateEscape = "keep the receiver's element type instead — annotate the callback's return ': boolean' " +
|
|
5794
5986
|
"(the checker then skips the predicate) or annotate the result with the receiver's own " +
|
|
5795
5987
|
"element type — and narrow the elements after";
|
|
@@ -5799,6 +5991,10 @@ export function lowerFilterNarrowCall(lowerer, call, access) {
|
|
|
5799
5991
|
lowerer.badType(call, callT); // defensive: a narrowed non-union receiver
|
|
5800
5992
|
}
|
|
5801
5993
|
tag = lowerer.armTag(elem.unionId, outElem);
|
|
5994
|
+
// Several kept arms: the generic path converts the kept elements to
|
|
5995
|
+
// the narrower union (filterResultElem).
|
|
5996
|
+
if (tag < 0 && !isBooleanArg)
|
|
5997
|
+
return null;
|
|
5802
5998
|
if (tag < 0) {
|
|
5803
5999
|
lowerer.unsupported("SC1090", call, `'.filter' narrowing '${lowerer.fmt(elem)}' elements to the multi-arm '${lowerer.fmt(outElem)}' ` +
|
|
5804
6000
|
`(only a SINGLE arm re-tags — ${annotateEscape})`);
|
|
@@ -5815,17 +6011,8 @@ export function lowerFilterNarrowCall(lowerer, call, access) {
|
|
|
5815
6011
|
const helper = filterNarrowHelper(lowerer, "truthy", elem, outElem ?? elem, tag, loc);
|
|
5816
6012
|
return { kind: "call", callee: helper, args: [receiver], type: arrayOf(outElem ?? elem), loc };
|
|
5817
6013
|
}
|
|
5818
|
-
//
|
|
5819
|
-
// annotation
|
|
5820
|
-
// checker reports a predicate over parameter 0.
|
|
5821
|
-
if (!ts.isArrowFunction(argNode) && !ts.isFunctionExpression(argNode)) {
|
|
5822
|
-
lowerer.unsupported("SC1090", argNode, `narrowing '.filter' through a callback VALUE ` +
|
|
5823
|
-
`(only an inline callback whose predicate the checker inferred can re-tag — ${annotateEscape})`);
|
|
5824
|
-
}
|
|
5825
|
-
if (argNode.type) {
|
|
5826
|
-
lowerer.unsupported("SC1090", argNode, `narrowing '.filter' with a hand-written type predicate ` +
|
|
5827
|
-
`(a written 'x is T' is an unchecked assertion nothing validates at runtime — ${annotateEscape})`);
|
|
5828
|
-
}
|
|
6014
|
+
// An inferred type predicate: an inline function literal with no return
|
|
6015
|
+
// annotation, over parameter 0 (written predicates returned above).
|
|
5829
6016
|
// The receiver evaluates FIRST, in the enclosing function, like JS.
|
|
5830
6017
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
5831
6018
|
const fnArg = lowerer.lowerExpr(argNode);
|
|
@@ -6103,8 +6290,10 @@ export function recordKeysArrayCall(lowerer, receiver, argIr, shape, loc) {
|
|
|
6103
6290
|
loc,
|
|
6104
6291
|
},
|
|
6105
6292
|
];
|
|
6106
|
-
|
|
6107
|
-
|
|
6293
|
+
// One walk per key order (see perKeyOrder).
|
|
6294
|
+
const orders = shapeKeyOrders(current);
|
|
6295
|
+
const walks = orders.map(() => []);
|
|
6296
|
+
for (const [k, name] of orders.flatMap((order, k) => order.map((name) => [k, name]))) {
|
|
6108
6297
|
const f = current.fields.find((x) => x.name === name);
|
|
6109
6298
|
const pushStmt = {
|
|
6110
6299
|
kind: "exprStmt",
|
|
@@ -6121,10 +6310,11 @@ export function recordKeysArrayCall(lowerer, receiver, argIr, shape, loc) {
|
|
|
6121
6310
|
// Fields that can be absent push behind their presence test (the
|
|
6122
6311
|
// key exists exactly when Object.keys would list it).
|
|
6123
6312
|
const present = lowerer.recordFieldPresent(ref, argIr.shapeId, f.name, loc);
|
|
6124
|
-
|
|
6313
|
+
walks[k].push(present.kind === "recordHas"
|
|
6125
6314
|
? { kind: "if", cond: present, then: [pushStmt], else_: null, loc }
|
|
6126
6315
|
: pushStmt);
|
|
6127
6316
|
}
|
|
6317
|
+
body.push(...perKeyOrder(current, ref, walks, loc));
|
|
6128
6318
|
body.push({ kind: "return", value: outRef, loc });
|
|
6129
6319
|
fn.body = body;
|
|
6130
6320
|
};
|
|
@@ -6140,7 +6330,7 @@ export function recordKeysArrayCall(lowerer, receiver, argIr, shape, loc) {
|
|
|
6140
6330
|
* (a key is own exactly when Object.keys would list it — the two share
|
|
6141
6331
|
* the test), everything else true. Unmatched keys probe the overflow
|
|
6142
6332
|
* map when present, so explicit undefined values remain own keys. */
|
|
6143
|
-
function recordHasOwnHelper(lowerer, shapeId, loc) {
|
|
6333
|
+
export function recordHasOwnHelper(lowerer, shapeId, loc) {
|
|
6144
6334
|
const key = `obj.hasOwn:${shapeId}`;
|
|
6145
6335
|
const existing = lowerer.arrHofHelpers.get(key);
|
|
6146
6336
|
if (existing)
|
|
@@ -7107,6 +7297,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7107
7297
|
...(fnName !== null ? { fnName } : {}),
|
|
7108
7298
|
};
|
|
7109
7299
|
}
|
|
7300
|
+
// A class value (`Object.defineProperty(Definition, "name", { value })`)
|
|
7301
|
+
// boxes to its constructor function, whose own-property table holds the
|
|
7302
|
+
// definition for every alias of the class.
|
|
7303
|
+
if (target?.type.kind === "classval" && lowerer.dynConvertible(target.type)) {
|
|
7304
|
+
target = { kind: "dynFrom", value: target, type: DYN, loc: locOf(call.arguments.nodes[0]) };
|
|
7305
|
+
}
|
|
7110
7306
|
const descriptorPrimitive = member === "getOwnPropertyDescriptor" &&
|
|
7111
7307
|
target &&
|
|
7112
7308
|
(target.type.kind === "bool" || target.type.kind === "f64" || target.type.kind === "string");
|
|
@@ -7215,6 +7411,22 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7215
7411
|
const fnIntegrity = functionIntegrity(lowerer, member, value, call.arguments.nodes[0], locOf(call));
|
|
7216
7412
|
if (fnIntegrity)
|
|
7217
7413
|
return fnIntegrity;
|
|
7414
|
+
// A Map or Set has no own properties: freeze, seal and preventExtensions
|
|
7415
|
+
// all only make it not extensible.
|
|
7416
|
+
if (value.type.kind === "map" || value.type.kind === "set") {
|
|
7417
|
+
if (member === "preventExtensions" || member === "seal")
|
|
7418
|
+
return lowerNativeFreeze(lowerer, "collection.preventExtensions", value, locOf(call));
|
|
7419
|
+
const extensible = {
|
|
7420
|
+
kind: "libCall",
|
|
7421
|
+
fn: "collection.isExtensible",
|
|
7422
|
+
args: [value],
|
|
7423
|
+
type: BOOL,
|
|
7424
|
+
loc: locOf(call),
|
|
7425
|
+
};
|
|
7426
|
+
return member === "isExtensible"
|
|
7427
|
+
? extensible
|
|
7428
|
+
: { kind: "unary", op: "!", operand: extensible, type: BOOL, loc: locOf(call) };
|
|
7429
|
+
}
|
|
7218
7430
|
if (member === "preventExtensions" || member === "seal") {
|
|
7219
7431
|
const integrity = lowerClassIntegrity(lowerer, call, member, value);
|
|
7220
7432
|
if (integrity)
|
|
@@ -7251,10 +7463,42 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7251
7463
|
// the argument — no alias exists, so the frozen bit is unobservable
|
|
7252
7464
|
// (writes through the Readonly<T> result are compile errors, and no
|
|
7253
7465
|
// other reference can write). Primitives pass through per ES2015.
|
|
7254
|
-
// Aliased
|
|
7255
|
-
//
|
|
7466
|
+
// Aliased records get the frozen bit of their rc word (frozen-records.ts);
|
|
7467
|
+
// other aliased objects keep a fence: a later write through the original
|
|
7468
|
+
// reference would need a runtime frozen bit (strict mode throws).
|
|
7256
7469
|
if (member === "isFrozen" && call.arguments.nodes.length === 1) {
|
|
7257
|
-
const
|
|
7470
|
+
const argNode = call.arguments.nodes[0];
|
|
7471
|
+
const probedKind = tryLowerExpression(lowerer, argNode)?.type.kind;
|
|
7472
|
+
if (probedKind === "record" ||
|
|
7473
|
+
probedKind === "array" ||
|
|
7474
|
+
probedKind === "map" ||
|
|
7475
|
+
probedKind === "set") {
|
|
7476
|
+
const native = lowerer.lowerExpr(argNode);
|
|
7477
|
+
const loc = locOf(call);
|
|
7478
|
+
if (native.type.kind === "record" || native.type.kind === "array")
|
|
7479
|
+
return {
|
|
7480
|
+
kind: "libCall",
|
|
7481
|
+
fn: native.type.kind === "record" ? "record.isFrozen" : "array.isFrozen",
|
|
7482
|
+
args: [native],
|
|
7483
|
+
type: BOOL,
|
|
7484
|
+
loc,
|
|
7485
|
+
};
|
|
7486
|
+
if (native.type.kind === "map" || native.type.kind === "set")
|
|
7487
|
+
return {
|
|
7488
|
+
kind: "unary",
|
|
7489
|
+
op: "!",
|
|
7490
|
+
operand: {
|
|
7491
|
+
kind: "libCall",
|
|
7492
|
+
fn: "collection.isExtensible",
|
|
7493
|
+
args: [native],
|
|
7494
|
+
type: BOOL,
|
|
7495
|
+
loc,
|
|
7496
|
+
},
|
|
7497
|
+
type: BOOL,
|
|
7498
|
+
loc,
|
|
7499
|
+
};
|
|
7500
|
+
}
|
|
7501
|
+
const value = lowerer.lowerExprExpecting(argNode, DYN);
|
|
7258
7502
|
return { kind: "libCall", fn: "dyn.isFrozen", args: [value], type: BOOL, loc: locOf(call) };
|
|
7259
7503
|
}
|
|
7260
7504
|
if (member === "freeze") {
|
|
@@ -7298,6 +7542,12 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7298
7542
|
const integrity = lowerClassIntegrity(lowerer, call, "freeze", value);
|
|
7299
7543
|
if (integrity)
|
|
7300
7544
|
return integrity;
|
|
7545
|
+
if (freezableRecordType(lowerer, value.type))
|
|
7546
|
+
return lowerNativeFreeze(lowerer, "record.freeze", value, locOf(call));
|
|
7547
|
+
if (value.type.kind === "array")
|
|
7548
|
+
return lowerNativeFreeze(lowerer, "array.freeze", value, locOf(call));
|
|
7549
|
+
if (value.type.kind === "map" || value.type.kind === "set")
|
|
7550
|
+
return lowerNativeFreeze(lowerer, "collection.preventExtensions", value, locOf(call));
|
|
7301
7551
|
lowerer.noLowering("Object.freeze of a possibly-aliased value", call, "freeze of a FRESH object/array literal (and of primitives) compiles — frozen-ness is unobservable there; an aliased target's later writes would need the runtime frozen bit");
|
|
7302
7552
|
}
|
|
7303
7553
|
// `Object.hasOwn(r, k)` over a RECORD receiver: a record's own-key set
|
|
@@ -7465,10 +7715,14 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7465
7715
|
const isJsUnion = probed?.type.kind === "union" &&
|
|
7466
7716
|
isJsSourceFile(ts.getSourceFileOfNode(call)) &&
|
|
7467
7717
|
lowerer.dynConvertible(probed.type);
|
|
7718
|
+
// An array walks its live view: the present indices, then its numeric
|
|
7719
|
+
// and named properties.
|
|
7720
|
+
const isArray = probed?.type.kind === "array" && lowerer.dynConvertible(probed.type);
|
|
7468
7721
|
if (isDyn ||
|
|
7469
7722
|
isPrimitive ||
|
|
7470
7723
|
isFunction ||
|
|
7471
7724
|
isJsUnion ||
|
|
7725
|
+
isArray ||
|
|
7472
7726
|
(probed && isDynTypedRefType(probed.type))) {
|
|
7473
7727
|
const fn = member === "keys"
|
|
7474
7728
|
? "dyn.objKeys"
|
|
@@ -7477,7 +7731,13 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7477
7731
|
: "dyn.objEntries";
|
|
7478
7732
|
let v = lowerer.lowerExpr(argNode);
|
|
7479
7733
|
if (v.type.kind !== "dyn")
|
|
7480
|
-
v = {
|
|
7734
|
+
v = {
|
|
7735
|
+
kind: "dynFrom",
|
|
7736
|
+
value: v,
|
|
7737
|
+
...(isArray ? { liveRef: true } : {}),
|
|
7738
|
+
type: DYN,
|
|
7739
|
+
loc: locOf(call),
|
|
7740
|
+
};
|
|
7481
7741
|
// In TypeScript the keys come back as a native string[] and the
|
|
7482
7742
|
// entries as a native [string, any][]: the checker keeps every later
|
|
7483
7743
|
// write to the arrays well typed. JavaScript may store anything into
|
|
@@ -7640,8 +7900,10 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7640
7900
|
loc,
|
|
7641
7901
|
},
|
|
7642
7902
|
];
|
|
7643
|
-
|
|
7644
|
-
|
|
7903
|
+
// One walk per key order (see perKeyOrder).
|
|
7904
|
+
const orders = shapeKeyOrders(current);
|
|
7905
|
+
const walks = orders.map(() => []);
|
|
7906
|
+
for (const [k, name] of orders.flatMap((order, k) => order.map((name) => [k, name]))) {
|
|
7645
7907
|
const f = current.fields.find((x) => x.name === name);
|
|
7646
7908
|
const raw = {
|
|
7647
7909
|
kind: "recordGet",
|
|
@@ -7796,8 +8058,9 @@ function lowerObjectStaticCall(lowerer, call, access) {
|
|
|
7796
8058
|
loc,
|
|
7797
8059
|
};
|
|
7798
8060
|
}
|
|
7799
|
-
|
|
8061
|
+
walks[k].push(stmt);
|
|
7800
8062
|
}
|
|
8063
|
+
body.push(...perKeyOrder(current, ref, walks, loc));
|
|
7801
8064
|
body.push({ kind: "return", value: outRef, loc });
|
|
7802
8065
|
fn.body = body;
|
|
7803
8066
|
};
|
|
@@ -8032,7 +8295,17 @@ export function lowerRecordFieldCall(lowerer, call, access) {
|
|
|
8032
8295
|
// A HYBRID (function-with-properties) field is callable through its
|
|
8033
8296
|
// reserved %call slot — `colors.blue("x")` where blue also carries
|
|
8034
8297
|
// `.bold` (the chalk shape).
|
|
8035
|
-
if (callee.type.kind === "
|
|
8298
|
+
if (callee.type.kind === "object" && !init) {
|
|
8299
|
+
const direct = callableInstanceStringCall(lowerer, call, callee, loc);
|
|
8300
|
+
if (direct)
|
|
8301
|
+
return direct;
|
|
8302
|
+
// Other argument counts call the %call closure through its value, as
|
|
8303
|
+
// a call on the builder itself does (`theme.error("a", "b")`).
|
|
8304
|
+
const closure = lowerer.hybridCallUnwrap(callee);
|
|
8305
|
+
if (closure !== callee)
|
|
8306
|
+
return lowerCallThroughValue(lowerer, call, closure, loc);
|
|
8307
|
+
}
|
|
8308
|
+
if (callee.type.kind === "record" || callee.type.kind === "object")
|
|
8036
8309
|
callee = lowerer.hybridCallUnwrap(callee);
|
|
8037
8310
|
// Inferred JavaScript option records can retain checked callables in
|
|
8038
8311
|
// fields even when the checker only describes those members as any.
|
|
@@ -8608,7 +8881,9 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
8608
8881
|
// so both guards would pass an emitter-named call).
|
|
8609
8882
|
if (info &&
|
|
8610
8883
|
!found &&
|
|
8611
|
-
(STREAM_API_MEMBERS.has(access.name.text) ||
|
|
8884
|
+
(STREAM_API_MEMBERS.has(access.name.text) ||
|
|
8885
|
+
STREAM_OPERATORS.has(access.name.text) ||
|
|
8886
|
+
access.name.text === "compose") &&
|
|
8612
8887
|
streamSidesOf(lowerer, info) !== null) {
|
|
8613
8888
|
const stream = lowerStreamMethodCall(lowerer, call, access, info);
|
|
8614
8889
|
if (stream)
|
|
@@ -8809,7 +9084,23 @@ export function lowerObjectMethodCall(lowerer, call, access) {
|
|
|
8809
9084
|
type: found.sig.ret,
|
|
8810
9085
|
loc,
|
|
8811
9086
|
};
|
|
8812
|
-
|
|
9087
|
+
// The declaring class's original value, built with the observed slot.
|
|
9088
|
+
// An override below (a virtual call) keeps the dynamic call: a slot
|
|
9089
|
+
// reassigned to an ancestor's method must not reach the override. So do
|
|
9090
|
+
// methods declared in unchecked JavaScript, whose results are inferred,
|
|
9091
|
+
// and calls with a spread argument: the dynamic call drains the spread
|
|
9092
|
+
// through the iterator's current `next`, which may be a replacement.
|
|
9093
|
+
const declarerFile = found.declarer.decl ? ts.getSourceFileOfNode(found.declarer.decl) : null;
|
|
9094
|
+
const original = virtual ||
|
|
9095
|
+
call.arguments.nodes.some(ts.isSpreadElement) ||
|
|
9096
|
+
!declarerFile ||
|
|
9097
|
+
(isJsSourceFile(declarerFile) && !lowerer.checkedJsFile(declarerFile))
|
|
9098
|
+
? undefined
|
|
9099
|
+
: {
|
|
9100
|
+
originalId: () => found.declarer.prototypeOriginals?.get(method),
|
|
9101
|
+
directCall: () => fallback,
|
|
9102
|
+
};
|
|
9103
|
+
const result = classCallbackCall(lowerer, value, method, call.arguments.nodes, fallback, loc, ts.getTextOfNode(access), original);
|
|
8813
9104
|
return {
|
|
8814
9105
|
kind: "seqExpr",
|
|
8815
9106
|
stmts: [{ kind: "varDecl", localId: local.id, init: receiver, loc }],
|
|
@@ -9541,4 +9832,115 @@ function fenceClassCopyIntoFreshObject(lowerer, call, srcNode, rawSource) {
|
|
|
9541
9832
|
return;
|
|
9542
9833
|
lowerer.unsupported("SC1090", srcNode, `Object.assign copying a '${lowerer.fmt(rawSource.type)}' instance into a fresh object typed as the class (the copy is a plain object holding the instance's own fields, not an instance — build the object literal from the fields you need)`);
|
|
9543
9834
|
}
|
|
9835
|
+
/** True when an untyped JavaScript receiver names a binding whose declaring
|
|
9836
|
+
* file assigns it an own `toString` (the TypeScript namespace downlevel
|
|
9837
|
+
* `errorUtil.toString = (message) => ...` in zod): its calls answer what
|
|
9838
|
+
* that function returns, not Object.prototype.toString's string. */
|
|
9839
|
+
function jsAssignsOwnToString(lowerer, receiver) {
|
|
9840
|
+
if (!ts.isIdentifier(receiver))
|
|
9841
|
+
return false;
|
|
9842
|
+
const decl = bindingDeclaration(lowerer, receiver);
|
|
9843
|
+
if (decl === undefined)
|
|
9844
|
+
return false;
|
|
9845
|
+
const sf = ts.getSourceFileOfNode(decl);
|
|
9846
|
+
if (!isJsSourceFile(sf))
|
|
9847
|
+
return false;
|
|
9848
|
+
let targets = lowerer.ownToStringTargets.get(sf);
|
|
9849
|
+
if (targets === undefined) {
|
|
9850
|
+
targets = ownToStringTargets(lowerer, sf);
|
|
9851
|
+
lowerer.ownToStringTargets.set(sf, targets);
|
|
9852
|
+
}
|
|
9853
|
+
return targets.has(decl);
|
|
9854
|
+
}
|
|
9855
|
+
const unparenthesized = (e) => {
|
|
9856
|
+
let out = e;
|
|
9857
|
+
while (ts.isParenthesizedExpression(out))
|
|
9858
|
+
out = out.expression;
|
|
9859
|
+
return out;
|
|
9860
|
+
};
|
|
9861
|
+
/** The declaration of the binding an identifier names, through imports. */
|
|
9862
|
+
function bindingDeclaration(lowerer, id) {
|
|
9863
|
+
let sym = lowerer.checker.getSymbolAtLocation(id);
|
|
9864
|
+
if (sym !== undefined && (sym.flags & ts.SymbolFlags.Alias) !== 0)
|
|
9865
|
+
sym = lowerer.checker.getAliasedSymbol(sym);
|
|
9866
|
+
return sym?.valueDeclaration ?? sym?.declarations?.[0];
|
|
9867
|
+
}
|
|
9868
|
+
/** The declarations of the bindings a file's assignments `x.toString = ...`
|
|
9869
|
+
* (or `x["toString"] = ...`) give an own `toString`. An assignment through
|
|
9870
|
+
* the parameter of an immediately called function counts for the binding
|
|
9871
|
+
* the call passes (`(function (ns) { ns.toString = f; })(ns || (ns = {}))`). */
|
|
9872
|
+
function ownToStringTargets(lowerer, sf) {
|
|
9873
|
+
const targets = new Set();
|
|
9874
|
+
const visit = (node) => {
|
|
9875
|
+
if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
|
|
9876
|
+
const left = unparenthesized(node.left);
|
|
9877
|
+
const named = (ts.isPropertyAccessExpression(left) && left.name.text === "toString") ||
|
|
9878
|
+
(ts.isElementAccessExpression(left) &&
|
|
9879
|
+
ts.isStringLiteralLike(left.argumentExpression) &&
|
|
9880
|
+
left.argumentExpression.text === "toString");
|
|
9881
|
+
const target = named
|
|
9882
|
+
? unparenthesized(left.expression)
|
|
9883
|
+
: undefined;
|
|
9884
|
+
if (target !== undefined && ts.isIdentifier(target)) {
|
|
9885
|
+
const decl = bindingDeclaration(lowerer, target);
|
|
9886
|
+
if (decl !== undefined) {
|
|
9887
|
+
targets.add(decl);
|
|
9888
|
+
const passed = iifeArgumentDeclaration(lowerer, decl);
|
|
9889
|
+
if (passed !== undefined)
|
|
9890
|
+
targets.add(passed);
|
|
9891
|
+
}
|
|
9892
|
+
}
|
|
9893
|
+
}
|
|
9894
|
+
ts.forEachChild(node, visit);
|
|
9895
|
+
};
|
|
9896
|
+
visit(sf);
|
|
9897
|
+
return targets;
|
|
9898
|
+
}
|
|
9899
|
+
/** For a parameter of an immediately called function, the declaration of
|
|
9900
|
+
* the binding its argument names: `x`, `x || (x = {})` or `(x = {})`. */
|
|
9901
|
+
function iifeArgumentDeclaration(lowerer, param) {
|
|
9902
|
+
if (!ts.isParameter(param))
|
|
9903
|
+
return undefined;
|
|
9904
|
+
const fn = param.parent;
|
|
9905
|
+
if (!ts.isFunctionExpression(fn) && !ts.isArrowFunction(fn))
|
|
9906
|
+
return undefined;
|
|
9907
|
+
let callee = fn;
|
|
9908
|
+
while (ts.isParenthesizedExpression(callee.parent))
|
|
9909
|
+
callee = callee.parent;
|
|
9910
|
+
const call = callee.parent;
|
|
9911
|
+
if (!ts.isCallExpression(call) || call.expression !== callee)
|
|
9912
|
+
return undefined;
|
|
9913
|
+
const index = fn.parameters.nodes.indexOf(param);
|
|
9914
|
+
let arg = index < 0 ? undefined : call.arguments.nodes[index];
|
|
9915
|
+
if (arg === undefined)
|
|
9916
|
+
return undefined;
|
|
9917
|
+
arg = unparenthesized(arg);
|
|
9918
|
+
if (ts.isBinaryExpression(arg) && arg.operatorToken.kind === ts.SyntaxKind.BarBarToken)
|
|
9919
|
+
arg = unparenthesized(arg.left);
|
|
9920
|
+
if (ts.isBinaryExpression(arg) && arg.operatorToken.kind === ts.SyntaxKind.EqualsToken)
|
|
9921
|
+
arg = unparenthesized(arg.left);
|
|
9922
|
+
return ts.isIdentifier(arg) ? bindingDeclaration(lowerer, arg) : undefined;
|
|
9923
|
+
}
|
|
9924
|
+
/** The runtime calls package shims declare as bodiless functions. */
|
|
9925
|
+
const SHIM_INTRINSICS = new Map([
|
|
9926
|
+
["scriptcUnixDgramSocket", { fn: "dgram.unixSocket", args: [], ret: F64 }],
|
|
9927
|
+
["scriptcUnixDgramConnect", { fn: "dgram.unixConnect", args: [F64, STRING], ret: F64 }],
|
|
9928
|
+
["scriptcUnixDgramSend", { fn: "dgram.unixSend", args: [F64, BYTES_U8], ret: F64 }],
|
|
9929
|
+
["scriptcUnixDgramClose", { fn: "dgram.unixClose", args: [F64], ret: F64 }],
|
|
9930
|
+
["scriptcResponseLight", { fn: "fetch.responseLight", args: [DYN], ret: arrayOf(STRING) }],
|
|
9931
|
+
]);
|
|
9932
|
+
function lowerShimIntrinsicCall(lowerer, expr, callee, loc) {
|
|
9933
|
+
const intrinsic = SHIM_INTRINSICS.get(callee.text);
|
|
9934
|
+
if (intrinsic === undefined)
|
|
9935
|
+
return null;
|
|
9936
|
+
const decl = lowerer.checker.getSymbolAtLocation(callee)?.valueDeclaration;
|
|
9937
|
+
if (decl === undefined ||
|
|
9938
|
+
!ts.isFunctionDeclaration(decl) ||
|
|
9939
|
+
decl.body ||
|
|
9940
|
+
!isPackageShimFile(ts.getSourceFileOfNode(decl).fileName) ||
|
|
9941
|
+
expr.arguments.nodes.length !== intrinsic.args.length)
|
|
9942
|
+
return null;
|
|
9943
|
+
const args = expr.arguments.nodes.map((arg, i) => lowerer.lowerExprExpecting(arg, intrinsic.args[i]));
|
|
9944
|
+
return { kind: "libCall", fn: intrinsic.fn, args, type: intrinsic.ret, loc };
|
|
9945
|
+
}
|
|
9544
9946
|
//# sourceMappingURL=lower-calls.js.map
|