@scriptc/compiler 0.4.1 → 0.4.2
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 +582 -78
- package/dist/backend/cycle-analysis.d.ts +2 -1
- package/dist/backend/cycle-analysis.js +4 -4
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +2 -1
- package/dist/backend/cycle-mutability.js +2 -2
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.js +4 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +2 -1
- package/dist/backend/immutability.js +2 -2
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/library-pack.js +4 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +7 -3
- package/dist/backend/llvm/alloc.js +7 -4
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/array-search.js +2 -1
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.d.ts +23 -2
- package/dist/backend/llvm/bytes-loop-versions.js +115 -19
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +131 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +72 -1
- package/dist/backend/llvm/classes.js +331 -45
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +223 -16
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +1 -3
- package/dist/backend/llvm/common.js +1 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.js +8 -4
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +4 -4
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/counted-loops.d.ts +4 -1
- package/dist/backend/llvm/counted-loops.js +62 -23
- package/dist/backend/llvm/counted-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.d.ts +19 -16
- package/dist/backend/llvm/dense-array-loops.js +46 -10
- package/dist/backend/llvm/dense-array-loops.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.test.js +50 -14
- package/dist/backend/llvm/dense-array-loops.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +25 -1
- package/dist/backend/llvm/dyn.js +331 -8
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +22 -6
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +17 -11
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +0 -23
- package/dist/backend/llvm/emit-statements.js +325 -25
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +141 -15
- package/dist/backend/llvm/emitter.js +537 -64
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -0
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +5 -2
- package/dist/backend/llvm/expr-bytes.js +110 -40
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +1 -1
- package/dist/backend/llvm/expr-calls.js +34 -22
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +21 -5
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +2 -3
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +54 -6
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +26 -8
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +38 -6
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +131 -35
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +10 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +61 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-http2.d.ts +4 -0
- package/dist/backend/llvm/lib-http2.js +20 -17
- package/dist/backend/llvm/lib-http2.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +65 -14
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +53 -1
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +65 -28
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/lib-tls.js +23 -0
- package/dist/backend/llvm/lib-tls.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +66 -45
- 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/publish.d.ts +8 -1
- package/dist/backend/llvm/publish.js +64 -25
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/publish.test.js +3 -0
- package/dist/backend/llvm/publish.test.js.map +1 -1
- package/dist/backend/llvm/receivers.js +1 -1
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +2 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.js +161 -14
- package/dist/backend/llvm/regex-matchers.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.test.js +18 -0
- package/dist/backend/llvm/regex-matchers.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +9 -7
- package/dist/backend/llvm/shapes.js +12 -10
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +2 -1
- 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 +84 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/wasm-modules.d.ts +6 -5
- package/dist/backend/llvm/wasm-modules.js +32 -9
- package/dist/backend/llvm/wasm-modules.js.map +1 -1
- package/dist/backend/mangle.d.ts +3 -0
- package/dist/backend/mangle.js +5 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +22 -4
- package/dist/backend/native/executable.js +24 -8
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +1 -0
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +11 -6
- package/dist/backend/native-codegen.js +36 -9
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +0 -23
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +14 -4
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/optimization.d.ts +2 -2
- 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 -1
- package/dist/backend/runtime-pack-core.js +1 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +4 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +0 -21
- package/dist/backend/runtime-pack.js +0 -29
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +9 -69
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +31 -1
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +26 -6
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/usage.d.ts +5 -1
- package/dist/cli/usage.js +7 -2
- package/dist/cli/usage.js.map +1 -1
- package/dist/contracts/check.js +1 -1
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.d.ts +7 -2
- package/dist/coverage/report.js +18 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +1 -0
- package/dist/coverage/verdict-cache.js +4 -0
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/coverage/verdict-semantic.js +4 -0
- package/dist/coverage/verdict-semantic.js.map +1 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-tier.d.ts +40 -0
- package/dist/diagnostics/dynamic-tier.js +57 -0
- package/dist/diagnostics/dynamic-tier.js.map +1 -0
- package/dist/diagnostics/envelope.d.ts +2 -1
- package/dist/diagnostics/envelope.js +5 -2
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +23 -1
- package/dist/executable/executable-cache.js +59 -7
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +45 -3
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +3 -1
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +1 -0
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/dispose-hook.d.ts +2 -0
- package/dist/frontend/dispose-hook.js +14 -0
- package/dist/frontend/dispose-hook.js.map +1 -0
- package/dist/frontend/jsx-entities.d.ts +4 -0
- package/dist/frontend/jsx-entities.js +259 -0
- package/dist/frontend/jsx-entities.js.map +1 -0
- package/dist/frontend/jsx-source.d.ts +71 -0
- package/dist/frontend/jsx-source.js +781 -0
- package/dist/frontend/jsx-source.js.map +1 -0
- package/dist/frontend/jsx-source.test.d.ts +1 -0
- package/dist/frontend/jsx-source.test.js +200 -0
- package/dist/frontend/jsx-source.test.js.map +1 -0
- package/dist/frontend/literal-values.test.js +8 -9
- package/dist/frontend/literal-values.test.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.js +2 -1
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +3 -2
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
- package/dist/frontend/lowering/binding-analysis.js +2 -2
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.d.ts +3 -0
- package/dist/frontend/lowering/builtins/arguments.js +30 -15
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.js +10 -6
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-async.js +2 -1
- package/dist/frontend/lowering/builtins/child-process-async.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js +2 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +4 -2
- package/dist/frontend/lowering/builtins/crypto.js +59 -3
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/date-classes.d.ts +46 -0
- package/dist/frontend/lowering/builtins/date-classes.js +477 -0
- package/dist/frontend/lowering/builtins/date-classes.js.map +1 -0
- package/dist/frontend/lowering/builtins/dates.d.ts +11 -1
- package/dist/frontend/lowering/builtins/dates.js +55 -26
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/dh.d.ts +15 -0
- package/dist/frontend/lowering/builtins/dh.js +151 -0
- package/dist/frontend/lowering/builtins/dh.js.map +1 -0
- package/dist/frontend/lowering/builtins/disposable-stack.js +2 -1
- package/dist/frontend/lowering/builtins/disposable-stack.js.map +1 -1
- package/dist/frontend/lowering/builtins/ecdh.d.ts +12 -1
- package/dist/frontend/lowering/builtins/ecdh.js +7 -7
- package/dist/frontend/lowering/builtins/ecdh.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.d.ts +15 -0
- package/dist/frontend/lowering/builtins/errors.js +110 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js +23 -17
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.js +6 -4
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-paths.d.ts +15 -0
- package/dist/frontend/lowering/builtins/fs-paths.js +209 -0
- package/dist/frontend/lowering/builtins/fs-paths.js.map +1 -0
- package/dist/frontend/lowering/builtins/hash-stream.d.ts +16 -4
- package/dist/frontend/lowering/builtins/hash-stream.js +86 -23
- package/dist/frontend/lowering/builtins/hash-stream.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +2 -1
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/key-object.d.ts +2 -1
- package/dist/frontend/lowering/builtins/key-object.js +20 -7
- package/dist/frontend/lowering/builtins/key-object.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +11 -4
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.js +9 -5
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.js +4 -3
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.js +3 -2
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +3 -2
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +3 -2
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/promisify-callback.js +2 -1
- package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +2 -1
- package/dist/frontend/lowering/builtins/readline.js +23 -6
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/strings.js +13 -5
- package/dist/frontend/lowering/builtins/strings.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +2 -1
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/timers.js +1 -1
- package/dist/frontend/lowering/builtins/timers.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +4 -3
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.js +2 -1
- package/dist/frontend/lowering/builtins/v8.js.map +1 -1
- package/dist/frontend/lowering/builtins/webcrypto.js +39 -20
- package/dist/frontend/lowering/builtins/webcrypto.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +2 -1
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.js +13 -6
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/caught-value-dispatch.d.ts +18 -1
- package/dist/frontend/lowering/caught-value-dispatch.js +201 -32
- package/dist/frontend/lowering/caught-value-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-assertions.js +3 -2
- package/dist/frontend/lowering/class-assertions.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +2 -1
- package/dist/frontend/lowering/class-construction.js +8 -13
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-descriptors.js +1 -1
- package/dist/frontend/lowering/class-descriptors.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +34 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +568 -151
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +77 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +3 -0
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-method-values.js +1 -1
- package/dist/frontend/lowering/class-method-values.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +7 -0
- package/dist/frontend/lowering/class-protocols.js +64 -4
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.d.ts +5 -0
- package/dist/frontend/lowering/class-prototypes.js +36 -3
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.js +25 -5
- package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +2 -1
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +6 -5
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +8 -7
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.js +8 -7
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/collection-ingestion.js +2 -1
- package/dist/frontend/lowering/collection-ingestion.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +7 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +14 -13
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-concat.js +2 -1
- package/dist/frontend/lowering/containers/array-concat.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +25 -4
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +6 -5
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.js +2 -1
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +1 -1
- package/dist/frontend/lowering/containers/bytes.js +129 -28
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +52 -2
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +3 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +8 -7
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +8 -7
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +32 -1
- package/dist/frontend/lowering/containers/iterator-helpers.js +6 -5
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +36 -9
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.js +2 -1
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.js +25 -4
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.d.ts +18 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +226 -115
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
- package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
- package/dist/frontend/lowering/dispatch-sites.d.ts +59 -0
- package/dist/frontend/lowering/dispatch-sites.js +204 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -0
- package/dist/frontend/lowering/dispatch-sites.test.d.ts +1 -0
- package/dist/frontend/lowering/dispatch-sites.test.js +59 -0
- package/dist/frontend/lowering/dispatch-sites.test.js.map +1 -0
- package/dist/frontend/lowering/dyn-streams.d.ts +3 -0
- package/dist/frontend/lowering/dyn-streams.js +1 -1
- package/dist/frontend/lowering/dyn-streams.js.map +1 -1
- package/dist/frontend/lowering/dynamic-tier.d.ts +25 -0
- package/dist/frontend/lowering/dynamic-tier.js +327 -0
- package/dist/frontend/lowering/dynamic-tier.js.map +1 -0
- package/dist/frontend/lowering/error-methods.js +4 -0
- package/dist/frontend/lowering/error-methods.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.js +15 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +45 -3
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +17 -1
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +46 -7
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +35 -5
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -3
- package/dist/frontend/lowering/expressions/object-literals.js +27 -6
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +5 -5
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +0 -4
- package/dist/frontend/lowering/expressions/property-access.js +99 -7
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +63 -5
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +63 -9
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.d.ts +6 -1
- package/dist/frontend/lowering/generator-dynamic-dispatch.js +20 -30
- package/dist/frontend/lowering/generator-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +42 -1
- package/dist/frontend/lowering/generic-functions.js +448 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/intern-tables.js +2 -1
- package/dist/frontend/lowering/intern-tables.js.map +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +9 -8
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/js-dynamic-objects.js +3 -2
- package/dist/frontend/lowering/js-dynamic-objects.js.map +1 -1
- package/dist/frontend/lowering/json-require.js +2 -1
- package/dist/frontend/lowering/json-require.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.d.ts +7 -2
- package/dist/frontend/lowering/key-order-witness.js +21 -4
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +38 -2
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lifetime-regions.js +2 -1
- package/dist/frontend/lowering/lifetime-regions.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +6 -5
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +3 -1
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +4 -0
- package/dist/frontend/lowering/lower-calls.js +339 -91
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +18 -0
- package/dist/frontend/lowering/lower-classes.js +280 -25
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +3 -2
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +14 -0
- package/dist/frontend/lowering/lower-event-emitter.js +267 -20
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +19 -2
- package/dist/frontend/lowering/lower-exprs.js +116 -11
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +304 -72
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +10 -6
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +2 -1
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-mock.js +2 -1
- package/dist/frontend/lowering/lower-mock.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +15 -5
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +2 -2
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +2 -1
- package/dist/frontend/lowering/lower-namespaces.js +4 -3
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +10 -0
- package/dist/frontend/lowering/lower-server.js +237 -59
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +12 -10
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +168 -20
- 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 +575 -165
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +4 -3
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +125 -28
- package/dist/frontend/lowering/lowerer.js +557 -63
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +21 -9
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.js +5 -0
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.js +1 -1
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/object-enumeration-receiver.js +2 -1
- package/dist/frontend/lowering/object-enumeration-receiver.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.js +2 -1
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -1
- package/dist/frontend/lowering/private-brands.d.ts +9 -0
- package/dist/frontend/lowering/private-brands.js +66 -15
- package/dist/frontend/lowering/private-brands.js.map +1 -1
- package/dist/frontend/lowering/promise-executor-adapter.js +2 -1
- package/dist/frontend/lowering/promise-executor-adapter.js.map +1 -1
- package/dist/frontend/lowering/require-initialization.js +2 -1
- package/dist/frontend/lowering/require-initialization.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-elements.d.ts +5 -0
- package/dist/frontend/lowering/runtime-optional-elements.js +17 -1
- package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-records.d.ts +2 -0
- package/dist/frontend/lowering/runtime-optional-records.js +18 -5
- package/dist/frontend/lowering/runtime-optional-records.js.map +1 -1
- package/dist/frontend/lowering/site-dependencies.d.ts +35 -0
- package/dist/frontend/lowering/site-dependencies.js +84 -0
- package/dist/frontend/lowering/site-dependencies.js.map +1 -0
- package/dist/frontend/lowering/site-dependencies.test.d.ts +1 -0
- package/dist/frontend/lowering/site-dependencies.test.js +53 -0
- package/dist/frontend/lowering/site-dependencies.test.js.map +1 -0
- package/dist/frontend/lowering/stable-names.d.ts +11 -0
- package/dist/frontend/lowering/stable-names.js +35 -0
- package/dist/frontend/lowering/stable-names.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +2 -2
- package/dist/frontend/lowering/static-typeof.js +42 -3
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-equality.js +2 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/structural-positions.d.ts +32 -0
- package/dist/frontend/lowering/structural-positions.js +108 -0
- package/dist/frontend/lowering/structural-positions.js.map +1 -0
- package/dist/frontend/lowering/surfaces.js +42 -26
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/var-hoisting.js +37 -3
- package/dist/frontend/lowering/var-hoisting.js.map +1 -1
- package/dist/frontend/npm-static-tsc-helpers.d.ts +5 -0
- package/dist/frontend/npm-static-tsc-helpers.js +106 -0
- package/dist/frontend/npm-static-tsc-helpers.js.map +1 -0
- package/dist/frontend/npm-static-tsc-helpers.test.d.ts +1 -0
- package/dist/frontend/npm-static-tsc-helpers.test.js +58 -0
- package/dist/frontend/npm-static-tsc-helpers.test.js.map +1 -0
- package/dist/frontend/npm-static-type-exports-host.d.ts +8 -0
- package/dist/frontend/npm-static-type-exports-host.js +214 -0
- package/dist/frontend/npm-static-type-exports-host.js.map +1 -0
- package/dist/frontend/npm-static-type-exports-host.test.d.ts +1 -0
- package/dist/frontend/npm-static-type-exports-host.test.js +53 -0
- package/dist/frontend/npm-static-type-exports-host.test.js.map +1 -0
- package/dist/frontend/npm-static-type-exports.d.ts +52 -0
- package/dist/frontend/npm-static-type-exports.js +261 -0
- package/dist/frontend/npm-static-type-exports.js.map +1 -0
- package/dist/frontend/npm-static-type-exports.test.d.ts +1 -0
- package/dist/frontend/npm-static-type-exports.test.js +103 -0
- package/dist/frontend/npm-static-type-exports.test.js.map +1 -0
- package/dist/frontend/npm-static-umd.d.ts +6 -0
- package/dist/frontend/npm-static-umd.js +203 -0
- package/dist/frontend/npm-static-umd.js.map +1 -0
- package/dist/frontend/npm-static-umd.test.d.ts +1 -0
- package/dist/frontend/npm-static-umd.test.js +105 -0
- package/dist/frontend/npm-static-umd.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +8 -0
- package/dist/frontend/npm-static.js +47 -2
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/program.d.ts +13 -0
- package/dist/frontend/program.js +103 -6
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +1 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/services.d.ts +6 -0
- package/dist/frontend/services.js +18 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +21 -7
- package/dist/frontend/ts7/ast-node.js +131 -29
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +60 -0
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +27 -2
- package/dist/frontend/ts7/ast-wire.js +124 -21
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast.d.ts +23 -2
- package/dist/frontend/ts7/ast.js +143 -2
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +13 -1
- package/dist/frontend/ts7/checker.js +75 -1
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +9 -6
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/enums.d.ts +3 -3
- package/dist/frontend/ts7/enums.generated.d.ts +10 -0
- package/dist/frontend/ts7/enums.generated.js +21 -0
- package/dist/frontend/ts7/enums.generated.js.map +1 -1
- package/dist/frontend/ts7/enums.js +19 -0
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/program-host.js +5 -2
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/semantic-checker.d.ts +10 -0
- package/dist/frontend/ts7/semantic-checker.js +25 -20
- package/dist/frontend/ts7/semantic-checker.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.d.ts +13 -0
- package/dist/frontend/ts7/semantic-json.js +146 -0
- package/dist/frontend/ts7/semantic-json.js.map +1 -1
- package/dist/frontend/ts7/semantic-json.test.js +57 -1
- package/dist/frontend/ts7/semantic-json.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.d.ts +15 -0
- package/dist/frontend/ts7/semantic-model.js +67 -19
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.test.js +3 -2
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
- package/dist/frontend/ts7/session.js +1 -1
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +1 -1
- package/dist/frontend/tsc-codes.js +7 -0
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +38 -6
- package/dist/frontend/type-mapper.js +265 -32
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +1 -1
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend-process-args.d.ts +4 -0
- package/dist/frontend-process-args.js +52 -0
- package/dist/frontend-process-args.js.map +1 -0
- package/dist/frontend-process-args.test.d.ts +1 -0
- package/dist/frontend-process-args.test.js +47 -0
- package/dist/frontend-process-args.test.js.map +1 -0
- package/dist/frontend-process.d.ts +1 -0
- package/dist/frontend-process.js +23 -0
- package/dist/frontend-process.js.map +1 -0
- package/dist/heap-collection.d.ts +16 -0
- package/dist/heap-collection.js +42 -0
- package/dist/heap-collection.js.map +1 -0
- package/dist/heap-collection.test.d.ts +1 -0
- package/dist/heap-collection.test.js +59 -0
- package/dist/heap-collection.test.js.map +1 -0
- package/dist/heap-pressure.d.ts +2 -0
- package/dist/heap-pressure.js +12 -0
- package/dist/heap-pressure.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +402 -86
- package/dist/index.js.map +1 -1
- package/dist/ir/array-length-stability.js +7 -0
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +25 -0
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +28 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +5 -1
- package/dist/ir/builtin-signatures.js +141 -12
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/final-fields.d.ts +2 -1
- package/dist/ir/final-fields.js +2 -2
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.test.js +2 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/int32-slots.d.ts +13 -5
- package/dist/ir/int32-slots.js +112 -115
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +3 -1
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-loop-facts.d.ts +9 -4
- package/dist/ir/integer-loop-facts.js +93 -18
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-loops.d.ts +49 -0
- package/dist/ir/integer-loops.js +193 -39
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +201 -1
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +64 -0
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +17 -2
- package/dist/ir/ir.js +3 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +31 -7
- package/dist/ir/runtime-features.js +138 -11
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.d.ts +2 -0
- package/dist/ir/traverse.js +14 -2
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +56 -16
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/ir-policy.js +10 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/prepare.js +2 -0
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +5 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/prepare.js +5 -1
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +4 -1
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/startup-cache.d.ts +1 -0
- package/dist/startup-cache.js +1 -0
- package/dist/startup-cache.js.map +1 -1
- package/dist/text-parts.d.ts +7 -0
- package/dist/text-parts.js +44 -0
- package/dist/text-parts.js.map +1 -1
- package/dist/text-parts.test.d.ts +1 -0
- package/dist/text-parts.test.js +46 -0
- package/dist/text-parts.test.js.map +1 -0
- package/dist/timing.d.ts +9 -2
- package/dist/timing.js +7 -4
- package/dist/timing.js.map +1 -1
- package/dist/wasm/translate.d.ts +4 -0
- package/dist/wasm/translate.js +2 -2
- package/dist/wasm/translate.js.map +1 -1
- package/package.json +21 -21
- package/shims/undici/core/client.ts +4 -4
- package/surface-manifest.json +19 -49
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { keyedHelperName } from "./stable-names.js";
|
|
1
2
|
import { nodeThrowExpr, boolLit, numLit, strLit } from "../../ir/build.js";
|
|
2
|
-
import {
|
|
3
|
+
import { isValueStream, valueStreamOf } from "./builtins/hash-stream.js";
|
|
3
4
|
import { InternalCompilerError } from "../../errors.js";
|
|
4
5
|
/* The node:stream lowering (the spoke-module pattern, like
|
|
5
6
|
* lower-event-emitter.ts): construction of the five runtime stream classes
|
|
@@ -43,8 +44,11 @@ import { dynUndefinedExpr, varRef } from "../../ir/build.js";
|
|
|
43
44
|
import { genResultRecord } from "../type-mapper.js";
|
|
44
45
|
import { noteUntypedStreamFlow, requestGeneralStreamSurface } from "./general-streams.js";
|
|
45
46
|
import { dynNativeBranch } from "./dyn-streams.js";
|
|
47
|
+
import { bindingNeverReassigned } from "./binding-analysis.js";
|
|
46
48
|
import { extractIteratorValue, genStep, genValue, stepDrivable } from "./lower-generators.js";
|
|
47
|
-
import {
|
|
49
|
+
import { LiftedFrame, driveGenerator } from "./containers/iterator-helpers.js";
|
|
50
|
+
import { lowerArrayIteratorValue, lowerStringIteratorValue } from "./iterator-adapters.js";
|
|
51
|
+
import { BOOL, DYN, F64, RUNTIME_STREAM_CLASSES, STRING, VOID, arrayOf, BYTES_U8, canBoxFuncIntoDyn, canConvertToDyn, funcOf, typeEquals, typeKey, UNDEFINED_T, } from "../../ir/ir.js";
|
|
48
52
|
const BYTES = BYTES_U8;
|
|
49
53
|
/** An expression that only reads bindings and properties (no calls,
|
|
50
54
|
* assignments or construction): reading it a step later observes the
|
|
@@ -229,7 +233,7 @@ export function streamForcedTuple(lowerer, info, name) {
|
|
|
229
233
|
* (Node calls them stream-bound); arrows keep lexical `this` (the hidden
|
|
230
234
|
* leading param is ABI-only). The declared parameters must be a
|
|
231
235
|
* typeEquals PREFIX of the callback's Node signature. */
|
|
232
|
-
function lowerStreamCallback(lowerer, which, node, thisType, fullTuple) {
|
|
236
|
+
function lowerStreamCallback(lowerer, which, node, thisType, fullTuple, chunkValues = true) {
|
|
233
237
|
const loc = locOf(node);
|
|
234
238
|
const { shapes, funcType } = lowerer.lambdaSignature(node);
|
|
235
239
|
if (node.modifiers?.nodes.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword)) {
|
|
@@ -245,11 +249,24 @@ function lowerStreamCallback(lowerer, which, node, thisType, fullTuple) {
|
|
|
245
249
|
// callable dyn whose glue dispatches to the runtime's *_done).
|
|
246
250
|
if (funcType.params[i].kind === "dyn")
|
|
247
251
|
continue;
|
|
252
|
+
// A write or transform chunk of another type converts from the
|
|
253
|
+
// chunk's value when the callback runs (an object-mode side's value),
|
|
254
|
+
// or throws a TypeError there — on a side known to be byte mode the
|
|
255
|
+
// chunk is a Buffer, so the declared type must be Node's or a
|
|
256
|
+
// supertype of it (`Buffer | string`); an encoding of another type
|
|
257
|
+
// (`string | null | undefined`) converts from the encoding argument's
|
|
258
|
+
// value.
|
|
259
|
+
if (((i === 0 && (chunkValues || widensInto(lowerer, fullTuple[0], funcType.params[0], loc))) ||
|
|
260
|
+
i === 1) &&
|
|
261
|
+
(which === "write" || which === "transform") &&
|
|
262
|
+
funcType.params[i].kind !== "func" &&
|
|
263
|
+
canConvertToDyn(funcType.params[i], (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
264
|
+
continue;
|
|
248
265
|
if (!typeEquals(funcType.params[i], fullTuple[i])) {
|
|
249
266
|
lowerer.noLowering(`a '${which}' callback whose parameter ${i} is '${lowerer.fmt(funcType.params[i])}' where Node passes '${lowerer.fmt(fullTuple[i])}'`, node, "annotate the parameter with the Node signature's type (chunks are Buffers here)");
|
|
250
267
|
}
|
|
251
268
|
}
|
|
252
|
-
const fnName =
|
|
269
|
+
const fnName = lowerer.closureName(loc, `_${which}cb`);
|
|
253
270
|
const fnCtx = newFnCtx(true, null, funcType, funcType.ret);
|
|
254
271
|
lowerer.fnStack.push(fnCtx);
|
|
255
272
|
try {
|
|
@@ -311,6 +328,52 @@ function lowerStreamCallback(lowerer, which, node, thisType, fullTuple) {
|
|
|
311
328
|
lowerer.fnStack.pop();
|
|
312
329
|
}
|
|
313
330
|
}
|
|
331
|
+
/** The objectMode, readableObjectMode and writableObjectMode members of a
|
|
332
|
+
* stream options literal (boolean literals; the sided keys count only on
|
|
333
|
+
* a Duplex, Transform or PassThrough, as in Node). */
|
|
334
|
+
function streamObjectModes(lowerer, ctorName, optsLit) {
|
|
335
|
+
const out = { readable: false, writable: false };
|
|
336
|
+
const duplexish = ctorName !== "Readable" && ctorName !== "Writable";
|
|
337
|
+
for (const prop of optsLit?.properties?.nodes ?? []) {
|
|
338
|
+
if (!ts.isPropertyAssignment(prop))
|
|
339
|
+
continue;
|
|
340
|
+
const name = ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name) ? prop.name.text : null;
|
|
341
|
+
if (name !== "objectMode" && name !== "readableObjectMode" && name !== "writableObjectMode")
|
|
342
|
+
continue;
|
|
343
|
+
const value = prop.initializer;
|
|
344
|
+
if (value.kind === ts.SyntaxKind.FalseKeyword)
|
|
345
|
+
continue;
|
|
346
|
+
if (value.kind !== ts.SyntaxKind.TrueKeyword) {
|
|
347
|
+
lowerer.noLowering(`${ctorName} with a runtime '${name}' value`, prop, `write '${name}: true' or '${name}: false'`);
|
|
348
|
+
}
|
|
349
|
+
if (name === "objectMode") {
|
|
350
|
+
out.readable = true;
|
|
351
|
+
out.writable = true;
|
|
352
|
+
}
|
|
353
|
+
else if (duplexish) {
|
|
354
|
+
if (name === "readableObjectMode")
|
|
355
|
+
out.readable = true;
|
|
356
|
+
else
|
|
357
|
+
out.writable = true;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return out;
|
|
361
|
+
}
|
|
362
|
+
/** Whether an options literal sets the writable side's object mode with a
|
|
363
|
+
* `true` literal (objectMode, or writableObjectMode on a duplex stream).
|
|
364
|
+
* Reports nothing: streamObjectModes fences the other value forms. */
|
|
365
|
+
function literalWritesValues(opts, duplexish) {
|
|
366
|
+
for (const prop of opts.properties?.nodes ?? []) {
|
|
367
|
+
if (!ts.isPropertyAssignment(prop))
|
|
368
|
+
continue;
|
|
369
|
+
const name = ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name) ? prop.name.text : null;
|
|
370
|
+
if (name !== "objectMode" && !(duplexish && name === "writableObjectMode"))
|
|
371
|
+
continue;
|
|
372
|
+
if (prop.initializer.kind !== ts.SyntaxKind.FalseKeyword)
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
314
377
|
/** The full Node parameter tuples of the option callbacks, given the
|
|
315
378
|
* concrete stream's `this` type. The trailing completion callbacks keep
|
|
316
379
|
* whatever func type the checker contextually gave the user's parameter
|
|
@@ -538,6 +601,8 @@ fallbackCb) {
|
|
|
538
601
|
badEncoding: null,
|
|
539
602
|
pushEncoding: null,
|
|
540
603
|
signal: null,
|
|
604
|
+
readableObject: false,
|
|
605
|
+
writableObject: false,
|
|
541
606
|
flags: 0,
|
|
542
607
|
cbs: [],
|
|
543
608
|
};
|
|
@@ -546,6 +611,16 @@ fallbackCb) {
|
|
|
546
611
|
if (optsLit !== undefined && !ts.isObjectLiteralExpression(optsLit)) {
|
|
547
612
|
lowerer.noLowering(`new ${ctorName} with a non-literal options argument`, optsLit, "the options must be an object literal, inline or through const-initialized bindings (the callbacks lower as compile-time closures)");
|
|
548
613
|
}
|
|
614
|
+
// Read before the callbacks lower: an object-mode readable side keeps a
|
|
615
|
+
// completion callback's `data: any` (its values are not only strings and
|
|
616
|
+
// Buffers). An object-mode side's high-water mark defaults to 16.
|
|
617
|
+
const objectModes = streamObjectModes(lowerer, ctorName, optsLit !== undefined && ts.isObjectLiteralExpression(optsLit) ? optsLit : undefined);
|
|
618
|
+
out.readableObject = objectModes.readable;
|
|
619
|
+
out.writableObject = objectModes.writable;
|
|
620
|
+
if (out.readableObject)
|
|
621
|
+
out.hwmR = numLit(16, loc);
|
|
622
|
+
if (out.writableObject)
|
|
623
|
+
out.hwmW = numLit(16, loc);
|
|
549
624
|
const tuples = cbTuples(lowerer);
|
|
550
625
|
const present = new Map();
|
|
551
626
|
for (const prop of optsLit?.properties?.nodes ?? []) {
|
|
@@ -583,7 +658,7 @@ fallbackCb) {
|
|
|
583
658
|
continue;
|
|
584
659
|
}
|
|
585
660
|
const full = tuples[name].map((t) => (t === "fn" ? null : t));
|
|
586
|
-
const pinned = pinAnyDataCompletion(lowerer, name, fnNode);
|
|
661
|
+
const pinned = out.readableObject ? null : pinAnyDataCompletion(lowerer, name, fnNode);
|
|
587
662
|
try {
|
|
588
663
|
// The completion-callback tail: typed by the checker contextually;
|
|
589
664
|
// accept the user's declared func type as the tuple's entry so the
|
|
@@ -598,7 +673,7 @@ fallbackCb) {
|
|
|
598
673
|
}
|
|
599
674
|
return declared ?? funcOf([], VOID);
|
|
600
675
|
});
|
|
601
|
-
present.set(name, lowerStreamCallback(lowerer, name, fnNode, thisType, tuple));
|
|
676
|
+
present.set(name, lowerStreamCallback(lowerer, name, fnNode, thisType, tuple, out.writableObject));
|
|
602
677
|
}
|
|
603
678
|
finally {
|
|
604
679
|
if (pinned)
|
|
@@ -641,13 +716,9 @@ fallbackCb) {
|
|
|
641
716
|
break;
|
|
642
717
|
case "objectMode":
|
|
643
718
|
case "readableObjectMode":
|
|
644
|
-
case "writableObjectMode":
|
|
645
|
-
//
|
|
646
|
-
if (value.kind === ts.SyntaxKind.FalseKeyword)
|
|
647
|
-
break;
|
|
648
|
-
lowerer.noLowering(`${ctorName} in objectMode`, prop, "object-mode streams have no static chunk type yet — chunks are Buffers (utf8 strings convert at push/write)");
|
|
719
|
+
case "writableObjectMode":
|
|
720
|
+
// read up front (streamObjectModes)
|
|
649
721
|
break;
|
|
650
|
-
}
|
|
651
722
|
case "decodeStrings": {
|
|
652
723
|
if (value.kind === ts.SyntaxKind.TrueKeyword)
|
|
653
724
|
break; // Node's default
|
|
@@ -788,6 +859,8 @@ function streamCtorArgs(lowerer, cls, arg, thisType, loc, fallbackCb) {
|
|
|
788
859
|
badEncoding: o.badEncoding,
|
|
789
860
|
pushEncoding: o.pushEncoding,
|
|
790
861
|
signal: o.signal,
|
|
862
|
+
readableObject: o.readableObject,
|
|
863
|
+
writableObject: o.writableObject,
|
|
791
864
|
};
|
|
792
865
|
}
|
|
793
866
|
/** `new Readable(opts?)` and friends — called from lowerNew once the
|
|
@@ -822,6 +895,17 @@ export function lowerStreamNew(lowerer, expr, info) {
|
|
|
822
895
|
return nodeThrowExpr(1, "ERR_UNKNOWN_ENCODING", `Unknown encoding: ${parsed.badEncoding}`, thisType, loc);
|
|
823
896
|
}
|
|
824
897
|
let built = { kind: "libCall", fn, args: parsed.args, type: thisType, loc };
|
|
898
|
+
if (parsed.readableObject || parsed.writableObject) {
|
|
899
|
+
// { objectMode }: applied before any other follow-up (answers the
|
|
900
|
+
// receiver +1).
|
|
901
|
+
built = {
|
|
902
|
+
kind: "libCall",
|
|
903
|
+
fn: "stream.objectMode",
|
|
904
|
+
args: [built, boolLit(parsed.readableObject, loc), boolLit(parsed.writableObject, loc)],
|
|
905
|
+
type: thisType,
|
|
906
|
+
loc,
|
|
907
|
+
};
|
|
908
|
+
}
|
|
825
909
|
if (parsed.pushEncoding !== null) {
|
|
826
910
|
// { defaultEncoding }: chain the push-side decode default (the
|
|
827
911
|
// setEncoding chaining shape — answers the receiver +1).
|
|
@@ -871,7 +955,7 @@ function widensInto(lowerer, passed, declared, loc) {
|
|
|
871
955
|
* overrides it (the ordinary devirtualization rule), so an inherited
|
|
872
956
|
* constructor still binds the DYNAMIC class's override. The method may
|
|
873
957
|
* declare any PREFIX of its Node signature (the option-callback rule). */
|
|
874
|
-
function streamMethodWrapper(lowerer, info, which, methodName, thisType, loc, blame) {
|
|
958
|
+
function streamMethodWrapper(lowerer, info, which, methodName, thisType, loc, blame, chunkValues = true) {
|
|
875
959
|
const found = lowerer.findMethodOn(info, methodName);
|
|
876
960
|
if (!found) {
|
|
877
961
|
// A DESCENDANT-only declaration (the base chain never declares it):
|
|
@@ -914,6 +998,16 @@ function streamMethodWrapper(lowerer, info, which, methodName, thisType, loc, bl
|
|
|
914
998
|
}
|
|
915
999
|
}
|
|
916
1000
|
else if (!typeEquals(got.type, want)) {
|
|
1001
|
+
// A write or transform encoding of another type (`string | null |
|
|
1002
|
+
// undefined`) converts from the encoding argument's value: an
|
|
1003
|
+
// object-mode write passes undefined, null or the name.
|
|
1004
|
+
if (i === 1 &&
|
|
1005
|
+
(which === "write" || which === "transform") &&
|
|
1006
|
+
got.type.kind !== "func" &&
|
|
1007
|
+
canConvertToDyn(got.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
1008
|
+
paramTypes.push(got.type);
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
917
1011
|
// A declared supertype of what Node passes (`chunk: Buffer | string`)
|
|
918
1012
|
// is sound: the wrapper takes Node's value and widens it into the
|
|
919
1013
|
// declared parameter.
|
|
@@ -921,12 +1015,23 @@ function streamMethodWrapper(lowerer, info, which, methodName, thisType, loc, bl
|
|
|
921
1015
|
paramTypes.push(want);
|
|
922
1016
|
continue;
|
|
923
1017
|
}
|
|
1018
|
+
// A write or transform chunk of another type converts from the
|
|
1019
|
+
// chunk's value when the method runs (an object-mode side's value),
|
|
1020
|
+
// or throws a TypeError there; a byte-mode side's chunk is a Buffer.
|
|
1021
|
+
if (i === 0 &&
|
|
1022
|
+
chunkValues &&
|
|
1023
|
+
(which === "write" || which === "transform") &&
|
|
1024
|
+
got.type.kind !== "func" &&
|
|
1025
|
+
canConvertToDyn(got.type, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
1026
|
+
paramTypes.push(got.type);
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
924
1029
|
lowerer.noLowering(`a '${methodName}' method whose parameter ${i} is '${lowerer.fmt(got.type)}' where Node passes '${lowerer.fmt(want)}'`, blame, "annotate the parameter with the Node signature's type or a supertype of it (chunks are Buffers here)");
|
|
925
1030
|
}
|
|
926
1031
|
paramTypes.push(got.type);
|
|
927
1032
|
}
|
|
928
1033
|
const ret = found.sig.ret;
|
|
929
|
-
const fnName =
|
|
1034
|
+
const fnName = lowerer.closureName(loc, `_${which}vt`);
|
|
930
1035
|
const funcType = funcOf([thisType, ...paramTypes], ret);
|
|
931
1036
|
lowerer.fnStack.push(newFnCtx(true, null, funcType, ret));
|
|
932
1037
|
try {
|
|
@@ -996,10 +1101,21 @@ export function lowerStreamSuperCall(lowerer, info, base, argNodes, thisLocal, l
|
|
|
996
1101
|
lowerer.noLowering(`super(...) with ${argNodes.length} arguments in a ${cls.slice(1)} subclass`, blame, "the supported form takes one inline options object (or none)");
|
|
997
1102
|
}
|
|
998
1103
|
const shape = streamCtorShape(cls);
|
|
1104
|
+
// Whether the writable side holds values: options read at run time may
|
|
1105
|
+
// set objectMode, and a literal says so with objectMode (or a Duplex's
|
|
1106
|
+
// writableObjectMode) true; otherwise _write and _transform receive
|
|
1107
|
+
// Buffers.
|
|
1108
|
+
// super(undefined) and super(null) pass no options (followOptionsArg
|
|
1109
|
+
// answers null), so their sides are byte mode too.
|
|
1110
|
+
const optsNode = argNodes[0] !== undefined ? followOptionsArg(lowerer, argNodes[0]) : null;
|
|
1111
|
+
const chunkValues = optsNode !== null &&
|
|
1112
|
+
optsNode !== undefined &&
|
|
1113
|
+
(!ts.isObjectLiteralExpression(optsNode) ||
|
|
1114
|
+
literalWritesValues(optsNode, cls !== "%Readable" && cls !== "%Writable"));
|
|
999
1115
|
const fallback = (name) => {
|
|
1000
1116
|
const methodName = UNDERSCORE_METHODS.get(name);
|
|
1001
1117
|
return methodName
|
|
1002
|
-
? streamMethodWrapper(lowerer, info, name, methodName, thisType, loc, blame)
|
|
1118
|
+
? streamMethodWrapper(lowerer, info, name, methodName, thisType, loc, blame, chunkValues)
|
|
1003
1119
|
: null;
|
|
1004
1120
|
};
|
|
1005
1121
|
const thisRef = () => ({ kind: "varRef", localId: thisLocal.id, type: thisType, loc });
|
|
@@ -1058,6 +1174,19 @@ export function lowerStreamSuperCall(lowerer, info, base, argNodes, thisLocal, l
|
|
|
1058
1174
|
loc,
|
|
1059
1175
|
},
|
|
1060
1176
|
];
|
|
1177
|
+
if (parsed.readableObject || parsed.writableObject) {
|
|
1178
|
+
out.push({
|
|
1179
|
+
kind: "exprStmt",
|
|
1180
|
+
expr: {
|
|
1181
|
+
kind: "libCall",
|
|
1182
|
+
fn: "stream.objectMode",
|
|
1183
|
+
args: [thisRef(), boolLit(parsed.readableObject, loc), boolLit(parsed.writableObject, loc)],
|
|
1184
|
+
type: thisType,
|
|
1185
|
+
loc,
|
|
1186
|
+
},
|
|
1187
|
+
loc,
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1061
1190
|
if (parsed.pushEncoding !== null) {
|
|
1062
1191
|
out.push({
|
|
1063
1192
|
kind: "exprStmt",
|
|
@@ -1330,7 +1459,13 @@ export function lowerStreamStaticCall(lowerer, call, access) {
|
|
|
1330
1459
|
};
|
|
1331
1460
|
}
|
|
1332
1461
|
const anySrc = srcT?.kind === "dyn" ||
|
|
1333
|
-
|
|
1462
|
+
// a Set or Map (entry arrays) of other values: the checked-dynamic
|
|
1463
|
+
// view iterates the collection itself
|
|
1464
|
+
((srcT?.kind === "set" || srcT?.kind === "map") &&
|
|
1465
|
+
canConvertToDyn(srcT, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) ||
|
|
1466
|
+
// an array of other values: the object-mode entries come from its
|
|
1467
|
+
// checked-dynamic copy
|
|
1468
|
+
(srcT?.kind === "array" && fromGenChunk(lowerer, srcT.elem) && typedElem(srcT.elem) === null) ||
|
|
1334
1469
|
(srcNode !== undefined &&
|
|
1335
1470
|
srcT === null &&
|
|
1336
1471
|
(lowerer.typeOf(srcNode).flags & ts.TypeFlags.Any) !== 0);
|
|
@@ -1344,19 +1479,17 @@ export function lowerStreamStaticCall(lowerer, call, access) {
|
|
|
1344
1479
|
if (srcNode && (single || elem)) {
|
|
1345
1480
|
lowerer.noLowering("Readable.from with these options", optsNode, "an object literal with 'objectMode' (true or false) and a number 'highWaterMark' is supported");
|
|
1346
1481
|
}
|
|
1347
|
-
lowerer.noLowering(`Readable.from over a '${srcT ? lowerer.fmt(srcT) : "?"}' source`, srcNode ?? call, "the supported sources are a string or Buffer, and arrays, Sets, generators and class iterables of
|
|
1482
|
+
lowerer.noLowering(`Readable.from over a '${srcT ? lowerer.fmt(srcT) : "?"}' source`, srcNode ?? call, "the supported sources are a string or Buffer, and arrays, Sets, Maps, generators and class iterables of values that convert to checked-dynamic values");
|
|
1348
1483
|
}
|
|
1349
|
-
/** Whether a generator's yields
|
|
1350
|
-
*
|
|
1351
|
-
* ERR_STREAM_NULL_VALUES)
|
|
1352
|
-
* pushed
|
|
1484
|
+
/** Whether a generator's yields can be stream chunks: values that box
|
|
1485
|
+
* into checked-dynamic values (null included: the runtime destroys the
|
|
1486
|
+
* stream with ERR_STREAM_NULL_VALUES). An object-mode stream takes any of
|
|
1487
|
+
* them; a byte-mode one checks them when they are pushed or written. */
|
|
1353
1488
|
function fromGenChunk(lowerer, t) {
|
|
1354
|
-
|
|
1355
|
-
if (t.kind === "dyn" || (chunk(t) && t.kind !== "nullT"))
|
|
1356
|
-
return true;
|
|
1357
|
-
if (t.kind !== "union")
|
|
1489
|
+
if (t.kind === "nullT" || t.kind === "void" || t.kind === "func")
|
|
1358
1490
|
return false;
|
|
1359
|
-
return
|
|
1491
|
+
return (t.kind === "dyn" ||
|
|
1492
|
+
canConvertToDyn(t, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)));
|
|
1360
1493
|
}
|
|
1361
1494
|
/** The helpers Readable.from pulls a compiled generator through, as
|
|
1362
1495
|
* closures in libcall order: a sync generator's next/return/throw answer
|
|
@@ -1399,7 +1532,7 @@ function fromGenHelpers(lowerer, gen, loc) {
|
|
|
1399
1532
|
const key = `streamFromGen:${role}:${typeKey(gen)}`;
|
|
1400
1533
|
let name = lowerer.valueHelpers.get(key);
|
|
1401
1534
|
if (!name) {
|
|
1402
|
-
name = `%stream.fromGen.${role}
|
|
1535
|
+
name = keyedHelperName(lowerer, `%stream.fromGen.${role}`, key);
|
|
1403
1536
|
lowerer.valueHelpers.set(key, name);
|
|
1404
1537
|
lowerer.liftedFns.push({
|
|
1405
1538
|
name,
|
|
@@ -1480,7 +1613,7 @@ function classIteratorObject(lowerer, cit, iter, loc) {
|
|
|
1480
1613
|
const key = `streamFromIter:${cit.iterT.className}`;
|
|
1481
1614
|
let name = lowerer.valueHelpers.get(key);
|
|
1482
1615
|
if (!name) {
|
|
1483
|
-
name =
|
|
1616
|
+
name = keyedHelperName(lowerer, "%stream.fromIter", key);
|
|
1484
1617
|
lowerer.valueHelpers.set(key, name);
|
|
1485
1618
|
const nextName = `${name}.next`;
|
|
1486
1619
|
const nextT = funcOf([], DYN);
|
|
@@ -1624,7 +1757,7 @@ function classAsyncIteratorObject(lowerer, cit, recv, loc) {
|
|
|
1624
1757
|
const key = `streamFromAsyncIter:${cit.className}`;
|
|
1625
1758
|
let name = lowerer.valueHelpers.get(key);
|
|
1626
1759
|
if (!name) {
|
|
1627
|
-
name =
|
|
1760
|
+
name = keyedHelperName(lowerer, "%stream.fromAsyncIter", key);
|
|
1628
1761
|
lowerer.valueHelpers.set(key, name);
|
|
1629
1762
|
const it = { id: "it.0", name: "it", type: cit.iterT, mutable: false, boxed: true };
|
|
1630
1763
|
const src = {
|
|
@@ -1743,10 +1876,10 @@ const PIPELINE_STAGE_EXPECTED = "of type function or an instance of Blob, Readab
|
|
|
1743
1876
|
* a ladder Node never throws. */
|
|
1744
1877
|
function lowerStreamArg(lowerer, node, what) {
|
|
1745
1878
|
const lowered = lowerer.lowerExpr(node);
|
|
1746
|
-
// A Hash or
|
|
1747
|
-
// keep the value alive until the stream settles.
|
|
1748
|
-
const v =
|
|
1749
|
-
?
|
|
1879
|
+
// A Hash, Hmac, Cipheriv or Decipheriv stage is its Transform; pipeline
|
|
1880
|
+
// and compose stages keep the value alive until the stream settles.
|
|
1881
|
+
const v = isValueStream(lowerer, node)
|
|
1882
|
+
? valueStreamOf(lowered, what === "pipeline" || what === "compose")
|
|
1750
1883
|
: lowered;
|
|
1751
1884
|
// A checked-dynamic pipeline stage (an untyped source or destination):
|
|
1752
1885
|
// a boxed native stream unwraps at run time; other values (iterables,
|
|
@@ -2025,9 +2158,9 @@ export function lowerStreamModuleCall(lowerer, call, bi, loc) {
|
|
|
2025
2158
|
? pipelineOptions(lowerer, lastArg)
|
|
2026
2159
|
: null;
|
|
2027
2160
|
const stageArgs = opts ? args.slice(0, -1) : args;
|
|
2028
|
-
if (stageArgs
|
|
2161
|
+
if (hasPipelineFunctionStage(lowerer, stageArgs)) {
|
|
2029
2162
|
if (opts) {
|
|
2030
|
-
lowerer.noLowering("pipeline with function stages and options", lastArg, "pipeline(source, async function* (source) { ... }, destination) without options is supported");
|
|
2163
|
+
lowerer.noLowering("pipeline with function stages or iterable sources and options", lastArg, "pipeline(source, async function* (source) { ... }, destination) without options is supported");
|
|
2031
2164
|
}
|
|
2032
2165
|
const staged = lowerPipelineStages(lowerer, stageArgs, loc);
|
|
2033
2166
|
// A promise destination's value settles the result (same type).
|
|
@@ -2091,7 +2224,10 @@ export function lowerStreamModuleCall(lowerer, call, bi, loc) {
|
|
|
2091
2224
|
// (finished/pipeline throw synchronously; consumers do not). A
|
|
2092
2225
|
// sync throw here would be observably wrong timing, so the
|
|
2093
2226
|
// provable case takes the named fence instead.
|
|
2094
|
-
|
|
2227
|
+
// A Hash, Hmac, Cipheriv or Decipheriv is read through its Transform.
|
|
2228
|
+
const argV = isValueStream(lowerer, args[0])
|
|
2229
|
+
? valueStreamOf(lowerer.lowerExpr(args[0]))
|
|
2230
|
+
: lowerer.lowerExpr(args[0]);
|
|
2095
2231
|
const argInfo = argV.type.kind === "object" ? lowerer.classes.get(argV.type.className) : undefined;
|
|
2096
2232
|
if (argV.type.kind !== "dyn" && !streamSidesOf(lowerer, argInfo)) {
|
|
2097
2233
|
lowerer.noLowering(`stream/consumers.${bi.member} over a value that is not a stream`, call, "Node rejects the promise with 'stream is not async iterable' — pass a readable stream");
|
|
@@ -2190,7 +2326,7 @@ export function lowerStreamModuleCall(lowerer, call, bi, loc) {
|
|
|
2190
2326
|
if (args.length < 3) {
|
|
2191
2327
|
lowerer.noLowering(`pipeline with ${args.length} arguments`, call, "the supported form is pipeline(source, ...streams, callback)");
|
|
2192
2328
|
}
|
|
2193
|
-
if (args.slice(0, -1)
|
|
2329
|
+
if (hasPipelineFunctionStage(lowerer, args.slice(0, -1))) {
|
|
2194
2330
|
const staged = lowerPipelineStages(lowerer, args.slice(0, -1), loc);
|
|
2195
2331
|
if (staged.dest !== 0) {
|
|
2196
2332
|
// callback(err, value): the destination's value reaches the
|
|
@@ -2240,61 +2376,274 @@ export function lowerStreamModuleCall(lowerer, call, bi, loc) {
|
|
|
2240
2376
|
return lowerStreamCompose(lowerer, call, loc);
|
|
2241
2377
|
return null;
|
|
2242
2378
|
}
|
|
2243
|
-
/**
|
|
2244
|
-
* function stage. */
|
|
2245
|
-
function
|
|
2246
|
-
|
|
2379
|
+
/** The function a pipeline() argument writes or names, or null when the
|
|
2380
|
+
* argument is not a function stage. */
|
|
2381
|
+
function pipelineStageFunction(lowerer, node) {
|
|
2382
|
+
if (ts.isFunctionExpression(node) || ts.isArrowFunction(node))
|
|
2383
|
+
return node;
|
|
2384
|
+
if (!ts.isIdentifier(node))
|
|
2385
|
+
return null;
|
|
2386
|
+
// The stage lowers the declaration's body again with its source typed
|
|
2387
|
+
// by the pipeline, so resolving it here must not report what collecting
|
|
2388
|
+
// the declaration's own signature deferred (resolveValueSymbol would).
|
|
2389
|
+
const resolve = (ident) => {
|
|
2390
|
+
const found = lowerer.checker.getSymbolAtLocation(ident);
|
|
2391
|
+
return found && found.flags & ts.SymbolFlags.Alias
|
|
2392
|
+
? lowerer.checker.getAliasedSymbol(found)
|
|
2393
|
+
: found;
|
|
2394
|
+
};
|
|
2395
|
+
const symbol = resolve(node);
|
|
2396
|
+
const declarations = symbol?.declarations ?? [];
|
|
2397
|
+
const bodies = declarations.filter((d) => !ts.isFunctionDeclaration(d) || d.body !== undefined);
|
|
2398
|
+
if (!symbol || bodies.length !== 1)
|
|
2399
|
+
return null;
|
|
2400
|
+
const decl = bodies[0];
|
|
2401
|
+
if (lowerer.isStdlibFile(ts.getSourceFileOfNode(decl)))
|
|
2402
|
+
return null;
|
|
2403
|
+
if (ts.isFunctionDeclaration(decl)) {
|
|
2404
|
+
return bindingNeverReassigned(lowerer, symbol, decl, resolve) ? decl : null;
|
|
2405
|
+
}
|
|
2406
|
+
if (ts.isVariableDeclaration(decl) &&
|
|
2407
|
+
decl.initializer &&
|
|
2408
|
+
ts.isVariableDeclarationList(decl.parent) &&
|
|
2409
|
+
(decl.parent.flags & ts.NodeFlags.Const) !== 0) {
|
|
2410
|
+
let init = decl.initializer;
|
|
2411
|
+
while (ts.isParenthesizedExpression(init))
|
|
2412
|
+
init = init.expression;
|
|
2413
|
+
if (ts.isFunctionExpression(init) || ts.isArrowFunction(init))
|
|
2414
|
+
return init;
|
|
2415
|
+
}
|
|
2416
|
+
return null;
|
|
2247
2417
|
}
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
*
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
let end = first;
|
|
2259
|
-
while (end < stageArgs.length && isPipelineFunctionStage(stageArgs[end]))
|
|
2260
|
-
end++;
|
|
2261
|
-
if (stageArgs.slice(end).some(isPipelineFunctionStage)) {
|
|
2262
|
-
lowerer.noLowering("pipeline with function stages separated by streams", stageArgs[end], "one run of function stages is supported");
|
|
2263
|
-
}
|
|
2264
|
-
const source = first === 0;
|
|
2265
|
-
const destFn = end === stageArgs.length;
|
|
2266
|
-
const before = [];
|
|
2267
|
-
const after = [];
|
|
2418
|
+
function hasPipelineFunctionStage(lowerer, args) {
|
|
2419
|
+
return (args.some((a) => pipelineStageFunction(lowerer, a) !== null) ||
|
|
2420
|
+
(args.length > 0 && iterableSourceType(lowerer, args[0]) !== null));
|
|
2421
|
+
}
|
|
2422
|
+
/** The element type of a pipeline source that is an iterable value (an
|
|
2423
|
+
* array, a string or a synchronous generator object), or null. */
|
|
2424
|
+
function iterableSourceType(lowerer, node) {
|
|
2425
|
+
if (pipelineStageFunction(lowerer, node) !== null)
|
|
2426
|
+
return null;
|
|
2427
|
+
let t;
|
|
2268
2428
|
try {
|
|
2269
|
-
|
|
2270
|
-
before.push(lowerStreamArg(lowerer, a, "pipeline"));
|
|
2429
|
+
t = lowerer.mapTypeOf(lowerer.typeOf(node));
|
|
2271
2430
|
}
|
|
2272
|
-
catch
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2431
|
+
catch {
|
|
2432
|
+
return null;
|
|
2433
|
+
}
|
|
2434
|
+
if (t?.kind === "array")
|
|
2435
|
+
return t.elem;
|
|
2436
|
+
if (t?.kind === "string")
|
|
2437
|
+
return STRING;
|
|
2438
|
+
if (t?.kind === "generator" && t.async !== true && stepDrivable(t))
|
|
2439
|
+
return t.yieldT;
|
|
2440
|
+
return null;
|
|
2441
|
+
}
|
|
2442
|
+
/** A pipeline source that is an iterable value or a synchronous generator
|
|
2443
|
+
* function without parameters, as an async generator closure that steps
|
|
2444
|
+
* the value's iterator (or the generator the function returns) and yields
|
|
2445
|
+
* each element. Node's pipeline iterates such a source with `for await`,
|
|
2446
|
+
* through an async-from-sync iterator, and an async generator that
|
|
2447
|
+
* yields the same elements resumes its consumer on the same ticks. Null
|
|
2448
|
+
* when the source has no such lowering. */
|
|
2449
|
+
function lowerIterableSource(lowerer, node, fn, loc) {
|
|
2450
|
+
let value;
|
|
2451
|
+
if (fn !== null) {
|
|
2452
|
+
if (fn.parameters.nodes.length > 0) {
|
|
2453
|
+
lowerer.noLowering("a synchronous generator function pipeline source with parameters", fn.parameters.nodes[0], "declare the source without parameters, or make it an async generator function");
|
|
2454
|
+
}
|
|
2455
|
+
value = lowerer.lowerLambda(fn);
|
|
2456
|
+
if (value.type.kind !== "func" || value.type.ret.kind !== "generator")
|
|
2457
|
+
return null;
|
|
2458
|
+
}
|
|
2459
|
+
else {
|
|
2460
|
+
value = lowerer.lowerExpr(node);
|
|
2461
|
+
}
|
|
2462
|
+
const srcT = value.type;
|
|
2463
|
+
const elemT = srcT.kind === "func" && srcT.ret.kind === "generator"
|
|
2464
|
+
? srcT.ret.yieldT
|
|
2465
|
+
: srcT.kind === "array"
|
|
2466
|
+
? srcT.elem
|
|
2467
|
+
: srcT.kind === "string"
|
|
2468
|
+
? STRING
|
|
2469
|
+
: srcT.kind === "generator" && srcT.async !== true
|
|
2470
|
+
? srcT.yieldT
|
|
2471
|
+
: null;
|
|
2472
|
+
if (elemT === null)
|
|
2473
|
+
return null;
|
|
2474
|
+
const out = {
|
|
2475
|
+
kind: "generator",
|
|
2476
|
+
async: true,
|
|
2477
|
+
yieldT: elemT,
|
|
2478
|
+
retT: VOID,
|
|
2479
|
+
nextT: UNDEFINED_T,
|
|
2480
|
+
};
|
|
2481
|
+
const resultType = genResultRecord(elemT, VOID, lowerer.shapes, lowerer.unions);
|
|
2482
|
+
if (!resultType)
|
|
2483
|
+
return null;
|
|
2484
|
+
const key = `pipelineSource:${typeKey(srcT)}`;
|
|
2485
|
+
let maker = lowerer.valueHelpers.get(key);
|
|
2486
|
+
if (!maker) {
|
|
2487
|
+
maker = `%stream.pipelineSource.${lowerer.valueHelpers.size}`;
|
|
2488
|
+
const genName = `${maker}.gen`;
|
|
2489
|
+
// The generator: g = the source's iterator; for (v of g) yield v.
|
|
2490
|
+
const frame = new LiftedFrame(loc);
|
|
2491
|
+
const srcId = frame.local("src", srcT, false);
|
|
2492
|
+
const src = varRef(srcId, srcT, loc);
|
|
2493
|
+
const syncT = {
|
|
2494
|
+
kind: "generator",
|
|
2495
|
+
yieldT: elemT,
|
|
2496
|
+
retT: VOID,
|
|
2497
|
+
nextT: UNDEFINED_T,
|
|
2498
|
+
};
|
|
2499
|
+
let iterator;
|
|
2500
|
+
if (srcT.kind === "func") {
|
|
2501
|
+
iterator = { kind: "callValue", callee: src, args: [], type: srcT.ret, loc };
|
|
2502
|
+
}
|
|
2503
|
+
else if (srcT.kind === "array") {
|
|
2504
|
+
iterator = lowerArrayIteratorValue(lowerer, src, "values", syncT, loc);
|
|
2505
|
+
}
|
|
2506
|
+
else if (srcT.kind === "string") {
|
|
2507
|
+
iterator = lowerStringIteratorValue(lowerer, src, syncT, loc);
|
|
2508
|
+
}
|
|
2509
|
+
else {
|
|
2510
|
+
iterator = src;
|
|
2511
|
+
}
|
|
2512
|
+
if (iterator === null || iterator.type.kind !== "generator" || !stepDrivable(iterator.type))
|
|
2513
|
+
return null;
|
|
2514
|
+
const iterT = iterator.type;
|
|
2515
|
+
const gId = frame.local("g", iterT, false);
|
|
2516
|
+
const body = [
|
|
2517
|
+
{ kind: "varDecl", localId: gId, init: iterator, loc },
|
|
2518
|
+
...driveGenerator(lowerer, frame, gId, iterT, elemT, [], (v) => [{ kind: "exprStmt", expr: { kind: "yieldExpr", value: v, type: VOID, loc }, loc }], loc),
|
|
2519
|
+
{ kind: "return", value: null, loc },
|
|
2520
|
+
];
|
|
2521
|
+
const srcLocal = frame.locals.find((l) => l.id === srcId);
|
|
2522
|
+
srcLocal.boxed = true;
|
|
2523
|
+
lowerer.valueHelpers.set(key, maker);
|
|
2524
|
+
lowerer.liftedFns.push({
|
|
2525
|
+
name: genName,
|
|
2526
|
+
params: [],
|
|
2527
|
+
returnType: VOID,
|
|
2528
|
+
async: true,
|
|
2529
|
+
captures: [{ localId: srcId, name: "src", type: srcT }],
|
|
2530
|
+
locals: frame.locals,
|
|
2531
|
+
body,
|
|
2532
|
+
generator: { yieldT: elemT, nextT: UNDEFINED_T, resultType },
|
|
2533
|
+
loc,
|
|
2534
|
+
});
|
|
2535
|
+
// The maker: (src) => the generator function closed over src.
|
|
2536
|
+
const makerSrc = { id: "src.0", name: "src", type: srcT, mutable: false, boxed: true };
|
|
2537
|
+
lowerer.liftedFns.push({
|
|
2538
|
+
name: maker,
|
|
2539
|
+
params: [{ localId: makerSrc.id, name: makerSrc.name, type: srcT }],
|
|
2540
|
+
returnType: funcOf([], out),
|
|
2541
|
+
locals: [makerSrc],
|
|
2542
|
+
body: [
|
|
2543
|
+
{
|
|
2544
|
+
kind: "return",
|
|
2545
|
+
value: {
|
|
2546
|
+
kind: "closure",
|
|
2547
|
+
fnName: genName,
|
|
2548
|
+
captures: [makerSrc.id],
|
|
2549
|
+
type: funcOf([], out),
|
|
2550
|
+
loc,
|
|
2551
|
+
},
|
|
2552
|
+
loc,
|
|
2553
|
+
},
|
|
2554
|
+
],
|
|
2555
|
+
loc,
|
|
2556
|
+
});
|
|
2276
2557
|
}
|
|
2277
|
-
|
|
2558
|
+
return {
|
|
2559
|
+
closure: { kind: "call", callee: maker, args: [value], type: funcOf([], out), loc },
|
|
2560
|
+
out,
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
/** pipeline(...) with function stages (pipeline.js). A function may
|
|
2564
|
+
* start the pipeline (a source function, called with `{ signal }`), may
|
|
2565
|
+
* end it (an async function whose promise's value reaches the callback or
|
|
2566
|
+
* the promise), and runs of async generator functions may sit between
|
|
2567
|
+
* streams; the last generator of a run that a stream follows is pumped
|
|
2568
|
+
* into that stream. Each stage's `source` parameter is typed as what the
|
|
2569
|
+
* pipeline passes it: makeAsyncIterable answers the previous stream
|
|
2570
|
+
* itself (a Readable is async iterable) or the previous stage's
|
|
2571
|
+
* generator. */
|
|
2572
|
+
function lowerPipelineStages(lowerer, stageArgs, loc) {
|
|
2573
|
+
if (stageArgs.length > 52) {
|
|
2574
|
+
lowerer.noLowering("pipeline with function stages and more than 52 stages", stageArgs[52], "split the pipeline");
|
|
2575
|
+
}
|
|
2576
|
+
const streams = [];
|
|
2278
2577
|
const stages = [];
|
|
2578
|
+
const helperArgs = [];
|
|
2579
|
+
let positions = 0;
|
|
2279
2580
|
let mask = 0;
|
|
2280
2581
|
let dest = 0;
|
|
2281
2582
|
let destPromise = null;
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2583
|
+
// What the next function stage receives: null before the first stage,
|
|
2584
|
+
// else the previous stream's type or the previous stage's generator.
|
|
2585
|
+
let srcT = null;
|
|
2586
|
+
// The streams and stages in argument order: the head lists all streams
|
|
2587
|
+
// before all stages, so when a stage precedes a stream the arguments
|
|
2588
|
+
// are bound to locals first, keeping JavaScript's evaluation order.
|
|
2589
|
+
const argOrder = [];
|
|
2590
|
+
for (let j = 0; j < stageArgs.length; j++) {
|
|
2591
|
+
const arg = stageArgs[j];
|
|
2592
|
+
const fn = pipelineStageFunction(lowerer, arg);
|
|
2593
|
+
const syncSourceFn = j === 0 &&
|
|
2594
|
+
fn !== null &&
|
|
2595
|
+
!ts.isArrowFunction(fn) &&
|
|
2596
|
+
fn.asteriskToken !== undefined &&
|
|
2597
|
+
!(fn.modifiers?.nodes ?? []).some((m) => m.kind === ts.SyntaxKind.AsyncKeyword);
|
|
2598
|
+
if (j === 0 && (syncSourceFn || (fn === null && iterableSourceType(lowerer, arg) !== null))) {
|
|
2599
|
+
const source = lowerIterableSource(lowerer, arg, syncSourceFn ? fn : null, loc);
|
|
2600
|
+
if (source === null)
|
|
2601
|
+
lowerer.noLowering("pipeline over this source", arg);
|
|
2602
|
+
positions += 1;
|
|
2603
|
+
argOrder.push({ list: stages, index: stages.length });
|
|
2604
|
+
stages.push(source.closure);
|
|
2605
|
+
srcT = source.out;
|
|
2606
|
+
continue;
|
|
2607
|
+
}
|
|
2608
|
+
if (fn === null) {
|
|
2609
|
+
if (srcT?.kind === "generator") {
|
|
2610
|
+
// the generator before this stream, pumped into it
|
|
2611
|
+
if (!fromGenChunk(lowerer, srcT.yieldT)) {
|
|
2612
|
+
lowerer.noLowering(`a pipeline stage yielding '${lowerer.fmt(srcT.yieldT)}'`, stageArgs[j - 1], "stage values written to a stream are strings or Buffers");
|
|
2613
|
+
}
|
|
2614
|
+
const helpers = fromGenHelpers(lowerer, srcT, loc);
|
|
2615
|
+
if (!helpers)
|
|
2616
|
+
lowerer.noLowering("a pipeline stage with this generator type", stageArgs[j - 1]);
|
|
2617
|
+
helperArgs.push(helpers[0], helpers[1], helpers[2]);
|
|
2618
|
+
}
|
|
2619
|
+
let stream;
|
|
2620
|
+
try {
|
|
2621
|
+
stream = lowerStreamArg(lowerer, arg, "pipeline");
|
|
2622
|
+
}
|
|
2623
|
+
catch (e) {
|
|
2624
|
+
if (e instanceof StreamArgTypeThrow)
|
|
2625
|
+
lowerer.noLowering("pipeline over this value", arg);
|
|
2626
|
+
throw e;
|
|
2627
|
+
}
|
|
2628
|
+
argOrder.push({ list: streams, index: streams.length });
|
|
2629
|
+
streams.push(stream);
|
|
2630
|
+
srcT = stream.type;
|
|
2631
|
+
continue;
|
|
2632
|
+
}
|
|
2633
|
+
const isLast = j === stageArgs.length - 1;
|
|
2285
2634
|
const isAsync = (fn.modifiers?.nodes ?? []).some((m) => m.kind === ts.SyntaxKind.AsyncKeyword);
|
|
2286
|
-
const isGen = ts.
|
|
2635
|
+
const isGen = !ts.isArrowFunction(fn) && fn.asteriskToken !== undefined;
|
|
2287
2636
|
if (isLast && isGen) {
|
|
2288
2637
|
// pipeline() pumps it into an object-mode PassThrough, whose
|
|
2289
2638
|
// buffering decides when the pipeline finishes
|
|
2290
|
-
lowerer.noLowering("a pipeline destination that is an async generator function",
|
|
2639
|
+
lowerer.noLowering("a pipeline destination that is an async generator function", arg, "end the pipeline with a stream or an async function (source) { for await (const chunk of source) ... }");
|
|
2291
2640
|
}
|
|
2292
2641
|
if (!isAsync || (!isGen && !isLast)) {
|
|
2293
2642
|
lowerer.noLowering(isLast
|
|
2294
2643
|
? "a pipeline destination that is not an async function"
|
|
2295
2644
|
: srcT === null
|
|
2296
2645
|
? "a pipeline source function that is not an async generator function"
|
|
2297
|
-
: "pipeline stages that are not async generator functions",
|
|
2646
|
+
: "pipeline stages that are not async generator functions", arg, "write the stage as async function* (source) { for await (const chunk of source) ... }");
|
|
2298
2647
|
}
|
|
2299
2648
|
const optionsAt = srcT === null ? 0 : 1;
|
|
2300
2649
|
if (fn.parameters.nodes.length > optionsAt + 1) {
|
|
@@ -2306,8 +2655,10 @@ function lowerPipelineStages(lowerer, stageArgs, loc) {
|
|
|
2306
2655
|
if (params[optionsAt].kind !== "dyn") {
|
|
2307
2656
|
lowerer.noLowering("a pipeline stage's options argument with this type", fn.parameters.nodes[optionsAt], "type it as { signal: AbortSignal }");
|
|
2308
2657
|
}
|
|
2309
|
-
mask |= 1 <<
|
|
2658
|
+
mask |= 1 << stages.length;
|
|
2310
2659
|
}
|
|
2660
|
+
positions += 2 ** j;
|
|
2661
|
+
argOrder.push({ list: stages, index: stages.length });
|
|
2311
2662
|
stages.push(lowered.closure);
|
|
2312
2663
|
if (lowered.out.kind === "promise") {
|
|
2313
2664
|
dest = 2;
|
|
@@ -2318,54 +2669,42 @@ function lowerPipelineStages(lowerer, stageArgs, loc) {
|
|
|
2318
2669
|
srcT = lowered.out;
|
|
2319
2670
|
}
|
|
2320
2671
|
}
|
|
2321
|
-
|
|
2322
|
-
for (const a of stageArgs.slice(end))
|
|
2323
|
-
after.push(lowerStreamArg(lowerer, a, "pipeline"));
|
|
2324
|
-
}
|
|
2325
|
-
catch (e) {
|
|
2326
|
-
if (e instanceof StreamArgTypeThrow)
|
|
2327
|
-
lowerer.noLowering("pipeline over this value", stageArgs[end]);
|
|
2328
|
-
throw e;
|
|
2329
|
-
}
|
|
2330
|
-
const helperArgs = [];
|
|
2331
|
-
if (dest !== 2) {
|
|
2332
|
-
// the generator pumped into the next stream or the PassThrough
|
|
2333
|
-
const lastGen = srcT;
|
|
2334
|
-
if (!fromGenChunk(lowerer, lastGen.yieldT)) {
|
|
2335
|
-
lowerer.noLowering(`a pipeline stage yielding '${lowerer.fmt(lastGen.yieldT)}'`, stageArgs[end - 1], "stage values written to a stream are strings or Buffers");
|
|
2336
|
-
}
|
|
2337
|
-
const helpers = fromGenHelpers(lowerer, lastGen, loc);
|
|
2338
|
-
if (!helpers)
|
|
2339
|
-
lowerer.noLowering("a pipeline stage with this generator type", stageArgs[end - 1]);
|
|
2340
|
-
helperArgs.push(helpers[0], helpers[1], helpers[2]);
|
|
2341
|
-
}
|
|
2342
|
-
else {
|
|
2672
|
+
if (dest === 2) {
|
|
2343
2673
|
const valueT = destPromise.inner;
|
|
2344
2674
|
if (valueT.kind !== "void" &&
|
|
2345
2675
|
!canConvertToDyn(valueT, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id))) {
|
|
2346
|
-
lowerer.noLowering(`a pipeline destination resolving to '${lowerer.fmt(valueT)}'`, stageArgs[
|
|
2676
|
+
lowerer.noLowering(`a pipeline destination resolving to '${lowerer.fmt(valueT)}'`, stageArgs[stageArgs.length - 1]);
|
|
2347
2677
|
}
|
|
2348
2678
|
helperArgs.push(pipelineBoxHelper(lowerer, destPromise, loc));
|
|
2349
2679
|
}
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2680
|
+
const argDecls = [];
|
|
2681
|
+
const firstStage = argOrder.findIndex((a) => a.list === stages);
|
|
2682
|
+
if (firstStage >= 0 && argOrder.slice(firstStage).some((a) => a.list === streams)) {
|
|
2683
|
+
for (const a of argOrder) {
|
|
2684
|
+
const init = a.list[a.index];
|
|
2685
|
+
const local = lowerer.declareHiddenLocal("%pipelineArg", init.type);
|
|
2686
|
+
argDecls.push({ kind: "varDecl", localId: local.id, init, loc: init.loc });
|
|
2687
|
+
a.list[a.index] = varRef(local.id, init.type, init.loc);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
const bindArgs = (call) => argDecls.length === 0
|
|
2691
|
+
? call
|
|
2692
|
+
: { kind: "seqExpr", stmts: argDecls, result: call, type: call.type, loc };
|
|
2693
|
+
// SCR_PIPE_* flags: bits 1-2 the destination, bit 5 the signal and abort.
|
|
2694
|
+
const flags = (dest << 1) | (mask !== 0 ? 32 : 0);
|
|
2354
2695
|
const head = [
|
|
2355
2696
|
numLit(streams.length, loc),
|
|
2356
|
-
numLit(before.length, loc),
|
|
2357
2697
|
numLit(stages.length, loc),
|
|
2698
|
+
numLit(positions, loc),
|
|
2358
2699
|
numLit(flags, loc),
|
|
2359
2700
|
numLit(mask, loc),
|
|
2360
2701
|
...streams,
|
|
2361
2702
|
...stages,
|
|
2362
2703
|
...helperArgs,
|
|
2363
2704
|
];
|
|
2364
|
-
const last =
|
|
2365
|
-
? { kind: "object", className: "%PassThrough" }
|
|
2366
|
-
: streams[streams.length - 1].type;
|
|
2705
|
+
const last = dest === 2 ? { kind: "object", className: "%PassThrough" } : streams[streams.length - 1].type;
|
|
2367
2706
|
if (mask === 0)
|
|
2368
|
-
return { args: head, last, dest, destPromise, wrap:
|
|
2707
|
+
return { args: head, last, dest, destPromise, wrap: bindArgs };
|
|
2369
2708
|
// const ac = new AbortController(): its signal goes to the stages, and
|
|
2370
2709
|
// finishImpl's ac.abort() runs through the abort closure.
|
|
2371
2710
|
const ac = lowerer.declareHiddenLocal("%pipelineAbort", DYN);
|
|
@@ -2382,7 +2721,7 @@ function lowerPipelineStages(lowerer, stageArgs, loc) {
|
|
|
2382
2721
|
last,
|
|
2383
2722
|
dest,
|
|
2384
2723
|
destPromise,
|
|
2385
|
-
wrap: (call) => ({
|
|
2724
|
+
wrap: (call) => bindArgs({
|
|
2386
2725
|
kind: "seqExpr",
|
|
2387
2726
|
stmts: [
|
|
2388
2727
|
{
|
|
@@ -2405,7 +2744,7 @@ function pipelineBoxHelper(lowerer, promiseT, loc) {
|
|
|
2405
2744
|
const key = `pipelineBox:${typeKey(promiseT)}`;
|
|
2406
2745
|
let name = lowerer.valueHelpers.get(key);
|
|
2407
2746
|
if (!name) {
|
|
2408
|
-
name =
|
|
2747
|
+
name = keyedHelperName(lowerer, "%stream.pipelineBox", key);
|
|
2409
2748
|
lowerer.valueHelpers.set(key, name);
|
|
2410
2749
|
lowerer.liftedFns.push({
|
|
2411
2750
|
name,
|
|
@@ -2431,7 +2770,7 @@ function pipelineAbortHelper(lowerer, ac, loc) {
|
|
|
2431
2770
|
let name = lowerer.valueHelpers.get(key);
|
|
2432
2771
|
const abortT = funcOf([], VOID);
|
|
2433
2772
|
if (!name) {
|
|
2434
|
-
name =
|
|
2773
|
+
name = keyedHelperName(lowerer, "%stream.pipelineAbort", key);
|
|
2435
2774
|
lowerer.valueHelpers.set(key, name);
|
|
2436
2775
|
const acLocal = { id: "ac.0", name: "ac", type: DYN, mutable: false, boxed: true };
|
|
2437
2776
|
const acRef = varRef(acLocal.id, DYN, loc);
|
|
@@ -2494,6 +2833,8 @@ function lowerStageFunction(lowerer, fn, srcT) {
|
|
|
2494
2833
|
if (param && !symbol) {
|
|
2495
2834
|
lowerer.noLowering("pipeline stage parameters that are patterns", param, "name the source parameter");
|
|
2496
2835
|
}
|
|
2836
|
+
// The loop variables of the `for await` loops over the source.
|
|
2837
|
+
const chunkSymbols = [];
|
|
2497
2838
|
if (symbol && fn.body) {
|
|
2498
2839
|
const visit = (node) => {
|
|
2499
2840
|
if (ts.isIdentifier(node) &&
|
|
@@ -2506,6 +2847,14 @@ function lowerStageFunction(lowerer, fn, srcT) {
|
|
|
2506
2847
|
parent.expression === node)) {
|
|
2507
2848
|
lowerer.noLowering("a pipeline stage's source used outside a for await loop head", node, "iterate the source with for await (const chunk of source)");
|
|
2508
2849
|
}
|
|
2850
|
+
const binding = ts.isVariableDeclarationList(parent.initializer)
|
|
2851
|
+
? parent.initializer.declarations.nodes[0]?.name
|
|
2852
|
+
: undefined;
|
|
2853
|
+
const chunk = binding && ts.isIdentifier(binding)
|
|
2854
|
+
? lowerer.checker.getSymbolAtLocation(binding)
|
|
2855
|
+
: undefined;
|
|
2856
|
+
if (chunk)
|
|
2857
|
+
chunkSymbols.push(chunk);
|
|
2509
2858
|
}
|
|
2510
2859
|
ts.forEachChild(node, visit);
|
|
2511
2860
|
};
|
|
@@ -2513,8 +2862,22 @@ function lowerStageFunction(lowerer, fn, srcT) {
|
|
|
2513
2862
|
}
|
|
2514
2863
|
if (symbol)
|
|
2515
2864
|
lowerer.stageSourceTypes.set(symbol, srcT);
|
|
2865
|
+
// In JavaScript the checker types the chunks of a source that is the
|
|
2866
|
+
// previous stage's generator `any`; they read as the strings or Buffers
|
|
2867
|
+
// the generator yields, so their members take the string and Buffer
|
|
2868
|
+
// lowerings.
|
|
2869
|
+
const previousImplicit = lowerer.implicitParamTypes;
|
|
2870
|
+
const chunkType = srcT?.kind === "generator" && isJsSourceFile(ts.getSourceFileOfNode(fn))
|
|
2871
|
+
? stageChunkCheckerType(lowerer, srcT.yieldT, fn)
|
|
2872
|
+
: null;
|
|
2873
|
+
if (chunkType && chunkSymbols.length > 0) {
|
|
2874
|
+
const implicit = new Map(previousImplicit ?? []);
|
|
2875
|
+
for (const chunk of chunkSymbols)
|
|
2876
|
+
implicit.set(chunk, chunkType);
|
|
2877
|
+
lowerer.implicitParamTypes = implicit;
|
|
2878
|
+
}
|
|
2516
2879
|
try {
|
|
2517
|
-
const closure = lowerer.
|
|
2880
|
+
const closure = lowerer.lowerLambda(fn);
|
|
2518
2881
|
const out = closure.type.kind === "func" ? closure.type.ret : null;
|
|
2519
2882
|
if (!(out?.kind === "generator" && out.async) && out?.kind !== "promise") {
|
|
2520
2883
|
lowerer.noLowering("a pipeline stage that does not return an async generator", fn);
|
|
@@ -2524,8 +2887,19 @@ function lowerStageFunction(lowerer, fn, srcT) {
|
|
|
2524
2887
|
finally {
|
|
2525
2888
|
if (symbol)
|
|
2526
2889
|
lowerer.stageSourceTypes.delete(symbol);
|
|
2890
|
+
lowerer.implicitParamTypes = previousImplicit;
|
|
2527
2891
|
}
|
|
2528
2892
|
}
|
|
2893
|
+
/** The checker type of a stage's string or Buffer chunks, or null for
|
|
2894
|
+
* other chunk types. */
|
|
2895
|
+
function stageChunkCheckerType(lowerer, chunk, at) {
|
|
2896
|
+
if (chunk.kind === "string")
|
|
2897
|
+
return lowerer.checker.getStringType();
|
|
2898
|
+
if (chunk.kind !== "bytes")
|
|
2899
|
+
return null;
|
|
2900
|
+
const buffer = lowerer.checker.resolveName("Buffer", ts.SymbolFlags.Type, at, false);
|
|
2901
|
+
return buffer ? lowerer.checker.getDeclaredTypeOfSymbol(buffer) : null;
|
|
2902
|
+
}
|
|
2529
2903
|
/** `stream.compose(...streams)` over stream instances: a Duplex writing
|
|
2530
2904
|
* to the first stream and reading from the last (scr_stream_compose). The
|
|
2531
2905
|
* classes fix which positions can be readable and writable; a stream in
|
|
@@ -2736,14 +3110,6 @@ function lowerStreamOperator(lowerer, call, access, member) {
|
|
|
2736
3110
|
}
|
|
2737
3111
|
throw new InternalCompilerError(`unknown stream operator ${member}`);
|
|
2738
3112
|
}
|
|
2739
|
-
/** The literal 'buffer' encoding on write()/end(): Node 24 takes it for a
|
|
2740
|
-
* Buffer chunk and throws ERR_UNKNOWN_ENCODING for a string chunk. */
|
|
2741
|
-
function isBufferEncoding(lowerer, arg) {
|
|
2742
|
-
if (arg === undefined)
|
|
2743
|
-
return false;
|
|
2744
|
-
const t = lowerer.typeOf(arg);
|
|
2745
|
-
return t.isStringLiteralType() && t.value === "buffer";
|
|
2746
|
-
}
|
|
2747
3113
|
/** The one supported encoding argument: utf8 (Node's default), as a
|
|
2748
3114
|
* compile-time literal or absent. */
|
|
2749
3115
|
function checkUtf8Encoding(lowerer, member, arg) {
|
|
@@ -3037,7 +3403,16 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3037
3403
|
if (probed?.type.kind === "nullT")
|
|
3038
3404
|
return "null";
|
|
3039
3405
|
}
|
|
3040
|
-
|
|
3406
|
+
// Any other value is a checked-dynamic chunk: one entry on an
|
|
3407
|
+
// object-mode side, Node's chunk type error on a byte-mode one
|
|
3408
|
+
// (undefined, which a byte-mode push ignores, included).
|
|
3409
|
+
if (t?.kind === "void" || t?.kind === "undefinedT")
|
|
3410
|
+
return "dyn";
|
|
3411
|
+
if (t !== null &&
|
|
3412
|
+
t.kind !== "func" &&
|
|
3413
|
+
canConvertToDyn(t, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))
|
|
3414
|
+
return "dyn";
|
|
3415
|
+
lowerer.noLowering(`${member} with a '${t ? lowerer.fmt(t) : "?"}' chunk`, node, "chunks are values that convert to checked-dynamic values: Buffers, strings, numbers, records, arrays and class instances");
|
|
3041
3416
|
};
|
|
3042
3417
|
if (member === "push" || member === "unshift") {
|
|
3043
3418
|
requireSide(readableSide, member);
|
|
@@ -3070,7 +3445,17 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3070
3445
|
checkUtf8Encoding(lowerer, member, args[1]);
|
|
3071
3446
|
const kind = chunkKind(args[0]);
|
|
3072
3447
|
if ((kind === "null" || kind === "union" || kind === "dyn") && member === "unshift") {
|
|
3073
|
-
|
|
3448
|
+
// unshift(value): an object-mode stream's value at the front, null
|
|
3449
|
+
// the end of the stream, as Node's readableAddChunk takes them
|
|
3450
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
3451
|
+
const chunk = lowerer.lowerExprExpecting(args[0], DYN);
|
|
3452
|
+
return {
|
|
3453
|
+
kind: "libCall",
|
|
3454
|
+
fn: "readable.unshiftDyn",
|
|
3455
|
+
args: [receiver, chunk],
|
|
3456
|
+
type: VOID,
|
|
3457
|
+
loc,
|
|
3458
|
+
};
|
|
3074
3459
|
}
|
|
3075
3460
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
3076
3461
|
if (kind === "null") {
|
|
@@ -3160,9 +3545,10 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3160
3545
|
if (args.length === 0 || args.length > 2) {
|
|
3161
3546
|
lowerer.noLowering(`pipe with ${args.length} arguments`, call, "the supported forms are (destination) and (destination, { end })");
|
|
3162
3547
|
}
|
|
3163
|
-
// A Hash or
|
|
3164
|
-
// answers the
|
|
3165
|
-
|
|
3548
|
+
// A Hash, Hmac, Cipheriv or Decipheriv destination pipes into its
|
|
3549
|
+
// Transform, and pipe() answers the value itself (the receiver
|
|
3550
|
+
// evaluates first, as in JS).
|
|
3551
|
+
if (isValueStream(lowerer, args[0])) {
|
|
3166
3552
|
const receiverValue = lowerer.lowerExpr(access.expression);
|
|
3167
3553
|
const source = lowerer.declareHiddenLocal("%pipeSource", receiverValue.type);
|
|
3168
3554
|
const hashValue = lowerer.lowerExpr(args[0]);
|
|
@@ -3180,7 +3566,7 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3180
3566
|
fn: "readable.pipe",
|
|
3181
3567
|
args: [
|
|
3182
3568
|
{ kind: "varRef", localId: source.id, type: receiverValue.type, loc },
|
|
3183
|
-
|
|
3569
|
+
valueStreamOf({ kind: "varRef", localId: hash.id, type: hashValue.type, loc }, true),
|
|
3184
3570
|
end,
|
|
3185
3571
|
],
|
|
3186
3572
|
type: { kind: "object", className: "%Transform" },
|
|
@@ -3314,9 +3700,50 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3314
3700
|
const kind = chunkKind(args[0]);
|
|
3315
3701
|
if (kind === "null")
|
|
3316
3702
|
lowerer.noLowering("write(null)", call, "end() finishes a writable");
|
|
3703
|
+
const lowerWriteCb = (cbArg) => {
|
|
3704
|
+
const cb = callbackDeclaresParameters(cbArg)
|
|
3705
|
+
? null
|
|
3706
|
+
: lowerer.lowerExprExpecting(cbArg, funcOf([], VOID));
|
|
3707
|
+
if (cb === null || cb.type.kind !== "func" || cb.type.params.length > 0) {
|
|
3708
|
+
lowerer.noLowering("write completion callbacks taking the error argument", cbArg, "() => void callbacks are supported (listen for 'error' to observe failures)");
|
|
3709
|
+
}
|
|
3710
|
+
return cb;
|
|
3711
|
+
};
|
|
3712
|
+
// write(chunk, encoding[, cb]), and write(value, cb): the encoding
|
|
3713
|
+
// argument reaches an object-mode side's _write as passed, null when
|
|
3714
|
+
// the callback took its place (a byte-mode side encodes a string
|
|
3715
|
+
// chunk with it).
|
|
3716
|
+
const writeEnc = (encArg, cbArg) => {
|
|
3717
|
+
const receiver = lowerer.lowerExpr(access.expression);
|
|
3718
|
+
const chunk = lowerer.lowerExprExpecting(args[0], DYN);
|
|
3719
|
+
const tail = [];
|
|
3720
|
+
if (encArg !== undefined)
|
|
3721
|
+
tail.push(lowerer.lowerExprExpecting(encArg, DYN));
|
|
3722
|
+
if (cbArg !== undefined)
|
|
3723
|
+
tail.push(lowerWriteCb(cbArg));
|
|
3724
|
+
const flags = (encArg !== undefined ? 1 : 0) | (cbArg !== undefined ? 2 : 0);
|
|
3725
|
+
return {
|
|
3726
|
+
kind: "libCall",
|
|
3727
|
+
fn: "writable.writeEnc",
|
|
3728
|
+
args: [receiver, numLit(flags, loc), chunk, ...tail],
|
|
3729
|
+
type: BOOL,
|
|
3730
|
+
loc,
|
|
3731
|
+
};
|
|
3732
|
+
};
|
|
3317
3733
|
if (kind === "dyn") {
|
|
3318
|
-
if (args.length
|
|
3319
|
-
|
|
3734
|
+
if (args.length === 3)
|
|
3735
|
+
return writeEnc(args[1], args[2]);
|
|
3736
|
+
if (args.length === 2) {
|
|
3737
|
+
// Node's write takes a function there as the callback, anything
|
|
3738
|
+
// else as the encoding
|
|
3739
|
+
const t = lowerer.mapTypeOf(lowerer.typeOf(args[1]));
|
|
3740
|
+
if (t?.kind === "func")
|
|
3741
|
+
return writeEnc(undefined, args[1]);
|
|
3742
|
+
if (t === null || t === undefined || t.kind === "dyn") {
|
|
3743
|
+
lowerer.noLowering("write with a dynamic second argument", args[1], "pass an encoding string or a completion callback");
|
|
3744
|
+
}
|
|
3745
|
+
return writeEnc(args[1], undefined);
|
|
3746
|
+
}
|
|
3320
3747
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
3321
3748
|
const chunk = lowerer.lowerExprExpecting(args[0], DYN);
|
|
3322
3749
|
return { kind: "libCall", fn: "writable.writeDyn", args: [receiver, chunk], type: BOOL, loc };
|
|
@@ -3340,23 +3767,16 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3340
3767
|
return { kind: "libCall", fn, args: [receiver, chunk], type: BOOL, loc };
|
|
3341
3768
|
}
|
|
3342
3769
|
// Disambiguate (chunk, cb?) vs (chunk, encoding, cb?) by the second
|
|
3343
|
-
// argument's static type.
|
|
3770
|
+
// argument's static type. A write with an encoding runs through
|
|
3771
|
+
// writeEnc, whose runtime checks and applies it as Node's _write does.
|
|
3344
3772
|
let cbArg;
|
|
3345
|
-
if (args.length
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
cbArg = args[2];
|
|
3349
|
-
}
|
|
3350
|
-
else if (args.length === 2) {
|
|
3773
|
+
if (args.length === 3)
|
|
3774
|
+
return writeEnc(args[1], args[2]);
|
|
3775
|
+
if (args.length === 2) {
|
|
3351
3776
|
const t = lowerer.mapTypeOf(lowerer.typeOf(args[1]));
|
|
3352
|
-
if (t?.kind === "string")
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
cbArg = args[1];
|
|
3356
|
-
}
|
|
3357
|
-
else if (args.length === 3) {
|
|
3358
|
-
checkUtf8Encoding(lowerer, "write", args[1]);
|
|
3359
|
-
cbArg = args[2];
|
|
3777
|
+
if (t?.kind === "string" || t?.kind === "nullT" || t?.kind === "undefinedT")
|
|
3778
|
+
return writeEnc(args[1], undefined);
|
|
3779
|
+
cbArg = args[1];
|
|
3360
3780
|
}
|
|
3361
3781
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
3362
3782
|
const chunk = kind === "bytes"
|
|
@@ -3364,12 +3784,7 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3364
3784
|
: lowerer.lowerExprExpecting(args[0], STRING);
|
|
3365
3785
|
const fn = kind === "bytes" ? "writable.write" : "writable.writeStr";
|
|
3366
3786
|
if (cbArg !== undefined) {
|
|
3367
|
-
const cb =
|
|
3368
|
-
? null
|
|
3369
|
-
: lowerer.lowerExprExpecting(cbArg, funcOf([], VOID));
|
|
3370
|
-
if (cb === null || cb.type.kind !== "func" || cb.type.params.length > 0) {
|
|
3371
|
-
lowerer.noLowering("write completion callbacks taking the error argument", cbArg, "() => void callbacks are supported (listen for 'error' to observe failures)");
|
|
3372
|
-
}
|
|
3787
|
+
const cb = lowerWriteCb(cbArg);
|
|
3373
3788
|
return { kind: "libCall", fn, args: [receiver, chunk, cb], type: BOOL, loc };
|
|
3374
3789
|
}
|
|
3375
3790
|
return { kind: "libCall", fn, args: [receiver, chunk], type: BOOL, loc };
|
|
@@ -3381,6 +3796,7 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3381
3796
|
// Forms: (), (cb), (chunk), (chunk, cb), (chunk, encoding, cb).
|
|
3382
3797
|
let chunkNode;
|
|
3383
3798
|
let cbArg;
|
|
3799
|
+
let encNode;
|
|
3384
3800
|
if (args.length === 1) {
|
|
3385
3801
|
const t = lowerer.mapTypeOf(lowerer.typeOf(args[0]));
|
|
3386
3802
|
if (t?.kind === "func")
|
|
@@ -3388,35 +3804,26 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3388
3804
|
else
|
|
3389
3805
|
chunkNode = args[0];
|
|
3390
3806
|
}
|
|
3391
|
-
else if (args.length >= 2 && isBufferEncoding(lowerer, args[1])) {
|
|
3392
|
-
chunkNode = args[0];
|
|
3393
|
-
const endKind = chunkKind(args[0]);
|
|
3394
|
-
if (endKind === "string") {
|
|
3395
|
-
const endT = lowerer.mapTypeOf(lowerer.typeOf(call)) ?? DYN;
|
|
3396
|
-
return nodeThrowExpr(1, "ERR_UNKNOWN_ENCODING", "Unknown encoding: buffer", endT, loc);
|
|
3397
|
-
}
|
|
3398
|
-
if (endKind !== "bytes")
|
|
3399
|
-
checkUtf8Encoding(lowerer, "end", args[1]);
|
|
3400
|
-
cbArg = args[2];
|
|
3401
|
-
}
|
|
3402
3807
|
else if (args.length === 2) {
|
|
3403
3808
|
chunkNode = args[0];
|
|
3404
3809
|
const t = lowerer.mapTypeOf(lowerer.typeOf(args[1]));
|
|
3405
|
-
if (t?.kind === "string")
|
|
3406
|
-
|
|
3810
|
+
if (t?.kind === "string" || t?.kind === "nullT" || t?.kind === "undefinedT")
|
|
3811
|
+
encNode = args[1];
|
|
3407
3812
|
else
|
|
3408
3813
|
cbArg = args[1];
|
|
3409
3814
|
}
|
|
3410
3815
|
else if (args.length === 3) {
|
|
3411
3816
|
chunkNode = args[0];
|
|
3412
|
-
|
|
3817
|
+
encNode = args[1];
|
|
3413
3818
|
cbArg = args[2];
|
|
3414
3819
|
}
|
|
3415
3820
|
const receiver = lowerer.lowerExpr(access.expression);
|
|
3416
3821
|
let flags = 0;
|
|
3417
3822
|
const tail = [];
|
|
3418
3823
|
if (chunkNode !== undefined) {
|
|
3419
|
-
|
|
3824
|
+
// end(chunk, encoding[, cb]) writes the chunk with the encoding
|
|
3825
|
+
// argument as passed (flags 16), through the dyn write
|
|
3826
|
+
const kind = encNode !== undefined ? "dyn" : chunkKind(chunkNode);
|
|
3420
3827
|
if (kind === "null" || kind === "union")
|
|
3421
3828
|
lowerer.noLowering("end(null)", call);
|
|
3422
3829
|
flags |= kind === "bytes" ? 1 : kind === "dyn" ? 8 : 2;
|
|
@@ -3425,6 +3832,10 @@ export function lowerStreamMethodCall(lowerer, call, access, info) {
|
|
|
3425
3832
|
: kind === "dyn"
|
|
3426
3833
|
? lowerer.lowerExprExpecting(chunkNode, DYN)
|
|
3427
3834
|
: lowerer.lowerExprExpecting(chunkNode, STRING));
|
|
3835
|
+
if (encNode !== undefined) {
|
|
3836
|
+
flags |= 16;
|
|
3837
|
+
tail.push(lowerer.lowerExprExpecting(encNode, DYN));
|
|
3838
|
+
}
|
|
3428
3839
|
}
|
|
3429
3840
|
if (cbArg !== undefined) {
|
|
3430
3841
|
const cb = callbackDeclaresParameters(cbArg)
|
|
@@ -3656,8 +4067,7 @@ export function lowerStreamProperty(lowerer, expr, info) {
|
|
|
3656
4067
|
return propCall(BOOL);
|
|
3657
4068
|
}
|
|
3658
4069
|
if (name === "writableObjectMode" && writableSide) {
|
|
3659
|
-
|
|
3660
|
-
return boolLit(false, loc);
|
|
4070
|
+
return propCall(BOOL);
|
|
3661
4071
|
}
|
|
3662
4072
|
if (name === "allowHalfOpen" && sides === "rw") {
|
|
3663
4073
|
return propCall(BOOL);
|