@scriptc/compiler 0.4.0 → 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 +617 -83
- 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 +10 -0
- 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 +7 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +2 -0
- package/dist/backend/link-plan-core.js +2 -0
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +1 -0
- package/dist/backend/link-plan.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 +4 -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 +99 -2
- package/dist/backend/llvm/classes.js +436 -57
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +235 -16
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +21 -5
- package/dist/backend/llvm/common.js +50 -5
- 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-access.d.ts +3 -1
- package/dist/backend/llvm/dense-array-access.js +61 -38
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +4 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.d.ts +19 -16
- package/dist/backend/llvm/dense-array-loops.js +49 -13
- 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 +34 -1
- package/dist/backend/llvm/dyn.js +393 -14
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +27 -8
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +67 -39
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +3 -25
- package/dist/backend/llvm/emit-statements.js +414 -37
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +159 -22
- package/dist/backend/llvm/emitter.js +573 -89
- 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 +51 -26
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +27 -14
- 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 +95 -5
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +29 -11
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -0
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +48 -20
- 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/integer-clones.js +3 -3
- package/dist/backend/llvm/integer-clones.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +18 -0
- package/dist/backend/llvm/js-ic.js +712 -0
- package/dist/backend/llvm/js-ic.js.map +1 -0
- package/dist/backend/llvm/jsval.js +139 -11
- package/dist/backend/llvm/jsval.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 +69 -17
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +75 -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 +91 -61
- 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/map-number-lookup.d.ts +20 -4
- package/dist/backend/llvm/map-number-lookup.js +43 -7
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/narrow-guards.js +64 -0
- package/dist/backend/llvm/narrow-guards.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +11 -1
- package/dist/backend/llvm/publish.js +80 -22
- 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/regions.js +2 -2
- package/dist/backend/llvm/regions.js.map +1 -1
- package/dist/backend/llvm/regions.test.js +7 -1
- package/dist/backend/llvm/regions.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +17 -9
- package/dist/backend/llvm/shapes.js +21 -17
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +20 -1
- package/dist/backend/llvm/speculative-integers.js +94 -6
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.test.js +55 -1
- package/dist/backend/llvm/speculative-integers.test.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 +4 -1
- package/dist/backend/llvm/string-reads.js +88 -4
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/thread-slots.test.js +5 -4
- package/dist/backend/llvm/thread-slots.test.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 +8 -0
- package/dist/backend/mangle.js +12 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +40 -2
- package/dist/backend/native/executable.js +40 -7
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +3 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +17 -6
- package/dist/backend/native-codegen.js +55 -9
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +18 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +30 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-profile.d.ts +32 -0
- package/dist/backend/native-profile.js +39 -0
- package/dist/backend/native-profile.js.map +1 -0
- package/dist/backend/native-profile.test.d.ts +1 -0
- package/dist/backend/native-profile.test.js +58 -0
- package/dist/backend/native-profile.test.js.map +1 -0
- package/dist/backend/native-tools.d.ts +14 -0
- package/dist/backend/native-tools.js +13 -0
- package/dist/backend/native-tools.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 +4 -0
- package/dist/backend/runtime-pack-core.js +4 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +7 -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 +12 -69
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +38 -1
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +6 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +89 -7
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +3 -0
- package/dist/cli/output-options.d.ts +2 -0
- package/dist/cli/output-options.js +9 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +15 -1
- package/dist/cli/usage.js +30 -2
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +9 -0
- package/dist/contracts/check.js +2 -3
- 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 +32 -0
- package/dist/executable/executable-cache.js +65 -7
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +50 -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/arguments-usage.d.ts +8 -0
- package/dist/frontend/arguments-usage.js +98 -0
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/arguments-usage.test.d.ts +1 -0
- package/dist/frontend/arguments-usage.test.js +32 -0
- package/dist/frontend/arguments-usage.test.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.d.ts +24 -0
- package/dist/frontend/builtin-package-aliases.js +133 -0
- package/dist/frontend/builtin-package-aliases.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.test.d.ts +1 -0
- package/dist/frontend/builtin-package-aliases.test.js +48 -0
- package/dist/frontend/builtin-package-aliases.test.js.map +1 -0
- 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/dts-paths.d.ts +4 -0
- package/dist/frontend/dts-paths.js +9 -1
- package/dist/frontend/dts-paths.js.map +1 -1
- 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/builtin-class-dyn.d.ts +8 -0
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js +50 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +3 -2
- package/dist/frontend/lowering/builtins/callable-aliases.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 +7 -2
- package/dist/frontend/lowering/builtins/crypto.js +63 -4
- 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 +21 -0
- package/dist/frontend/lowering/builtins/ecdh.js +208 -0
- package/dist/frontend/lowering/builtins/ecdh.js.map +1 -0
- 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 +54 -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.d.ts +9 -0
- package/dist/frontend/lowering/builtins/process.js +47 -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.d.ts +3 -0
- package/dist/frontend/lowering/builtins/promisify-callback.js +23 -4
- 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/reflection.js +26 -0
- package/dist/frontend/lowering/builtins/reflection.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 +6 -2
- package/dist/frontend/lowering/builtins/timers.js.map +1 -1
- package/dist/frontend/lowering/builtins/typed-array-members.d.ts +7 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js +160 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js.map +1 -0
- 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.d.ts +4 -0
- package/dist/frontend/lowering/call-signatures.js +137 -13
- 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/cjs-exports-object.js +34 -1
- package/dist/frontend/lowering/cjs-exports-object.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 +577 -152
- 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 +17 -0
- package/dist/frontend/lowering/class-protocols.js +117 -7
- 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 +42 -4
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.d.ts +2 -2
- package/dist/frontend/lowering/class-to-primitive.js +31 -8
- 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/fresh-spread.d.ts +13 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js +95 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +105 -75
- 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 +15 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +36 -32
- 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 +32 -4
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +11 -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 +10 -1
- package/dist/frontend/lowering/containers/bytes.js +601 -24
- 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 +80 -10
- 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 +85 -22
- 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.d.ts +26 -10
- package/dist/frontend/lowering/cycle-initialization.js +177 -39
- 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 +48 -13
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +124 -8
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +30 -7
- 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/keyed-field-targets.d.ts +14 -2
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +91 -10
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +52 -7
- 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 +75 -7
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +17 -8
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +5 -4
- package/dist/frontend/lowering/expressions/property-access.js +351 -16
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +112 -9
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +13 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +64 -10
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +191 -1
- package/dist/frontend/lowering/generator-delegation.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 +46 -1
- package/dist/frontend/lowering/generic-functions.js +660 -73
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +24 -0
- package/dist/frontend/lowering/handle-properties.js +281 -0
- package/dist/frontend/lowering/handle-properties.js.map +1 -0
- package/dist/frontend/lowering/intern-tables.js +2 -1
- package/dist/frontend/lowering/intern-tables.js.map +1 -1
- package/dist/frontend/lowering/iterable-spelling.d.ts +7 -0
- package/dist/frontend/lowering/iterable-spelling.js +38 -0
- package/dist/frontend/lowering/iterable-spelling.js.map +1 -0
- 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-array-sort.d.ts +33 -15
- package/dist/frontend/lowering/lower-array-sort.js +117 -21
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +93 -14
- package/dist/frontend/lowering/lower-array-sort.test.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-builtin-values.js +1 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +4 -0
- package/dist/frontend/lowering/lower-calls.js +504 -97
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +22 -0
- package/dist/frontend/lowering/lower-classes.js +339 -32
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +65 -15
- 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 +148 -12
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +308 -72
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +10 -4
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +578 -16
- 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.d.ts +11 -3
- package/dist/frontend/lowering/lower-modules.js +227 -72
- 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 +24 -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 +263 -60
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +39 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +7 -10
- package/dist/frontend/lowering/lower-stmts.js +584 -69
- 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 +21 -4
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +151 -30
- package/dist/frontend/lowering/lowerer.js +725 -84
- 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/rebindable-functions.d.ts +8 -0
- package/dist/frontend/lowering/rebindable-functions.js +54 -0
- package/dist/frontend/lowering/rebindable-functions.js.map +1 -0
- 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 +26 -0
- package/dist/frontend/lowering/static-typeof.js +172 -0
- package/dist/frontend/lowering/static-typeof.js.map +1 -0
- package/dist/frontend/lowering/strict-equality.js +2 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/string-index-bounds.js +3 -2
- package/dist/frontend/lowering/string-index-bounds.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 +72 -30
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/thenables.d.ts +16 -0
- package/dist/frontend/lowering/thenables.js +124 -0
- package/dist/frontend/lowering/thenables.js.map +1 -0
- package/dist/frontend/lowering/var-hoisting.js +37 -3
- package/dist/frontend/lowering/var-hoisting.js.map +1 -1
- package/dist/frontend/npm-static-builtin-aliases.d.ts +8 -0
- package/dist/frontend/npm-static-builtin-aliases.js +65 -0
- package/dist/frontend/npm-static-builtin-aliases.js.map +1 -0
- package/dist/frontend/npm-static-bundled-chunks.d.ts +8 -1
- package/dist/frontend/npm-static-bundled-chunks.js +173 -2
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
- package/dist/frontend/npm-static-bundled-chunks.test.js +112 -0
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.js +224 -4
- package/dist/frontend/npm-static-bundled-esm.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.test.js +129 -0
- package/dist/frontend/npm-static-bundled-esm.test.js.map +1 -1
- package/dist/frontend/npm-static-enum-iife.d.ts +6 -0
- package/dist/frontend/npm-static-enum-iife.js +280 -0
- package/dist/frontend/npm-static-enum-iife.js.map +1 -0
- package/dist/frontend/npm-static-enum-iife.test.d.ts +1 -0
- package/dist/frontend/npm-static-enum-iife.test.js +116 -0
- package/dist/frontend/npm-static-enum-iife.test.js.map +1 -0
- 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 +16 -0
- package/dist/frontend/npm-static.js +93 -3
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.js +13 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +47 -0
- package/dist/frontend/package-shims.js +300 -0
- package/dist/frontend/package-shims.js.map +1 -0
- package/dist/frontend/pipeline.js +67 -1
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +21 -0
- package/dist/frontend/program.js +174 -14
- 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/resolve.js +13 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/services.d.ts +12 -0
- package/dist/frontend/services.js +37 -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.d.ts +6 -5
- package/dist/frontend/ts7/program-host.js +12 -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 +18 -0
- package/dist/frontend/ts7/semantic-model.js +90 -16
- 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.d.ts +19 -4
- 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 +466 -47
- 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 +8 -0
- package/dist/index.js +453 -85
- package/dist/index.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +3 -2
- package/dist/ir/array-length-stability.js +22 -2
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +47 -1
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +41 -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 +187 -16
- 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 +14 -4
- package/dist/ir/integer-loop-facts.js +172 -32
- 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.d.ts +10 -1
- package/dist/ir/integer-ranges.js +122 -25
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +255 -1
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +17 -2
- package/dist/ir/ir.js +11 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-ic.d.ts +52 -0
- package/dist/ir/js-ic.js +199 -0
- package/dist/ir/js-ic.js.map +1 -0
- package/dist/ir/js-ic.test.d.ts +1 -0
- package/dist/ir/js-ic.test.js +148 -0
- package/dist/ir/js-ic.test.js.map +1 -0
- package/dist/ir/jsval.js +38 -4
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +64 -5
- package/dist/ir/runtime-features.js +358 -101
- 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 +124 -70
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +77 -24
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +15 -2
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +11 -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 +22 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +33 -4
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache.js +3 -0
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.js +8 -1
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +10 -0
- 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 +22 -21
- package/shims/fs-extra/core/api.ts +1192 -0
- package/shims/fs-extra/index.ts +9 -0
- package/shims/undici/core/agent.ts +163 -0
- package/shims/undici/core/api.ts +93 -0
- package/shims/undici/core/client.ts +1304 -0
- package/shims/undici/core/connector.ts +157 -0
- package/shims/undici/core/diagnostics-types.ts +68 -0
- package/shims/undici/core/diagnostics.ts +16 -0
- package/shims/undici/core/dispatcher.ts +574 -0
- package/shims/undici/core/errors-v5.ts +22 -0
- package/shims/undici/core/errors-v7.ts +25 -0
- package/shims/undici/core/errors.ts +255 -0
- package/shims/undici/core/fetch.ts +635 -0
- package/shims/undici/core/pool.ts +280 -0
- package/shims/undici/core/readable.ts +268 -0
- package/shims/undici/core/request.ts +313 -0
- package/shims/undici/core/timers.ts +80 -0
- package/shims/undici/core/types.ts +167 -0
- package/shims/undici/core/util.ts +67 -0
- package/shims/undici/v5.ts +119 -0
- package/shims/undici/v7.ts +119 -0
- package/surface-manifest.json +20 -52
|
@@ -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
|
|
@@ -101,9 +111,13 @@ export function genericCallInstance(lowerer, expr, info) {
|
|
|
101
111
|
// reconcile bridge, like the non-generic path).
|
|
102
112
|
{
|
|
103
113
|
const rdecl = rsig ? rsig.declaration : undefined;
|
|
104
|
-
if (
|
|
114
|
+
if (rsig &&
|
|
115
|
+
rdecl &&
|
|
105
116
|
(ts.isFunctionDeclaration(rdecl) || ts.isMethodDeclaration(rdecl)) &&
|
|
106
117
|
!rdecl.body) {
|
|
118
|
+
const overload = overloadCallInstance(lowerer, expr, info, rsig, rdecl);
|
|
119
|
+
if (overload)
|
|
120
|
+
return overload;
|
|
107
121
|
lowerer.unsupported("SC1090", expr, `calls selecting an overload signature of a generic ${ts.isMethodDeclaration(rdecl) ? "method" : "function"} (only the implementation signature monomorphizes)`);
|
|
108
122
|
}
|
|
109
123
|
}
|
|
@@ -129,14 +143,7 @@ export function genericCallInstance(lowerer, expr, info) {
|
|
|
129
143
|
fenceGenericSignatureResult(lowerer, expr, retTs);
|
|
130
144
|
lowerer.badType(expr, retTs);
|
|
131
145
|
}
|
|
132
|
-
|
|
133
|
-
// there, as in JavaScript, whatever the declared result says. An async
|
|
134
|
-
// body's promise is always present and settles with undefined there.
|
|
135
|
-
const returnType = lowerer.runtimeOptionalGenericReturns.has(info.decl)
|
|
136
|
-
? mappedReturn.kind === "promise"
|
|
137
|
-
? { kind: "promise", inner: lowerer.runtimeOptionalType(mappedReturn.inner) }
|
|
138
|
-
: lowerer.runtimeOptionalType(mappedReturn)
|
|
139
|
-
: mappedReturn;
|
|
146
|
+
const returnType = runtimeReturnType(lowerer, info, mappedReturn);
|
|
140
147
|
// keyof-constrained type parameters (`K extends keyof T`): the bound
|
|
141
148
|
// LITERAL is semantic — the instance body reads the named field — so
|
|
142
149
|
// the bindings compute EAGERLY (the key needs them) and each literal
|
|
@@ -146,36 +153,120 @@ export function genericCallInstance(lowerer, expr, info) {
|
|
|
146
153
|
// share one runtime-keyed instance per IR signature, exactly the
|
|
147
154
|
// widened discipline.
|
|
148
155
|
const named = staticNameBindings(lowerer, expr, info);
|
|
149
|
-
|
|
150
|
-
if (keyofTps.size > 0) {
|
|
156
|
+
if (keyofConstrainedTypeParams(info).size > 0) {
|
|
151
157
|
const tsBindings = new Map();
|
|
152
158
|
const bindings = lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings);
|
|
153
|
-
const litKey = info.typeParams
|
|
154
|
-
.filter((tp) => keyofTps.has(tp))
|
|
155
|
-
.map((tp) => {
|
|
156
|
-
const bound = tsBindings.get(tp);
|
|
157
|
-
return bound?.isStringLiteralType()
|
|
158
|
-
? JSON.stringify(bound.value)
|
|
159
|
-
: bound?.isNumberLiteralType()
|
|
160
|
-
? String(bound.value)
|
|
161
|
-
: "*";
|
|
162
|
-
})
|
|
163
|
-
.join(",");
|
|
164
159
|
return internGenericInstance(lowerer, expr, info, params, returnType, () => bindings, {
|
|
165
|
-
extraKey:
|
|
160
|
+
extraKey: `${keyofLiteralKey(info, tsBindings)}${named?.key ?? ""}`,
|
|
166
161
|
tsBindings,
|
|
167
162
|
...(named ? { staticFnNames: named.names } : {}),
|
|
168
163
|
});
|
|
169
164
|
}
|
|
170
165
|
return internGenericInstance(lowerer, expr, info, params, returnType, (tsBindings) => lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings), named ? { extraKey: named.key, staticFnNames: named.names } : undefined);
|
|
171
166
|
}
|
|
167
|
+
/** A call that resolved to an OVERLOAD signature of a generic function
|
|
168
|
+
* or method with an implementation (`request<T>(p: WithHandler<T>):
|
|
169
|
+
* Promise<T>; request(p: Plain): Promise<Res>; request<T>(p: Params<T>)
|
|
170
|
+
* {...}`): the implementation monomorphizes under the bindings the
|
|
171
|
+
* overload's resolved signature proves for its type parameters (the
|
|
172
|
+
* structural unification every generic call uses, run against the
|
|
173
|
+
* overload; unbound parameters take their declared defaults). The
|
|
174
|
+
* instance's parameters and result are the IMPLEMENTATION's under those
|
|
175
|
+
* bindings — the body was checked against them — and the call's
|
|
176
|
+
* arguments and result coerce across, exactly as a non-generic overload
|
|
177
|
+
* call reconciles with its implementation (parameters the overload omits
|
|
178
|
+
* must be optional in the implementation). Null when the overload does
|
|
179
|
+
* not belong to this implementation or the arities do not line up. */
|
|
180
|
+
function overloadCallInstance(lowerer, expr, info, rsig, rdecl) {
|
|
181
|
+
const impl = info.decl;
|
|
182
|
+
if (rdecl.parent !== impl.parent ||
|
|
183
|
+
rdecl.name === undefined ||
|
|
184
|
+
impl.name === undefined ||
|
|
185
|
+
rdecl.name.getText() !== impl.name.getText() ||
|
|
186
|
+
rdecl.parameters.nodes.length > impl.parameters.nodes.length ||
|
|
187
|
+
impl.parameters.nodes
|
|
188
|
+
.slice(rdecl.parameters.nodes.length)
|
|
189
|
+
.some((p) => p.questionToken === undefined && p.initializer === undefined) ||
|
|
190
|
+
rdecl.parameters.nodes.some((p) => p.dotDotDotToken !== undefined))
|
|
191
|
+
return null;
|
|
192
|
+
const declSig = lowerer.checker.getSignatureFromDeclaration(impl);
|
|
193
|
+
if (!declSig)
|
|
194
|
+
return null;
|
|
195
|
+
const tsBindings = new Map();
|
|
196
|
+
const bindings = new Map();
|
|
197
|
+
unifySignatureBindings(lowerer, info, rsig, bindings, tsBindings);
|
|
198
|
+
// Explicit type arguments name the OVERLOAD's type parameters, which
|
|
199
|
+
// need not match the implementation's in order: the resolved overload
|
|
200
|
+
// already carries them, so unification binds first, and an explicit
|
|
201
|
+
// argument binds only a still-unbound implementation parameter of the
|
|
202
|
+
// same name.
|
|
203
|
+
const overloadTps = rdecl.typeParameters?.nodes ?? [];
|
|
204
|
+
expr.typeArguments?.nodes.forEach((ta, i) => {
|
|
205
|
+
const name = overloadTps[i]?.name.text;
|
|
206
|
+
const tp = info.typeParams.find((p) => ts.symbolName(p) === name);
|
|
207
|
+
if (!tp || bindings.has(tp))
|
|
208
|
+
return;
|
|
209
|
+
const taT = lowerer.checker.getTypeFromTypeNode(ta);
|
|
210
|
+
const mapped = lowerer.mapTypeOf(taT);
|
|
211
|
+
if (mapped) {
|
|
212
|
+
bindings.set(tp, mapped);
|
|
213
|
+
tsBindings.set(tp, taT);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
bindDefaultTypeParams(lowerer, info.typeParams, impl.typeParameters?.nodes, bindings, tsBindings);
|
|
217
|
+
// A type parameter the overload never mentions (a handler the overload
|
|
218
|
+
// omits) is `unknown`, the checker's own answer for an uninferred one.
|
|
219
|
+
for (const tp of info.typeParams) {
|
|
220
|
+
if (bindings.has(tp))
|
|
221
|
+
continue;
|
|
222
|
+
bindings.set(tp, DYN);
|
|
223
|
+
tsBindings.set(tp, lowerer.checker.getUnknownType());
|
|
224
|
+
}
|
|
225
|
+
const previous = lowerer.typeParamBindings;
|
|
226
|
+
const previousTs = lowerer.typeParamTsBindings;
|
|
227
|
+
lowerer.typeParamBindings = bindings;
|
|
228
|
+
lowerer.typeParamTsBindings = tsBindings;
|
|
229
|
+
let params;
|
|
230
|
+
let returnType;
|
|
231
|
+
try {
|
|
232
|
+
params = paramShapes(lowerer, impl.parameters.nodes, declSig, (_param, i) => expr.arguments.nodes[i] ?? expr);
|
|
233
|
+
returnType = lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(declSig));
|
|
234
|
+
}
|
|
235
|
+
finally {
|
|
236
|
+
lowerer.typeParamBindings = previous;
|
|
237
|
+
lowerer.typeParamTsBindings = previousTs;
|
|
238
|
+
}
|
|
239
|
+
if (!returnType)
|
|
240
|
+
return null;
|
|
241
|
+
// keyof-constrained parameters key their instance on the bound literal,
|
|
242
|
+
// as on the implementation-signature path.
|
|
243
|
+
const runtimeReturn = runtimeReturnType(lowerer, info, returnType);
|
|
244
|
+
return internGenericInstance(lowerer, expr, info, params, runtimeReturn, () => bindings, {
|
|
245
|
+
...(keyofConstrainedTypeParams(info).size > 0
|
|
246
|
+
? { extraKey: keyofLiteralKey(info, tsBindings) }
|
|
247
|
+
: {}),
|
|
248
|
+
tsBindings,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
/** An instance's result type: a body that can return an indexed read
|
|
252
|
+
* that misses returns undefined there, as in JavaScript, whatever the
|
|
253
|
+
* declared result says. An async body's promise is always present and
|
|
254
|
+
* settles with undefined there. */
|
|
255
|
+
function runtimeReturnType(lowerer, info, mapped) {
|
|
256
|
+
if (!lowerer.runtimeOptionalGenericReturns.has(info.decl))
|
|
257
|
+
return mapped;
|
|
258
|
+
return mapped.kind === "promise"
|
|
259
|
+
? { kind: "promise", inner: lowerer.runtimeOptionalType(mapped.inner) }
|
|
260
|
+
: lowerer.runtimeOptionalType(mapped);
|
|
261
|
+
}
|
|
172
262
|
/** A generic factory whose result is one of its own local classes
|
|
173
263
|
* (`function base<T>(v: T) { return class { value: T = v }; }`). Each
|
|
174
264
|
* instance has its own class, so the instance is keyed on its bindings and
|
|
175
265
|
* the result maps inside it, where the local class takes the instance's
|
|
176
266
|
* name and bindings. */
|
|
177
267
|
function localClassResultInstance(lowerer, expr, info, rsig, params, retTs) {
|
|
178
|
-
|
|
268
|
+
const resultClass = localClassOfResult(lowerer, info, retTs);
|
|
269
|
+
if (!resultClass)
|
|
179
270
|
return null;
|
|
180
271
|
const tsBindings = new Map();
|
|
181
272
|
const bindings = lowerer.inferTypeParamBindings(expr, info, rsig, tsBindings);
|
|
@@ -192,12 +283,39 @@ function localClassResultInstance(lowerer, expr, info, rsig, params, retTs) {
|
|
|
192
283
|
});
|
|
193
284
|
if (inst.returnType !== pending)
|
|
194
285
|
return inst;
|
|
195
|
-
|
|
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
|
+
});
|
|
196
307
|
if (!returnType) {
|
|
197
308
|
fenceGenericSignatureResult(lowerer, expr, retTs);
|
|
198
309
|
lowerer.badType(expr, retTs);
|
|
199
310
|
}
|
|
200
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
|
+
}
|
|
201
319
|
// Values of the class outside the factory (`const b = new B()`, `b.read()`)
|
|
202
320
|
// carry the instantiated checker type; record which class it names. A
|
|
203
321
|
// call inside another generic instance can have a type that depends on
|
|
@@ -270,15 +388,103 @@ function insideGenericFunction(node) {
|
|
|
270
388
|
* constructor or instance type of, or null. */
|
|
271
389
|
function localClassOfResult(lowerer, info, type) {
|
|
272
390
|
const symbol = type.getSymbol();
|
|
273
|
-
|
|
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)
|
|
274
400
|
return null;
|
|
275
|
-
const
|
|
276
|
-
|
|
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)
|
|
277
437
|
return null;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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;
|
|
282
488
|
}
|
|
283
489
|
/** Runs `fn` under an instance's type bindings and local-class names, as
|
|
284
490
|
* its body lowers. */
|
|
@@ -287,15 +493,18 @@ function withInstanceScope(lowerer, info, inst, fn) {
|
|
|
287
493
|
const prevTsBindings = lowerer.typeParamTsBindings;
|
|
288
494
|
const previousPath = lowerer.genericInstantiationPath;
|
|
289
495
|
const prevContext = lowerer.instantiationContext;
|
|
496
|
+
const prevResultClass = lowerer.instanceResultClass;
|
|
290
497
|
lowerer.typeParamBindings = inst.bindings;
|
|
291
498
|
lowerer.typeParamTsBindings = inst.tsBindings ?? null;
|
|
292
499
|
lowerer.genericInstantiationPath = inst.path;
|
|
293
500
|
lowerer.instantiationContext = `instantiating '${info.baseName}' with ${inst.typeArgsText}`;
|
|
501
|
+
lowerer.instanceResultClass = inst.resultClass ?? null;
|
|
294
502
|
lowerer.localClassInstantiations.push({ owner: info.decl, name: inst.name });
|
|
295
503
|
try {
|
|
296
504
|
return fn();
|
|
297
505
|
}
|
|
298
506
|
finally {
|
|
507
|
+
lowerer.instanceResultClass = prevResultClass;
|
|
299
508
|
lowerer.localClassInstantiations.pop();
|
|
300
509
|
lowerer.typeParamBindings = prevBindings;
|
|
301
510
|
lowerer.typeParamTsBindings = prevTsBindings;
|
|
@@ -339,7 +548,7 @@ function internGenericInstance(lowerer, blame, info, params, returnType, makeBin
|
|
|
339
548
|
const typeArgsText = `<${rendered.length > 80 ? rendered.slice(0, 77) + "..." : rendered}>`;
|
|
340
549
|
inst = {
|
|
341
550
|
path,
|
|
342
|
-
name: `${info.qualifiedName}
|
|
551
|
+
name: keyedHelperName(lowerer, `${info.qualifiedName}%`, key, ""),
|
|
343
552
|
ordinal: info.instances.size,
|
|
344
553
|
params,
|
|
345
554
|
returnType,
|
|
@@ -374,6 +583,24 @@ function keyofConstrainedTypeParams(info) {
|
|
|
374
583
|
info.keyofTps = out;
|
|
375
584
|
return out;
|
|
376
585
|
}
|
|
586
|
+
/** The instance-key suffix of the literals bound to `info`'s
|
|
587
|
+
* keyof-constrained type parameters (`@"a"`; `*` for a non-literal
|
|
588
|
+
* binding): two literals can map to one IR signature while their bodies
|
|
589
|
+
* read different fields. */
|
|
590
|
+
function keyofLiteralKey(info, tsBindings) {
|
|
591
|
+
const keyofTps = keyofConstrainedTypeParams(info);
|
|
592
|
+
const literals = info.typeParams
|
|
593
|
+
.filter((tp) => keyofTps.has(tp))
|
|
594
|
+
.map((tp) => {
|
|
595
|
+
const bound = tsBindings.get(tp);
|
|
596
|
+
return bound?.isStringLiteralType()
|
|
597
|
+
? JSON.stringify(bound.value)
|
|
598
|
+
: bound?.isNumberLiteralType()
|
|
599
|
+
? String(bound.value)
|
|
600
|
+
: "*";
|
|
601
|
+
});
|
|
602
|
+
return `@${literals.join(",")}`;
|
|
603
|
+
}
|
|
377
604
|
/** Type-parameter symbol → concrete IR type for one instantiation.
|
|
378
605
|
* Explicit type arguments bind directly; the rest come from structurally
|
|
379
606
|
* matching each DECLARED param/return type (which mentions the type
|
|
@@ -491,6 +718,31 @@ function unifySignatureBindings(lowerer, info, rsig, bindings, tsBindings) {
|
|
|
491
718
|
// too is safe only when no undeclared null arm remains.
|
|
492
719
|
unify(dParts[0], lowerer.checker.getNonNullableType(inst), depth + 1);
|
|
493
720
|
}
|
|
721
|
+
else if (dParts.length > 1 && iParts.length === dParts.length) {
|
|
722
|
+
// `T | Promise<T>` against `Res | Promise<Res>`: each declared
|
|
723
|
+
// part that names a generic target (Promise, an interface, an
|
|
724
|
+
// alias) pairs with the one instantiated part of the same target;
|
|
725
|
+
// a single remaining bare type parameter takes the single
|
|
726
|
+
// remaining instantiated part.
|
|
727
|
+
const remaining = [...iParts];
|
|
728
|
+
const bare = [];
|
|
729
|
+
for (const d of dParts) {
|
|
730
|
+
if (d.flags & ts.TypeFlags.TypeParameter) {
|
|
731
|
+
bare.push(d);
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
const target = d.getSymbol() ?? d.getAliasSymbol();
|
|
735
|
+
if (target === undefined)
|
|
736
|
+
return;
|
|
737
|
+
const matches = remaining.filter((i) => (i.getSymbol() ?? i.getAliasSymbol()) === target);
|
|
738
|
+
if (matches.length !== 1)
|
|
739
|
+
return;
|
|
740
|
+
remaining.splice(remaining.indexOf(matches[0]), 1);
|
|
741
|
+
unify(d, matches[0], depth + 1);
|
|
742
|
+
}
|
|
743
|
+
if (bare.length === 1 && remaining.length === 1)
|
|
744
|
+
unify(bare[0], remaining[0], depth + 1);
|
|
745
|
+
}
|
|
494
746
|
return;
|
|
495
747
|
}
|
|
496
748
|
// Instantiations of the SAME generic ALIAS (Partial<T> vs
|
|
@@ -783,6 +1035,12 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
783
1035
|
lowerer.noteEdge(inst.name);
|
|
784
1036
|
return { kind: "closure", fnName: inst.name, captures: [], type: funcType, loc };
|
|
785
1037
|
}
|
|
1038
|
+
// Each call of the enclosing function makes a new function object for a
|
|
1039
|
+
// binding declared inside it (`make() !== make()` when make returns
|
|
1040
|
+
// it), which one shared compiled instance cannot give.
|
|
1041
|
+
if (info.functionScoped) {
|
|
1042
|
+
lowerer.unsupported("SC1090", ref, `generic arrow/function-expression bindings declared inside functions as values (each call of the enclosing function makes a new '${info.baseName}' function object, while its compiled instances are shared module functions — call '${info.baseName}' directly, or declare it at module scope)`);
|
|
1043
|
+
}
|
|
786
1044
|
const fenceUnpinned = () => lowerer.unsupported("SC1090", ref, `generic functions as values without a pinned concrete signature (annotate the destination — e.g. 'const f: (x: number) => number = ${info.baseName}' — instantiate explicitly ('${info.baseName}<number>'), or call '${info.baseName}' directly)`);
|
|
787
1045
|
// The PINNING type: an instantiation expression's own checker type
|
|
788
1046
|
// (explicit type arguments applied), else the reference's contextual
|
|
@@ -815,6 +1073,78 @@ export function lowerGenericFnValue(lowerer, ref, info) {
|
|
|
815
1073
|
}
|
|
816
1074
|
if (!target)
|
|
817
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);
|
|
818
1148
|
const bindings = new Map();
|
|
819
1149
|
unifySignatureBindings(lowerer, info, target, bindings);
|
|
820
1150
|
const hofBinding = runtimeOptionalHofGenericBinding(lowerer, ref, info);
|
|
@@ -1611,7 +1941,7 @@ function internImplicitInstance(lowerer, blame, info, shapes, argTypes, patternK
|
|
|
1611
1941
|
const declared = dynamicBroadPromise ? null : implicitDeclaredReturn(lowerer, info);
|
|
1612
1942
|
inst = {
|
|
1613
1943
|
path,
|
|
1614
|
-
name: `${info.qualifiedName}
|
|
1944
|
+
name: keyedHelperName(lowerer, `${info.qualifiedName}%`, key, ""),
|
|
1615
1945
|
ordinal: info.instances.size,
|
|
1616
1946
|
params: shapes,
|
|
1617
1947
|
// The promise callers rely on before the body settles it: the
|
|
@@ -1711,28 +2041,50 @@ export function implicitLocalFnNodeOf(lowerer, decl) {
|
|
|
1711
2041
|
return null;
|
|
1712
2042
|
if (!isConst && !bindingNeverReassigned(lowerer, sym, decl))
|
|
1713
2043
|
return null;
|
|
1714
|
-
//
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
2044
|
+
// Instances are module functions with no frame.
|
|
2045
|
+
return capturesEnclosingFrame(lowerer, init, decl, init.body) ? null : init;
|
|
2046
|
+
};
|
|
2047
|
+
const node = probe();
|
|
2048
|
+
if (node === null) {
|
|
2049
|
+
lowerer.implicitLocalFns.set(decl, null);
|
|
2050
|
+
return null;
|
|
2051
|
+
}
|
|
2052
|
+
return node;
|
|
2053
|
+
}
|
|
2054
|
+
/** True when `fn`, bound by `decl`, uses its enclosing function's frame
|
|
2055
|
+
* somewhere in `scope`: `this`, `super`, `arguments` or `new.target`, or
|
|
2056
|
+
* a value or type declared in an enclosing function (a local, a parameter,
|
|
2057
|
+
* an enclosing generic's type parameter). Module-scope declarations and
|
|
2058
|
+
* the binding itself are reachable from the module functions the
|
|
2059
|
+
* instances compile to. */
|
|
2060
|
+
function capturesEnclosingFrame(lowerer, fn, decl, scope) {
|
|
2061
|
+
const file = ts.getSourceFileOfNode(decl);
|
|
2062
|
+
const self = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
2063
|
+
let captures = false;
|
|
2064
|
+
const scan = (n) => {
|
|
2065
|
+
if (captures)
|
|
2066
|
+
return;
|
|
2067
|
+
if (n.kind === ts.SyntaxKind.ThisKeyword ||
|
|
2068
|
+
n.kind === ts.SyntaxKind.SuperKeyword ||
|
|
2069
|
+
ts.isMetaProperty(n)) {
|
|
2070
|
+
// Arrow bodies see the ENCLOSING this; function expressions
|
|
2071
|
+
// rebind their own — but a bare `this` there is untyped JS
|
|
2072
|
+
// dynamism either way. Reject both, cheaply and soundly.
|
|
2073
|
+
captures = true;
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
if (ts.isIdentifier(n)) {
|
|
2077
|
+
const s = lowerer.checker.getSymbolAtLocation(n);
|
|
2078
|
+
if (s === undefined) {
|
|
2079
|
+
if (n.text === "arguments")
|
|
2080
|
+
captures = true;
|
|
1725
2081
|
}
|
|
1726
|
-
if (
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
// Declared outside the initializer, in this file: a capture
|
|
1733
|
-
// exactly when some enclosing FUNCTION scope declares it —
|
|
1734
|
-
// module-scope declarations are reachable from any module
|
|
1735
|
-
// function.
|
|
2082
|
+
else if (s !== self) {
|
|
2083
|
+
for (const d of s.declarations) {
|
|
2084
|
+
if (ts.getSourceFileOfNode(d) !== file || (d.pos >= fn.pos && d.end <= fn.end))
|
|
2085
|
+
continue;
|
|
2086
|
+
// Declared outside the function, in this file: a capture
|
|
2087
|
+
// exactly when some enclosing FUNCTION scope declares it.
|
|
1736
2088
|
for (let p = d.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
1737
2089
|
if (ts.isFunctionLike(p)) {
|
|
1738
2090
|
captures = true;
|
|
@@ -1741,17 +2093,11 @@ export function implicitLocalFnNodeOf(lowerer, decl) {
|
|
|
1741
2093
|
}
|
|
1742
2094
|
}
|
|
1743
2095
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
scan(init.body);
|
|
1747
|
-
return captures ? null : init;
|
|
2096
|
+
}
|
|
2097
|
+
ts.forEachChild(n, scan);
|
|
1748
2098
|
};
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
lowerer.implicitLocalFns.set(decl, null);
|
|
1752
|
-
return null;
|
|
1753
|
-
}
|
|
1754
|
-
return node;
|
|
2099
|
+
scan(scope);
|
|
2100
|
+
return captures;
|
|
1755
2101
|
}
|
|
1756
2102
|
/** Registers (or returns) the GenericFnInfo of a qualifying implicit-any
|
|
1757
2103
|
* function-value binding — implicitLocalFnNodeOf's companion, the
|
|
@@ -1776,7 +2122,7 @@ export function implicitLocalFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1776
2122
|
const info = {
|
|
1777
2123
|
decl: fnNode,
|
|
1778
2124
|
baseName: name,
|
|
1779
|
-
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)}`),
|
|
1780
2126
|
typeParams: [],
|
|
1781
2127
|
instances: new Map(),
|
|
1782
2128
|
implicitParams: implicit,
|
|
@@ -1848,7 +2194,7 @@ export function objLitGenericFnInfoOf(lowerer, blame, name, found) {
|
|
|
1848
2194
|
const info = {
|
|
1849
2195
|
decl: fnNode,
|
|
1850
2196
|
baseName: name,
|
|
1851
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(fnNode), `%ol${
|
|
2197
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(fnNode), `%ol${positionTag(lowerer, fnNode)}.${name}`),
|
|
1852
2198
|
typeParams,
|
|
1853
2199
|
instances: new Map(),
|
|
1854
2200
|
objectLiteral: true,
|
|
@@ -1925,9 +2271,16 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1925
2271
|
const name = decl.name.text;
|
|
1926
2272
|
if (fnNode.asteriskToken)
|
|
1927
2273
|
lowerer.unsupported("SC1071", fnNode);
|
|
2274
|
+
// Inside a function, the compiled instances are module functions, so
|
|
2275
|
+
// the initializer may not use the enclosing frame.
|
|
2276
|
+
let functionScoped = false;
|
|
1928
2277
|
for (let n = decl.parent; n !== undefined && !ts.isSourceFile(n); n = n.parent) {
|
|
1929
2278
|
if (ts.isFunctionLike(n)) {
|
|
1930
|
-
lowerer
|
|
2279
|
+
if (capturesEnclosingFrame(lowerer, fnNode, decl, fnNode)) {
|
|
2280
|
+
lowerer.unsupported("SC1090", fnNode, `generic arrow/function-expression bindings that use the frames of their enclosing functions (the compiled instantiations of '${name}' are module functions and cannot capture its locals, parameters, type parameters or 'this' — pass them as arguments, or declare the binding at module scope)`);
|
|
2281
|
+
}
|
|
2282
|
+
functionScoped = true;
|
|
2283
|
+
break;
|
|
1931
2284
|
}
|
|
1932
2285
|
}
|
|
1933
2286
|
const sym = lowerer.checker.getSymbolAtLocation(decl.name);
|
|
@@ -1956,15 +2309,30 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1956
2309
|
}
|
|
1957
2310
|
checkGenericParameterNames(lowerer, fnNode.parameters.nodes, true);
|
|
1958
2311
|
const stmt = decl.parent?.parent; // declarator → list → statement (nsPathPrefix wants the statement)
|
|
2312
|
+
// A binding in a function or block can share its name with another; its
|
|
2313
|
+
// instances take the declaration's position.
|
|
2314
|
+
const topLevel = stmt?.parent !== undefined && (ts.isSourceFile(stmt.parent) || ts.isModuleBlock(stmt.parent));
|
|
1959
2315
|
const info = {
|
|
1960
2316
|
decl: fnNode,
|
|
1961
2317
|
baseName: name,
|
|
1962
|
-
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(stmt ?? decl, decl) +
|
|
2318
|
+
qualifiedName: lowerer.qualify(ts.getSourceFileOfNode(decl), nsPathPrefix(lowerer, stmt ?? decl, decl) +
|
|
2319
|
+
(topLevel ? name : `${name}%l${ts.tokenStartOfNode(decl)}`)),
|
|
1963
2320
|
typeParams,
|
|
1964
2321
|
instances: new Map(),
|
|
2322
|
+
...(functionScoped ? { functionScoped: true } : {}),
|
|
2323
|
+
bindingDecl: decl,
|
|
1965
2324
|
};
|
|
1966
2325
|
lowerer.bindingGenericFns.set(fnNode, info);
|
|
1967
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
|
+
}
|
|
1968
2336
|
if (ts.isFunctionExpression(fnNode) && fnNode.name !== undefined) {
|
|
1969
2337
|
const inner = lowerer.checker.getSymbolAtLocation(fnNode.name);
|
|
1970
2338
|
if (inner)
|
|
@@ -1972,6 +2340,225 @@ export function bindingGenericFnInfoOf(lowerer, decl, fnNode) {
|
|
|
1972
2340
|
}
|
|
1973
2341
|
return info;
|
|
1974
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
|
+
}
|
|
1975
2562
|
/** `const h = id` — a binding ALIASING a generic function (a top-level
|
|
1976
2563
|
* declaration, a registered generic binding, or another alias — resolved
|
|
1977
2564
|
* left to right in declaration order). The alias registers the SAME info
|