@scriptc/compiler 0.4.6 → 0.4.8
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/node-fallback/child_process.d.ts +71 -22
- package/ambient/node-fallback/crypto.d.ts +15 -7
- package/ambient/node-fallback/events.d.ts +29 -6
- package/ambient/node-fallback/fs-promises.d.ts +1 -1
- package/ambient/node-fallback/fs.d.ts +57 -12
- package/ambient/node-fallback/http.d.ts +26 -18
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +25 -0
- package/ambient/node-fallback/os.d.ts +11 -1
- package/ambient/node-fallback/path-posix.d.ts +6 -0
- package/ambient/node-fallback/path-win32.d.ts +5 -0
- package/ambient/node-fallback/path.d.ts +2 -0
- package/ambient/node-fallback/querystring.d.ts +3 -3
- package/ambient/node-fallback/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +95 -20
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +22 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +12 -1
- package/dist/backend/immutability.js +50 -4
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/immutability.test.js +95 -1
- package/dist/backend/immutability.test.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +18 -5
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/library-pack.test.d.ts +1 -0
- package/dist/backend/library-pack.test.js +28 -0
- package/dist/backend/library-pack.test.js.map +1 -0
- package/dist/backend/linker.d.ts +20 -2
- package/dist/backend/linker.js +221 -35
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +15 -6
- package/dist/backend/lld.js +24 -16
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +13 -5
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -2
- package/dist/backend/llvm/alloc.js +172 -36
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +69 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +17 -4
- package/dist/backend/llvm/arenas.js +105 -10
- package/dist/backend/llvm/arenas.js.map +1 -1
- package/dist/backend/llvm/arenas.test.js +229 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.js +10 -1
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.js +6 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +10 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -9
- package/dist/backend/llvm/classes.js +142 -37
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +42 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +50 -1
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +34 -9
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +64 -3
- package/dist/backend/llvm/dyn.js +251 -15
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +68 -5
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +226 -77
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.d.ts +1 -0
- package/dist/backend/llvm/emit-module.test.js +52 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -0
- package/dist/backend/llvm/emit-statements.js +138 -34
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +142 -10
- package/dist/backend/llvm/emitter.js +523 -73
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +31 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +16 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +4 -1
- package/dist/backend/llvm/expr-calls.js +38 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +237 -23
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +123 -12
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +124 -56
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +59 -2
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +2 -0
- package/dist/backend/llvm/integer-values.js +6 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-groups.d.ts +21 -0
- package/dist/backend/llvm/js-groups.js +277 -0
- package/dist/backend/llvm/js-groups.js.map +1 -0
- package/dist/backend/llvm/js-ic.d.ts +57 -1
- package/dist/backend/llvm/js-ic.js +389 -22
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +152 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +116 -11
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +33 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +180 -27
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +139 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +67 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +32 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
- package/dist/backend/llvm/loop-entry-versions.js +43 -21
- package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +7 -1
- package/dist/backend/llvm/loop-state.js +26 -3
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
- package/dist/backend/llvm/map-entry-fusion.js +3 -3
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
- package/dist/backend/llvm/map-number-lookup.js +7 -3
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +58 -17
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +7 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +4 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
- package/dist/backend/llvm/receiver-brackets.test.js +68 -0
- package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
- package/dist/backend/llvm/receivers.js +3 -0
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
- package/dist/backend/llvm/record-entry-fusion.js +217 -0
- package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +5 -2
- package/dist/backend/llvm/record-results.js +13 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-views.d.ts +22 -2
- package/dist/backend/llvm/record-views.js +147 -12
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/record-views.test.js +76 -0
- package/dist/backend/llvm/record-views.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +1 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +4 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-ir.js +1 -0
- package/dist/backend/llvm/region-ir.js.map +1 -1
- package/dist/backend/llvm/region-sites.d.ts +18 -0
- package/dist/backend/llvm/region-sites.js +79 -1
- package/dist/backend/llvm/region-sites.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +53 -6
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +36 -3
- package/dist/backend/llvm/shapes.js +201 -16
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +4 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +10 -1
- package/dist/backend/llvm/speculative-integers.js +59 -8
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +1 -2
- package/dist/backend/llvm/stack-objects.js +8 -5
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.d.ts +3 -3
- package/dist/backend/llvm/unwind-abi.js +8 -3
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +47 -3
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +12 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +13 -0
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +94 -0
- package/dist/backend/native/executable.js +134 -10
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/helper-identity-record.d.ts +11 -0
- package/dist/backend/native/helper-identity-record.js +76 -0
- package/dist/backend/native/helper-identity-record.js.map +1 -0
- package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
- package/dist/backend/native/helper-identity-record.test.js +101 -0
- package/dist/backend/native/helper-identity-record.test.js.map +1 -0
- package/dist/backend/native/library.js +10 -2
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +8 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +13 -10
- package/dist/backend/native-codegen-core.js +26 -13
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +30 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +110 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +72 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +1 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-profile.d.ts +4 -1
- package/dist/backend/native-profile.js +12 -1
- package/dist/backend/native-profile.js.map +1 -1
- package/dist/backend/native-profile.test.js +10 -0
- package/dist/backend/native-profile.test.js.map +1 -1
- package/dist/backend/publication.d.ts +4 -1
- package/dist/backend/publication.js +4 -2
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +46 -7
- package/dist/backend/runtime-pack-core.js +37 -2
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.d.ts +18 -1
- package/dist/backend/runtime-pack-native.js +138 -29
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-native.test.js +166 -4
- package/dist/backend/runtime-pack-native.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -0
- package/dist/backend/runtime-pack.js +25 -3
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +213 -12
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/tree-classes.d.ts +42 -0
- package/dist/backend/tree-classes.js +723 -0
- package/dist/backend/tree-classes.js.map +1 -0
- package/dist/backend/tree-classes.test.d.ts +1 -0
- package/dist/backend/tree-classes.test.js +338 -0
- package/dist/backend/tree-classes.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +8 -1
- package/dist/backend/vendor-archives.js +313 -8
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +60 -3
- package/dist/backend/vendor-inputs.js +109 -3
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +62 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +2 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +7 -1
- package/dist/compat/fetch-profile.js +25 -12
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- package/dist/contracts/check.d.ts +3 -0
- package/dist/contracts/check.js +18 -5
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.js +47 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +14 -0
- package/dist/diagnostics/codes.js +14 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +68 -0
- package/dist/diagnostics/diagnostic.js +186 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-tier.js +3 -1
- package/dist/diagnostics/dynamic-tier.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +18 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +48 -0
- package/dist/executable/executable-cache.js +38 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +127 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +13 -3
- package/dist/executable/prepare.js +438 -234
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +200 -18
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +4 -0
- package/dist/frontend/builtin-modules.js +10 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +24 -0
- package/dist/frontend/early-errors.js +836 -0
- package/dist/frontend/early-errors.js.map +1 -0
- package/dist/frontend/early-errors.test.d.ts +1 -0
- package/dist/frontend/early-errors.test.js +207 -0
- package/dist/frontend/early-errors.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +88 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +47 -0
- package/dist/frontend/input-tracker.js +173 -36
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +86 -2
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/js-inference.d.ts +2 -0
- package/dist/frontend/js-inference.js +18 -0
- package/dist/frontend/js-inference.js.map +1 -0
- package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
- package/dist/frontend/jsx-opinion-sites.test.js +86 -0
- package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
- package/dist/frontend/lib-exports.d.ts +23 -4
- package/dist/frontend/lib-exports.js +98 -26
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
- package/dist/frontend/lowering/binding-analysis.js +86 -4
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/buffers.d.ts +8 -0
- package/dist/frontend/lowering/buffers.js +43 -0
- package/dist/frontend/lowering/buffers.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.js +13 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
- package/dist/frontend/lowering/builtin-namespaces.js +41 -3
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
- package/dist/frontend/lowering/builtin-statics.js +407 -0
- package/dist/frontend/lowering/builtin-statics.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +12 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
- package/dist/frontend/lowering/builtins/atomics.js +87 -1
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +52 -12
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
- package/dist/frontend/lowering/builtins/child-process.js +565 -28
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
- package/dist/frontend/lowering/builtins/compression.js +41 -21
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +7 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
- package/dist/frontend/lowering/builtins/dates.js +23 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
- package/dist/frontend/lowering/builtins/environment.js +213 -2
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +75 -18
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
- package/dist/frontend/lowering/builtins/filesystem.js +185 -16
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +4 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +42 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
- package/dist/frontend/lowering/builtins/numbers.js +10 -2
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +9 -5
- package/dist/frontend/lowering/builtins/operating-system.js +101 -20
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +18 -2
- package/dist/frontend/lowering/builtins/process.js +386 -25
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +169 -8
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +6 -2
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
- package/dist/frontend/lowering/builtins/querystring.js +202 -18
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +200 -38
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +60 -1
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +55 -13
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
- package/dist/frontend/lowering/builtins/v8.js +7 -5
- package/dist/frontend/lowering/builtins/v8.js.map +1 -1
- package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
- package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
- package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +2 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +10 -0
- package/dist/frontend/lowering/call-arguments.js +37 -2
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +10 -0
- package/dist/frontend/lowering/call-signatures.js +180 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.js +5 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +14 -2
- package/dist/frontend/lowering/class-construction.js +99 -5
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +14 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1376 -1009
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +59 -10
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +20 -15
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +35 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +21 -4
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/class-views.d.ts +13 -0
- package/dist/frontend/lowering/class-views.js +51 -0
- package/dist/frontend/lowering/class-views.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +63 -10
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +15 -0
- package/dist/frontend/lowering/coercions/state.js +24 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +75 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +39 -2
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
- package/dist/frontend/lowering/coercions/unions.js +54 -10
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
- package/dist/frontend/lowering/constructor-returns.js +284 -58
- package/dist/frontend/lowering/constructor-returns.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +288 -90
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +37 -8
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.js +139 -3
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
- package/dist/frontend/lowering/containers/array-iteration.js +24 -7
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +30 -11
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
- package/dist/frontend/lowering/containers/bytes.js +450 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +16 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +74 -12
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +52 -17
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +5 -5
- package/dist/frontend/lowering/dispatch-sites.js +3 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +40 -0
- package/dist/frontend/lowering/divergences.js +239 -20
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/effect-free.d.ts +12 -0
- package/dist/frontend/lowering/effect-free.js +44 -0
- package/dist/frontend/lowering/effect-free.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +24 -0
- package/dist/frontend/lowering/expressions/array-literals.js +88 -10
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +216 -14
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +272 -11
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +173 -4
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +195 -18
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
- package/dist/frontend/lowering/expressions/object-literals.js +951 -240
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +71 -21
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +39 -0
- package/dist/frontend/lowering/expressions/property-access.js +1141 -87
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +262 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +25 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
- package/dist/frontend/lowering/expressions/union-fields.js +103 -13
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +156 -22
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +6 -0
- package/dist/frontend/lowering/frozen-records.js +10 -4
- package/dist/frontend/lowering/frozen-records.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
- package/dist/frontend/lowering/frozen-records.test.js +44 -0
- package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
- package/dist/frontend/lowering/function-names.d.ts +9 -0
- package/dist/frontend/lowering/function-names.js +95 -0
- package/dist/frontend/lowering/function-names.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +42 -13
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.js +5 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
- package/dist/frontend/lowering/generator-delegation.js +301 -118
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +75 -0
- package/dist/frontend/lowering/generic-functions.js +790 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-function-values.d.ts +25 -0
- package/dist/frontend/lowering/global-function-values.js +193 -0
- package/dist/frontend/lowering/global-function-values.js.map +1 -0
- package/dist/frontend/lowering/global-values.d.ts +15 -4
- package/dist/frontend/lowering/global-values.js +67 -9
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.js +34 -1
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/host-global-values.d.ts +31 -0
- package/dist/frontend/lowering/host-global-values.js +121 -0
- package/dist/frontend/lowering/host-global-values.js.map +1 -0
- package/dist/frontend/lowering/host-globals.d.ts +74 -0
- package/dist/frontend/lowering/host-globals.js +344 -0
- package/dist/frontend/lowering/host-globals.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +46 -17
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
- package/dist/frontend/lowering/iterator-prototype.js +160 -0
- package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
- package/dist/frontend/lowering/key-order-witness.js +571 -9
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +25 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +140 -16
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
- package/dist/frontend/lowering/lower-async-iteration.js +15 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
- package/dist/frontend/lowering/lower-builtin-values.js +342 -58
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +47 -1
- package/dist/frontend/lowering/lower-calls.js +1354 -273
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-calls.test.js +121 -0
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +36 -5
- package/dist/frontend/lowering/lower-classes.js +630 -89
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +15 -2
- package/dist/frontend/lowering/lower-event-emitter.js +610 -98
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +15 -1
- package/dist/frontend/lowering/lower-exprs.js +96 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +27 -6
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +57 -10
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
- package/dist/frontend/lowering/lower-global-value.js +14 -5
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +713 -92
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +135 -27
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +18 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
- package/dist/frontend/lowering/lower-node-island.js +472 -67
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +463 -96
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-shared-modules.js +13 -1
- package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
- package/dist/frontend/lowering/lower-stdlib.js +77 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -4
- package/dist/frontend/lowering/lower-stmts.js +831 -136
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +126 -8
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +243 -48
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +6 -3
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +363 -21
- package/dist/frontend/lowering/lowerer.js +1224 -129
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +19 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
- package/dist/frontend/lowering/lowering-facts.js +323 -0
- package/dist/frontend/lowering/lowering-facts.js.map +1 -0
- package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
- package/dist/frontend/lowering/lowering-facts.test.js +100 -0
- package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
- package/dist/frontend/lowering/module-namespace-elements.js +15 -0
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
- package/dist/frontend/lowering/nan-coded-reads.js +112 -9
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +2 -2
- package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
- package/dist/frontend/lowering/optional-arguments.js +26 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.d.ts +36 -0
- package/dist/frontend/lowering/partial-assertions.js +189 -0
- package/dist/frontend/lowering/partial-assertions.js.map +1 -0
- package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
- package/dist/frontend/lowering/primitive-throws.js +241 -0
- package/dist/frontend/lowering/primitive-throws.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
- package/dist/frontend/lowering/primitive-wrappers.js +221 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
- package/dist/frontend/lowering/private-statics.d.ts +46 -0
- package/dist/frontend/lowering/private-statics.js +322 -0
- package/dist/frontend/lowering/private-statics.js.map +1 -0
- package/dist/frontend/lowering/record-inherited.d.ts +17 -1
- package/dist/frontend/lowering/record-inherited.js +16 -2
- package/dist/frontend/lowering/record-inherited.js.map +1 -1
- package/dist/frontend/lowering/record-links.d.ts +73 -0
- package/dist/frontend/lowering/record-links.js +797 -0
- package/dist/frontend/lowering/record-links.js.map +1 -0
- package/dist/frontend/lowering/record-sources.d.ts +12 -1
- package/dist/frontend/lowering/record-sources.js +60 -0
- package/dist/frontend/lowering/record-sources.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
- package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
- package/dist/frontend/lowering/runtime-optional-report.js +300 -0
- package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +3 -1
- package/dist/frontend/lowering/static-typeof.js +6 -1
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-equality.d.ts +4 -0
- package/dist/frontend/lowering/strict-equality.js +14 -0
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/strict-mode.d.ts +1 -5
- package/dist/frontend/lowering/strict-mode.js +4 -30
- package/dist/frontend/lowering/strict-mode.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +7 -0
- package/dist/frontend/lowering/structural-instances.js +23 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +42 -1
- package/dist/frontend/lowering/surfaces.js +212 -71
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +13 -1
- package/dist/frontend/lowering/union-retag.js +55 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +51 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +136 -17
- package/dist/frontend/lowering/unit-journal.js +324 -53
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +126 -3
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
- package/dist/frontend/lowering/unit-reuse.js +1008 -0
- package/dist/frontend/lowering/unit-reuse.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +12 -0
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-file-import.test.d.ts +1 -0
- package/dist/frontend/npm-file-import.test.js +76 -0
- package/dist/frontend/npm-file-import.test.js.map +1 -0
- package/dist/frontend/npm-static.js +95 -11
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +95 -2
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/npm.d.ts +9 -0
- package/dist/frontend/npm.js +82 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/pipeline-native.js +2 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +9 -4
- package/dist/frontend/pipeline.js +162 -38
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +68 -11
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-node.d.ts +3 -0
- package/dist/frontend/program-node.js +13 -6
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +71 -2
- package/dist/frontend/program.js +836 -411
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +37 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.js +4 -0
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/services-node.d.ts +7 -0
- package/dist/frontend/services-node.js +32 -1
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +51 -0
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/services.d.ts +14 -0
- package/dist/frontend/services.js +52 -2
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +61 -1
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/shape-inference/analyze.d.ts +5 -0
- package/dist/frontend/shape-inference/analyze.js +104 -4
- package/dist/frontend/shape-inference/analyze.js.map +1 -1
- package/dist/frontend/shape-inference/domain.js +0 -1
- package/dist/frontend/shape-inference/domain.js.map +1 -1
- package/dist/frontend/shape-inference/index.js +5 -1
- package/dist/frontend/shape-inference/index.js.map +1 -1
- package/dist/frontend/shape-inference/memo.d.ts +2 -1
- package/dist/frontend/shape-inference/memo.js +6 -2
- package/dist/frontend/shape-inference/memo.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.d.ts +1 -1
- package/dist/frontend/shape-inference/overlay.js +184 -4
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/shape-inference/static-objects.js +11 -6
- package/dist/frontend/shape-inference/static-objects.js.map +1 -1
- package/dist/frontend/source-phase-imports.test.d.ts +1 -0
- package/dist/frontend/source-phase-imports.test.js +37 -0
- package/dist/frontend/source-phase-imports.test.js.map +1 -0
- package/dist/frontend/tier-analysis.d.ts +9 -0
- package/dist/frontend/tier-analysis.js +1 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +12 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
- package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.js +3 -5
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +13 -0
- package/dist/frontend/ts7/checker-backend.js +84 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +126 -2
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +22 -1
- package/dist/frontend/ts7/program-host.js +49 -4
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +83 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.d.ts +16 -1
- package/dist/frontend/ts7/rpc-process.js +170 -92
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js +49 -21
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +956 -101
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.js +221 -12
- package/dist/frontend/tsc-codes.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +98 -11
- package/dist/frontend/type-mapper.js +770 -182
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +224 -15
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +60 -0
- package/dist/index.test.js.map +1 -0
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/build.d.ts +3 -2
- package/dist/ir/build.js +4 -2
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.js +96 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +453 -26
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +3 -2
- package/dist/ir/callback-specialization.js +35 -25
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +8 -4
- package/dist/ir/capture-values.js +9 -6
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +6 -2
- package/dist/ir/char-unit-locals.js +11 -2
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/class-key-index.d.ts +18 -0
- package/dist/ir/class-key-index.js +29 -0
- package/dist/ir/class-key-index.js.map +1 -0
- package/dist/ir/class-key-index.test.d.ts +1 -0
- package/dist/ir/class-key-index.test.js +25 -0
- package/dist/ir/class-key-index.test.js.map +1 -0
- package/dist/ir/codec.d.ts +82 -0
- package/dist/ir/codec.generated.d.ts +13 -0
- package/dist/ir/codec.generated.js +5350 -0
- package/dist/ir/codec.generated.js.map +1 -0
- package/dist/ir/codec.js +325 -0
- package/dist/ir/codec.js.map +1 -0
- package/dist/ir/codec.test.d.ts +1 -0
- package/dist/ir/codec.test.js +225 -0
- package/dist/ir/codec.test.js.map +1 -0
- package/dist/ir/constant-globals.d.ts +5 -2
- package/dist/ir/constant-globals.js +25 -27
- package/dist/ir/constant-globals.js.map +1 -1
- package/dist/ir/expression-inlining.d.ts +4 -2
- package/dist/ir/expression-inlining.js +8 -2
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/field-values.d.ts +5 -2
- package/dist/ir/field-values.js +32 -21
- package/dist/ir/field-values.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +29 -10
- package/dist/ir/fields.generated.js +1039 -11
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/fields.test.js +46 -2
- package/dist/ir/fields.test.js.map +1 -1
- package/dist/ir/final-fields.js +1 -1
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +6 -4
- package/dist/ir/function-references.js +11 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +14 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +4 -2
- package/dist/ir/init-only-globals.js +17 -18
- package/dist/ir/init-only-globals.js.map +1 -1
- package/dist/ir/inline-array-sources.js +4 -1
- package/dist/ir/inline-array-sources.js.map +1 -1
- package/dist/ir/inline-array-views.d.ts +13 -0
- package/dist/ir/inline-array-views.js +945 -0
- package/dist/ir/inline-array-views.js.map +1 -0
- package/dist/ir/inline-arrays.d.ts +7 -0
- package/dist/ir/inline-arrays.js +190 -55
- package/dist/ir/inline-arrays.js.map +1 -1
- package/dist/ir/inline-arrays.test.js +140 -2
- package/dist/ir/inline-arrays.test.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/integer-ranges.js +16 -6
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +130 -44
- package/dist/ir/ir.js +7 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-groups.d.ts +51 -0
- package/dist/ir/js-groups.js +394 -0
- package/dist/ir/js-groups.js.map +1 -0
- package/dist/ir/js-groups.test.d.ts +1 -0
- package/dist/ir/js-groups.test.js +555 -0
- package/dist/ir/js-groups.test.js.map +1 -0
- package/dist/ir/js-ic.d.ts +10 -9
- package/dist/ir/js-ic.js +58 -25
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +37 -3
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/jsval.js +374 -63
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/jsval.test.js +96 -2
- package/dist/ir/jsval.test.js.map +1 -1
- package/dist/ir/loop-entry-ranges.js +112 -9
- package/dist/ir/loop-entry-ranges.js.map +1 -1
- package/dist/ir/loop-entry-ranges.test.js +40 -0
- package/dist/ir/loop-entry-ranges.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +23 -6
- package/dist/ir/node-index.js +126 -49
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +4 -2
- package/dist/ir/numeric-call-specialization.js +40 -26
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.d.ts +4 -2
- package/dist/ir/paired-while-loops.js +8 -2
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +13 -3
- package/dist/ir/parameter-versions.js +63 -40
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/property-bags.d.ts +4 -2
- package/dist/ir/property-bags.js +22 -17
- package/dist/ir/property-bags.js.map +1 -1
- package/dist/ir/receiver-readers.js +58 -2
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +4 -2
- package/dist/ir/row-pairs.js +12 -11
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +139 -5
- package/dist/ir/runtime-features.js +397 -19
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +135 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/runtime-jam-loops.d.ts +35 -0
- package/dist/ir/runtime-jam-loops.js +604 -0
- package/dist/ir/runtime-jam-loops.js.map +1 -0
- package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
- package/dist/ir/runtime-jam-loops.test.js +565 -0
- package/dist/ir/runtime-jam-loops.test.js.map +1 -0
- package/dist/ir/saturating-loop-jams.d.ts +11 -2
- package/dist/ir/saturating-loop-jams.js +56 -16
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/saturating-loop-jams.test.js +39 -1
- package/dist/ir/saturating-loop-jams.test.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +5 -2
- package/dist/ir/scalar-records.js +12 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.d.ts +4 -2
- package/dist/ir/self-captures.js +40 -28
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/self-captures.test.js +15 -0
- package/dist/ir/self-captures.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +8 -2
- package/dist/ir/serialize.js +92 -24
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +26 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/typed-argument-clones.d.ts +30 -0
- package/dist/ir/typed-argument-clones.js +789 -0
- package/dist/ir/typed-argument-clones.js.map +1 -0
- package/dist/ir/union-arm-loops.d.ts +3 -0
- package/dist/ir/union-arm-loops.js +373 -0
- package/dist/ir/union-arm-loops.js.map +1 -0
- package/dist/ir/union-arm-loops.test.d.ts +1 -0
- package/dist/ir/union-arm-loops.test.js +230 -0
- package/dist/ir/union-arm-loops.test.js.map +1 -0
- package/dist/ir/validate.js +170 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +46 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +8 -2
- package/dist/library/compiler-self-identity.js +92 -18
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +150 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/int-infer.d.ts +5 -0
- package/dist/library/int-infer.js +15 -3
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +4 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +4 -0
- package/dist/library/library-cache.js +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +26 -0
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/prepare.js +99 -31
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cache.d.ts +7 -0
- package/dist/native/cache.js +49 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +13 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +2 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +26 -5
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache-open.test.js +31 -5
- package/dist/native/executable-cache-open.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +6 -1
- package/dist/native/executable-cache.js +7 -1
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -0
- package/dist/native/prepare.js +74 -28
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +25 -3
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.js +63 -4
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +93 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.js +9 -2
- package/dist/native/toolchain.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +37 -1
- package/dist/node-islands/boundary.js +65 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.d.ts +1 -0
- package/dist/node-islands/boundary.test.js +76 -0
- package/dist/node-islands/boundary.test.js.map +1 -0
- package/dist/node-islands/detect.d.ts +27 -1
- package/dist/node-islands/detect.js +475 -40
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +175 -4
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/effect-gate.js +30 -20
- package/dist/node-islands/effect-gate.js.map +1 -1
- package/dist/node-islands/effect-gate.test.js +4 -1
- package/dist/node-islands/effect-gate.test.js.map +1 -1
- package/dist/node-islands/graph-islands.d.ts +40 -0
- package/dist/node-islands/graph-islands.js +128 -0
- package/dist/node-islands/graph-islands.js.map +1 -0
- package/dist/node-islands/growth.d.ts +57 -0
- package/dist/node-islands/growth.js +205 -0
- package/dist/node-islands/growth.js.map +1 -0
- package/dist/node-islands/libnode.d.ts +1 -1
- package/dist/node-islands/libnode.js +1 -1
- package/dist/node-islands/libnode.js.map +1 -1
- package/dist/node-islands/modules.d.ts +28 -0
- package/dist/node-islands/modules.js +156 -0
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +105 -1
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/policy.js +2 -3
- package/dist/node-islands/policy.js.map +1 -1
- package/dist/node-islands/probe-recorder.d.ts +1 -0
- package/dist/node-islands/probe-recorder.js +596 -0
- package/dist/node-islands/probe-recorder.js.map +1 -0
- package/dist/node-islands/probe-recorder.test.d.ts +1 -0
- package/dist/node-islands/probe-recorder.test.js +80 -0
- package/dist/node-islands/probe-recorder.test.js.map +1 -0
- package/dist/node-islands/report.d.ts +12 -0
- package/dist/node-islands/report.js +28 -0
- package/dist/node-islands/report.js.map +1 -1
- package/dist/node-islands/report.test.js +4 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +9 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +16 -1
- package/dist/node-islands/scan.js +110 -9
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/node-islands/snapshot.d.ts +38 -1
- package/dist/node-islands/snapshot.js +165 -161
- package/dist/node-islands/snapshot.js.map +1 -1
- package/dist/node-islands/snapshot.test.js +63 -2
- package/dist/node-islands/snapshot.test.js.map +1 -1
- package/dist/node-islands/summary.js +8 -0
- package/dist/node-islands/summary.js.map +1 -1
- package/dist/node-islands/type-strip.d.ts +11 -0
- package/dist/node-islands/type-strip.js +157 -0
- package/dist/node-islands/type-strip.js.map +1 -0
- package/dist/node-islands/type-strip.test.d.ts +1 -0
- package/dist/node-islands/type-strip.test.js +31 -0
- package/dist/node-islands/type-strip.test.js.map +1 -0
- package/dist/project-config.d.ts +4 -0
- package/dist/project-config.js +19 -0
- package/dist/project-config.js.map +1 -1
- package/dist/project-config.test.js +10 -0
- package/dist/project-config.test.js.map +1 -1
- package/dist/wasm/translate.js +11 -5
- package/dist/wasm/translate.js.map +1 -1
- package/dist/wasm/translate.test.js +35 -0
- package/dist/wasm/translate.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +221 -122
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isJsIteratorGlobal, iteratorPrototypeExpr, lowerIteratorNew, } from "./iterator-prototype.js";
|
|
2
|
+
import { lowerWrapperNew } from "./primitive-wrappers.js";
|
|
1
3
|
import { lowerAsyncLocalStorageOptions } from "./builtins/async-context.js";
|
|
2
4
|
import { shapeOverlayAnnotated } from "../shape-inference/index.js";
|
|
3
5
|
import { DATE_TIME_FIELD, dateRootOf, dateSuperCall, isDatePrototypeMethod, lowerDateSuperMethodCall, } from "./builtins/date-classes.js";
|
|
@@ -8,7 +10,8 @@ import { keyedHelperName } from "./stable-names.js";
|
|
|
8
10
|
import { lowerValueReturningConstructorNew } from "./js-dynamic-objects.js";
|
|
9
11
|
import { adaptPromiseExecutor } from "./promise-executor-adapter.js";
|
|
10
12
|
import { dynUndefinedExpr, nodeThrowExpr, strLit, varRef } from "../../ir/build.js";
|
|
11
|
-
import {
|
|
13
|
+
import { isBuiltinIdentityToken, isPrimitiveValueType, staticallyPrimitive, throwAfterEach, throwTypeError, } from "./primitive-throws.js";
|
|
14
|
+
import { constructedFromValue, constructedValue, constructorPrimitiveFlag, superIntoResultSlot, } from "./constructor-returns.js";
|
|
12
15
|
import { checkedIterableSpread } from "./checked-iterable-spread.js";
|
|
13
16
|
import { lowerReadlineInterfaceNew, lowerReadlineUiNew } from "./builtins/readline.js";
|
|
14
17
|
import { builtinMemberBindingTarget, builtinMemberRequireDecl, } from "./builtins/module-bindings.js";
|
|
@@ -28,15 +31,15 @@ import { lowerZlibStreamNew, zlibClassName, zlibStreamModeOf } from "./builtins/
|
|
|
28
31
|
import { everyStmtList } from "../../ir/traverse.js";
|
|
29
32
|
import { builtinClassAliasOf, builtinClassRefOf, } from "./builtins/class-values.js";
|
|
30
33
|
import { inlineNamespaceRequireOf, lowerWithInlineRequireInit } from "./cjs-inline-require.js";
|
|
31
|
-
import { BOOL, BYTES_U8, canDynCheckTo, DATE_T, DYN, F64, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, classValueConstructor, UNDEFINED_T, VOID, arrayOf, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
34
|
+
import { BIGINT_BYTES_NAMES, BOOL, BYTES_U8, canDynCheckTo, DATE_T, DYN, F64, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, classValueConstructor, UNDEFINED_T, VOID, arrayOf, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
32
35
|
import { genericCallInstance, implicitAnyParamSymbolsOf, implicitCallInstance, implicitMonoFile, genericLocalClassResult, } from "./generic-functions.js";
|
|
33
36
|
import { extendInstantiationPath, MAX_INSTANTIATION_RECURSION, } from "./instantiation-path.js";
|
|
34
37
|
import { appendImplicitUndefinedReturn, hasExplicitJsDocReturn } from "./function-returns.js";
|
|
35
38
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
36
39
|
import { errorNameAfterField, errorViewFields } from "./error-name-order.js";
|
|
37
|
-
import { checkedJsDocumentedParameter, documentedParameter, generatorMeta, } from "./call-signatures.js";
|
|
40
|
+
import { checkedJsDocumentedParameter, documentedParameter, generatorMeta, generatorParamsBindAtCall, } from "./call-signatures.js";
|
|
38
41
|
import { omittedArgFor } from "./call-arguments.js";
|
|
39
|
-
import { checkerTypeDescription, isGenericCallableMemberType, jsOpenObjectType, typeKey, withUnitArm, X509_DER_FIELD, X509_PUBLIC_KEY_FIELD, } from "../type-mapper.js";
|
|
42
|
+
import { checkerTypeDescription, isGenericCallableMemberType, jsOpenObjectType, noteScopeSensitiveMapping, typeKey, withUnitArm, X509_DER_FIELD, X509_PUBLIC_KEY_FIELD, } from "../type-mapper.js";
|
|
40
43
|
import { canonicalBuiltinModule, cjsClassExprWholeExportOf, isCjsJsFile, isJsSourceFile, isModuleExportsAccess, locOf, requireSpecOf, } from "../program.js";
|
|
41
44
|
import { PoisonError, dynFallbackType, jsFuncNameOf, newFnCtx, own } from "./lowerer.js";
|
|
42
45
|
import { islandValueOrigin } from "../node-api-import.js";
|
|
@@ -61,6 +64,7 @@ import { declSymbolOf } from "./lower-modules.js";
|
|
|
61
64
|
import { INSPECT_CUSTOM_MEMBER, classSymbolKeyOf, classSymbolKeyOfSymbol, symbolFieldDisplayName, } from "./symbol-fields.js";
|
|
62
65
|
import { lowerHttpAgentNew, lowerHttpServerNew, lowerTlsSocketNew } from "./lower-server.js";
|
|
63
66
|
import { ambientNsRootOf, ambientUndefReadType, ambientUndefVarRootOf, ambientUndefinedFnSymbolOf, contextualUndefReadType, fenceEarlyAliasUse, fenceEarlyNsMemberRef, nsMemberIdentOf, nsUndefRead, } from "./lower-namespaces.js";
|
|
67
|
+
import { hostGlobalNameOfRead } from "./host-globals.js";
|
|
64
68
|
import { mixinResultBindingClassOf } from "./lower-mixins.js";
|
|
65
69
|
import { hasLexicalPrivateReference, hasStaticThis, rejectStaticThis } from "./static-this.js";
|
|
66
70
|
import { lowerUrlNew } from "./lower-url.js";
|
|
@@ -72,8 +76,8 @@ import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
|
72
76
|
import { lowerInstanceConstructorNew } from "./class-instance-constructor.js";
|
|
73
77
|
import { classPrototypeData, reflectClassPrototype } from "./class-prototypes.js";
|
|
74
78
|
import { constructionEscape } from "./construction-escapes.js";
|
|
75
|
-
import { checkedClassConstruction, checkedClassConstructionPacked } from "./class-construction.js";
|
|
76
|
-
import { initializeRuntimeStatics, hasRuntimeStatics } from "./class-runtime-statics.js";
|
|
79
|
+
import { checkedClassConstruction, checkedClassConstructionPacked, primitiveCheckedConstruction, } from "./class-construction.js";
|
|
80
|
+
import { initializeRuntimeStatics, hasRuntimeStatics, runtimeStaticDefines, } from "./class-runtime-statics.js";
|
|
77
81
|
import { reflectedClassMethodValue, reflectedClassStaticMethodValue, } from "./class-method-values.js";
|
|
78
82
|
import { identifierReadSymbol } from "./surfaces.js";
|
|
79
83
|
export function returnsOnlyThis(member) {
|
|
@@ -131,13 +135,94 @@ export function returnsOnlyThisValue(member) {
|
|
|
131
135
|
ts.forEachChild(body, visit);
|
|
132
136
|
return valid;
|
|
133
137
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
/** True when evaluating this class definition creates a class VALUE more
|
|
139
|
+
* than once, so each evaluation must mint its own constructor object,
|
|
140
|
+
* prototype and statics. A function body runs per call, a loop body per
|
|
141
|
+
* iteration, and an instance field initializer (or constructor parameter
|
|
142
|
+
* default) per construction. A class expression nested in a STATIC member
|
|
143
|
+
* initializer, a computed key or the heritage follows its enclosing
|
|
144
|
+
* class's own evaluation, so the walk continues through those.
|
|
145
|
+
* Top-level definitions evaluated once keep the immortal template. */
|
|
146
|
+
export function perEvaluationClass(decl) {
|
|
147
|
+
let child = decl;
|
|
148
|
+
for (let parent = decl.parent; parent && !ts.isSourceFile(parent); child = parent, parent = parent.parent) {
|
|
149
|
+
if (ts.isFunctionLike(parent) || ts.isClassStaticBlockDeclaration(parent))
|
|
150
|
+
return true;
|
|
151
|
+
if (ts.isForStatement(parent) ||
|
|
152
|
+
ts.isForInStatement(parent) ||
|
|
153
|
+
ts.isForOfStatement(parent) ||
|
|
154
|
+
ts.isWhileStatement(parent) ||
|
|
155
|
+
ts.isDoStatement(parent))
|
|
156
|
+
return true;
|
|
157
|
+
if ((ts.isClassDeclaration(parent) || ts.isClassExpression(parent)) && perInstanceMember(child))
|
|
137
158
|
return true;
|
|
138
159
|
}
|
|
139
160
|
return false;
|
|
140
161
|
}
|
|
162
|
+
/** True when `node` — the direct child of the enclosing class on the path
|
|
163
|
+
* to a nested class definition — is evaluated once per INSTANCE: an
|
|
164
|
+
* instance field with an initializer, or a constructor whose parameters
|
|
165
|
+
* have defaults (parameter properties included). */
|
|
166
|
+
function perInstanceMember(node) {
|
|
167
|
+
if (ts.isConstructorDeclaration(node))
|
|
168
|
+
return node.parameters.nodes.some((param) => param.initializer !== undefined);
|
|
169
|
+
if (!ts.isPropertyDeclaration(node) || node.initializer === undefined)
|
|
170
|
+
return false;
|
|
171
|
+
return !ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword);
|
|
172
|
+
}
|
|
173
|
+
/** `Symbol.hasInstance` over the standard global. */
|
|
174
|
+
export function isSymbolHasInstanceKey(lowerer, key) {
|
|
175
|
+
let e = key;
|
|
176
|
+
while (ts.isParenthesizedExpression(e))
|
|
177
|
+
e = e.expression;
|
|
178
|
+
return (ts.isPropertyAccessExpression(e) &&
|
|
179
|
+
!e.questionDotToken &&
|
|
180
|
+
ts.isIdentifier(e.expression) &&
|
|
181
|
+
lowerer.isStdlibGlobal(e.expression, "Symbol") &&
|
|
182
|
+
ts.isIdentifier(e.name) &&
|
|
183
|
+
e.name.text === "hasInstance");
|
|
184
|
+
}
|
|
185
|
+
/** The static members keyed by `Symbol.hasInstance`
|
|
186
|
+
* (`static [Symbol.hasInstance](v) { … }`): defining them on the class
|
|
187
|
+
* value's own-property table gives `instanceof` its hook (the runtime
|
|
188
|
+
* consults that table, scr_dyn_has_instance_hook). */
|
|
189
|
+
export function staticHasInstanceHookMembers(lowerer, decl) {
|
|
190
|
+
return decl.members.nodes.filter((member) => {
|
|
191
|
+
const name = member.name;
|
|
192
|
+
return (name !== undefined &&
|
|
193
|
+
ts.isComputedPropertyName(name) &&
|
|
194
|
+
ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) ===
|
|
195
|
+
true &&
|
|
196
|
+
isSymbolHasInstanceKey(lowerer, name.expression));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/** Whether `info` or an ancestor declares a static `Symbol.hasInstance`
|
|
200
|
+
* member. Node's `instanceof` asks the hook on the constructor (inherited
|
|
201
|
+
* through the static prototype chain) and uses OrdinaryHasInstance only
|
|
202
|
+
* when no hook exists. */
|
|
203
|
+
export function classDeclaresHasInstanceHook(info) {
|
|
204
|
+
for (let current = info; current; current = current.base) {
|
|
205
|
+
if (current.hasInstanceHook === true)
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
/** Whether `expression` reads an element of a JavaScript array whose
|
|
211
|
+
* compiled storage is checked-dynamic (`const classes = [A, B]`; the
|
|
212
|
+
* array literal of several class constructors lowers as the checked
|
|
213
|
+
* array, and an unannotated file-scope binding keeps that layout). */
|
|
214
|
+
function jsCheckedDynamicArrayElement(lowerer, expression) {
|
|
215
|
+
if (!ts.isElementAccessExpression(expression))
|
|
216
|
+
return false;
|
|
217
|
+
if (!isJsSourceFile(ts.getSourceFileOfNode(expression)))
|
|
218
|
+
return false;
|
|
219
|
+
if (!ts.isIdentifier(expression.expression))
|
|
220
|
+
return false;
|
|
221
|
+
const stored = lowerer.peekLocal(expression.expression) ?? lowerer.globalOf(expression.expression);
|
|
222
|
+
if (!stored)
|
|
223
|
+
return false;
|
|
224
|
+
return (stored.type.kind === "dyn" || (stored.type.kind === "array" && stored.type.elem.kind === "dyn"));
|
|
225
|
+
}
|
|
141
226
|
export function storedClassValueType(lowerer, expression, visiting = new Set()) {
|
|
142
227
|
if (visiting.has(expression))
|
|
143
228
|
return null;
|
|
@@ -145,7 +230,7 @@ export function storedClassValueType(lowerer, expression, visiting = new Set())
|
|
|
145
230
|
if (ts.isParenthesizedExpression(expression))
|
|
146
231
|
return storedClassValueType(lowerer, expression.expression, visiting);
|
|
147
232
|
if (ts.isClassExpression(expression) &&
|
|
148
|
-
!
|
|
233
|
+
!perEvaluationClass(expression) &&
|
|
149
234
|
!lowerer.collectingExprClasses.has(expression)) {
|
|
150
235
|
const info = lowerer.lowerClassExpressionInfo(expression);
|
|
151
236
|
return { kind: "classval", className: info.def.name };
|
|
@@ -183,13 +268,19 @@ export function storedClassValueType(lowerer, expression, visiting = new Set())
|
|
|
183
268
|
}
|
|
184
269
|
const type = lowerer.typeOf(expression);
|
|
185
270
|
const mapped = lowerer.mapTypeOf(type);
|
|
271
|
+
// An element of a CHECKED-DYNAMIC JavaScript array (`const classes =
|
|
272
|
+
// [A, B]`, `both[1]`): the storage holds whichever constructor the array
|
|
273
|
+
// holds, so tsc's inferred element type — best common type spells the
|
|
274
|
+
// first — does not name the class the slot holds at run time.
|
|
275
|
+
if (mapped?.kind === "classval" && jsCheckedDynamicArrayElement(lowerer, expression))
|
|
276
|
+
return null;
|
|
186
277
|
if (mapped?.kind === "classval" && !lowerer.classes.has(mapped.className)) {
|
|
187
278
|
for (const signature of lowerer.checker.getConstructSignatures(type)) {
|
|
188
279
|
const constructor = signature.declaration;
|
|
189
280
|
const declaration = constructor && ts.isConstructorDeclaration(constructor) ? constructor.parent : undefined;
|
|
190
281
|
if (declaration &&
|
|
191
282
|
ts.isClassExpression(declaration) &&
|
|
192
|
-
!
|
|
283
|
+
!perEvaluationClass(declaration) &&
|
|
193
284
|
!lowerer.collectingExprClasses.has(declaration)) {
|
|
194
285
|
const info = lowerer.lowerClassExpressionInfo(declaration);
|
|
195
286
|
return { kind: "classval", className: info.def.name };
|
|
@@ -1387,6 +1478,15 @@ mixin) {
|
|
|
1387
1478
|
const adoptCallableBase = (expression) => {
|
|
1388
1479
|
if (familyMode || inst || mixin)
|
|
1389
1480
|
return false;
|
|
1481
|
+
if (isJsIteratorGlobal(lowerer, expression)) {
|
|
1482
|
+
callableBase = {
|
|
1483
|
+
expression,
|
|
1484
|
+
constructorId: `%g.${className}.base`,
|
|
1485
|
+
prototypeId: `%g.${className}.basePrototype`,
|
|
1486
|
+
iterator: true,
|
|
1487
|
+
};
|
|
1488
|
+
return true;
|
|
1489
|
+
}
|
|
1390
1490
|
if (lowerer.computedCallableBases.has(decl)) {
|
|
1391
1491
|
callableBase = {
|
|
1392
1492
|
expression,
|
|
@@ -1461,7 +1561,13 @@ mixin) {
|
|
|
1461
1561
|
const emitterBase = lowerer.builtinEmitterInfoOf(resolved);
|
|
1462
1562
|
const streamBaseNs = builtinStreamInfoOf(lowerer, resolved);
|
|
1463
1563
|
if (emitterBase || streamBaseNs) {
|
|
1464
|
-
|
|
1564
|
+
// An EventEmitter's type argument is the listener MAP, a pure
|
|
1565
|
+
// typing aid: the emitter base is one runtime class whatever the
|
|
1566
|
+
// map says, and the map's keys never reach the layout (Node's
|
|
1567
|
+
// own generic erases at runtime), so `extends
|
|
1568
|
+
// EventEmitter<MyEvents>` adopts the same base. A stream base's
|
|
1569
|
+
// argument IS the element layout, which still has to be concrete.
|
|
1570
|
+
if (!emitterBase && t.typeArguments?.nodes)
|
|
1465
1571
|
lowerer.unsupported("SC1090", t, "extending generic classes");
|
|
1466
1572
|
base = (emitterBase ?? streamBaseNs);
|
|
1467
1573
|
continue;
|
|
@@ -1652,7 +1758,12 @@ mixin) {
|
|
|
1652
1758
|
base = instBase;
|
|
1653
1759
|
continue;
|
|
1654
1760
|
}
|
|
1655
|
-
|
|
1761
|
+
// An EventEmitter base's type argument is the listener MAP — a pure
|
|
1762
|
+
// typing aid (the runtime base is one emitter class whatever the map
|
|
1763
|
+
// says, and Node erases it too), so `extends EventEmitter<Events>`
|
|
1764
|
+
// adopts the same base. Every other generic base still refuses:
|
|
1765
|
+
// its argument can carry a layout.
|
|
1766
|
+
if (t.typeArguments?.nodes && lowerer.builtinEmitterInfoOf(symbol) === null)
|
|
1656
1767
|
lowerer.unsupported("SC1090", t, "extending generic classes");
|
|
1657
1768
|
if (named?.extendsArray)
|
|
1658
1769
|
lowerer.unsupported("SC1090", t, `extending '${t.expression.text}', a class that extends Array (one level of Array subclass compiles)`);
|
|
@@ -1674,7 +1785,7 @@ mixin) {
|
|
|
1674
1785
|
throw new PoisonError();
|
|
1675
1786
|
}
|
|
1676
1787
|
}
|
|
1677
|
-
if (base?.localClass && !
|
|
1788
|
+
if (base?.localClass && !perEvaluationClass(decl) && !computedBase && !factoryBaseExpression) {
|
|
1678
1789
|
const heritage = decl.heritageClauses?.nodes.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types?.nodes[0];
|
|
1679
1790
|
if (heritage)
|
|
1680
1791
|
factoryBaseExpression = heritage.expression;
|
|
@@ -1741,7 +1852,13 @@ mixin) {
|
|
|
1741
1852
|
decl.members.nodes.some((member) => ts.isAccessor(member) &&
|
|
1742
1853
|
!ts.isPrivateIdentifier(member.name) &&
|
|
1743
1854
|
member.modifiers?.nodes.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword))) &&
|
|
1744
|
-
|
|
1855
|
+
// A private static ACCESSOR has no native storage yet, and a private
|
|
1856
|
+
// static method that reads `arguments` would lose the arguments past
|
|
1857
|
+
// its parameters when called through its value (`this.#m` returned by
|
|
1858
|
+
// a getter): keep such a class on the static path, whose public
|
|
1859
|
+
// static accessors refuse.
|
|
1860
|
+
!decl.members.nodes.some((member) => (ts.isAccessor(member) ||
|
|
1861
|
+
(ts.isMethodDeclaration(member) && bodyReadsArguments(member))) &&
|
|
1745
1862
|
ts.isPrivateIdentifier(member.name) &&
|
|
1746
1863
|
ts
|
|
1747
1864
|
.getModifiers(member)
|
|
@@ -1796,17 +1913,31 @@ mixin) {
|
|
|
1796
1913
|
});
|
|
1797
1914
|
};
|
|
1798
1915
|
for (const member of decl.members.nodes) {
|
|
1799
|
-
if ((
|
|
1916
|
+
if ((perEvaluationClass(decl) || checkedStatics) &&
|
|
1800
1917
|
(isJsSourceFile(ts.getSourceFileOfNode(decl)) ||
|
|
1801
|
-
(
|
|
1918
|
+
(perEvaluationClass(decl) && ts.isMethodDeclaration(member))) &&
|
|
1802
1919
|
(ts.isClassStaticBlockDeclaration(member) ||
|
|
1803
1920
|
ts
|
|
1804
1921
|
.getModifiers(member)
|
|
1805
1922
|
?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword))) {
|
|
1806
|
-
|
|
1807
|
-
|
|
1923
|
+
// A private static of a declaration-level class keeps its native
|
|
1924
|
+
// storage (the %C.static:#m function, the %g.s.C.#x global): the
|
|
1925
|
+
// constructor object never carries a property for it, and every
|
|
1926
|
+
// access brand-checks its receiver (private-statics.ts). A field
|
|
1927
|
+
// also stays in runtimeStatics, so its initializer runs in source
|
|
1928
|
+
// order with the constructor's other initializers.
|
|
1929
|
+
const privateStatic = checkedStatics &&
|
|
1930
|
+
!perEvaluationClass(decl) &&
|
|
1931
|
+
member.name !== undefined &&
|
|
1932
|
+
ts.isPrivateIdentifier(member.name);
|
|
1933
|
+
if (!privateStatic) {
|
|
1934
|
+
runtimeStatics.push(member);
|
|
1935
|
+
continue;
|
|
1936
|
+
}
|
|
1937
|
+
if (ts.isPropertyDeclaration(member))
|
|
1938
|
+
runtimeStatics.push(member);
|
|
1808
1939
|
}
|
|
1809
|
-
if (
|
|
1940
|
+
if (perEvaluationClass(decl) &&
|
|
1810
1941
|
isJsSourceFile(ts.getSourceFileOfNode(decl)) &&
|
|
1811
1942
|
(ts.isMethodDeclaration(member) || ts.isAccessor(member)) &&
|
|
1812
1943
|
member.body &&
|
|
@@ -1900,7 +2031,7 @@ mixin) {
|
|
|
1900
2031
|
}
|
|
1901
2032
|
staticMethods.set(member.name.text, { params: shapes, ret: ft.ret, member });
|
|
1902
2033
|
if (implicitMonoFile(ts.getSourceFileOfNode(decl)) &&
|
|
1903
|
-
!
|
|
2034
|
+
!perEvaluationClass(decl) &&
|
|
1904
2035
|
inst === undefined &&
|
|
1905
2036
|
decl.typeParameters === undefined) {
|
|
1906
2037
|
const implicit = implicitAnyParamSymbolsOf(lowerer, member, true);
|
|
@@ -2530,7 +2661,7 @@ mixin) {
|
|
|
2530
2661
|
// name (the override stays on the vtable), a shadowed field, or
|
|
2531
2662
|
// a generic-class instantiation's member.
|
|
2532
2663
|
if (implicitMonoFile(ts.getSourceFileOfNode(decl)) &&
|
|
2533
|
-
!
|
|
2664
|
+
!perEvaluationClass(decl) &&
|
|
2534
2665
|
ts.isIdentifier(member.name) &&
|
|
2535
2666
|
!lowerer.virtualJsMethods.has(member) &&
|
|
2536
2667
|
!lowerer.checkedJsOverrideMethods.has(member) &&
|
|
@@ -2741,7 +2872,7 @@ mixin) {
|
|
|
2741
2872
|
// boundary (lowerClassMethodMemberInner).
|
|
2742
2873
|
const ownAsync = member.modifiers?.nodes.some((m) => m.kind === ts.SyntaxKind.AsyncKeyword) === true;
|
|
2743
2874
|
if (!fencedJsOverride &&
|
|
2744
|
-
!
|
|
2875
|
+
!perEvaluationClass(decl) &&
|
|
2745
2876
|
overridden.sig.gen === undefined &&
|
|
2746
2877
|
// An async base's slot answers its promise: a Promise type, or
|
|
2747
2878
|
// the checked-dynamic value of an untyped async method.
|
|
@@ -2830,7 +2961,7 @@ mixin) {
|
|
|
2830
2961
|
!returnAdapters.has(mName) &&
|
|
2831
2962
|
(asyncMember || overridden.sig.async === true) &&
|
|
2832
2963
|
!isJsSourceFile(ts.getSourceFileOfNode(member)) &&
|
|
2833
|
-
!
|
|
2964
|
+
!perEvaluationClass(decl) &&
|
|
2834
2965
|
member.asteriskToken === undefined &&
|
|
2835
2966
|
overridden.sig.gen === undefined &&
|
|
2836
2967
|
!overridden.sig.abstract &&
|
|
@@ -3477,7 +3608,18 @@ mixin) {
|
|
|
3477
3608
|
bodyReadsArguments(ctor)) {
|
|
3478
3609
|
ctorParams.push({ type: DYN, mode: "arguments" });
|
|
3479
3610
|
}
|
|
3611
|
+
// A static `Symbol.hasInstance` member of a class that otherwise keeps
|
|
3612
|
+
// its statics in module storage: the hook only exists if the CLASS
|
|
3613
|
+
// VALUE carries it, so the member joins the runtime property table
|
|
3614
|
+
// (initializeRuntimeStatics). Only the hook members are added; every
|
|
3615
|
+
// other static keeps its current representation.
|
|
3616
|
+
const hasInstanceHooks = staticHasInstanceHookMembers(lowerer, decl);
|
|
3617
|
+
for (const member of hasInstanceHooks) {
|
|
3618
|
+
if (!runtimeStatics.includes(member))
|
|
3619
|
+
runtimeStatics.push(member);
|
|
3620
|
+
}
|
|
3480
3621
|
const info = {
|
|
3622
|
+
...(hasInstanceHooks.length ? { hasInstanceHook: true } : {}),
|
|
3481
3623
|
...(runtimeStatics.length || checkedStatics ? { runtimeStatics } : {}),
|
|
3482
3624
|
...(runtimePrototypeMembers.length ? { runtimePrototypeMembers } : {}),
|
|
3483
3625
|
def: {
|
|
@@ -3622,7 +3764,7 @@ mixin) {
|
|
|
3622
3764
|
lowerer.subclassLinks++;
|
|
3623
3765
|
}
|
|
3624
3766
|
lowerer.classes.set(className, info);
|
|
3625
|
-
if (computedBase && !
|
|
3767
|
+
if (computedBase && !perEvaluationClass(decl)) {
|
|
3626
3768
|
info.def.baseValueGlobal = `%g.${className}.computedBase`;
|
|
3627
3769
|
lowerer.globalsList.push({
|
|
3628
3770
|
id: info.def.baseValueGlobal,
|
|
@@ -3631,7 +3773,7 @@ mixin) {
|
|
|
3631
3773
|
mutable: false,
|
|
3632
3774
|
});
|
|
3633
3775
|
}
|
|
3634
|
-
if (factoryBaseExpression && !
|
|
3776
|
+
if (factoryBaseExpression && !perEvaluationClass(decl)) {
|
|
3635
3777
|
info.def.baseValueGlobal = `%g.${className}.computedBase`;
|
|
3636
3778
|
lowerer.globalsList.push({
|
|
3637
3779
|
id: info.def.baseValueGlobal,
|
|
@@ -3640,7 +3782,7 @@ mixin) {
|
|
|
3640
3782
|
mutable: false,
|
|
3641
3783
|
});
|
|
3642
3784
|
}
|
|
3643
|
-
if (callableBase && !
|
|
3785
|
+
if (callableBase && !perEvaluationClass(decl)) {
|
|
3644
3786
|
lowerer.globalsList.push({ id: callableBase.constructorId, name: `${className} base`, type: DYN, mutable: false }, {
|
|
3645
3787
|
id: callableBase.prototypeId,
|
|
3646
3788
|
name: `${className} base prototype`,
|
|
@@ -3741,6 +3883,9 @@ export function genericClassInstanceType(lowerer, decl, ref, mapArgument) {
|
|
|
3741
3883
|
// body (`this.v = v` types the receiver as `this`, not a reference).
|
|
3742
3884
|
// Inside an instantiation the CURRENT bindings are the arguments;
|
|
3743
3885
|
// anywhere else the reference is honestly unmappable.
|
|
3886
|
+
// The current instance's bindings ARE the arguments: the mapping
|
|
3887
|
+
// belongs to that instance.
|
|
3888
|
+
noteScopeSensitiveMapping();
|
|
3744
3889
|
for (const tp of gci.typeParams) {
|
|
3745
3890
|
const b = lowerer.typeParamBindings?.get(tp);
|
|
3746
3891
|
if (!b)
|
|
@@ -4074,16 +4219,23 @@ function lowerStaticFieldInitsInner(lowerer, info) {
|
|
|
4074
4219
|
}, {
|
|
4075
4220
|
kind: "assign",
|
|
4076
4221
|
localId: prototypeId,
|
|
4077
|
-
value:
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4222
|
+
value: info.callableBase.iterator
|
|
4223
|
+
? iteratorPrototypeExpr(loc)
|
|
4224
|
+
: {
|
|
4225
|
+
kind: "libCall",
|
|
4226
|
+
fn: "dyn.classBasePrototype",
|
|
4227
|
+
args: [{ kind: "varRef", localId: constructorId, type: DYN, loc }],
|
|
4228
|
+
type: DYN,
|
|
4229
|
+
loc,
|
|
4230
|
+
},
|
|
4084
4231
|
loc,
|
|
4085
4232
|
});
|
|
4086
|
-
|
|
4233
|
+
// An iterator subclass's instances are driven by the runtime's helpers,
|
|
4234
|
+
// which read `next` and `return` (methods or accessors) through the
|
|
4235
|
+
// instance's view: its prototype holds every member.
|
|
4236
|
+
const prototype = info.callableBase.iterator && info.decl
|
|
4237
|
+
? reflectClassPrototype(lowerer, info, loc, classValueRef(lowerer, info, info.decl))
|
|
4238
|
+
: classPrototypeData(lowerer, info, loc);
|
|
4087
4239
|
if (prototype)
|
|
4088
4240
|
out.push({ kind: "exprStmt", expr: prototype, loc });
|
|
4089
4241
|
out.push({
|
|
@@ -4109,7 +4261,15 @@ function lowerStaticFieldInitsInner(lowerer, info) {
|
|
|
4109
4261
|
});
|
|
4110
4262
|
}
|
|
4111
4263
|
const items = [
|
|
4112
|
-
|
|
4264
|
+
// A runtime-statics class initializes the private static fields its
|
|
4265
|
+
// property table carries with its other initializers
|
|
4266
|
+
// (initializeRuntimeStatics). One whose table carries only its
|
|
4267
|
+
// `Symbol.hasInstance` hook keeps its native initializers here.
|
|
4268
|
+
...info.staticFields
|
|
4269
|
+
.filter((f) => !(info.runtimeStatics &&
|
|
4270
|
+
f.name.startsWith("#") &&
|
|
4271
|
+
runtimeStaticDefines(lowerer, info, f.name)))
|
|
4272
|
+
.map((f) => ({
|
|
4113
4273
|
pos: ts.tokenStartOfNode(f.initializer),
|
|
4114
4274
|
kind: "field",
|
|
4115
4275
|
f,
|
|
@@ -4721,7 +4881,13 @@ export function lowerClassStaticRead(lowerer, info, name, receiver, site) {
|
|
|
4721
4881
|
["now", "parse", "UTC"].includes(name) &&
|
|
4722
4882
|
!(ts.isCallExpression(site.parent) && site.parent.expression === site))
|
|
4723
4883
|
lowerer.noLowering(`Date.${name} read through a class that extends Date`, site);
|
|
4724
|
-
|
|
4884
|
+
// A statically known member that the class value's table does not carry
|
|
4885
|
+
// (a class whose only runtime static is its `Symbol.hasInstance` hook)
|
|
4886
|
+
// reads its own storage, as it would without the hook.
|
|
4887
|
+
if (hasRuntimeStatics(info) &&
|
|
4888
|
+
!found?.field &&
|
|
4889
|
+
!name.startsWith("#") &&
|
|
4890
|
+
(!found || runtimeStaticDefines(lowerer, info, name)))
|
|
4725
4891
|
return {
|
|
4726
4892
|
kind: "dynKeyGet",
|
|
4727
4893
|
value: lowerer.coerceToExpected(classValueRef(lowerer, info, receiver), DYN),
|
|
@@ -4823,6 +4989,15 @@ function namedEvaluationName(expr) {
|
|
|
4823
4989
|
return p.name.text;
|
|
4824
4990
|
if (ts.isParameter(p) && ts.isIdentifier(p.name))
|
|
4825
4991
|
return p.name.text;
|
|
4992
|
+
// A destructuring default: `const [c = class {}] = []` and
|
|
4993
|
+
// `({ c = class {} } = o)` name the class after the bound identifier. An
|
|
4994
|
+
// array-literal element that is not a pattern element stays unnamed.
|
|
4995
|
+
if (ts.isBindingElement(p) && p.initializer !== undefined && ts.isIdentifier(p.name))
|
|
4996
|
+
return p.name.text;
|
|
4997
|
+
if (ts.isShorthandPropertyAssignment(p) &&
|
|
4998
|
+
p.objectAssignmentInitializer !== undefined &&
|
|
4999
|
+
ts.isIdentifier(p.name))
|
|
5000
|
+
return p.name.text;
|
|
4826
5001
|
return "";
|
|
4827
5002
|
}
|
|
4828
5003
|
/** Each evaluation of a function-local class creates fresh private names,
|
|
@@ -4889,10 +5064,13 @@ function privateNamesOnlyOnThis(expr) {
|
|
|
4889
5064
|
}
|
|
4890
5065
|
return true;
|
|
4891
5066
|
}
|
|
4892
|
-
/** Collect a class expression once per enclosing specialization.
|
|
4893
|
-
*
|
|
4894
|
-
*
|
|
4895
|
-
*
|
|
5067
|
+
/** Collect a class expression once per enclosing specialization. A class
|
|
5068
|
+
* definition the program can EVALUATE more than once (perEvaluationClass:
|
|
5069
|
+
* a function body, a loop body, an instance initializer) allocates fresh
|
|
5070
|
+
* constructor objects, so identity, statics and prototype belong to that
|
|
5071
|
+
* evaluation; definitions evaluated once use immortal templates. Static
|
|
5072
|
+
* initialization remains limited to whole top-level initializers, where
|
|
5073
|
+
* pendingClassExprInits preserves its evaluation point. */
|
|
4896
5074
|
export function lowerClassExpressionInfo(lowerer, expr) {
|
|
4897
5075
|
const cached = lowerer.exprClassInfoByName.get(lowerer.classNamer(expr));
|
|
4898
5076
|
if (cached)
|
|
@@ -4907,14 +5085,12 @@ export function lowerClassExpressionInfo(lowerer, expr) {
|
|
|
4907
5085
|
if (lowerer.collectingExprClasses.has(expr)) {
|
|
4908
5086
|
lowerer.unsupported("SC1090", expr, "class expressions whose extends chain re-enters their own collection (a cyclic base through property assignments)");
|
|
4909
5087
|
}
|
|
4910
|
-
let local = false;
|
|
4911
5088
|
for (let p = expr.parent; p !== undefined && !ts.isSourceFile(p); p = p.parent) {
|
|
4912
5089
|
if (ts.isClassStaticBlockDeclaration(p)) {
|
|
4913
5090
|
lowerer.unsupported("SC1090", expr, "class expressions inside static blocks");
|
|
4914
5091
|
}
|
|
4915
|
-
if (ts.isFunctionLike(p))
|
|
4916
|
-
local = true;
|
|
4917
5092
|
}
|
|
5093
|
+
const local = perEvaluationClass(expr);
|
|
4918
5094
|
if (local &&
|
|
4919
5095
|
expr.members.nodes.some((member) => member.name && ts.isPrivateIdentifier(member.name)) &&
|
|
4920
5096
|
!localPrivateFieldsAgree(expr)) {
|
|
@@ -5160,7 +5336,15 @@ function lowerClassValue(lowerer, expr, info, binding) {
|
|
|
5160
5336
|
fn: "dyn.classPrototype",
|
|
5161
5337
|
args: [
|
|
5162
5338
|
boxed,
|
|
5163
|
-
|
|
5339
|
+
info.callableBase.iterator
|
|
5340
|
+
? iteratorPrototypeExpr(loc)
|
|
5341
|
+
: {
|
|
5342
|
+
kind: "libCall",
|
|
5343
|
+
fn: "dyn.classBasePrototype",
|
|
5344
|
+
args: [baseRef],
|
|
5345
|
+
type: DYN,
|
|
5346
|
+
loc,
|
|
5347
|
+
},
|
|
5164
5348
|
],
|
|
5165
5349
|
type: DYN,
|
|
5166
5350
|
loc,
|
|
@@ -5539,10 +5723,15 @@ function staticCallOn(lowerer, call, access, info, throughValue) {
|
|
|
5539
5723
|
if (date)
|
|
5540
5724
|
return date;
|
|
5541
5725
|
}
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5726
|
+
const staticMember = findStaticOn(lowerer, info, access.name.text);
|
|
5727
|
+
// A statically known member that the class value's table does not carry
|
|
5728
|
+
// (a class whose only runtime static is its `Symbol.hasInstance` hook)
|
|
5729
|
+
// calls its own function, as it would without the hook.
|
|
5730
|
+
if ((hasRuntimeStatics(info) &&
|
|
5731
|
+
!access.name.text.startsWith("#") &&
|
|
5732
|
+
!staticMember?.field &&
|
|
5733
|
+
(!staticMember || runtimeStaticDefines(lowerer, info, access.name.text))) ||
|
|
5734
|
+
(info.callableBase && !staticMember && !findGenericStaticOn(lowerer, info, access.name.text)))
|
|
5546
5735
|
return {
|
|
5547
5736
|
kind: "dynInvoke",
|
|
5548
5737
|
recv: lowerer.lowerExprExpecting(access.expression, DYN),
|
|
@@ -5730,9 +5919,12 @@ function directRuntimeStaticCall(lowerer, call, access, info, throughValue) {
|
|
|
5730
5919
|
c.staticMethods?.has(name) === true ||
|
|
5731
5920
|
c.genericStatics?.has(name) === true)
|
|
5732
5921
|
return null;
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5922
|
+
// A computed name defines the key it folds to, so `static ['m']` in
|
|
5923
|
+
// this class answers for `m` and hides the inherited method.
|
|
5924
|
+
const runtime = c.runtimeStatics?.find((element) => {
|
|
5925
|
+
const elementName = element.name;
|
|
5926
|
+
return elementName !== undefined && classMemberNameOf(lowerer, elementName) === name;
|
|
5927
|
+
});
|
|
5736
5928
|
if (runtime) {
|
|
5737
5929
|
if (!ts.isMethodDeclaration(runtime) || !runtime.body)
|
|
5738
5930
|
return null;
|
|
@@ -5924,9 +6116,16 @@ export function lowerClassValueProperty(lowerer, expr) {
|
|
|
5924
6116
|
// its other statics (`Error.stackTraceLimit`) keep their own lowerings.
|
|
5925
6117
|
if (info?.def.runtime && member !== "name")
|
|
5926
6118
|
return null;
|
|
6119
|
+
const storedMember = info ? findStaticOn(lowerer, info, member) : undefined;
|
|
6120
|
+
// A statically known member that the class value's table does not carry
|
|
6121
|
+
// (a class whose only runtime static is its `Symbol.hasInstance` hook)
|
|
6122
|
+
// reads its own storage, as it would without the hook.
|
|
5927
6123
|
if (info &&
|
|
5928
|
-
((hasRuntimeStatics(info) &&
|
|
5929
|
-
(
|
|
6124
|
+
((hasRuntimeStatics(info) &&
|
|
6125
|
+
!member.startsWith("#") &&
|
|
6126
|
+
!storedMember?.field &&
|
|
6127
|
+
(!storedMember || runtimeStaticDefines(lowerer, info, member))) ||
|
|
6128
|
+
(info.callableBase && !storedMember)))
|
|
5930
6129
|
return {
|
|
5931
6130
|
kind: "dynKeyGet",
|
|
5932
6131
|
value: lowerer.lowerExprExpecting(expr.expression, DYN),
|
|
@@ -6142,7 +6341,7 @@ function localSubclassesOf(lowerer, base) {
|
|
|
6142
6341
|
ts.walkPreorder(sf, (node) => {
|
|
6143
6342
|
if ((ts.isClassDeclaration(node) || ts.isClassExpression(node)) &&
|
|
6144
6343
|
node.heritageClauses !== undefined &&
|
|
6145
|
-
|
|
6344
|
+
perEvaluationClass(node)) {
|
|
6146
6345
|
const extended = extendedClassNode(lowerer, node);
|
|
6147
6346
|
if (extended) {
|
|
6148
6347
|
const list = index.get(extended);
|
|
@@ -6768,6 +6967,20 @@ function lowerClassCtorInner(lowerer, info) {
|
|
|
6768
6967
|
const thisLocal = lowerer.declareThis(thisType);
|
|
6769
6968
|
const params = [{ localId: thisLocal.id, name: "this", type: thisType }];
|
|
6770
6969
|
const body = [];
|
|
6970
|
+
// A derived constructor that can return a primitive records the pending
|
|
6971
|
+
// TypeError for the construction site to raise. Drop a stale record on
|
|
6972
|
+
// entry: a `finally` that throws after the return abandons the
|
|
6973
|
+
// construction before any site reads it.
|
|
6974
|
+
const pendingPrimitive = constructorPrimitiveFlag(lowerer, info);
|
|
6975
|
+
if (pendingPrimitive !== null) {
|
|
6976
|
+
const clearLoc = locOf(info.ctor ?? info.decl);
|
|
6977
|
+
body.push({
|
|
6978
|
+
kind: "assign",
|
|
6979
|
+
localId: pendingPrimitive.id,
|
|
6980
|
+
value: { kind: "boolLit", value: false, type: BOOL, loc: clearLoc },
|
|
6981
|
+
loc: clearLoc,
|
|
6982
|
+
});
|
|
6983
|
+
}
|
|
6771
6984
|
// The construction-relevant base: generic families are transparent
|
|
6772
6985
|
// (an instantiation of a base-less generic class IS a base class —
|
|
6773
6986
|
// its source has no super()).
|
|
@@ -7441,7 +7654,16 @@ function lowerClassMethodBody(lowerer, info, fnLike, fnName, sig) {
|
|
|
7441
7654
|
if (shape.mode === "arguments")
|
|
7442
7655
|
fnCtx.argumentsLocal = local;
|
|
7443
7656
|
}
|
|
7444
|
-
|
|
7657
|
+
// See lowerFunction: a generator binds its parameters at the CALL
|
|
7658
|
+
// (FunctionDeclarationInstantiation runs before GeneratorStart) exactly
|
|
7659
|
+
// when that is observable — a destructuring or rest pattern, a default
|
|
7660
|
+
// that evaluates anything, or a body that reads `arguments`.
|
|
7661
|
+
const bindsAtCall = genCh !== null && declared.prologue.length > 0 && generatorParamsBindAtCall(fnLike);
|
|
7662
|
+
const body = [
|
|
7663
|
+
...declared.prologue,
|
|
7664
|
+
...(bindsAtCall ? [{ kind: "genBindBarrier", loc: locOf(fnLike) }] : []),
|
|
7665
|
+
...lowerer.lowerStmts(fnLike.body.statements.nodes),
|
|
7666
|
+
];
|
|
7445
7667
|
appendImplicitUndefinedReturn(lowerer, body, bodyReturn, locOf(fnLike));
|
|
7446
7668
|
const fn = {
|
|
7447
7669
|
name: fnName,
|
|
@@ -7455,7 +7677,7 @@ function lowerClassMethodBody(lowerer, info, fnLike, fnName, sig) {
|
|
|
7455
7677
|
if (isAsync)
|
|
7456
7678
|
fn.async = true;
|
|
7457
7679
|
if (genCh !== null)
|
|
7458
|
-
fn.generator = genCh;
|
|
7680
|
+
fn.generator = bindsAtCall ? { ...genCh, bindAtCall: true } : genCh;
|
|
7459
7681
|
return fn;
|
|
7460
7682
|
}
|
|
7461
7683
|
finally {
|
|
@@ -7501,7 +7723,14 @@ export function lowerStaticMethod(lowerer, info, name) {
|
|
|
7501
7723
|
declared.params.push({ localId: local.id, name: "%arguments", type: DYN });
|
|
7502
7724
|
fnCtx.argumentsLocal = local;
|
|
7503
7725
|
}
|
|
7504
|
-
|
|
7726
|
+
// See lowerFunction: a generator binds its parameters at the CALL
|
|
7727
|
+
// exactly when that is observable.
|
|
7728
|
+
const bindsAtCall = genCh !== null && declared.prologue.length > 0 && generatorParamsBindAtCall(entry.member);
|
|
7729
|
+
const body = [
|
|
7730
|
+
...declared.prologue,
|
|
7731
|
+
...(bindsAtCall ? [{ kind: "genBindBarrier", loc: locOf(entry.member) }] : []),
|
|
7732
|
+
...lowerer.lowerStmts(entry.member.body.statements.nodes),
|
|
7733
|
+
];
|
|
7505
7734
|
appendImplicitUndefinedReturn(lowerer, body, bodyReturn, locOf(entry.member));
|
|
7506
7735
|
const fn = {
|
|
7507
7736
|
name: `%${info.def.name}.static:${name}`,
|
|
@@ -7514,7 +7743,7 @@ export function lowerStaticMethod(lowerer, info, name) {
|
|
|
7514
7743
|
if (isAsync)
|
|
7515
7744
|
fn.async = true;
|
|
7516
7745
|
if (genCh !== null)
|
|
7517
|
-
fn.generator = genCh;
|
|
7746
|
+
fn.generator = bindsAtCall ? { ...genCh, bindAtCall: true } : genCh;
|
|
7518
7747
|
return fn;
|
|
7519
7748
|
}
|
|
7520
7749
|
catch (e) {
|
|
@@ -7919,6 +8148,10 @@ export function superCallStmt(lowerer, info, thisLocal, args, loc) {
|
|
|
7919
8148
|
return dateSuperCall(thisRef, info, args[0], loc);
|
|
7920
8149
|
if (info.extendsArray)
|
|
7921
8150
|
return arraySuperCall(info, thisRef, args[0], loc);
|
|
8151
|
+
// super() into %Iterator%: NewTarget is the subclass, so the abstract
|
|
8152
|
+
// constructor only creates the receiver the derived constructor made.
|
|
8153
|
+
if (info.callableBase?.iterator)
|
|
8154
|
+
return { kind: "exprStmt", expr: args[0], loc };
|
|
7922
8155
|
if (info.callableBase)
|
|
7923
8156
|
return {
|
|
7924
8157
|
kind: "exprStmt",
|
|
@@ -8473,6 +8706,20 @@ function lowerProgramClassNew(lowerer, expr, declaredInfo, loc) {
|
|
|
8473
8706
|
loc,
|
|
8474
8707
|
});
|
|
8475
8708
|
}
|
|
8709
|
+
/** The supported map layout a contextual type pins for `new Map()`: the type
|
|
8710
|
+
* itself, or the single map arm of a union — a nullable annotation such as
|
|
8711
|
+
* `Map<K, V> | undefined`, or `ReadonlyMap<K, V> | undefined`, where a Map
|
|
8712
|
+
* value can only inhabit the map arm and the no-argument constructor gives
|
|
8713
|
+
* the checker nothing to infer the type arguments from. */
|
|
8714
|
+
function contextualMapLayout(lowerer, ctx) {
|
|
8715
|
+
const mapped = lowerer.mapTypeOf(ctx);
|
|
8716
|
+
if (mapped?.kind === "map")
|
|
8717
|
+
return mapped;
|
|
8718
|
+
if (mapped?.kind !== "union")
|
|
8719
|
+
return null;
|
|
8720
|
+
const arms = (lowerer.unions.get(mapped.unionId)?.arms ?? []).filter((arm) => arm.kind === "map");
|
|
8721
|
+
return arms.length === 1 ? arms[0] : null;
|
|
8722
|
+
}
|
|
8476
8723
|
function assignedThisFieldType(lowerer, expr) {
|
|
8477
8724
|
const parent = expr.parent;
|
|
8478
8725
|
if (!ts.isBinaryExpression(parent) ||
|
|
@@ -8537,13 +8784,162 @@ function checkedElementConstruction(lowerer, info, narrowed, args, loc) {
|
|
|
8537
8784
|
loc,
|
|
8538
8785
|
};
|
|
8539
8786
|
}
|
|
8787
|
+
/** `new x.someLibMethod(...)`: a built-in method is not a constructor.
|
|
8788
|
+
* Node evaluates the receiver, reads the member, evaluates the arguments,
|
|
8789
|
+
* then throws `TypeError: <callee> is not a constructor` (V8 prints an
|
|
8790
|
+
* anonymous intermediate value as `(intermediate value)`). On a typed
|
|
8791
|
+
* receiver and on %Iterator.prototype% the member is the built-in method.
|
|
8792
|
+
* Any other checked-dynamic receiver may hold any value: the read throws
|
|
8793
|
+
* Node's TypeError for undefined and null before any argument evaluates
|
|
8794
|
+
* and runs an accessor, and a function it answers constructs as for any
|
|
8795
|
+
* dynamic callee. Null otherwise. */
|
|
8796
|
+
function lowerNonConstructorNew(lowerer, expr) {
|
|
8797
|
+
let callee = expr.expression;
|
|
8798
|
+
while (ts.isParenthesizedExpression(callee))
|
|
8799
|
+
callee = callee.expression;
|
|
8800
|
+
if (!ts.isPropertyAccessExpression(callee) || callee.questionDotToken)
|
|
8801
|
+
return null;
|
|
8802
|
+
if (!lowerer.isStdlibMember(callee))
|
|
8803
|
+
return null;
|
|
8804
|
+
const symbol = lowerer.checker.getSymbolAtLocation(callee.name);
|
|
8805
|
+
const method = symbol?.declarations?.some((decl) => ts.isMethodSignatureDeclaration(decl) || ts.isMethodDeclaration(decl));
|
|
8806
|
+
if (!method)
|
|
8807
|
+
return null;
|
|
8808
|
+
const args = expr.arguments?.nodes ?? [];
|
|
8809
|
+
if (args.some(ts.isSpreadElement))
|
|
8810
|
+
return null;
|
|
8811
|
+
const loc = locOf(expr);
|
|
8812
|
+
let receiver = callee.expression;
|
|
8813
|
+
while (ts.isParenthesizedExpression(receiver))
|
|
8814
|
+
receiver = receiver.expression;
|
|
8815
|
+
const left = ts.isClassExpression(receiver) ||
|
|
8816
|
+
ts.isFunctionExpression(receiver) ||
|
|
8817
|
+
ts.isArrowFunction(receiver)
|
|
8818
|
+
? "(intermediate value)"
|
|
8819
|
+
: ts.getTextOfNode(receiver);
|
|
8820
|
+
const message = `${left}.${callee.name.text} is not a constructor`;
|
|
8821
|
+
const recv = lowerer.lowerExpr(receiver);
|
|
8822
|
+
// %Iterator.prototype% (scr_js_iterator.c) holds the runtime's helpers.
|
|
8823
|
+
const intrinsic = recv.kind === "libCall" && recv.fn === "iterator.prototype";
|
|
8824
|
+
if (intrinsic || (recv.type.kind !== "dyn" && recv.type.kind !== "union")) {
|
|
8825
|
+
const stmts = [
|
|
8826
|
+
{ kind: "exprStmt", expr: recv, loc: locOf(receiver) },
|
|
8827
|
+
...args.map((arg) => ({
|
|
8828
|
+
kind: "exprStmt",
|
|
8829
|
+
expr: lowerer.lowerExpr(arg),
|
|
8830
|
+
loc: locOf(arg),
|
|
8831
|
+
})),
|
|
8832
|
+
];
|
|
8833
|
+
return {
|
|
8834
|
+
kind: "seqExpr",
|
|
8835
|
+
stmts,
|
|
8836
|
+
result: nodeThrowExpr(1, "", message, DYN, loc),
|
|
8837
|
+
type: DYN,
|
|
8838
|
+
loc,
|
|
8839
|
+
};
|
|
8840
|
+
}
|
|
8841
|
+
const member = lowerer.declareHiddenLocal("%newMember", DYN);
|
|
8842
|
+
const stmts = [
|
|
8843
|
+
{
|
|
8844
|
+
kind: "varDecl",
|
|
8845
|
+
localId: member.id,
|
|
8846
|
+
init: {
|
|
8847
|
+
kind: "dynKeyGet",
|
|
8848
|
+
key: strLit(callee.name.text, loc),
|
|
8849
|
+
value: lowerer.coerceToExpected(recv, DYN),
|
|
8850
|
+
type: DYN,
|
|
8851
|
+
loc: locOf(callee),
|
|
8852
|
+
},
|
|
8853
|
+
loc: locOf(callee),
|
|
8854
|
+
},
|
|
8855
|
+
];
|
|
8856
|
+
const argRefs = args.map((arg) => {
|
|
8857
|
+
const local = lowerer.declareHiddenLocal("%newArg", DYN);
|
|
8858
|
+
stmts.push({
|
|
8859
|
+
kind: "varDecl",
|
|
8860
|
+
localId: local.id,
|
|
8861
|
+
init: lowerer.coerceToExpected(lowerer.lowerExpr(arg), DYN),
|
|
8862
|
+
loc: locOf(arg),
|
|
8863
|
+
});
|
|
8864
|
+
return varRef(local.id, DYN, loc);
|
|
8865
|
+
});
|
|
8866
|
+
return {
|
|
8867
|
+
kind: "seqExpr",
|
|
8868
|
+
stmts,
|
|
8869
|
+
result: {
|
|
8870
|
+
kind: "ternary",
|
|
8871
|
+
cond: {
|
|
8872
|
+
kind: "dynTest",
|
|
8873
|
+
test: "function",
|
|
8874
|
+
value: varRef(member.id, DYN, loc),
|
|
8875
|
+
type: BOOL,
|
|
8876
|
+
loc,
|
|
8877
|
+
},
|
|
8878
|
+
then: checkedClassConstruction(lowerer, varRef(member.id, DYN, loc), argRefs, loc, `${left}.${callee.name.text}`),
|
|
8879
|
+
else_: nodeThrowExpr(1, "", message, DYN, loc),
|
|
8880
|
+
type: DYN,
|
|
8881
|
+
loc,
|
|
8882
|
+
},
|
|
8883
|
+
type: DYN,
|
|
8884
|
+
loc,
|
|
8885
|
+
};
|
|
8886
|
+
}
|
|
8540
8887
|
/** Map, Set and the error classes construct in lowerNew's identifier
|
|
8541
8888
|
* branch, which a module member alias of one (`new mod.M()`) also takes. */
|
|
8542
8889
|
function isCollectionOrErrorClass(ref) {
|
|
8543
8890
|
return ref?.kind === "collection" || ref?.kind === "error";
|
|
8544
8891
|
}
|
|
8892
|
+
/** `new url.URL(...)` / `new url.URLSearchParams(...)`: the member of a
|
|
8893
|
+
* node:url binding (a namespace import, a require result, or an import=
|
|
8894
|
+
* alias) resolves to the stdlib class symbol the named import binds, so the
|
|
8895
|
+
* construction takes the same lowering. A binding that holds the class
|
|
8896
|
+
* (`const U = url.URL`) follows its initializer to the same symbol. */
|
|
8897
|
+
function stdlibUrlClassOf(lowerer, callee) {
|
|
8898
|
+
const classNamed = (sym) => {
|
|
8899
|
+
if (!sym || !lowerer.isStdlibSymbol(sym))
|
|
8900
|
+
return null;
|
|
8901
|
+
const name = ts.symbolName(sym);
|
|
8902
|
+
return name === "URL" || name === "URLSearchParams" ? name : null;
|
|
8903
|
+
};
|
|
8904
|
+
const aliased = (raw) => raw && raw.flags & ts.SymbolFlags.Alias ? lowerer.checker.getAliasedSymbol(raw) : raw;
|
|
8905
|
+
let selected = callee;
|
|
8906
|
+
for (let hops = 0; hops < 4; hops++) {
|
|
8907
|
+
while (ts.isParenthesizedExpression(selected))
|
|
8908
|
+
selected = selected.expression;
|
|
8909
|
+
if (ts.isPropertyAccessExpression(selected) && !selected.questionDotToken) {
|
|
8910
|
+
return classNamed(aliased(lowerer.checker.getSymbolAtLocation(selected.name)));
|
|
8911
|
+
}
|
|
8912
|
+
if (!ts.isIdentifier(selected))
|
|
8913
|
+
return null;
|
|
8914
|
+
const sym = aliased(lowerer.checker.getSymbolAtLocation(selected));
|
|
8915
|
+
if (!sym)
|
|
8916
|
+
return null;
|
|
8917
|
+
const known = classNamed(sym);
|
|
8918
|
+
if (known !== null)
|
|
8919
|
+
return known;
|
|
8920
|
+
const decl = sym.valueDeclaration;
|
|
8921
|
+
if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)
|
|
8922
|
+
return null;
|
|
8923
|
+
let next = decl.initializer;
|
|
8924
|
+
while (ts.isParenthesizedExpression(next))
|
|
8925
|
+
next = next.expression;
|
|
8926
|
+
if (next === selected)
|
|
8927
|
+
return null;
|
|
8928
|
+
selected = next;
|
|
8929
|
+
}
|
|
8930
|
+
return null;
|
|
8931
|
+
}
|
|
8545
8932
|
export function lowerNew(lowerer, expr) {
|
|
8546
8933
|
const loc = locOf(expr);
|
|
8934
|
+
// Constructing a Node 24 global the native runtime does not provide
|
|
8935
|
+
// (WebSocket, FormData, …): the value a read answers refuses construction
|
|
8936
|
+
// (host-global-values.ts), so the construction is that refusal — SC2020,
|
|
8937
|
+
// which a JavaScript source defers to the throw at this statement.
|
|
8938
|
+
{
|
|
8939
|
+
const hostGlobal = hostGlobalNameOfRead(lowerer, expr.expression);
|
|
8940
|
+
if (hostGlobal !== null)
|
|
8941
|
+
lowerer.hostGlobalFence(hostGlobal, expr.expression);
|
|
8942
|
+
}
|
|
8547
8943
|
// The deprecated `new Buffer(...)` (containers/bytes.ts).
|
|
8548
8944
|
{
|
|
8549
8945
|
const buffer = lowerBufferConstruct(lowerer, expr);
|
|
@@ -8571,6 +8967,25 @@ export function lowerNew(lowerer, expr) {
|
|
|
8571
8967
|
return lowerWithInlineRequireInit(lowerer, req, () => lowerNew(lowerer, expr));
|
|
8572
8968
|
}
|
|
8573
8969
|
}
|
|
8970
|
+
// `new url.URL(input)` / `new url.URLSearchParams(init?)`: the node:url
|
|
8971
|
+
// member names the same class the named import does, so both take the
|
|
8972
|
+
// class's own lowering (including its argument diagnostics).
|
|
8973
|
+
{
|
|
8974
|
+
const urlClass = stdlibUrlClassOf(lowerer, expr.expression);
|
|
8975
|
+
if (urlClass === "URL")
|
|
8976
|
+
return lowerUrlNew(lowerer, expr);
|
|
8977
|
+
if (urlClass === "URLSearchParams")
|
|
8978
|
+
return lowerSearchParamsNew(lowerer, expr, loc);
|
|
8979
|
+
}
|
|
8980
|
+
const wrapper = lowerWrapperNew(lowerer, expr);
|
|
8981
|
+
if (wrapper)
|
|
8982
|
+
return wrapper;
|
|
8983
|
+
const abstractIterator = lowerIteratorNew(lowerer, expr);
|
|
8984
|
+
if (abstractIterator)
|
|
8985
|
+
return abstractIterator;
|
|
8986
|
+
const nonConstructor = lowerNonConstructorNew(lowerer, expr);
|
|
8987
|
+
if (nonConstructor)
|
|
8988
|
+
return nonConstructor;
|
|
8574
8989
|
const worker = lowerWorkerNew(lowerer, expr);
|
|
8575
8990
|
if (worker)
|
|
8576
8991
|
return worker;
|
|
@@ -8644,7 +9059,15 @@ export function lowerNew(lowerer, expr) {
|
|
|
8644
9059
|
expr.expression.name.text === "Segmenter" &&
|
|
8645
9060
|
lowerer.isStdlibGlobal(expr.expression.expression, "Intl")) {
|
|
8646
9061
|
const args = expr.arguments?.nodes ?? [];
|
|
8647
|
-
|
|
9062
|
+
// An argument whose value IS undefined: exactly undefined, or void. A
|
|
9063
|
+
// union that merely includes undefined may hold a locale or an options
|
|
9064
|
+
// object at run time, and the constructor cannot inspect either — such
|
|
9065
|
+
// an argument is refused below rather than silently read as the default
|
|
9066
|
+
// locale or the default options.
|
|
9067
|
+
const undefinedArg = (arg) => {
|
|
9068
|
+
const flags = lowerer.typeOf(arg).flags;
|
|
9069
|
+
return flags === ts.TypeFlags.Undefined || flags === ts.TypeFlags.Void;
|
|
9070
|
+
};
|
|
8648
9071
|
// A literal language tag: Unicode grapheme clusters have no locale
|
|
8649
9072
|
// tailoring. Only tags of the form language[-script][-region] are
|
|
8650
9073
|
// accepted; each is well-formed, so Node constructs the segmenter
|
|
@@ -8654,27 +9077,28 @@ export function lowerNew(lowerer, expr) {
|
|
|
8654
9077
|
if (args.length > 2 || (args[0] && !undefinedArg(args[0]) && !literalLocale(args[0]))) {
|
|
8655
9078
|
lowerer.noLowering("Intl.Segmenter locale negotiation", expr, "omit the locale, pass undefined, or pass one language tag as a string literal");
|
|
8656
9079
|
}
|
|
8657
|
-
//
|
|
8658
|
-
//
|
|
8659
|
-
//
|
|
8660
|
-
// TypeScript sources keep the
|
|
9080
|
+
// Word segmentation lowers through ICU (scr_intl.c). Sentence
|
|
9081
|
+
// segmentation does not: JavaScript dependencies may construct sentence
|
|
9082
|
+
// segmenters they use only on some paths, so the construction compiles
|
|
9083
|
+
// and their segment() throws SC2020; TypeScript sources keep the
|
|
9084
|
+
// build-time refusal.
|
|
8661
9085
|
const granularities = isJsSourceFile(ts.getSourceFileOfNode(expr))
|
|
8662
9086
|
? ["grapheme", "word", "sentence"]
|
|
8663
|
-
: ["grapheme"];
|
|
9087
|
+
: ["grapheme", "word"];
|
|
8664
9088
|
const options = args[1];
|
|
8665
9089
|
let granularity = "grapheme";
|
|
8666
9090
|
if (options && !undefinedArg(options)) {
|
|
8667
9091
|
// An object literal of `granularity` entries (none: the default; a
|
|
8668
9092
|
// repeated key: the last one, as in JavaScript).
|
|
8669
9093
|
if (!ts.isObjectLiteralExpression(options))
|
|
8670
|
-
lowerer.noLowering("Intl.Segmenter options", options, 'the native segmenter supports default options
|
|
9094
|
+
lowerer.noLowering("Intl.Segmenter options", options, 'the native segmenter supports default options, { granularity: "grapheme" } and { granularity: "word" }; sentence segmentation remains unsupported');
|
|
8671
9095
|
for (const property of options.properties.nodes) {
|
|
8672
9096
|
if (!ts.isPropertyAssignment(property) ||
|
|
8673
9097
|
!(ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) ||
|
|
8674
9098
|
property.name.text !== "granularity" ||
|
|
8675
9099
|
!ts.isStringLiteral(property.initializer) ||
|
|
8676
9100
|
!granularities.includes(property.initializer.text)) {
|
|
8677
|
-
lowerer.noLowering("Intl.Segmenter options", options, 'the native segmenter supports default options
|
|
9101
|
+
lowerer.noLowering("Intl.Segmenter options", options, 'the native segmenter supports default options, { granularity: "grapheme" } and { granularity: "word" }; sentence segmentation remains unsupported');
|
|
8678
9102
|
}
|
|
8679
9103
|
granularity = property.initializer.text;
|
|
8680
9104
|
}
|
|
@@ -8688,12 +9112,28 @@ export function lowerNew(lowerer, expr) {
|
|
|
8688
9112
|
loc: locOf(arg),
|
|
8689
9113
|
};
|
|
8690
9114
|
});
|
|
9115
|
+
// Grapheme segmentation is the engine-free table-driven segmenter
|
|
9116
|
+
// (scr_grapheme.c). NOTE: once ICU is established everywhere, this fast
|
|
9117
|
+
// path is deleted in favor of ICU's character iterator (design I4).
|
|
8691
9118
|
let result = { kind: "libCall", fn: "intl.segmenterNew", args: [], type: DYN, loc };
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
9119
|
+
if (granularity === "word") {
|
|
9120
|
+
// ICU's word iterator at the requested locale; a literal language tag
|
|
9121
|
+
// is the locale, and the empty string means the default locale (what
|
|
9122
|
+
// Node negotiates when the argument is absent or undefined).
|
|
9123
|
+
const tag = args[0] !== undefined && ts.isStringLiteralLike(args[0]) ? args[0].text : "";
|
|
9124
|
+
result = {
|
|
9125
|
+
kind: "libCall",
|
|
9126
|
+
fn: "icu.segmenterWord",
|
|
9127
|
+
args: [strLit(tag, loc)],
|
|
9128
|
+
type: DYN,
|
|
9129
|
+
loc,
|
|
9130
|
+
};
|
|
9131
|
+
}
|
|
9132
|
+
// A sentence segmenter carries its segment() refusal, which coverage
|
|
9133
|
+
// lists as deferred to runtime.
|
|
9134
|
+
if (granularity === "sentence") {
|
|
8695
9135
|
const surface = `Intl.Segmenter segmentation with granularity '${granularity}'`;
|
|
8696
|
-
lowerer.runtimeFences.push(noLoweringDiag(surface, loc, "only grapheme segmenters segment;
|
|
9136
|
+
lowerer.runtimeFences.push(noLoweringDiag(surface, loc, "only grapheme and word segmenters segment; sentence segmenters construct"));
|
|
8697
9137
|
const line = ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(expr), loc.start).line;
|
|
8698
9138
|
const refusal = `${surface} is not supported yet [SC2020 at ${loc.file}:${line + 1}]`;
|
|
8699
9139
|
result = {
|
|
@@ -9066,7 +9506,21 @@ export function lowerNew(lowerer, expr) {
|
|
|
9066
9506
|
if (args.some(ts.isSpreadElement))
|
|
9067
9507
|
lowerer.noLowering("new RegExp with spread arguments", expr);
|
|
9068
9508
|
const values = args.map((arg) => lowerer.lowerExpr(arg));
|
|
9069
|
-
|
|
9509
|
+
// The statically spelled form below needs a string or undefined in
|
|
9510
|
+
// each slot. Every other value — a `dyn` or `regex` argument, and
|
|
9511
|
+
// any primitive or object the static form cannot spell, such as a
|
|
9512
|
+
// boolean, number or null flags argument — reaches the runtime's
|
|
9513
|
+
// JavaScript ToString, exactly the coercion the spec's RegExp
|
|
9514
|
+
// builtin performs, so an invalid flags string throws Node's
|
|
9515
|
+
// SyntaxError at construction instead of refusing the build.
|
|
9516
|
+
const stringSlot = (value) => value.type.kind === "string" ||
|
|
9517
|
+
value.type.kind === "undefinedT" ||
|
|
9518
|
+
(value.type.kind === "union" &&
|
|
9519
|
+
(lowerer.unions
|
|
9520
|
+
.get(value.type.unionId)
|
|
9521
|
+
?.arms.every((arm) => arm.kind === "string" || arm.kind === "undefinedT") ??
|
|
9522
|
+
false));
|
|
9523
|
+
if (values.some((value) => value.type.kind === "dyn" || value.type.kind === "regex" || !stringSlot(value))) {
|
|
9070
9524
|
const checked = [0, 1].map((index) => values[index]
|
|
9071
9525
|
? lowerer.coerceInto(args[index], values[index], DYN)
|
|
9072
9526
|
: dynUndefinedExpr(loc));
|
|
@@ -9078,7 +9532,9 @@ export function lowerNew(lowerer, expr) {
|
|
|
9078
9532
|
loc,
|
|
9079
9533
|
};
|
|
9080
9534
|
}
|
|
9081
|
-
|
|
9535
|
+
// Every slot reaches here as a string or a nullish cover of one: the
|
|
9536
|
+
// checked path above took every other value.
|
|
9537
|
+
const strArg = (a) => {
|
|
9082
9538
|
if (!a)
|
|
9083
9539
|
return { kind: "strLit", value: "", type: STRING, loc };
|
|
9084
9540
|
const v = values[args.indexOf(a)];
|
|
@@ -9094,19 +9550,13 @@ export function lowerNew(lowerer, expr) {
|
|
|
9094
9550
|
loc,
|
|
9095
9551
|
};
|
|
9096
9552
|
}
|
|
9097
|
-
if (v.type.kind === "union"
|
|
9098
|
-
lowerer.unions
|
|
9099
|
-
.get(v.type.unionId)
|
|
9100
|
-
?.arms.every((arm) => arm.kind === "string" || arm.kind === "undefinedT")) {
|
|
9553
|
+
if (v.type.kind === "union") {
|
|
9101
9554
|
return { kind: "nullish", left: v, right: empty, type: STRING, loc: locOf(a) };
|
|
9102
9555
|
}
|
|
9103
|
-
if (v.type.kind !== "string") {
|
|
9104
|
-
lowerer.noLowering(`new RegExp with a '${lowerer.fmt(v.type)}' ${what}`, a, "string or undefined arguments are the lowered form (a RegExp copy or ToString coercion has no lowering)");
|
|
9105
|
-
}
|
|
9106
9556
|
return v;
|
|
9107
9557
|
};
|
|
9108
|
-
const pattern = strArg(args[0]
|
|
9109
|
-
const flags = strArg(args[1]
|
|
9558
|
+
const pattern = strArg(args[0]);
|
|
9559
|
+
const flags = strArg(args[1]);
|
|
9110
9560
|
// Node accepts the 'd' flag the engine does not have; a literal
|
|
9111
9561
|
// flags string refuses here like the literal regex form.
|
|
9112
9562
|
if (flags.kind === "strLit" && args[1] !== undefined && flags.value.includes("d")) {
|
|
@@ -9234,8 +9684,9 @@ export function lowerNew(lowerer, expr) {
|
|
|
9234
9684
|
// starting at 0 (nothing buffered). A literal Buffer encoding folds
|
|
9235
9685
|
// its alias at compile time; any other encoding argument is
|
|
9236
9686
|
// normalized at run time (Node's normalizeEncoding, which throws
|
|
9237
|
-
// ERR_UNKNOWN_ENCODING for an unknown name).
|
|
9238
|
-
//
|
|
9687
|
+
// ERR_UNKNOWN_ENCODING for an unknown name). An encoding that may not
|
|
9688
|
+
// be a string takes strdec.encodingValue, which formats the error
|
|
9689
|
+
// with %s. Omitted means utf8, Node's default.
|
|
9239
9690
|
if (symbol && ts.symbolName(symbol) === "StringDecoder" && lowerer.isStdlibSymbol(symbol)) {
|
|
9240
9691
|
const args = expr.arguments?.nodes ?? [];
|
|
9241
9692
|
if (args.length > 1) {
|
|
@@ -9248,11 +9699,16 @@ export function lowerNew(lowerer, expr) {
|
|
|
9248
9699
|
: encT.isStringLiteralType()
|
|
9249
9700
|
? knownBufEncoding(encT.value)
|
|
9250
9701
|
: undefined;
|
|
9702
|
+
const textual = (type) => type.isUnionType()
|
|
9703
|
+
? ts.constituentTypes(type).every(textual)
|
|
9704
|
+
: (type.flags &
|
|
9705
|
+
(ts.TypeFlags.StringLike | ts.TypeFlags.Undefined | ts.TypeFlags.Null)) !==
|
|
9706
|
+
0;
|
|
9251
9707
|
const encoding = encName !== undefined
|
|
9252
9708
|
? { kind: "strLit", value: encName, type: STRING, loc }
|
|
9253
9709
|
: {
|
|
9254
9710
|
kind: "libCall",
|
|
9255
|
-
fn: "strdec.encoding",
|
|
9711
|
+
fn: textual(encT) ? "strdec.encoding" : "strdec.encodingValue",
|
|
9256
9712
|
args: [lowerer.lowerExprExpecting(encNode, DYN)],
|
|
9257
9713
|
type: STRING,
|
|
9258
9714
|
loc,
|
|
@@ -9357,10 +9813,10 @@ export function lowerNew(lowerer, expr) {
|
|
|
9357
9813
|
}
|
|
9358
9814
|
else if (mapped?.kind !== "map" || contextualSeed) {
|
|
9359
9815
|
const ctx = lowerer.checker.getContextualType(expr);
|
|
9360
|
-
const
|
|
9361
|
-
if (ctx &&
|
|
9816
|
+
const ctxMap = ctx ? contextualMapLayout(lowerer, ctx) : null;
|
|
9817
|
+
if (ctx && ctxMap !== null) {
|
|
9362
9818
|
tsType = ctx;
|
|
9363
|
-
mapped =
|
|
9819
|
+
mapped = ctxMap;
|
|
9364
9820
|
}
|
|
9365
9821
|
}
|
|
9366
9822
|
// `new Map(source)` the checker types `Map<any, any>` because the
|
|
@@ -9632,7 +10088,16 @@ export function lowerNew(lowerer, expr) {
|
|
|
9632
10088
|
// TextEncoder, ...) typechecks and reports SC2020 here. The named
|
|
9633
10089
|
// families carry pointed hints: each states WHY no honest static
|
|
9634
10090
|
// lowering exists (or what to use instead).
|
|
9635
|
-
|
|
10091
|
+
// `new BigInt64Array(...)` / `new BigUint64Array(...)` are exempt where
|
|
10092
|
+
// the checked-dynamic tier exists: the typed IR has no BigInt element
|
|
10093
|
+
// kind, so these construct through the typed-array constructor VALUE
|
|
10094
|
+
// (the checked-construction fallback below, whose runtime build reads and
|
|
10095
|
+
// stores BigInt elements). Static code keeps the refusal.
|
|
10096
|
+
const bigintBytesCtor = ts.isIdentifier(identifier) &&
|
|
10097
|
+
symbol != null &&
|
|
10098
|
+
BIGINT_BYTES_NAMES.has(ts.symbolName(symbol)) &&
|
|
10099
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr));
|
|
10100
|
+
if (!bigintBytesCtor && lowerer.isStdlibSymbol(symbol ?? undefined)) {
|
|
9636
10101
|
const ctorHints = {
|
|
9637
10102
|
RegExp: "use a regex literal (/pattern/flags) — constructed regexes have no lowering",
|
|
9638
10103
|
String: "boxed wrapper objects have no lowering — use the string primitive (the box is only distinguishable via typeof/identity, which nothing here can honor)",
|
|
@@ -9873,6 +10338,31 @@ export function lowerNew(lowerer, expr) {
|
|
|
9873
10338
|
}
|
|
9874
10339
|
// Checked construction supports emitted classes and builtin typed arrays.
|
|
9875
10340
|
const callee = tryLowerExpression(lowerer, expr.expression);
|
|
10341
|
+
// A callee whose VALUE is a primitive (`new (null)()`, `new (5)()`, and a
|
|
10342
|
+
// union whose arms are all primitives): JavaScript's IsConstructor step
|
|
10343
|
+
// throws Node's TypeError, which names the constructed expression. V8
|
|
10344
|
+
// evaluates the callee, then every argument, and only then checks, so the
|
|
10345
|
+
// arguments lower for their effects ahead of the throw.
|
|
10346
|
+
if (callee &&
|
|
10347
|
+
isPrimitiveValueType(callee.type) &&
|
|
10348
|
+
!isBuiltinIdentityToken(lowerer, expr.expression, callee)) {
|
|
10349
|
+
return primitiveCalleeThrow(lowerer, expr, callee, loc);
|
|
10350
|
+
}
|
|
10351
|
+
if (callee && callee.type.kind === "union") {
|
|
10352
|
+
const arms = lowerer.unions.get(callee.type.unionId)?.arms ?? [];
|
|
10353
|
+
if (arms.length > 0 && arms.every(isPrimitiveValueType)) {
|
|
10354
|
+
return primitiveCalleeThrow(lowerer, expr, callee, loc);
|
|
10355
|
+
}
|
|
10356
|
+
}
|
|
10357
|
+
// A callee the CHECKER types as a primitive that still lowers to a
|
|
10358
|
+
// dynamic slot (`const n = null`, or a property whose initializer was
|
|
10359
|
+
// null): the same Node TypeError, but the value decides at run time,
|
|
10360
|
+
// because a JavaScript property keeps its initializer's type through a
|
|
10361
|
+
// later assignment (`reg.ctor = Foo; new reg.ctor()`). A typed
|
|
10362
|
+
// construction site and an `any` callee keep the lowering they had.
|
|
10363
|
+
if (callee && callee.type.kind === "dyn" && staticallyPrimitive(lowerer, expr.expression)) {
|
|
10364
|
+
return primitiveCheckedNew(lowerer, expr, callee, loc);
|
|
10365
|
+
}
|
|
9876
10366
|
if (callee &&
|
|
9877
10367
|
(callee.type.kind === "dyn" ||
|
|
9878
10368
|
((callee.type.kind === "func" || callee.type.kind === "classval") &&
|
|
@@ -9899,6 +10389,57 @@ function lowerCheckedConstructor(lowerer, expr, callee) {
|
|
|
9899
10389
|
}
|
|
9900
10390
|
return checkedClassConstruction(lowerer, callee, args.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), loc);
|
|
9901
10391
|
}
|
|
10392
|
+
/** A checker-primitive callee whose value is a dynamic slot: the callee and
|
|
10393
|
+
* every argument evaluate, then the runtime primitive check throws Node's
|
|
10394
|
+
* "<callee> is not a constructor" — or, when the slot holds something else
|
|
10395
|
+
* after all, constructs it as a dynamic `new` always did. */
|
|
10396
|
+
function primitiveCheckedNew(lowerer, expr, callee, loc) {
|
|
10397
|
+
const message = `${constructorSpelling(expr.expression)} is not a constructor`;
|
|
10398
|
+
const args = expr.arguments?.nodes ?? [];
|
|
10399
|
+
if (args.some(ts.isSpreadElement)) {
|
|
10400
|
+
const packed = lowerer.completeArgs(args, [{ type: DYN, mode: "dynRest" }], loc, expr)[0];
|
|
10401
|
+
return primitiveCheckedConstruction(lowerer, callee, message, [], loc, packed);
|
|
10402
|
+
}
|
|
10403
|
+
return primitiveCheckedConstruction(lowerer, callee, message, args.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), loc);
|
|
10404
|
+
}
|
|
10405
|
+
/** The always-throwing construction of a provably primitive callee. */
|
|
10406
|
+
function primitiveCalleeThrow(lowerer, expr, callee, loc) {
|
|
10407
|
+
const args = expr.arguments?.nodes ?? [];
|
|
10408
|
+
const effects = [callee];
|
|
10409
|
+
if (args.some(ts.isSpreadElement)) {
|
|
10410
|
+
effects.push(lowerer.completeArgs(args, [{ type: DYN, mode: "dynRest" }], loc, expr)[0]);
|
|
10411
|
+
}
|
|
10412
|
+
else {
|
|
10413
|
+
for (const arg of args)
|
|
10414
|
+
effects.push(lowerer.lowerExpr(arg));
|
|
10415
|
+
}
|
|
10416
|
+
return throwAfterEach(effects, throwTypeError(strLit(`${constructorSpelling(expr.expression)} is not a constructor`, loc), DYN, loc), loc);
|
|
10417
|
+
}
|
|
10418
|
+
/** The constructed expression as V8 names it in "is not a constructor": its
|
|
10419
|
+
* source text, without the parentheses that only group it (`new (null)()`
|
|
10420
|
+
* reports "null is not a constructor") and with a call's argument list
|
|
10421
|
+
* abbreviated to "..." (`new (factory(null))()` reports "factory(...)",
|
|
10422
|
+
* `new (factory(o).f)()` "factory(...).f", `new o["f"]()` "o.f"). A comma
|
|
10423
|
+
* expression keeps V8's own "(a , b)" spelling. */
|
|
10424
|
+
function constructorSpelling(node) {
|
|
10425
|
+
let spelled = node;
|
|
10426
|
+
while (ts.isParenthesizedExpression(spelled))
|
|
10427
|
+
spelled = spelled.expression;
|
|
10428
|
+
if (ts.isCallExpression(spelled))
|
|
10429
|
+
return `${constructorSpelling(spelled.expression)}(...)`;
|
|
10430
|
+
if (ts.isPropertyAccessExpression(spelled)) {
|
|
10431
|
+
return `${constructorSpelling(spelled.expression)}.${spelled.name.text}`;
|
|
10432
|
+
}
|
|
10433
|
+
if (ts.isElementAccessExpression(spelled) &&
|
|
10434
|
+
ts.isStringLiteralLike(spelled.argumentExpression) &&
|
|
10435
|
+
/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(spelled.argumentExpression.text)) {
|
|
10436
|
+
return `${constructorSpelling(spelled.expression)}.${spelled.argumentExpression.text}`;
|
|
10437
|
+
}
|
|
10438
|
+
if (ts.isBinaryExpression(spelled) && spelled.operatorToken.kind === ts.SyntaxKind.CommaToken) {
|
|
10439
|
+
return `(${constructorSpelling(spelled.left)} , ${constructorSpelling(spelled.right)})`;
|
|
10440
|
+
}
|
|
10441
|
+
return spelled.getText();
|
|
10442
|
+
}
|
|
9902
10443
|
/** A getter/setter invocation over an accessor target's receiver — the
|
|
9903
10444
|
* same whole-program devirtualization as method calls: a virtualCall
|
|
9904
10445
|
* when some strict subclass of the receiver's static class overrides
|