@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,7 +1,10 @@
|
|
|
1
1
|
import { staticNameBindings } from "./static-function-names.js";
|
|
2
|
+
import { positionTag } from "./structural-positions.js";
|
|
3
|
+
import { keyedHelperName } from "./stable-names.js";
|
|
2
4
|
import * as ts from "../ts7/adapter.js";
|
|
3
5
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
4
|
-
import { DYN, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
6
|
+
import { BOOL, DYN, STRING, VOID, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
7
|
+
import { helperLoc, nodeThrowExpr } from "../../ir/build.js";
|
|
5
8
|
import { isJsSourceFile, locOf } from "../program.js";
|
|
6
9
|
import { typeKey } from "../type-mapper.js";
|
|
7
10
|
import { functionCanReturnUndefined } from "../function-completion.js";
|
|
@@ -12,7 +15,7 @@ import { nsPathPrefix } from "./lower-namespaces.js";
|
|
|
12
15
|
import { declSymbolOf } from "./lower-modules.js";
|
|
13
16
|
import { npmStaticPackageOfPath } from "../npm-static.js";
|
|
14
17
|
import { rejectStaticThis } from "./static-this.js";
|
|
15
|
-
import { jsBindingHasOpenWrites } from "./lower-stmts.js";
|
|
18
|
+
import { isVarDeclared, jsBindingHasOpenWrites } from "./lower-stmts.js";
|
|
16
19
|
import { paramShapes, generatorMeta, funcTypeFromParamShapes, } from "./call-signatures.js";
|
|
17
20
|
import { fenceGenericSignatureResult, blockBodyOf, resolveInferredReturn, appendImplicitUndefinedReturn, hasExplicitJsDocReturn, promiseCarriesDyn, } from "./function-returns.js";
|
|
18
21
|
import { bindingNeverReassigned, stripValueWrappers } from "./binding-analysis.js";
|
|
@@ -63,7 +66,7 @@ export function collectGenericSignature(lowerer, decl) {
|
|
|
63
66
|
lowerer.genericFnsBySymbol.set(symbol, {
|
|
64
67
|
decl,
|
|
65
68
|
baseName: nameText,
|
|
66
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(decl) + nameText),
|
|
69
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(lowerer, decl) + nameText),
|
|
67
70
|
typeParams,
|
|
68
71
|
instances: new Map(),
|
|
69
72
|
});
|
|
@@ -85,7 +88,14 @@ export function lowerGenericCall(lowerer, expr, info) {
|
|
|
85
88
|
? implicitCallInstance(lowerer, expr, info)
|
|
86
89
|
: genericCallInstance(lowerer, expr, info);
|
|
87
90
|
const args = lowerer.completeArgs(expr.arguments.nodes, instance.params, loc, expr);
|
|
88
|
-
|
|
91
|
+
const call = {
|
|
92
|
+
kind: "call",
|
|
93
|
+
callee: instance.name,
|
|
94
|
+
args,
|
|
95
|
+
type: instance.returnType,
|
|
96
|
+
loc,
|
|
97
|
+
};
|
|
98
|
+
return guardEarlyBindingCall(lowerer, info, expr, call);
|
|
89
99
|
}
|
|
90
100
|
/** The instance a CALL of a generic function-like names: resolved
|
|
91
101
|
* signature → mapped param shapes/return → interned instance. Shared by
|
|
@@ -255,7 +265,8 @@ function runtimeReturnType(lowerer, info, mapped) {
|
|
|
255
265
|
* the result maps inside it, where the local class takes the instance's
|
|
256
266
|
* name and bindings. */
|
|
257
267
|
function localClassResultInstance(lowerer, expr, info, rsig, params, retTs) {
|
|
258
|
-
|
|
268
|
+
const resultClass = localClassOfResult(lowerer, info, retTs);
|
|
269
|
+
if (!resultClass)
|
|
259
270
|
return null;
|
|
260
271
|
const tsBindings = new Map();
|
|
261
272
|
const bindings = lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings);
|
|
@@ -272,12 +283,39 @@ function localClassResultInstance(lowerer, expr, info, rsig, params, retTs) {
|
|
|
272
283
|
});
|
|
273
284
|
if (inst.returnType !== pending)
|
|
274
285
|
return inst;
|
|
275
|
-
|
|
286
|
+
// A result typed by a declared constructor type rather than the class
|
|
287
|
+
// (`Struct<S>`) is the class value of the local class the body returns.
|
|
288
|
+
const declaredResult = info.decl.type
|
|
289
|
+
? lowerer.checker.getTypeFromTypeNode(info.decl.type)
|
|
290
|
+
: undefined;
|
|
291
|
+
const viaConstructorType = retTs.getSymbol()?.valueDeclaration !== resultClass;
|
|
292
|
+
const returnType = withInstanceScope(lowerer, info, inst, () => {
|
|
293
|
+
if (!viaConstructorType)
|
|
294
|
+
return lowerer.mapTypeOf(retTs);
|
|
295
|
+
// The local class's own constructor type: a class expression's type is
|
|
296
|
+
// its constructor type, named or not (`return class { ... } as Struct<S>`).
|
|
297
|
+
const classSymbol = !ts.isClassExpression(resultClass) && resultClass.name
|
|
298
|
+
? lowerer.checker.getSymbolAtLocation(resultClass.name)
|
|
299
|
+
: undefined;
|
|
300
|
+
const classType = ts.isClassExpression(resultClass)
|
|
301
|
+
? lowerer.checker.getTypeAtLocation(resultClass)
|
|
302
|
+
: classSymbol
|
|
303
|
+
? lowerer.checker.getTypeOfSymbol(classSymbol)
|
|
304
|
+
: undefined;
|
|
305
|
+
return classType ? lowerer.mapTypeOf(classType) : null;
|
|
306
|
+
});
|
|
276
307
|
if (!returnType) {
|
|
277
308
|
fenceGenericSignatureResult(lowerer, expr, retTs);
|
|
278
309
|
lowerer.badType(expr, retTs);
|
|
279
310
|
}
|
|
280
311
|
inst.returnType = returnType;
|
|
312
|
+
if (viaConstructorType && returnType.kind === "classval") {
|
|
313
|
+
if (declaredResult)
|
|
314
|
+
inst.resultClass = { declared: declaredResult.id, value: returnType };
|
|
315
|
+
if (lowerer.typeParamBindings === null)
|
|
316
|
+
lowerer.localClassValueTypes.set(retTs.id, returnType);
|
|
317
|
+
return inst;
|
|
318
|
+
}
|
|
281
319
|
// Values of the class outside the factory (`const b = new B()`, `b.read()`)
|
|
282
320
|
// carry the instantiated checker type; record which class it names. A
|
|
283
321
|
// call inside another generic instance can have a type that depends on
|
|
@@ -350,15 +388,103 @@ function insideGenericFunction(node) {
|
|
|
350
388
|
* constructor or instance type of, or null. */
|
|
351
389
|
function localClassOfResult(lowerer, info, type) {
|
|
352
390
|
const symbol = type.getSymbol();
|
|
353
|
-
|
|
391
|
+
const decl = symbol && symbol.flags & ts.SymbolFlags.Class ? symbol.valueDeclaration : undefined;
|
|
392
|
+
if (decl && (ts.isClassExpression(decl) || ts.isClassDeclaration(decl)))
|
|
393
|
+
return declaredInside(decl, info.decl) ? decl : null;
|
|
394
|
+
// A result typed by a constructor type (`Struct<S>`, `new () => S`) whose
|
|
395
|
+
// every return gives back the one local class, through parentheses and
|
|
396
|
+
// assertions (`return Base as Struct<S>`).
|
|
397
|
+
// A mixin (a class extending one of the function's parameters) keeps the
|
|
398
|
+
// mixin instantiation, which keys on the argument class.
|
|
399
|
+
if (lowerer.checker.getConstructSignatures(type).length === 0)
|
|
354
400
|
return null;
|
|
355
|
-
const
|
|
356
|
-
|
|
401
|
+
const returned = returnedLocalClass(lowerer, info);
|
|
402
|
+
return returned && !extendsParameter(lowerer, returned, info) ? returned : null;
|
|
403
|
+
}
|
|
404
|
+
function extendsParameter(lowerer, decl, info) {
|
|
405
|
+
const params = new Set();
|
|
406
|
+
const fn = info.decl;
|
|
407
|
+
for (const param of fn.parameters?.nodes ?? []) {
|
|
408
|
+
const symbol = ts.isIdentifier(param.name)
|
|
409
|
+
? lowerer.checker.getSymbolAtLocation(param.name)
|
|
410
|
+
: undefined;
|
|
411
|
+
if (symbol !== undefined)
|
|
412
|
+
params.add(symbol);
|
|
413
|
+
}
|
|
414
|
+
for (const clause of decl.heritageClauses?.nodes ?? [])
|
|
415
|
+
for (const base of clause.types.nodes) {
|
|
416
|
+
const symbol = ts.isIdentifier(base.expression)
|
|
417
|
+
? lowerer.checker.getSymbolAtLocation(base.expression)
|
|
418
|
+
: undefined;
|
|
419
|
+
if (symbol !== undefined && params.has(symbol))
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
function declaredInside(node, owner) {
|
|
425
|
+
for (let parent = node.parent; parent && !ts.isSourceFile(parent); parent = parent.parent)
|
|
426
|
+
if (parent === owner)
|
|
427
|
+
return true;
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
/** The local class every return of `info`'s body gives back, or null when a
|
|
431
|
+
* return gives anything else (or nothing). Nested functions and classes keep
|
|
432
|
+
* their own returns. */
|
|
433
|
+
function returnedLocalClass(lowerer, info) {
|
|
434
|
+
const fn = info.decl;
|
|
435
|
+
const body = fn.body;
|
|
436
|
+
if (!body)
|
|
357
437
|
return null;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
438
|
+
const classOf = (node) => {
|
|
439
|
+
let expr = node;
|
|
440
|
+
while (ts.isParenthesizedExpression(expr) ||
|
|
441
|
+
ts.isAsExpression(expr) ||
|
|
442
|
+
ts.isSatisfiesExpression(expr) ||
|
|
443
|
+
ts.isNonNullExpression(expr))
|
|
444
|
+
expr = expr.expression;
|
|
445
|
+
if (ts.isClassExpression(expr))
|
|
446
|
+
return declaredInside(expr, info.decl) ? expr : null;
|
|
447
|
+
if (!ts.isIdentifier(expr))
|
|
448
|
+
return null;
|
|
449
|
+
const declaration = lowerer.checker.getSymbolAtLocation(expr)?.valueDeclaration;
|
|
450
|
+
if (!declaration || !declaredInside(declaration, info.decl))
|
|
451
|
+
return null;
|
|
452
|
+
if (ts.isClassDeclaration(declaration))
|
|
453
|
+
return declaration;
|
|
454
|
+
// A `const` bound to a class expression (`const C = class { ... }; return C`).
|
|
455
|
+
if (ts.isVariableDeclaration(declaration) &&
|
|
456
|
+
ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const &&
|
|
457
|
+
declaration.initializer) {
|
|
458
|
+
let init = declaration.initializer;
|
|
459
|
+
while (ts.isParenthesizedExpression(init))
|
|
460
|
+
init = init.expression;
|
|
461
|
+
if (ts.isClassExpression(init))
|
|
462
|
+
return init;
|
|
463
|
+
}
|
|
464
|
+
return null;
|
|
465
|
+
};
|
|
466
|
+
if (!ts.isBlock(body))
|
|
467
|
+
return classOf(body);
|
|
468
|
+
let found = null;
|
|
469
|
+
let valid = true;
|
|
470
|
+
const visit = (node) => {
|
|
471
|
+
if (!valid ||
|
|
472
|
+
ts.isFunctionLike(node) ||
|
|
473
|
+
ts.isClassDeclaration(node) ||
|
|
474
|
+
ts.isClassExpression(node))
|
|
475
|
+
return;
|
|
476
|
+
if (ts.isReturnStatement(node)) {
|
|
477
|
+
const returned = node.expression ? classOf(node.expression) : null;
|
|
478
|
+
if (!returned || (found !== null && found !== returned))
|
|
479
|
+
valid = false;
|
|
480
|
+
else
|
|
481
|
+
found = returned;
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
ts.forEachChild(node, visit);
|
|
485
|
+
};
|
|
486
|
+
ts.forEachChild(body, visit);
|
|
487
|
+
return valid ? found : null;
|
|
362
488
|
}
|
|
363
489
|
/** Runs `fn` under an instance's type bindings and local-class names, as
|
|
364
490
|
* its body lowers. */
|
|
@@ -367,15 +493,18 @@ function withInstanceScope(lowerer, info, inst, fn) {
|
|
|
367
493
|
const prevTsBindings = lowerer.typeParamTsBindings;
|
|
368
494
|
const previousPath = lowerer.genericInstantiationPath;
|
|
369
495
|
const prevContext = lowerer.instantiationContext;
|
|
496
|
+
const prevResultClass = lowerer.instanceResultClass;
|
|
370
497
|
lowerer.typeParamBindings = inst.bindings;
|
|
371
498
|
lowerer.typeParamTsBindings = inst.tsBindings ?? null;
|
|
372
499
|
lowerer.genericInstantiationPath = inst.path;
|
|
373
500
|
lowerer.instantiationContext = `instantiating '${info.baseName}' with ${inst.typeArgsText}`;
|
|
501
|
+
lowerer.instanceResultClass = inst.resultClass ?? null;
|
|
374
502
|
lowerer.localClassInstantiations.push({ owner: info.decl, name: inst.name });
|
|
375
503
|
try {
|
|
376
504
|
return fn();
|
|
377
505
|
}
|
|
378
506
|
finally {
|
|
507
|
+
lowerer.instanceResultClass = prevResultClass;
|
|
379
508
|
lowerer.localClassInstantiations.pop();
|
|
380
509
|
lowerer.typeParamBindings = prevBindings;
|
|
381
510
|
lowerer.typeParamTsBindings = prevTsBindings;
|
|
@@ -419,7 +548,7 @@ function internGenericInstance(lowerer, blame, info, params, returnType, makeBin
|
|
|
419
548
|
const typeArgsText = `<${rendered.length > 80 ? rendered.slice(0, 77) + "..." : rendered}>`;
|
|
420
549
|
inst = {
|
|
421
550
|
path,
|
|
422
|
-
name: `${info.qualifiedName}
|
|
551
|
+
name: keyedHelperName(lowerer, `${info.qualifiedName}%`, key, ""),
|
|
423
552
|
ordinal: info.instances.size,
|
|
424
553
|
params,
|
|
425
554
|
returnType,
|
|
@@ -944,6 +1073,78 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
944
1073
|
}
|
|
945
1074
|
if (!target)
|
|
946
1075
|
fenceUnpinned();
|
|
1076
|
+
return guardEarlyBindingValue(lowerer, info, ref, pinnedGenericClosure(lowerer, ref, info, target, fenceUnpinned));
|
|
1077
|
+
}
|
|
1078
|
+
/** The value a generic binding declared inside a function stores when a
|
|
1079
|
+
* nested function read it before the declaration lowered (`const read =
|
|
1080
|
+
* () => id; const id: (x: number) => number = <T>(x: T): T => x`): such
|
|
1081
|
+
* a read resolves to an ordinary TDZ local, so the declaration assigns it
|
|
1082
|
+
* the instance its concrete declared signature pins. Each evaluation of
|
|
1083
|
+
* the declaration makes a new function object, as in JavaScript: the
|
|
1084
|
+
* value is a closure over a forwarder to the instance, not the instance's
|
|
1085
|
+
* interned closure. */
|
|
1086
|
+
export function genericBindingStoredValue(lowerer, decl, info) {
|
|
1087
|
+
const name = decl.name;
|
|
1088
|
+
const fenceUnpinned = () => lowerer.unsupported("SC1090", name, `generic function bindings read before their declaration without a concrete declared signature (annotate '${info.baseName}' with one, or declare it before its uses)`);
|
|
1089
|
+
const sigs = lowerer.checker.getCallSignatures(lowerer.typeOf(name));
|
|
1090
|
+
if (sigs.length !== 1)
|
|
1091
|
+
fenceUnpinned();
|
|
1092
|
+
const pinned = pinnedGenericClosure(lowerer, name, info, sigs[0], fenceUnpinned);
|
|
1093
|
+
const async = ts.getModifiers(info.decl)?.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword);
|
|
1094
|
+
if (pinned.kind !== "closure" || pinned.type.kind !== "func" || pinned.type.rest || async)
|
|
1095
|
+
return lowerer.unsupported("SC1090", name, `async or rest-parameter generic function bindings read before their declaration (each evaluation of '${info.baseName}' makes a new function object)`);
|
|
1096
|
+
return {
|
|
1097
|
+
...pinned,
|
|
1098
|
+
fnName: genericValueForwarder(lowerer, info, pinned.fnName, pinned.type, pinned.loc),
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/** A lifted function that calls the instance `instance` (of type `type`)
|
|
1102
|
+
* with its own arguments. Lifted functions get a new closure object per
|
|
1103
|
+
* evaluation; module functions, which instances are, get one interned
|
|
1104
|
+
* closure. */
|
|
1105
|
+
function genericValueForwarder(lowerer, info, instance, type, at) {
|
|
1106
|
+
info.valueForwarders ??= new Map();
|
|
1107
|
+
const existing = info.valueForwarders.get(instance);
|
|
1108
|
+
if (existing !== undefined)
|
|
1109
|
+
return existing;
|
|
1110
|
+
const name = `${instance}%value`;
|
|
1111
|
+
const loc = helperLoc(at);
|
|
1112
|
+
const params = type.params.map((paramType, i) => ({
|
|
1113
|
+
localId: `%arg${i}.0`,
|
|
1114
|
+
name: `%arg${i}`,
|
|
1115
|
+
type: paramType,
|
|
1116
|
+
}));
|
|
1117
|
+
const call = {
|
|
1118
|
+
kind: "call",
|
|
1119
|
+
callee: instance,
|
|
1120
|
+
args: params.map((p) => ({ kind: "varRef", localId: p.localId, type: p.type, loc })),
|
|
1121
|
+
type: type.ret,
|
|
1122
|
+
loc,
|
|
1123
|
+
};
|
|
1124
|
+
lowerer.liftedFns.push({
|
|
1125
|
+
name,
|
|
1126
|
+
params,
|
|
1127
|
+
returnType: type.ret,
|
|
1128
|
+
locals: params.map((p) => ({ id: p.localId, name: p.name, type: p.type, mutable: false })),
|
|
1129
|
+
captures: [],
|
|
1130
|
+
...(ts.isFunctionExpression(info.decl) ? { ownsPrototype: true } : {}),
|
|
1131
|
+
body: type.ret.kind === "void"
|
|
1132
|
+
? [
|
|
1133
|
+
{ kind: "exprStmt", expr: call, loc },
|
|
1134
|
+
{ kind: "return", value: null, loc },
|
|
1135
|
+
]
|
|
1136
|
+
: [{ kind: "return", value: call, loc }],
|
|
1137
|
+
loc,
|
|
1138
|
+
});
|
|
1139
|
+
lowerer.noteEdge(name);
|
|
1140
|
+
info.valueForwarders.set(instance, name);
|
|
1141
|
+
return name;
|
|
1142
|
+
}
|
|
1143
|
+
/** The closure of the instance of `info` that `target` pins, for a value
|
|
1144
|
+
* read at `ref`. `fenceUnpinned` reports a signature that leaves a type
|
|
1145
|
+
* parameter unbound. */
|
|
1146
|
+
function pinnedGenericClosure(lowerer, ref, info, target, fenceUnpinned) {
|
|
1147
|
+
const loc = locOf(ref);
|
|
947
1148
|
const bindings = new Map();
|
|
948
1149
|
unifySignatureBindings(lowerer, info, target, bindings);
|
|
949
1150
|
const hofBinding = runtimeOptionalHofGenericBinding(lowerer, ref, info);
|
|
@@ -1740,7 +1941,7 @@ function internImplicitInstance(lowerer, blame, info, shapes, argTypes, patternK
|
|
|
1740
1941
|
const declared = dynamicBroadPromise ? null : implicitDeclaredReturn(lowerer, info);
|
|
1741
1942
|
inst = {
|
|
1742
1943
|
path,
|
|
1743
|
-
name: `${info.qualifiedName}
|
|
1944
|
+
name: keyedHelperName(lowerer, `${info.qualifiedName}%`, key, ""),
|
|
1744
1945
|
ordinal: info.instances.size,
|
|
1745
1946
|
params: shapes,
|
|
1746
1947
|
// The promise callers rely on before the body settles it: the
|
|
@@ -1921,7 +2122,7 @@ export function implicitLocalFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1921
2122
|
const info = {
|
|
1922
2123
|
decl: fnNode,
|
|
1923
2124
|
baseName: name,
|
|
1924
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(stmt ?? decl, decl) + `${name}%l${
|
|
2125
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(lowerer, stmt ?? decl, decl) + `${name}%l${positionTag(lowerer, decl)}`),
|
|
1925
2126
|
typeParams: [],
|
|
1926
2127
|
instances: new Map(),
|
|
1927
2128
|
implicitParams: implicit,
|
|
@@ -1993,7 +2194,7 @@ export function objLitGenericFnInfoOf(lowerer, blame, name, found) {
|
|
|
1993
2194
|
const info = {
|
|
1994
2195
|
decl: fnNode,
|
|
1995
2196
|
baseName: name,
|
|
1996
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(fnNode), `%ol${
|
|
2197
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(fnNode), `%ol${positionTag(lowerer, fnNode)}.${name}`),
|
|
1997
2198
|
typeParams,
|
|
1998
2199
|
instances: new Map(),
|
|
1999
2200
|
objectLiteral: true,
|
|
@@ -2114,14 +2315,24 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
2114
2315
|
const info = {
|
|
2115
2316
|
decl: fnNode,
|
|
2116
2317
|
baseName: name,
|
|
2117
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(stmt ?? decl, decl) +
|
|
2318
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(lowerer, stmt ?? decl, decl) +
|
|
2118
2319
|
(topLevel ? name : `${name}%l${ts.tokenStartOfNode(decl)}`)),
|
|
2119
2320
|
typeParams,
|
|
2120
2321
|
instances: new Map(),
|
|
2121
2322
|
...(functionScoped ? { functionScoped: true } : {}),
|
|
2323
|
+
bindingDecl: decl,
|
|
2122
2324
|
};
|
|
2123
2325
|
lowerer.bindingGenericFns.set(fnNode, info);
|
|
2124
2326
|
lowerer.genericFnsBySymbol.set(sym, info);
|
|
2327
|
+
// Module-scope uses resolve to the instances from the start, so those
|
|
2328
|
+
// that can run first need the flag. Inside a function the declaration
|
|
2329
|
+
// registers before any later use lowers, and earlier uses read a TDZ
|
|
2330
|
+
// box (genericBindingStoredValue).
|
|
2331
|
+
if (!functionScoped) {
|
|
2332
|
+
const presence = bindingPresenceOf(lowerer, info, decl, sym);
|
|
2333
|
+
if (presence !== undefined)
|
|
2334
|
+
info.presence = presence;
|
|
2335
|
+
}
|
|
2125
2336
|
if (ts.isFunctionExpression(fnNode) && fnNode.name !== undefined) {
|
|
2126
2337
|
const inner = lowerer.checker.getSymbolAtLocation(fnNode.name);
|
|
2127
2338
|
if (inner)
|
|
@@ -2129,6 +2340,225 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
2129
2340
|
}
|
|
2130
2341
|
return info;
|
|
2131
2342
|
}
|
|
2343
|
+
/** Whether `use`, a reference to the binding `info` declares, can only
|
|
2344
|
+
* run after the declaration has run: it follows the declaration in its
|
|
2345
|
+
* statement list (closures count where they are created), sits inside the
|
|
2346
|
+
* initializer itself, or is inside a function declaration whose every
|
|
2347
|
+
* reference does. References from other modules run after this module's
|
|
2348
|
+
* body, and export specifiers only export. A use the check cannot place
|
|
2349
|
+
* answers false. */
|
|
2350
|
+
export function runsAfterDeclaration(lowerer, info, use) {
|
|
2351
|
+
const decl = info.bindingDecl;
|
|
2352
|
+
if (decl === undefined)
|
|
2353
|
+
return true;
|
|
2354
|
+
info.ordering ??= new Map();
|
|
2355
|
+
return useRunsAfter(lowerer, decl, use, info.ordering, new Set());
|
|
2356
|
+
}
|
|
2357
|
+
function useRunsAfter(lowerer, decl, use, memo, inProgress) {
|
|
2358
|
+
if (ts.getSourceFileOfNode(use) !== ts.getSourceFileOfNode(decl))
|
|
2359
|
+
return true;
|
|
2360
|
+
const init = decl.initializer;
|
|
2361
|
+
if (init !== undefined && use.pos >= init.pos && use.end <= init.end)
|
|
2362
|
+
return true;
|
|
2363
|
+
const stmt = decl.parent?.parent;
|
|
2364
|
+
const list = stmt?.parent;
|
|
2365
|
+
if (stmt === undefined || list === undefined)
|
|
2366
|
+
return false;
|
|
2367
|
+
for (let n = use; n.parent !== undefined; n = n.parent) {
|
|
2368
|
+
if (n.parent === list)
|
|
2369
|
+
return n === stmt ? use.pos >= decl.end : n.pos >= stmt.end;
|
|
2370
|
+
if (ts.isFunctionDeclaration(n))
|
|
2371
|
+
return functionRunsAfter(lowerer, decl, n, memo, inProgress);
|
|
2372
|
+
}
|
|
2373
|
+
return false;
|
|
2374
|
+
}
|
|
2375
|
+
/** Whether every call of the function declaration `fn` runs after `decl`
|
|
2376
|
+
* has run. A function in progress counts as running after: its calls of
|
|
2377
|
+
* itself, directly or through other functions, add no earlier caller.
|
|
2378
|
+
* Only answers that depend on no function in progress are memoized. */
|
|
2379
|
+
function functionRunsAfter(lowerer, decl, fn, memo, inProgress) {
|
|
2380
|
+
const known = memo.get(fn);
|
|
2381
|
+
if (known !== undefined)
|
|
2382
|
+
return known;
|
|
2383
|
+
if (inProgress.has(fn))
|
|
2384
|
+
return true;
|
|
2385
|
+
// `export default function () {}`: only importers call it, after this
|
|
2386
|
+
// module's body has run.
|
|
2387
|
+
if (fn.name === undefined)
|
|
2388
|
+
return true;
|
|
2389
|
+
inProgress.add(fn);
|
|
2390
|
+
let result = true;
|
|
2391
|
+
try {
|
|
2392
|
+
const symbol = lowerer.checker.getSymbolAtLocation(fn.name);
|
|
2393
|
+
if (symbol === undefined)
|
|
2394
|
+
result = false;
|
|
2395
|
+
else {
|
|
2396
|
+
for (const ref of bindingReferences(lowerer, ts.getSourceFileOfNode(fn), symbol, fn.name)) {
|
|
2397
|
+
if (ref.pos >= fn.pos && ref.end <= fn.end)
|
|
2398
|
+
continue;
|
|
2399
|
+
if (!useRunsAfter(lowerer, decl, ref, memo, inProgress)) {
|
|
2400
|
+
result = false;
|
|
2401
|
+
break;
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
finally {
|
|
2407
|
+
inProgress.delete(fn);
|
|
2408
|
+
}
|
|
2409
|
+
if (inProgress.size === 0)
|
|
2410
|
+
memo.set(fn, result);
|
|
2411
|
+
return result;
|
|
2412
|
+
}
|
|
2413
|
+
/** The value references of `symbol` in `file` other than `name` (its
|
|
2414
|
+
* declaration name): identifiers spelled like it that resolve to it,
|
|
2415
|
+
* outside type positions and export specifiers. */
|
|
2416
|
+
function bindingReferences(lowerer, file, symbol, name) {
|
|
2417
|
+
let byName = lowerer.bindingIdentifiers.get(file);
|
|
2418
|
+
if (byName === undefined) {
|
|
2419
|
+
byName = new Map();
|
|
2420
|
+
lowerer.bindingIdentifiers.set(file, byName);
|
|
2421
|
+
}
|
|
2422
|
+
let idents = byName.get(name.text);
|
|
2423
|
+
if (idents === undefined) {
|
|
2424
|
+
const found = [];
|
|
2425
|
+
ts.walkPreorder(file, (node) => {
|
|
2426
|
+
if (ts.isIdentifier(node) && node.text === name.text)
|
|
2427
|
+
found.push(node);
|
|
2428
|
+
return undefined;
|
|
2429
|
+
});
|
|
2430
|
+
lowerer.checker.prefetchSymbolNodesExact(found);
|
|
2431
|
+
byName.set(name.text, found);
|
|
2432
|
+
idents = found;
|
|
2433
|
+
}
|
|
2434
|
+
return idents.filter((ident) => {
|
|
2435
|
+
if (ident === name)
|
|
2436
|
+
return false;
|
|
2437
|
+
const parent = ident.parent;
|
|
2438
|
+
if (parent === undefined || ts.isExportSpecifier(parent) || ts.isExportAssignment(parent))
|
|
2439
|
+
return false;
|
|
2440
|
+
let resolved = lowerer.checker.getSymbolAtLocation(ident);
|
|
2441
|
+
if (ts.isShorthandPropertyAssignment(parent) && parent.name === ident)
|
|
2442
|
+
resolved = lowerer.checker.getShorthandAssignmentValueSymbol(parent) ?? resolved;
|
|
2443
|
+
if (resolved !== symbol)
|
|
2444
|
+
return false;
|
|
2445
|
+
for (let p = parent; p !== undefined; p = p.parent) {
|
|
2446
|
+
if (ts.isTypeNode(p) && p.kind !== ts.SyntaxKind.ExpressionWithTypeArguments)
|
|
2447
|
+
return false;
|
|
2448
|
+
if (ts.isStatement(p) || ts.isFunctionLike(p))
|
|
2449
|
+
break;
|
|
2450
|
+
}
|
|
2451
|
+
return true;
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
/** The presence flag of a module-scope generic binding that code can use
|
|
2455
|
+
* before its declaration runs (a hoisted function or an earlier closure
|
|
2456
|
+
* called during module evaluation), or undefined when every use runs
|
|
2457
|
+
* after it. The declaration statement sets the flag. */
|
|
2458
|
+
function bindingPresenceOf(lowerer, info, decl, symbol) {
|
|
2459
|
+
const name = decl.name;
|
|
2460
|
+
const early = bindingReferences(lowerer, ts.getSourceFileOfNode(decl), symbol, name).some((ref) => !runsAfterDeclaration(lowerer, info, ref));
|
|
2461
|
+
if (!early)
|
|
2462
|
+
return undefined;
|
|
2463
|
+
const flagId = `%g.${info.qualifiedName}%initialized`;
|
|
2464
|
+
lowerer.globalsList.push({ id: flagId, name: "%initialized", type: BOOL, mutable: true });
|
|
2465
|
+
return { flagId, lexical: !isVarDeclared(decl) };
|
|
2466
|
+
}
|
|
2467
|
+
/** The statement that records a generic binding's declaration as run,
|
|
2468
|
+
* for a binding with a presence flag. */
|
|
2469
|
+
export function genericBindingPresenceStore(info, decl) {
|
|
2470
|
+
if (info.presence === undefined)
|
|
2471
|
+
return null;
|
|
2472
|
+
const loc = locOf(decl);
|
|
2473
|
+
return {
|
|
2474
|
+
kind: "assign",
|
|
2475
|
+
localId: info.presence.flagId,
|
|
2476
|
+
value: { kind: "boolLit", value: true, type: BOOL, loc },
|
|
2477
|
+
loc,
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
/** A call of a generic binding where the binding may not be initialized
|
|
2481
|
+
* yet. A `let`/`const` binding in its temporal dead zone throws Node's
|
|
2482
|
+
* ReferenceError before the arguments run; an unassigned `var` is
|
|
2483
|
+
* undefined, so the arguments run and the call throws "is not a
|
|
2484
|
+
* function". Calls that run after the declaration stay direct. */
|
|
2485
|
+
function guardEarlyBindingCall(lowerer, info, expr, call) {
|
|
2486
|
+
if (info.bindingDecl === undefined || runsAfterDeclaration(lowerer, info, expr))
|
|
2487
|
+
return call;
|
|
2488
|
+
const loc = call.loc;
|
|
2489
|
+
const presence = requirePresence(lowerer, info, expr.expression);
|
|
2490
|
+
const flag = { kind: "varRef", localId: presence.flagId, type: BOOL, loc };
|
|
2491
|
+
if (presence.lexical)
|
|
2492
|
+
return {
|
|
2493
|
+
kind: "seqExpr",
|
|
2494
|
+
stmts: [tdzCheck(flag, info.baseName, loc)],
|
|
2495
|
+
result: call,
|
|
2496
|
+
type: call.type,
|
|
2497
|
+
loc,
|
|
2498
|
+
};
|
|
2499
|
+
// Arguments first, in order, then the check: Node evaluates them
|
|
2500
|
+
// before it finds the callee is not callable.
|
|
2501
|
+
const stmts = [];
|
|
2502
|
+
const args = call.args.map((arg) => {
|
|
2503
|
+
const id = `%earlyCallArg.${lowerer.ctx.locals.length}`;
|
|
2504
|
+
lowerer.ctx.locals.push({ id, name: "%earlyCallArg", type: arg.type, mutable: false });
|
|
2505
|
+
stmts.push({ kind: "varDecl", localId: id, init: arg, loc });
|
|
2506
|
+
return { kind: "varRef", localId: id, type: arg.type, loc };
|
|
2507
|
+
});
|
|
2508
|
+
return {
|
|
2509
|
+
kind: "seqExpr",
|
|
2510
|
+
stmts,
|
|
2511
|
+
result: {
|
|
2512
|
+
kind: "ternary",
|
|
2513
|
+
cond: flag,
|
|
2514
|
+
then: { ...call, args },
|
|
2515
|
+
else_: nodeThrowExpr(1, "", `${info.baseName} is not a function`, call.type, loc),
|
|
2516
|
+
type: call.type,
|
|
2517
|
+
loc,
|
|
2518
|
+
},
|
|
2519
|
+
type: call.type,
|
|
2520
|
+
loc,
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
/** A generic binding read as a value where it may not be initialized
|
|
2524
|
+
* yet: a `let`/`const` binding checks its temporal dead zone first. */
|
|
2525
|
+
function guardEarlyBindingValue(lowerer, info, ref, value) {
|
|
2526
|
+
if (info.bindingDecl === undefined || runsAfterDeclaration(lowerer, info, ref))
|
|
2527
|
+
return value;
|
|
2528
|
+
const presence = requirePresence(lowerer, info, ref);
|
|
2529
|
+
if (!presence.lexical)
|
|
2530
|
+
lowerer.unsupported("SC1090", ref, `generic 'var' bindings read as values before their declaration runs (Node reads undefined there; declare '${info.baseName}' with const)`);
|
|
2531
|
+
const loc = value.loc;
|
|
2532
|
+
const flag = { kind: "varRef", localId: presence.flagId, type: BOOL, loc };
|
|
2533
|
+
return {
|
|
2534
|
+
kind: "seqExpr",
|
|
2535
|
+
stmts: [tdzCheck(flag, info.baseName, loc)],
|
|
2536
|
+
result: value,
|
|
2537
|
+
type: value.type,
|
|
2538
|
+
loc,
|
|
2539
|
+
};
|
|
2540
|
+
}
|
|
2541
|
+
/** The presence flag a use that can run before the declaration checks.
|
|
2542
|
+
* Only module-scope bindings have one: a binding inside a function would
|
|
2543
|
+
* need a per-call flag that its closures share. */
|
|
2544
|
+
function requirePresence(lowerer, info, blame) {
|
|
2545
|
+
if (info.presence !== undefined)
|
|
2546
|
+
return info.presence;
|
|
2547
|
+
return lowerer.unsupported("SC1090", blame, `generic arrow/function-expression bindings declared inside functions that code can call before their declaration runs (the binding '${info.baseName}' is a 'var' in a branch or block, or is called from a place that can run first — declare it with const before its uses)`);
|
|
2548
|
+
}
|
|
2549
|
+
function tdzCheck(flag, name, loc) {
|
|
2550
|
+
return {
|
|
2551
|
+
kind: "exprStmt",
|
|
2552
|
+
expr: {
|
|
2553
|
+
kind: "intrinsic",
|
|
2554
|
+
name: "module.tdzCheck",
|
|
2555
|
+
args: [flag, { kind: "strLit", value: name, type: STRING, loc }],
|
|
2556
|
+
type: VOID,
|
|
2557
|
+
loc,
|
|
2558
|
+
},
|
|
2559
|
+
loc,
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2132
2562
|
/** `const h = id` — a binding ALIASING a generic function (a top-level
|
|
2133
2563
|
* declaration, a registered generic binding, or another alias — resolved
|
|
2134
2564
|
* left to right in declaration order). The alias registers the SAME info
|