@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,13 +1,20 @@
|
|
|
1
|
+
import { lowerIteratorMemberValue } from "../iterator-prototype.js";
|
|
1
2
|
import { widensReducedRecords } from "../function-returns.js";
|
|
3
|
+
import { nullishReadTypeError, throwAfterEach } from "../primitive-throws.js";
|
|
4
|
+
import { lowerStaticPrivateRead } from "../private-statics.js";
|
|
2
5
|
import { widthNarrowHelper } from "../coercions/unions.js";
|
|
3
6
|
/* Property reads (`a.b`): lowerExprInner's property-access branch, intrinsic and union properties, field reads and targets, and match-group reads. */
|
|
4
7
|
import { jsSpecialGlobalValue } from "../global-values.js";
|
|
8
|
+
import { HOST_GLOBAL_PROTOTYPE_MEMBERS, HOST_GLOBAL_VALUE_MEMBERS, hostGlobalCallTarget, hostGlobalNameOfMember, hostGlobalNameOfRead, hostGlobalPrototypeOf, } from "../host-globals.js";
|
|
9
|
+
import { hostGlobalValue } from "../host-global-values.js";
|
|
10
|
+
import { globalFunctionValue } from "../global-function-values.js";
|
|
5
11
|
import { arrayClassMemberOwner, arrayClassReceiver, lowerArrayClassConstructorRead, } from "../builtins/array-classes.js";
|
|
6
12
|
import { indexedUnionArms, lowerIndexedUnionMember } from "../indexed-unions.js";
|
|
7
13
|
import { keyedHelperName } from "../stable-names.js";
|
|
8
14
|
import { builtinNamespaceValue } from "../builtin-namespaces.js";
|
|
9
15
|
import { staticallySelected } from "../static-typeof.js";
|
|
10
16
|
import { lowerWebStreamClassRead } from "../builtins/web-streams-dyn.js";
|
|
17
|
+
import { wrapperConstructors } from "../primitive-wrappers.js";
|
|
11
18
|
import * as ts from "../../ts7/adapter.js";
|
|
12
19
|
import { lowerHistogramProperty } from "../builtins/performance.js";
|
|
13
20
|
import { staticFunctionNameRead } from "../static-function-names.js";
|
|
@@ -17,7 +24,7 @@ import { isThisParameter } from "../call-signatures.js";
|
|
|
17
24
|
import { argumentCountSlot, contextualCallCount, usedAsValue } from "../argument-counts.js";
|
|
18
25
|
import { checkedPrivateValue, localPrivateBrandClass, privateNameClass, } from "../private-brands.js";
|
|
19
26
|
import { PoisonError, builtinValueNameOf, jsFuncNameOf, neverTaintedJsType, own, } from "../lowerer.js";
|
|
20
|
-
import { ARRAY_METHODS, MAP_METHODS, NARROW_FIRST,
|
|
27
|
+
import { ARRAY_METHODS, MAP_METHODS, NARROW_FIRST, SET_METHODS, STDLIB_SURFACE, STRING_INDEX_METHODS, STR_METHODS, isChildSurfaceMember, stdlibGlobalNameOf, } from "../surfaces.js";
|
|
21
28
|
import { isGenericCallableMemberType, isLegacyUrlSymbol, isOsConstantsType, isParseArgsDynTypeName, } from "../../type-mapper.js";
|
|
22
29
|
import { BIGINT_T, BOOL, BYTES_U8, DYN, F64, NULL_T, SEARCH_PARAMS_T, STRING, SYMBOL_T, UNDEFINED_T, arrayOf, canBoxFuncIntoDyn, funcOf, isDynTypedRefType, isUnitType, typeEquals, typeKey, unionContainerArmsOk, BYTES_ELEMENT_SIZE, } from "../../../ir/ir.js";
|
|
23
30
|
import { lowerNavigatorMember, navigatorValue } from "../builtins/navigator.js";
|
|
@@ -40,10 +47,11 @@ import { hasOptionalChainGuard, isOptionalChainTail, isRequireMainFilename, } fr
|
|
|
40
47
|
import { isCjsModuleGlobal, lowerNodeModuleProperty, lowerRequireMainProperty, } from "../lower-node-module.js";
|
|
41
48
|
import { dynUndefinedExpr, nodeThrowExpr, numLit, strLit, varRef } from "../../../ir/build.js";
|
|
42
49
|
import { typedArrayLacksMember } from "../builtins/typed-array-members.js";
|
|
43
|
-
import { TEMPORAL_GLOBAL } from "../../builtin-modules.js";
|
|
50
|
+
import { COMMONJS_MODULE_BINDINGS, TEMPORAL_GLOBAL } from "../../builtin-modules.js";
|
|
44
51
|
import { tryLowerExpression } from "./try-lower-expression.js";
|
|
45
52
|
import { applyDeferredAssertion, assertedReceiverNode, deferredMemberReadTarget, deferredProbeReadAccess, } from "./asserted-receiver.js";
|
|
46
53
|
import { lowerRecordInheritedMember } from "../record-inherited.js";
|
|
54
|
+
import { MUTABLE_BUFFER_MEMBERS } from "../buffers.js";
|
|
47
55
|
import { DATE_METHOD_HINT } from "../builtins/dates.js";
|
|
48
56
|
import { cjsClassExprWholeExportOf, cjsExportAssignmentOf, cjsExportDiscardReason, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isModuleExportsAccess, isNodeEsmFile, locOf, } from "../../program.js";
|
|
49
57
|
import { ambientNsRootOf, ambientUndefReadType, ambientUndefVarRootOf, contextualUndefReadType, fenceEarlyNsMemberRef, nsMemberIdentOf, nsUndefRead, } from "../lower-namespaces.js";
|
|
@@ -63,9 +71,9 @@ import { npmStaticPackageOfPath } from "../../npm-static.js";
|
|
|
63
71
|
import { importMetaField, isImportMeta } from "../import-meta.js";
|
|
64
72
|
import { createRequireCalleeFileOf } from "../builtins/module-bindings.js";
|
|
65
73
|
import { createRequireResolveFenceValue, createRequireResolveValue, } from "../builtins/module-resolution.js";
|
|
66
|
-
import { builtinPrototypeMethod,
|
|
67
|
-
import {
|
|
68
|
-
import { lowerBufferPrototypeMember } from "../containers/bytes.js";
|
|
74
|
+
import { builtinPrototypeMethod, lowerCheckedPredicateValue } from "../lower-builtin-values.js";
|
|
75
|
+
import { constructorStaticValue, objectFreezeValue } from "../builtin-statics.js";
|
|
76
|
+
import { lowerBufferPrototypeMember, lowerBufferPrototypeObject } from "../containers/bytes.js";
|
|
69
77
|
import { lowerNetAddressStaticRead } from "../builtins/net-address.js";
|
|
70
78
|
import { STATS_TYPE_TESTS } from "../builtins/filesystem.js";
|
|
71
79
|
import { arrayValueRead, arrayValueType } from "../array-values.js";
|
|
@@ -74,13 +82,15 @@ import { reflectMemberValue } from "../builtins/reflection.js";
|
|
|
74
82
|
import { objLitGenericFnInfoOf, objLitGenericFnNodeOf, requireObjLitGenericReceiver, } from "../generic-functions.js";
|
|
75
83
|
import { narrowStoredClassValue, structuralReadType } from "../class-unions.js";
|
|
76
84
|
import { InternalCompilerError } from "../../../errors.js";
|
|
77
|
-
import { lowerUnionFieldRead } from "./union-fields.js";
|
|
85
|
+
import { lowerUnionFieldRead, narrowedArmRead, narrowedUnionView } from "./union-fields.js";
|
|
78
86
|
import { errorPropertyRead } from "../error-methods.js";
|
|
79
87
|
import { isSafeToDiscard, isSafeToRepeat } from "./evaluation-safety.js";
|
|
88
|
+
import { partialAssertionFields, partialFieldRead } from "../partial-assertions.js";
|
|
80
89
|
import { isZlibStreamMember, lowerZlibStreamBytesWritten } from "../builtins/compression.js";
|
|
81
90
|
import { isWebCryptoReceiver } from "../builtins/crypto.js";
|
|
82
91
|
import { isFsStreamMember, lowerFsStreamProperty } from "../builtins/fs-streams.js";
|
|
83
92
|
import { keyedFieldRead } from "./keyed-field-targets.js";
|
|
93
|
+
import { heldEnvValueType } from "../builtins/environment.js";
|
|
84
94
|
import { promisePrototypeValue } from "../thenables.js";
|
|
85
95
|
import { lowerChildPropertyRead } from "../handle-properties.js";
|
|
86
96
|
/** True when a property access names an ABSTRACT property declaration
|
|
@@ -156,6 +166,26 @@ function isStatFsDynProperty(lowerer, expr) {
|
|
|
156
166
|
return false;
|
|
157
167
|
}));
|
|
158
168
|
}
|
|
169
|
+
/** The Iterator.prototype helpers and the iterator members with no typed
|
|
170
|
+
* value lowering, read as values on a typed iterator in JavaScript.
|
|
171
|
+
* `next` and `return` answer the function Node's prototype chain holds
|
|
172
|
+
* (a generator's, or an iterator helper object's); `throw` is not here
|
|
173
|
+
* because an iterator helper object has none. */
|
|
174
|
+
const TYPED_ITERATOR_MEMBER_VALUES = new Set([
|
|
175
|
+
"next",
|
|
176
|
+
"map",
|
|
177
|
+
"filter",
|
|
178
|
+
"take",
|
|
179
|
+
"drop",
|
|
180
|
+
"flatMap",
|
|
181
|
+
"reduce",
|
|
182
|
+
"toArray",
|
|
183
|
+
"forEach",
|
|
184
|
+
"some",
|
|
185
|
+
"every",
|
|
186
|
+
"find",
|
|
187
|
+
"return",
|
|
188
|
+
]);
|
|
159
189
|
/** The dgram.Socket methods its checked-dynamic handle answers as
|
|
160
190
|
* function values (scr_dgram.c's scr_dgram_dyn_method_names). */
|
|
161
191
|
const DGRAM_METHOD_VALUES = new Set([
|
|
@@ -174,6 +204,22 @@ const DGRAM_METHOD_VALUES = new Set([
|
|
|
174
204
|
"ref",
|
|
175
205
|
"unref",
|
|
176
206
|
]);
|
|
207
|
+
/** A lib builtin iterator whose prototype chain holds no `return` in Node
|
|
208
|
+
* 24: the Array, String, Map and Set iterators. Generators and iterator
|
|
209
|
+
* helper objects do have one. */
|
|
210
|
+
function builtinIteratorWithoutReturn(lowerer, node) {
|
|
211
|
+
const symbol = lowerer.typeOf(node).getSymbol();
|
|
212
|
+
if (symbol === undefined)
|
|
213
|
+
return false;
|
|
214
|
+
const name = ts.symbolName(symbol);
|
|
215
|
+
if (name !== "ArrayIterator" &&
|
|
216
|
+
name !== "StringIterator" &&
|
|
217
|
+
name !== "MapIterator" &&
|
|
218
|
+
name !== "SetIterator")
|
|
219
|
+
return false;
|
|
220
|
+
return (symbol.declarations.length > 0 &&
|
|
221
|
+
symbol.declarations.every((d) => lowerer.isStdlibFile(ts.getSourceFileOfNode(d))));
|
|
222
|
+
}
|
|
177
223
|
function isCreateRequireResolveValue(lowerer, expr) {
|
|
178
224
|
let resolve = expr;
|
|
179
225
|
if (expr.name.text === "paths" &&
|
|
@@ -186,9 +232,21 @@ function isCreateRequireResolveValue(lowerer, expr) {
|
|
|
186
232
|
createRequireCalleeFileOf(lowerer, resolve.expression) !== null);
|
|
187
233
|
}
|
|
188
234
|
export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
235
|
+
// A JavaScript source reading a member that resizes, grows or detaches a
|
|
236
|
+
// buffer is the mutableBuffers fact (buffers.ts, t262-dc §2.4). The name
|
|
237
|
+
// decides: the receiver may be a checked-dynamic value.
|
|
238
|
+
if (MUTABLE_BUFFER_MEMBERS.has(expr.name.text) && isJsSourceFile(ts.getSourceFileOfNode(expr)))
|
|
239
|
+
lowerer.buffersMutable = true;
|
|
189
240
|
const arrayClassConstructor = lowerArrayClassConstructorRead(lowerer, expr, loc);
|
|
190
241
|
if (arrayClassConstructor !== null)
|
|
191
242
|
return arrayClassConstructor;
|
|
243
|
+
// `R.#x` for a static private on a checked-dynamic receiver: the brand
|
|
244
|
+
// check, then the native storage (private-statics.ts).
|
|
245
|
+
{
|
|
246
|
+
const staticPrivate = lowerStaticPrivateRead(lowerer, expr, loc);
|
|
247
|
+
if (staticPrivate)
|
|
248
|
+
return staticPrivate;
|
|
249
|
+
}
|
|
192
250
|
// `value.#x` on a checked-dynamic value, or on a checked extraction of
|
|
193
251
|
// one: the field of the brand-checked receiver (checkedPrivateValue).
|
|
194
252
|
if (ts.isPrivateIdentifier(expr.name)) {
|
|
@@ -223,7 +281,7 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
223
281
|
};
|
|
224
282
|
}
|
|
225
283
|
{
|
|
226
|
-
const member = lowerBufferPrototypeMember(lowerer, expr);
|
|
284
|
+
const member = lowerBufferPrototypeMember(lowerer, expr) ?? lowerBufferPrototypeObject(lowerer, expr);
|
|
227
285
|
if (member)
|
|
228
286
|
return member;
|
|
229
287
|
}
|
|
@@ -420,33 +478,8 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
420
478
|
loc,
|
|
421
479
|
};
|
|
422
480
|
}
|
|
423
|
-
if (lowerer.stdlibGlobalMember(expr, "Object") === "freeze")
|
|
424
|
-
|
|
425
|
-
lowerer.untypedIntegrity = true;
|
|
426
|
-
const name = "%builtin.Object.freeze";
|
|
427
|
-
if (!lowerer.liftedFns.some((fn) => fn.name === name))
|
|
428
|
-
lowerer.liftedFns.push({
|
|
429
|
-
name,
|
|
430
|
-
params: [{ localId: "value", name: "value", type: DYN }],
|
|
431
|
-
locals: [{ id: "value", name: "value", type: DYN, mutable: false }],
|
|
432
|
-
returnType: DYN,
|
|
433
|
-
body: [
|
|
434
|
-
{
|
|
435
|
-
kind: "return",
|
|
436
|
-
value: {
|
|
437
|
-
kind: "libCall",
|
|
438
|
-
fn: "dyn.freeze",
|
|
439
|
-
args: [varRef("value", DYN, loc)],
|
|
440
|
-
type: DYN,
|
|
441
|
-
loc,
|
|
442
|
-
},
|
|
443
|
-
loc,
|
|
444
|
-
},
|
|
445
|
-
],
|
|
446
|
-
loc,
|
|
447
|
-
});
|
|
448
|
-
return { kind: "closure", fnName: name, captures: [], type: funcOf([DYN], DYN), loc };
|
|
449
|
-
}
|
|
481
|
+
if (lowerer.stdlibGlobalMember(expr, "Object") === "freeze")
|
|
482
|
+
return objectFreezeValue(lowerer, loc);
|
|
450
483
|
// An Hmac has no copy() (Hash does): Node answers undefined, which
|
|
451
484
|
// `typeof mac.copy` feature checks read. TypeScript rejects the read.
|
|
452
485
|
if (expr.name.text === "copy" &&
|
|
@@ -477,6 +510,38 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
477
510
|
loc,
|
|
478
511
|
};
|
|
479
512
|
}
|
|
513
|
+
// A read of a Node 24 global the native runtime does not implement
|
|
514
|
+
// (globalThis.WebSocket, (globalThis as T).FormData, alias.X) is not a
|
|
515
|
+
// capability probe: the branch below would answer undefined, where Node
|
|
516
|
+
// has the constructor. Answer the constructor (host-global-values.ts);
|
|
517
|
+
// constructing or calling it is the use that refuses (SC2020,
|
|
518
|
+
// host-global).
|
|
519
|
+
{
|
|
520
|
+
const hostGlobal = hostGlobalNameOfMember(lowerer, expr);
|
|
521
|
+
if (hostGlobal !== null) {
|
|
522
|
+
if (hostGlobalCallTarget(expr))
|
|
523
|
+
lowerer.hostGlobalFence(hostGlobal, expr);
|
|
524
|
+
return hostGlobalValue(lowerer, hostGlobal, expr);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
// A member read off that value (`WebSocket.OPEN`, `FormData.prototype`):
|
|
528
|
+
// the value carries the function intrinsics only, and its prototype
|
|
529
|
+
// carries the constructor link (`FormData.prototype.constructor`). Node's
|
|
530
|
+
// class also has static members and instance methods, which native code
|
|
531
|
+
// does not provide, so reading one is a use of that surface and refuses
|
|
532
|
+
// (SC2020, host-global) instead of answering undefined.
|
|
533
|
+
{
|
|
534
|
+
const hostGlobal = hostGlobalNameOfRead(lowerer, expr.expression);
|
|
535
|
+
if (hostGlobal !== null) {
|
|
536
|
+
if (!HOST_GLOBAL_VALUE_MEMBERS.has(expr.name.text))
|
|
537
|
+
lowerer.hostGlobalFence(hostGlobal, expr);
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
const prototypeOf = hostGlobalPrototypeOf(lowerer, expr.expression);
|
|
541
|
+
if (prototypeOf !== null && !HOST_GLOBAL_PROTOTYPE_MEMBERS.has(expr.name.text))
|
|
542
|
+
lowerer.hostGlobalFence(prototypeOf, expr);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
480
545
|
// Missing host globals (Bun/Deno capability probes) have no binding
|
|
481
546
|
// in a native program. Declared globals retain their own lowering;
|
|
482
547
|
// arbitrary global-object mutation remains fenced. Preserve a dyn
|
|
@@ -552,7 +617,9 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
552
617
|
};
|
|
553
618
|
}
|
|
554
619
|
}
|
|
555
|
-
|
|
620
|
+
// `re.exec(s)?.index` takes the same read: the chain lowering binds the
|
|
621
|
+
// guarded receiver (non-nullish inside the guard) before re-dispatching.
|
|
622
|
+
if (expr.name.text === "index" || expr.name.text === "input") {
|
|
556
623
|
const represented = tryLowerExpression(lowerer, expr.expression);
|
|
557
624
|
if (represented &&
|
|
558
625
|
isMatchSliceType(lowerer, represented.type) &&
|
|
@@ -760,6 +827,26 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
760
827
|
if (promiseMember)
|
|
761
828
|
return promiseMember;
|
|
762
829
|
}
|
|
830
|
+
// A weak collection's method read as a VALUE in a JavaScript source
|
|
831
|
+
// (`wm.has.call(x, k)` — the WeakMap/WeakSet brand-check tests): the
|
|
832
|
+
// runtime's interned prototype function, which applies the method to its
|
|
833
|
+
// own receiver and throws Node's TypeError for a foreign one. A direct
|
|
834
|
+
// call keeps the instance fast path (`dynKeyGet` dispatches to the
|
|
835
|
+
// handle), and an optional read keeps the fence.
|
|
836
|
+
if (!expr.questionDotToken &&
|
|
837
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr)) &&
|
|
838
|
+
!isCalleeOf(expr) &&
|
|
839
|
+
// `WeakMap.prototype.has` is the prototype table's own read: it never
|
|
840
|
+
// lowers the prototype object (a value read of `WeakMap.prototype`
|
|
841
|
+
// is a fence), so leave that spelling there.
|
|
842
|
+
!(ts.isPropertyAccessExpression(expr.expression) &&
|
|
843
|
+
expr.expression.name.text === "prototype" &&
|
|
844
|
+
stdlibGlobalNameOf(lowerer, expr.expression.expression) !== null)) {
|
|
845
|
+
const weak = lowerer.weakCollectionNamesOf(lowerer.typeOf(expr.expression));
|
|
846
|
+
if (weak !== null &&
|
|
847
|
+
weak.names.some((prototype) => WEAK_COLLECTION_METHOD_NAMES[prototype].has(expr.name.text)))
|
|
848
|
+
return weakCollectionMethodValue(lowerer, expr, weak.names, weak.nullable, expr.name.text);
|
|
849
|
+
}
|
|
763
850
|
const handled = lowerer.lowerProcessEnvGet(expr) ??
|
|
764
851
|
lowerer.lowerServerProperty(expr) ??
|
|
765
852
|
// diagnostics_channel Channel receivers — name/hasSubscribers
|
|
@@ -842,8 +929,9 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
842
929
|
if (canonical !== null) {
|
|
843
930
|
if (canonical === "globalThis")
|
|
844
931
|
return lowerGlobalValue(lowerer, expr);
|
|
845
|
-
// Typed for the programs that name it, absent in Node 24
|
|
846
|
-
|
|
932
|
+
// Typed for the programs that name it, absent in Node 24, and the
|
|
933
|
+
// CommonJS module bindings, which the global object does not hold.
|
|
934
|
+
if (canonical === TEMPORAL_GLOBAL || COMMONJS_MODULE_BINDINGS.has(canonical))
|
|
847
935
|
return dynUndefinedExpr(loc);
|
|
848
936
|
const value = jsSpecialGlobalValue(lowerer, canonical, loc);
|
|
849
937
|
if (value)
|
|
@@ -1005,14 +1093,19 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
1005
1093
|
// by the property or function it reads. A builtin function value
|
|
1006
1094
|
// keeps its length when that is not its adapter's parameter count
|
|
1007
1095
|
// (`Math.max.length` is 2).
|
|
1008
|
-
const
|
|
1009
|
-
const
|
|
1096
|
+
const builtinName = builtinValueNameOf(expr.expression, lowerer);
|
|
1097
|
+
const fnName = builtinName ?? jsFuncNameOf(expr.expression, lowerer);
|
|
1098
|
+
const identity = lowerer.builtinFunctionIdentity(probed);
|
|
1099
|
+
const fnLength = identity.fnLength;
|
|
1010
1100
|
const boxed = {
|
|
1011
1101
|
kind: "dynFrom",
|
|
1012
1102
|
value: probed,
|
|
1013
1103
|
type: DYN,
|
|
1014
1104
|
...(fnName !== null ? { fnName } : {}),
|
|
1015
1105
|
...(fnLength !== undefined ? { fnLength } : {}),
|
|
1106
|
+
...(builtinName !== null && identity.fnNameMainThreadOnly
|
|
1107
|
+
? { fnNameMainThreadOnly: true }
|
|
1108
|
+
: {}),
|
|
1016
1109
|
loc,
|
|
1017
1110
|
};
|
|
1018
1111
|
const key = {
|
|
@@ -1097,7 +1190,13 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
1097
1190
|
isStatFsDynProperty(lowerer, expr) ||
|
|
1098
1191
|
segmentDataProperty ||
|
|
1099
1192
|
osConstants ||
|
|
1100
|
-
|
|
1193
|
+
// A record, not the Lowerer itself: the compiler lowers its own source,
|
|
1194
|
+
// and a class instance does not width-coerce to this shape.
|
|
1195
|
+
isLegacyUrlSymbol(lowerer.checker.getSymbolAtLocation(expr.name), {
|
|
1196
|
+
isStdlibFile: (sf) => lowerer.isStdlibFile(sf),
|
|
1197
|
+
symbolProvenance: lowerer.symbolProvenance,
|
|
1198
|
+
verifySymbolProvenance: lowerer.verifySymbolProvenance,
|
|
1199
|
+
})) {
|
|
1101
1200
|
const recv = lowerer.lowerExpr(expr.expression);
|
|
1102
1201
|
if (recv.type.kind === "dyn") {
|
|
1103
1202
|
const key = {
|
|
@@ -1363,6 +1462,20 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
1363
1462
|
const asserted = assertedMemberRead(lowerer, expr.expression, expr.name.text, recvLowered, loc);
|
|
1364
1463
|
if (asserted)
|
|
1365
1464
|
return asserted;
|
|
1465
|
+
// Lowering erases flow narrowing, so a checker-NARROWED receiver keeps
|
|
1466
|
+
// the wider union it stores (`stored?.type` after the earlier arm
|
|
1467
|
+
// returned, `(entry as { role: string }).role`): the checker's type
|
|
1468
|
+
// names one record while the value still carries its siblings. Read the
|
|
1469
|
+
// member off whichever arm the value holds — an arm that does not
|
|
1470
|
+
// declare it answers undefined, exactly Node's get — and narrow the
|
|
1471
|
+
// answer to the checker's type, which traps on an arm the checker's
|
|
1472
|
+
// narrowing ruled out (types do not lie). Reaching this point means no
|
|
1473
|
+
// lowering above claimed the read, so only refusals gain a lowering.
|
|
1474
|
+
if (recvLowered.type.kind === "union") {
|
|
1475
|
+
const read = lowerUnionValueRead(lowerer, expr, recvLowered, true);
|
|
1476
|
+
if (read)
|
|
1477
|
+
return lowerer.maybeNarrow(read, expr);
|
|
1478
|
+
}
|
|
1366
1479
|
// A checker-`any` receiver whose value is a FRESH typed result of an
|
|
1367
1480
|
// earlier step in the chain (`out.split(" ").length`, where split
|
|
1368
1481
|
// extracted the string and answered a native string[]): the member read
|
|
@@ -1397,6 +1510,22 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
1397
1510
|
typedArrayLacksMember(expr.name.text, recvLowered.type.elem === "u8")) {
|
|
1398
1511
|
return afterReceiver(recvLowered, dynUndefinedExpr(loc), loc);
|
|
1399
1512
|
}
|
|
1513
|
+
// Buffer.prototype's parent and offset getters, which @types/node does not
|
|
1514
|
+
// declare (so only JavaScript reads them): the box answers a Buffer's
|
|
1515
|
+
// ArrayBuffer and byteOffset, and undefined for a Uint8Array, by the
|
|
1516
|
+
// runtime flag that tells the two apart.
|
|
1517
|
+
if (recvLowered.type.kind === "bytes" &&
|
|
1518
|
+
recvLowered.type.elem === "u8" &&
|
|
1519
|
+
(expr.name.text === "parent" || expr.name.text === "offset") &&
|
|
1520
|
+
!declaredMemberOf(lowerer, expr.expression, expr.name.text)) {
|
|
1521
|
+
return {
|
|
1522
|
+
kind: "dynKeyGet",
|
|
1523
|
+
value: lowerer.coerceToExpected(recvLowered, DYN),
|
|
1524
|
+
key: { kind: "strLit", value: expr.name.text, type: STRING, loc },
|
|
1525
|
+
type: DYN,
|
|
1526
|
+
loc,
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1400
1529
|
// A typed array under a checker `any` (a JS binding its own initializer's
|
|
1401
1530
|
// inference refers to: hono's etag digest `nextChunk`) reads through its
|
|
1402
1531
|
// box, as the method-call twin dispatches. The box shares the native
|
|
@@ -1411,6 +1540,25 @@ export function lowerPropertyAccessExpr(lowerer, expr, loc) {
|
|
|
1411
1540
|
loc,
|
|
1412
1541
|
}, expr);
|
|
1413
1542
|
}
|
|
1543
|
+
// A NULLISH receiver: JavaScript's RequireObjectCoercible throws Node's
|
|
1544
|
+
// TypeError at the read (only an optional chain, lowered elsewhere,
|
|
1545
|
+
// answers undefined). A primitive receiver that is not nullish never
|
|
1546
|
+
// reaches this fence — its members lower above.
|
|
1547
|
+
if (isUnitType(recvLowered.type)) {
|
|
1548
|
+
const unit = recvLowered.type.kind === "nullT" ? "null" : "undefined";
|
|
1549
|
+
const t = ambientUndefReadType(lowerer, expr) ?? contextualUndefReadType(lowerer, expr) ?? F64;
|
|
1550
|
+
return throwAfterEach([recvLowered], nullishReadTypeError(unit, expr.name.text, t, loc), loc);
|
|
1551
|
+
}
|
|
1552
|
+
// The site is about to be refused: a checker-narrowed receiver still
|
|
1553
|
+
// stores the wider union, whose other arms may be what refuse the member
|
|
1554
|
+
// (the OAuth arm's index signature beside `ApiKeyCredential.key`). Read
|
|
1555
|
+
// it off the arms the checker still allows, exactly where the refusal
|
|
1556
|
+
// would be.
|
|
1557
|
+
if (recvLowered.type.kind === "union") {
|
|
1558
|
+
const read = narrowedUnionValueRead(lowerer, expr, recvLowered);
|
|
1559
|
+
if (read)
|
|
1560
|
+
return read;
|
|
1561
|
+
}
|
|
1414
1562
|
lowerer.unsupported("SC1090", expr, `reading '${expr.name.text}' from a value of type '${lowerer.checker.typeToString(lowerer.typeOf(expr.expression))}'`);
|
|
1415
1563
|
}
|
|
1416
1564
|
/** `result` after evaluating `receiver` for its effects (none to keep when
|
|
@@ -1602,9 +1750,165 @@ function mergeReadTypes(lowerer, types) {
|
|
|
1602
1750
|
function importMetaProperty(lowerer, expr) {
|
|
1603
1751
|
return isImportMeta(expr.expression) ? importMetaField(lowerer, expr, expr.name.text) : null;
|
|
1604
1752
|
}
|
|
1753
|
+
const DATE_PROTOTYPE_WRITE_MESSAGE = "writing through a standard library prototype (`Date.prototype` is a value for reads; a Date never observes a write to it)";
|
|
1754
|
+
/** How many member steps separate `node` from `Date.prototype` in the read
|
|
1755
|
+
* chain `node` is part of: 0 for `Date.prototype` itself, 1 for a member, 2
|
|
1756
|
+
* for a property read on a member (the interned function object). Null when
|
|
1757
|
+
* the chain is not rooted at `Date.prototype`. */
|
|
1758
|
+
function datePrototypeDepth(lowerer, node) {
|
|
1759
|
+
let depth = 0;
|
|
1760
|
+
let cur = node;
|
|
1761
|
+
for (;;) {
|
|
1762
|
+
if (ts.isPropertyAccessExpression(cur) &&
|
|
1763
|
+
lowerer.stdlibGlobalMember(cur, "Date") === "prototype")
|
|
1764
|
+
return depth;
|
|
1765
|
+
if (ts.isPropertyAccessExpression(cur) || ts.isElementAccessExpression(cur)) {
|
|
1766
|
+
cur = cur.expression;
|
|
1767
|
+
depth++;
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
return null;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
/** The prototype object and its members are a read surface: a write that
|
|
1774
|
+
* replaces a member, or a key of the prototype itself, keeps the SC1090
|
|
1775
|
+
* refusal it reached before the prototype had a value, because a typed Date
|
|
1776
|
+
* never observes it and the write would silently differ from Node. A property
|
|
1777
|
+
* OF a member (the interned function object, `Date.prototype.getTime.length
|
|
1778
|
+
* = 1`) writes the function the dynamic tier shares with Node, which matches,
|
|
1779
|
+
* so it stays open. True when `node` is the target of such a write
|
|
1780
|
+
* (assignment, compound assignment, `delete`, `++`/`--`), directly or as the
|
|
1781
|
+
* base of the target's member chain. */
|
|
1782
|
+
export function isDatePrototypeWrite(lowerer, node) {
|
|
1783
|
+
const depth = datePrototypeDepth(lowerer, node);
|
|
1784
|
+
if (depth === null)
|
|
1785
|
+
return false;
|
|
1786
|
+
let steps = 0;
|
|
1787
|
+
let cur = node;
|
|
1788
|
+
for (;;) {
|
|
1789
|
+
while (ts.isParenthesizedExpression(cur.parent))
|
|
1790
|
+
cur = cur.parent;
|
|
1791
|
+
const parent = cur.parent;
|
|
1792
|
+
if (!parent)
|
|
1793
|
+
return false;
|
|
1794
|
+
if ((ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) &&
|
|
1795
|
+
parent.expression === cur) {
|
|
1796
|
+
cur = parent;
|
|
1797
|
+
steps++;
|
|
1798
|
+
continue;
|
|
1799
|
+
}
|
|
1800
|
+
const written = (ts.isBinaryExpression(parent) &&
|
|
1801
|
+
parent.left === cur &&
|
|
1802
|
+
(parent.operatorToken.kind === ts.SyntaxKind.EqualsToken ||
|
|
1803
|
+
(parent.operatorToken.kind >= ts.SyntaxKind.FirstCompoundAssignment &&
|
|
1804
|
+
parent.operatorToken.kind <= ts.SyntaxKind.LastCompoundAssignment))) ||
|
|
1805
|
+
ts.isDeleteExpression(parent) ||
|
|
1806
|
+
// `++`/`--` write their operand; the other prefix unary forms (`!`,
|
|
1807
|
+
// `typeof`, `void`, `+`, `-`, `~`) only read it.
|
|
1808
|
+
((ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) &&
|
|
1809
|
+
(parent.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
1810
|
+
parent.operator === ts.SyntaxKind.MinusMinusToken));
|
|
1811
|
+
return written && depth + steps <= 1;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
/** The fence for a write found while lowering a property access (see
|
|
1815
|
+
* isDatePrototypeWrite). The cheap syntactic pre-test keeps every other
|
|
1816
|
+
* property access down to one identifier comparison: only a chain rooted at
|
|
1817
|
+
* the `Date` global can name the prototype, and the write path reaches this
|
|
1818
|
+
* before chainBlocked's early return. */
|
|
1819
|
+
export function fenceDatePrototypeWrite(lowerer, expr) {
|
|
1820
|
+
let root = expr;
|
|
1821
|
+
while (ts.isPropertyAccessExpression(root) || ts.isElementAccessExpression(root))
|
|
1822
|
+
root = root.expression;
|
|
1823
|
+
while (ts.isParenthesizedExpression(root))
|
|
1824
|
+
root = root.expression;
|
|
1825
|
+
if (!ts.isIdentifier(root) || root.text !== "Date")
|
|
1826
|
+
return;
|
|
1827
|
+
if (isDatePrototypeWrite(lowerer, expr))
|
|
1828
|
+
lowerer.unsupported("SC1090", expr, DATE_PROTOTYPE_WRITE_MESSAGE);
|
|
1829
|
+
}
|
|
1830
|
+
/** The same fence for a call-shaped write (`Object.defineProperty`,
|
|
1831
|
+
* `Object.assign`) whose target argument is `Date.prototype` or one of its
|
|
1832
|
+
* members. */
|
|
1833
|
+
export function fenceDatePrototypeWriteCall(lowerer, node) {
|
|
1834
|
+
const depth = datePrototypeDepth(lowerer, node);
|
|
1835
|
+
if (depth !== null && depth <= 1)
|
|
1836
|
+
lowerer.unsupported("SC1090", node, DATE_PROTOTYPE_WRITE_MESSAGE);
|
|
1837
|
+
}
|
|
1605
1838
|
/** The TypeError of a deferred-init field read that finds the field
|
|
1606
1839
|
* unassigned where its declared type cannot hold undefined. */
|
|
1607
1840
|
export const DEFERRED_READ_MESSAGE = "undefined is not representable in the target union (a value narrowed or asserted past it still held it)";
|
|
1841
|
+
/** A collection method read as a VALUE (`s.add`, `m.has` — the `f.call(x)`
|
|
1842
|
+
* tests and callback plumbing): the runtime's interned prototype function
|
|
1843
|
+
* for that name, which applies the method to its own receiver and throws
|
|
1844
|
+
* Node's brand-check TypeError when that receiver is not a collection of
|
|
1845
|
+
* the right kind. Only JavaScript sources take this path: a typed source
|
|
1846
|
+
* keeps its refusal (the checker's Set/Map signature has no value form).
|
|
1847
|
+
* The receiver expression still runs for its effects, and a receiver the
|
|
1848
|
+
* checker typed with an undefined arm (an out-of-bounds element of a
|
|
1849
|
+
* `Set[]`, `xs[1].has`) throws Node's TypeError at the read itself: the
|
|
1850
|
+
* member access on a nullish receiver fails before any method exists. */
|
|
1851
|
+
function dynCollectionMethodValue(lowerer, expr, prototype, name) {
|
|
1852
|
+
const loc = locOf(expr);
|
|
1853
|
+
const method = {
|
|
1854
|
+
kind: "libCall",
|
|
1855
|
+
fn: "dyn.builtinMethod",
|
|
1856
|
+
args: [
|
|
1857
|
+
{ kind: "strLit", value: prototype, type: STRING, loc },
|
|
1858
|
+
{ kind: "strLit", value: name, type: STRING, loc: locOf(expr.name) },
|
|
1859
|
+
],
|
|
1860
|
+
type: DYN,
|
|
1861
|
+
loc,
|
|
1862
|
+
};
|
|
1863
|
+
const receiver = lowerer.lowerExpr(expr.expression);
|
|
1864
|
+
const unionType = receiver.type.kind === "union" ? receiver.type : null;
|
|
1865
|
+
const units = [];
|
|
1866
|
+
if (unionType) {
|
|
1867
|
+
const def = lowerer.unions.get(unionType.unionId);
|
|
1868
|
+
def?.arms.forEach((arm, tag) => {
|
|
1869
|
+
if (isUnitType(arm))
|
|
1870
|
+
units.push({ tag, unit: arm.kind === "nullT" ? "null" : "undefined" });
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
if (units.length === 0 || unionType === null) {
|
|
1874
|
+
return isSafeToDiscard(receiver)
|
|
1875
|
+
? method
|
|
1876
|
+
: {
|
|
1877
|
+
kind: "seqExpr",
|
|
1878
|
+
stmts: [{ kind: "exprStmt", expr: receiver, loc: locOf(expr.expression) }],
|
|
1879
|
+
result: method,
|
|
1880
|
+
type: DYN,
|
|
1881
|
+
loc,
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
const held = lowerer.declareHiddenLocal("%collectionMethodReceiver", unionType);
|
|
1885
|
+
let result = method;
|
|
1886
|
+
for (const { tag, unit } of units) {
|
|
1887
|
+
result = {
|
|
1888
|
+
kind: "ternary",
|
|
1889
|
+
cond: {
|
|
1890
|
+
kind: "unionIsTag",
|
|
1891
|
+
unionId: unionType.unionId,
|
|
1892
|
+
tag,
|
|
1893
|
+
negated: false,
|
|
1894
|
+
value: varRef(held.id, unionType, loc),
|
|
1895
|
+
type: BOOL,
|
|
1896
|
+
loc,
|
|
1897
|
+
},
|
|
1898
|
+
then: nodeThrowExpr(1, "", `Cannot read properties of ${unit} (reading '${name}')`, DYN, loc),
|
|
1899
|
+
else_: result,
|
|
1900
|
+
type: DYN,
|
|
1901
|
+
loc,
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
return {
|
|
1905
|
+
kind: "seqExpr",
|
|
1906
|
+
stmts: [{ kind: "varDecl", localId: held.id, init: receiver, loc }],
|
|
1907
|
+
result,
|
|
1908
|
+
type: DYN,
|
|
1909
|
+
loc,
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1608
1912
|
/** Property access on a string or array receiver: `.length` lowers to the
|
|
1609
1913
|
* matching intrinsic; a bare method reference (`const f = s.slice` — a
|
|
1610
1914
|
* function value) is rejected with a specific message. Returns null for
|
|
@@ -1619,13 +1923,60 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
1619
1923
|
}
|
|
1620
1924
|
if (lowerer.stdlibGlobalMember(expr, "Reflect") === "ownKeys")
|
|
1621
1925
|
return reflectMemberValue(lowerer, "ownKeys", locOf(expr));
|
|
1926
|
+
// A write, `delete` or defineProperty through `Date.prototype` keeps its
|
|
1927
|
+
// fence: the value below is a read surface, and a typed Date never observes
|
|
1928
|
+
// a dynamic write to it. This runs before the chainBlocked early return
|
|
1929
|
+
// because a write lowers the prototype read with the chain blocked.
|
|
1930
|
+
fenceDatePrototypeWrite(lowerer, expr);
|
|
1622
1931
|
if (lowerer.chainBlocked(expr))
|
|
1623
1932
|
return null;
|
|
1933
|
+
// Iterator.prototype, its members and Iterator's own members in
|
|
1934
|
+
// JavaScript: the live objects (scr_js_iterator.c).
|
|
1935
|
+
const iteratorMember = lowerIteratorMemberValue(lowerer, expr);
|
|
1936
|
+
if (iteratorMember)
|
|
1937
|
+
return iteratorMember;
|
|
1938
|
+
// A helper method read as a value on a typed iterator in JavaScript
|
|
1939
|
+
// (`g().map === Iterator.prototype.map`), or a member the typed iterator
|
|
1940
|
+
// has no lowering for (`[].values().return` is undefined): the value the
|
|
1941
|
+
// runtime answers through the boxed iterator, exactly Node's.
|
|
1942
|
+
if (!expr.questionDotToken &&
|
|
1943
|
+
TYPED_ITERATOR_MEMBER_VALUES.has(expr.name.text) &&
|
|
1944
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr))) {
|
|
1945
|
+
const recvT = lowerer.mapTypeOf(lowerer.typeOf(expr.expression));
|
|
1946
|
+
if (recvT?.kind === "generator" && recvT.async !== true) {
|
|
1947
|
+
// Node's builtin iterators (%ArrayIteratorPrototype%'s family) hold
|
|
1948
|
+
// no `return`; a generator's and an iterator helper object's do.
|
|
1949
|
+
if (expr.name.text === "return" && builtinIteratorWithoutReturn(lowerer, expr.expression))
|
|
1950
|
+
return {
|
|
1951
|
+
kind: "seqExpr",
|
|
1952
|
+
stmts: [
|
|
1953
|
+
{
|
|
1954
|
+
kind: "exprStmt",
|
|
1955
|
+
expr: lowerer.lowerExpr(expr.expression),
|
|
1956
|
+
loc: locOf(expr.expression),
|
|
1957
|
+
},
|
|
1958
|
+
],
|
|
1959
|
+
result: dynUndefinedExpr(locOf(expr)),
|
|
1960
|
+
type: DYN,
|
|
1961
|
+
loc: locOf(expr),
|
|
1962
|
+
};
|
|
1963
|
+
return {
|
|
1964
|
+
kind: "dynKeyGet",
|
|
1965
|
+
value: lowerer.coerceToExpected(lowerer.lowerExpr(expr.expression), DYN),
|
|
1966
|
+
key: { kind: "strLit", value: expr.name.text, type: STRING, loc: locOf(expr.name) },
|
|
1967
|
+
type: DYN,
|
|
1968
|
+
loc: locOf(expr),
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1624
1972
|
// Object.prototype.constructor: the Object constructor value.
|
|
1625
1973
|
if (expr.name.text === "constructor" &&
|
|
1626
1974
|
ts.isPropertyAccessExpression(expr.expression) &&
|
|
1627
1975
|
lowerer.stdlibGlobalMember(expr.expression, "Object") === "prototype")
|
|
1628
1976
|
return builtinGlobalValue("Object", locOf(expr));
|
|
1977
|
+
const primitivePrototype = jsPrimitivePrototypeValue(lowerer, expr);
|
|
1978
|
+
if (primitivePrototype)
|
|
1979
|
+
return primitivePrototype;
|
|
1629
1980
|
const builtinPrototype = builtinPrototypeMethod(lowerer, expr);
|
|
1630
1981
|
if (builtinPrototype)
|
|
1631
1982
|
return {
|
|
@@ -1660,21 +2011,42 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
1660
2011
|
return { kind: "libCall", fn: "dyn.functionApply", args: [], type: DYN, loc: locOf(expr) };
|
|
1661
2012
|
if (lowerer.stdlibGlobalMember(expr, "Array") === "prototype")
|
|
1662
2013
|
return { kind: "libCall", fn: "dyn.arrayPrototype", args: [], type: DYN, loc: locOf(expr) };
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
//
|
|
1666
|
-
// and
|
|
1667
|
-
//
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
if (lowerer.stdlibGlobalMember(expr, "Error") === "captureStackTrace")
|
|
2014
|
+
// Date.prototype as a value, and its members read through it: the
|
|
2015
|
+
// prototype object the language defines (an ordinary object carrying the
|
|
2016
|
+
// interface's methods), not a Date. `Date.prototype.hasOwnProperty("x")`
|
|
2017
|
+
// and `Date.prototype.getTime` are reads of that object; a Date method
|
|
2018
|
+
// CALLED on it is a TypeError, which the checked-dynamic method dispatch
|
|
2019
|
+
// answers because the receiver is not a Date handle.
|
|
2020
|
+
if (lowerer.stdlibGlobalMember(expr, "Date") === "prototype") {
|
|
1671
2021
|
return {
|
|
1672
2022
|
kind: "libCall",
|
|
1673
|
-
fn: "dyn.
|
|
1674
|
-
args: [],
|
|
2023
|
+
fn: "dyn.stdlibPrototype",
|
|
2024
|
+
args: [{ kind: "strLit", value: "Date", type: STRING, loc: locOf(expr) }],
|
|
1675
2025
|
type: DYN,
|
|
1676
2026
|
loc: locOf(expr),
|
|
1677
2027
|
};
|
|
2028
|
+
}
|
|
2029
|
+
if (ts.isPropertyAccessExpression(expr.expression) &&
|
|
2030
|
+
lowerer.stdlibGlobalMember(expr.expression, "Date") === "prototype") {
|
|
2031
|
+
return {
|
|
2032
|
+
kind: "dynKeyGet",
|
|
2033
|
+
value: {
|
|
2034
|
+
kind: "libCall",
|
|
2035
|
+
fn: "dyn.stdlibPrototype",
|
|
2036
|
+
args: [{ kind: "strLit", value: "Date", type: STRING, loc: locOf(expr.expression) }],
|
|
2037
|
+
type: DYN,
|
|
2038
|
+
loc: locOf(expr.expression),
|
|
2039
|
+
},
|
|
2040
|
+
key: { kind: "strLit", value: expr.name.text, type: STRING, loc: locOf(expr.name) },
|
|
2041
|
+
type: DYN,
|
|
2042
|
+
loc: locOf(expr),
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
if (lowerer.stdlibGlobalMember(expr, "Object") === "prototype")
|
|
2046
|
+
return { kind: "libCall", fn: "dyn.objectPrototype", args: [], type: DYN, loc: locOf(expr) };
|
|
2047
|
+
// Error.prototype as a value (`F.prototype = Object.create(Error.prototype)`).
|
|
2048
|
+
if (isErrorPrototypeValue(lowerer, expr))
|
|
2049
|
+
return { kind: "libCall", fn: "dyn.errorPrototype", args: [], type: DYN, loc: locOf(expr) };
|
|
1678
2050
|
// Function.prototype as a VALUE (a prototype-chain link:
|
|
1679
2051
|
// `Object.setPrototypeOf(F.prototype, Function.prototype)`): one
|
|
1680
2052
|
// anonymous function answering undefined, length 0 — a zero-capture
|
|
@@ -1703,16 +2075,19 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
1703
2075
|
loc,
|
|
1704
2076
|
};
|
|
1705
2077
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
2078
|
+
// Array.isArray, Object.keys, Date.now, Error.captureStackTrace (`if
|
|
2079
|
+
// (Error.captureStackTrace) ...`) and the other statics with function
|
|
2080
|
+
// values: the same values a read through the constructor's untyped value
|
|
2081
|
+
// answers (builtin-statics.ts).
|
|
2082
|
+
{
|
|
2083
|
+
const owner = stdlibGlobalNameOf(lowerer, expr.expression);
|
|
2084
|
+
const member = owner === null ? null : lowerer.stdlibGlobalMember(expr, owner);
|
|
2085
|
+
const value = owner === null || member === null
|
|
2086
|
+
? null
|
|
2087
|
+
: constructorStaticValue(lowerer, owner, member, locOf(expr));
|
|
2088
|
+
if (value !== null)
|
|
2089
|
+
return value;
|
|
2090
|
+
}
|
|
1716
2091
|
if (lowerer.stdlibGlobalMember(expr, "Buffer") === "poolSize")
|
|
1717
2092
|
return { kind: "libCall", fn: "buffer.poolSize", args: [], type: F64, loc: locOf(expr) };
|
|
1718
2093
|
{
|
|
@@ -1765,20 +2140,6 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
1765
2140
|
{ mode: "required", type: DYN },
|
|
1766
2141
|
],
|
|
1767
2142
|
}, "Buffer.compare", locOf(expr));
|
|
1768
|
-
if (lowerer.stdlibGlobalMember(expr, "Date") === "now")
|
|
1769
|
-
return lowerer.lowerNativeCallableValue({
|
|
1770
|
-
fn: "date.now",
|
|
1771
|
-
params: [],
|
|
1772
|
-
result: F64,
|
|
1773
|
-
valueParams: [],
|
|
1774
|
-
}, "Date.now", locOf(expr));
|
|
1775
|
-
if (stdlibGlobalNameOf(lowerer, expr.expression) === "Object") {
|
|
1776
|
-
if (expr.name.text === "assign")
|
|
1777
|
-
return lowerObjectAssignValue(lowerer, locOf(expr));
|
|
1778
|
-
const fn = own(OBJECT_CALLABLE_VALUES, expr.name.text);
|
|
1779
|
-
if (fn)
|
|
1780
|
-
return lowerer.lowerNativeCallableValue(fn, `Object.${expr.name.text}`, locOf(expr));
|
|
1781
|
-
}
|
|
1782
2143
|
// A never-tainted JS receiver type lowered checked-dynamic
|
|
1783
2144
|
// (neverTaintedJsType — `cmd.length` on `const cmd = ['pwd', []]`):
|
|
1784
2145
|
// stand down so the dyn keyed read below the chain answers, instead
|
|
@@ -2216,6 +2577,21 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
2216
2577
|
const receiver = expected?.kind === "bytes" ? strictReceiver(expected) : lowerer.lowerExpr(expr.expression);
|
|
2217
2578
|
return { kind: "bytesIntrinsic", method: "buffer", receiver, args: [], type: DYN, loc };
|
|
2218
2579
|
}
|
|
2580
|
+
// A method read as a value in JavaScript (`buf.indexOf ===
|
|
2581
|
+
// Buffer.prototype.indexOf`, `const write = buf.writeUInt8`): the box
|
|
2582
|
+
// answers the function Node's prototype holds, which runs on the
|
|
2583
|
+
// receiver it is called with.
|
|
2584
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr))) {
|
|
2585
|
+
const expected = lowerer.mapTypeOf(lowerer.typeOf(expr.expression));
|
|
2586
|
+
const receiver = expected?.kind === "bytes" ? strictReceiver(expected) : lowerer.lowerExpr(expr.expression);
|
|
2587
|
+
return {
|
|
2588
|
+
kind: "dynKeyGet",
|
|
2589
|
+
value: lowerer.coerceToExpected(receiver, DYN),
|
|
2590
|
+
key: { kind: "strLit", value: name, type: STRING, loc },
|
|
2591
|
+
type: DYN,
|
|
2592
|
+
loc,
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2219
2595
|
if (name === "slice" || name === "subarray" || name === "set" || name === "toString") {
|
|
2220
2596
|
lowerer.unsupported("SC1090", expr, `typed-array methods as values (call '${name}' directly)`);
|
|
2221
2597
|
}
|
|
@@ -2235,6 +2611,8 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
2235
2611
|
};
|
|
2236
2612
|
}
|
|
2237
2613
|
if (MAP_METHODS.has(name) || name === "forEach") {
|
|
2614
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr)) && !expr.questionDotToken)
|
|
2615
|
+
return dynCollectionMethodValue(lowerer, expr, "Map", name);
|
|
2238
2616
|
lowerer.unsupported("SC1090", expr, `Map methods as values (call '${name}' directly)`);
|
|
2239
2617
|
}
|
|
2240
2618
|
return null;
|
|
@@ -2253,6 +2631,8 @@ export function lowerIntrinsicProperty(lowerer, expr) {
|
|
|
2253
2631
|
};
|
|
2254
2632
|
}
|
|
2255
2633
|
if (SET_METHODS.has(name)) {
|
|
2634
|
+
if (isJsSourceFile(ts.getSourceFileOfNode(expr)) && !expr.questionDotToken)
|
|
2635
|
+
return dynCollectionMethodValue(lowerer, expr, "Set", name);
|
|
2256
2636
|
lowerer.unsupported("SC1090", expr, `Set methods as values (call '${name}' directly)`);
|
|
2257
2637
|
}
|
|
2258
2638
|
return null;
|
|
@@ -3100,8 +3480,19 @@ function unreachableReceiver(lowerer, expr) {
|
|
|
3100
3480
|
export function lowerUnionProperty(lowerer, expr) {
|
|
3101
3481
|
if (lowerer.chainBlocked(expr))
|
|
3102
3482
|
return null;
|
|
3103
|
-
const
|
|
3483
|
+
const spelled = structuralReadType(lowerer, expr.expression) ??
|
|
3104
3484
|
lowerer.mapTypeOf(lowerer.typeOf(expr.expression));
|
|
3485
|
+
// Inside an optional-chain body the guarded receiver is checker-typed by
|
|
3486
|
+
// its non-nullish narrowing — often one record of a discriminated union
|
|
3487
|
+
// — while the bound chain value still carries the whole present union
|
|
3488
|
+
// (`stored?.type` after an earlier `stored?.type === "oauth"` return
|
|
3489
|
+
// narrowed `stored` to `ApiKeyCredential`, though the runtime-optional
|
|
3490
|
+
// storage still holds `ApiKeyCredential | OAuthCredential`). The union
|
|
3491
|
+
// reader dispatches on the runtime tag, so take the union the chain
|
|
3492
|
+
// binding hands to `lowerExpr` below instead of the spelled narrowing.
|
|
3493
|
+
const chainRecv = lowerer.chainRecvByNode.get(expr.expression);
|
|
3494
|
+
const chainUnion = spelled?.kind !== "union" && chainRecv?.type.kind === "union" ? chainRecv.type : null;
|
|
3495
|
+
const receiverIr = chainUnion ?? spelled;
|
|
3105
3496
|
// The checker can rule the receiver UNREACHABLE and the assertion that
|
|
3106
3497
|
// escapes it (`const x: never = event; (event as any).type` — the
|
|
3107
3498
|
// `default:` branch of a switch that exhausts every arm) erases to
|
|
@@ -3130,6 +3521,16 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3130
3521
|
else
|
|
3131
3522
|
value = narrowStoredClassValue(lowerer, value, receiverIr) ?? value;
|
|
3132
3523
|
}
|
|
3524
|
+
// The spelled type is a narrowing, so every path below (dyn, record,
|
|
3525
|
+
// object, array) was unreachable for this read before it took the stored
|
|
3526
|
+
// union: answer it only when the union reader can, and otherwise hand the
|
|
3527
|
+
// read back to the lowering the spelled type used to reach. A stored arm
|
|
3528
|
+
// the checker ruled out that has no such member (`m1?.name` where the
|
|
3529
|
+
// stored union still carries a `string` arm) must not turn an accepted
|
|
3530
|
+
// program into a refusal.
|
|
3531
|
+
if (chainUnion !== null) {
|
|
3532
|
+
return value.type.kind === "union" ? lowerUnionValueRead(lowerer, expr, value) : null;
|
|
3533
|
+
}
|
|
3133
3534
|
// A checker-union receiver whose VALUE lowered to a plain RECORD (the
|
|
3134
3535
|
// merged-signature fiction — `runner(cmd, args)` where runner joined
|
|
3135
3536
|
// a structural runner type with spawnSync's, and the local adopted
|
|
@@ -3189,12 +3590,53 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3189
3590
|
loc: locOf(expr),
|
|
3190
3591
|
};
|
|
3191
3592
|
}
|
|
3593
|
+
if (isUnitType(value.type)) {
|
|
3594
|
+
// A nullish receiver: Node's RequireObjectCoercible TypeError, after
|
|
3595
|
+
// the receiver's own evaluation.
|
|
3596
|
+
const unit = value.type.kind === "nullT" ? "null" : "undefined";
|
|
3597
|
+
return throwAfterEach([value], nullishReadTypeError(unit, expr.name.text, lowerer.mapTypeOf(lowerer.typeOf(expr)) ?? DYN, locOf(expr)), locOf(expr));
|
|
3598
|
+
}
|
|
3192
3599
|
if (value.type.kind !== "union") {
|
|
3193
3600
|
lowerer.unsupported("SC1090", expr, "shared property access without a represented union receiver");
|
|
3194
3601
|
}
|
|
3195
|
-
const
|
|
3602
|
+
const read = lowerUnionValueRead(lowerer, expr, value) ?? narrowedUnionValueRead(lowerer, expr, value);
|
|
3603
|
+
if (read)
|
|
3604
|
+
return read;
|
|
3605
|
+
lowerer.unsupported("SC1090", expr, `reading '${expr.name.text}' on a union-typed value (every arm must be an object/record ` +
|
|
3606
|
+
`with a same-typed field '${expr.name.text}'; ` +
|
|
3607
|
+
`${NARROW_FIRST})`);
|
|
3608
|
+
}
|
|
3609
|
+
/** The member read itself on a lowered UNION value: `lowerUnionProperty`
|
|
3610
|
+
* after it has produced the value (retagged to the checker's union when
|
|
3611
|
+
* the checker removed arms) and the dispatcher's narrowed-receiver
|
|
3612
|
+
* fallback, which reaches the same read with the value a checker-narrowed
|
|
3613
|
+
* receiver still stores. Returns null when no arm can answer — the caller
|
|
3614
|
+
* owns the diagnostic. */
|
|
3615
|
+
export function lowerUnionValueRead(lowerer, expr, value, missingFieldAsUndefined = false) {
|
|
3616
|
+
return unionValueRead(lowerer, expr, value, missingFieldAsUndefined);
|
|
3617
|
+
}
|
|
3618
|
+
/** The stored-union read again over the arms the checker's narrowing still
|
|
3619
|
+
* allows: an arm it ruled out at this site refused the read (the OAuth
|
|
3620
|
+
* arm's index signature beside `ApiKeyCredential.key`, behind an
|
|
3621
|
+
* optional-chain discriminant guard). Only the REFUSAL points call this —
|
|
3622
|
+
* a site another lowering answers keeps it — so no compiling program
|
|
3623
|
+
* gains a second, narrowed lowering. Returns null when the site's type is
|
|
3624
|
+
* not a narrowing of the value's union. */
|
|
3625
|
+
export function narrowedUnionValueRead(lowerer, expr, value) {
|
|
3626
|
+
const narrowed = narrowedUnionView(lowerer, expr.expression, value, locOf(expr));
|
|
3627
|
+
if (!narrowed)
|
|
3628
|
+
return null;
|
|
3629
|
+
if (narrowed.arm)
|
|
3630
|
+
return narrowedArmRead(lowerer, expr, narrowed.value, narrowed.arm);
|
|
3631
|
+
return unionValueRead(lowerer, expr, narrowed.value, false);
|
|
3632
|
+
}
|
|
3633
|
+
function unionValueRead(lowerer, expr, value, missingFieldAsUndefined) {
|
|
3634
|
+
if (value.type.kind !== "union")
|
|
3635
|
+
return null;
|
|
3636
|
+
const unionId = value.type.unionId;
|
|
3637
|
+
const def = lowerer.unions.get(unionId);
|
|
3196
3638
|
if (!def)
|
|
3197
|
-
throw new InternalCompilerError(`lowerer bug: unknown union ${
|
|
3639
|
+
throw new InternalCompilerError(`lowerer bug: unknown union ${unionId}`);
|
|
3198
3640
|
const field = expr.name.text;
|
|
3199
3641
|
if (field === "length") {
|
|
3200
3642
|
const presentArms = def.arms.filter((arm) => !isUnitType(arm));
|
|
@@ -3221,6 +3663,31 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3221
3663
|
};
|
|
3222
3664
|
}
|
|
3223
3665
|
}
|
|
3666
|
+
// A union of arrays and strings (`Model[] | ModelRef[]`,
|
|
3667
|
+
// `string[] | Buffer[]`): every arm answers its own length, so the
|
|
3668
|
+
// read dispatches on the tag. Node's `.length` is a number for both,
|
|
3669
|
+
// and no arm can be absent here (a unit arm would have to throw on
|
|
3670
|
+
// this read, which the checker's narrowing already excludes).
|
|
3671
|
+
if (def.arms.length > 1 &&
|
|
3672
|
+
def.arms.every((arm) => arm.kind === "array" || arm.kind === "string")) {
|
|
3673
|
+
return perArmUnionRead(lowerer, expr, unionId, value, F64, "%unionLength", (arm, _tag, receiver) => arm.kind === "string"
|
|
3674
|
+
? {
|
|
3675
|
+
kind: "strIntrinsic",
|
|
3676
|
+
method: "length",
|
|
3677
|
+
receiver,
|
|
3678
|
+
args: [],
|
|
3679
|
+
type: F64,
|
|
3680
|
+
loc: locOf(expr),
|
|
3681
|
+
}
|
|
3682
|
+
: {
|
|
3683
|
+
kind: "arrIntrinsic",
|
|
3684
|
+
method: "length",
|
|
3685
|
+
receiver,
|
|
3686
|
+
args: [],
|
|
3687
|
+
type: F64,
|
|
3688
|
+
loc: locOf(expr),
|
|
3689
|
+
});
|
|
3690
|
+
}
|
|
3224
3691
|
}
|
|
3225
3692
|
const nonUnitArms = def.arms.filter((arm) => !isUnitType(arm));
|
|
3226
3693
|
if (nonUnitArms.length === 1 && nonUnitArms[0]?.kind === "object") {
|
|
@@ -3229,7 +3696,7 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3229
3696
|
if (fieldType !== undefined) {
|
|
3230
3697
|
let receiver = lowerer.runtimeOptionalPropertyReceiver(expr.expression, value, objectType, field);
|
|
3231
3698
|
if (receiver === null) {
|
|
3232
|
-
const helper = lowerer.narrowedArmHelper(
|
|
3699
|
+
const helper = lowerer.narrowedArmHelper(unionId, objectType, locOf(expr.expression));
|
|
3233
3700
|
if (helper !== null)
|
|
3234
3701
|
receiver = lowerer.checkedNarrowCall(helper, value, objectType, locOf(expr.expression));
|
|
3235
3702
|
}
|
|
@@ -3245,6 +3712,15 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3245
3712
|
}
|
|
3246
3713
|
}
|
|
3247
3714
|
}
|
|
3715
|
+
// A member the arms answer through an ACCESSOR (a getter inherited
|
|
3716
|
+
// from a shared base class — `renderer.hasOverlayEntries` on
|
|
3717
|
+
// `FullscreenRenderer | RegularRenderer`): there is no field slot
|
|
3718
|
+
// `unionDisc` could read, so dispatch on the tag and call each arm's
|
|
3719
|
+
// own getter. Fires only when some arm's answer is an accessor, so
|
|
3720
|
+
// data-field unions keep their `unionDisc` lowering.
|
|
3721
|
+
const accessorRead = lowerUnionAccessorRead(lowerer, expr, unionId, value);
|
|
3722
|
+
if (accessorRead)
|
|
3723
|
+
return accessorRead;
|
|
3248
3724
|
let common = null;
|
|
3249
3725
|
for (const arm of def.arms) {
|
|
3250
3726
|
let ft;
|
|
@@ -3274,7 +3750,7 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3274
3750
|
// arms): the JOIN path — `env.PORTLESS_PORT` on `ProcessEnv |
|
|
3275
3751
|
// Record<string, string>`, the tail read of `loaded?.config.script`.
|
|
3276
3752
|
const key = { kind: "strLit", value: field, type: STRING, loc: locOf(expr.name) };
|
|
3277
|
-
const keyed = lowerUnionKeyedRead(lowerer, expr,
|
|
3753
|
+
const keyed = lowerUnionKeyedRead(lowerer, expr, unionId, value, key, field, missingFieldAsUndefined);
|
|
3278
3754
|
if (keyed)
|
|
3279
3755
|
return keyed;
|
|
3280
3756
|
// Class arms declaring the field with compatible but different types
|
|
@@ -3304,9 +3780,197 @@ export function lowerUnionProperty(lowerer, expr) {
|
|
|
3304
3780
|
if (member)
|
|
3305
3781
|
return member;
|
|
3306
3782
|
}
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3783
|
+
return null;
|
|
3784
|
+
}
|
|
3785
|
+
/** Evaluate `value` once into a hidden local and answer the read by
|
|
3786
|
+
* dispatching on the union's tag: arm `tag` (narrowed from the local)
|
|
3787
|
+
* answers `answer(arm, tag, narrowed)`. The first non-unit arm's answer
|
|
3788
|
+
* is the fallback branch, which a representable union never reaches. */
|
|
3789
|
+
function perArmUnionRead(lowerer, expr, unionId, value, type, name, answer) {
|
|
3790
|
+
const loc = locOf(expr);
|
|
3791
|
+
const def = lowerer.unions.get(unionId);
|
|
3792
|
+
if (!def)
|
|
3793
|
+
throw new InternalCompilerError(`lowerer bug: unknown union ${unionId}`);
|
|
3794
|
+
const stable = lowerer.declareHiddenLocal(name, value.type);
|
|
3795
|
+
const ref = () => ({ kind: "varRef", localId: stable.id, type: value.type, loc });
|
|
3796
|
+
let result = null;
|
|
3797
|
+
def.arms.forEach((arm, tag) => {
|
|
3798
|
+
if (isUnitType(arm))
|
|
3799
|
+
return;
|
|
3800
|
+
const receiver = { kind: "unionNarrow", unionId, tag, value: ref(), type: arm, loc };
|
|
3801
|
+
const read = answer(arm, tag, receiver);
|
|
3802
|
+
result =
|
|
3803
|
+
result === null
|
|
3804
|
+
? read
|
|
3805
|
+
: {
|
|
3806
|
+
kind: "ternary",
|
|
3807
|
+
cond: {
|
|
3808
|
+
kind: "unionIsTag",
|
|
3809
|
+
unionId,
|
|
3810
|
+
tag,
|
|
3811
|
+
value: ref(),
|
|
3812
|
+
negated: false,
|
|
3813
|
+
type: BOOL,
|
|
3814
|
+
loc,
|
|
3815
|
+
},
|
|
3816
|
+
then: read,
|
|
3817
|
+
else_: result,
|
|
3818
|
+
type,
|
|
3819
|
+
loc,
|
|
3820
|
+
};
|
|
3821
|
+
});
|
|
3822
|
+
if (result === null)
|
|
3823
|
+
throw new InternalCompilerError(`lowerer bug: no arm answers ${name}`);
|
|
3824
|
+
return {
|
|
3825
|
+
kind: "seqExpr",
|
|
3826
|
+
stmts: [{ kind: "varDecl", localId: stable.id, init: value, loc }],
|
|
3827
|
+
result,
|
|
3828
|
+
type,
|
|
3829
|
+
loc,
|
|
3830
|
+
};
|
|
3831
|
+
}
|
|
3832
|
+
/** A member read the arms answer through an ACCESSOR — an inherited
|
|
3833
|
+
* getter (`this.renderer.hasOverlayEntries`). `unionDisc` reads record
|
|
3834
|
+
* and class FIELD slots, so a getter arm needs the tag dispatch: each
|
|
3835
|
+
* arm calls its own getter (once per read, as Node's read does). Data
|
|
3836
|
+
* arms in the same union read their slot. Every arm must answer one
|
|
3837
|
+
* type; a unit arm or an arm without the member declines (the caller's
|
|
3838
|
+
* keyed read and fences own those). Null when no arm answers through an
|
|
3839
|
+
* accessor — plain field unions keep `unionDisc`. */
|
|
3840
|
+
function lowerUnionAccessorRead(lowerer, expr, unionId, value) {
|
|
3841
|
+
const def = lowerer.unions.get(unionId);
|
|
3842
|
+
if (!def)
|
|
3843
|
+
return null;
|
|
3844
|
+
const field = expr.name.text;
|
|
3845
|
+
const getterName = `get:${field}`;
|
|
3846
|
+
let type = null;
|
|
3847
|
+
let anyAccessor = false;
|
|
3848
|
+
const arms = [];
|
|
3849
|
+
for (let tag = 0; tag < def.arms.length; tag++) {
|
|
3850
|
+
const arm = def.arms[tag];
|
|
3851
|
+
if (isUnitType(arm))
|
|
3852
|
+
return null;
|
|
3853
|
+
let answer;
|
|
3854
|
+
let read;
|
|
3855
|
+
if (arm.kind === "record") {
|
|
3856
|
+
const shape = lowerer.shapes.get(arm.shapeId);
|
|
3857
|
+
if (!shape || shape.tuple)
|
|
3858
|
+
return null;
|
|
3859
|
+
const data = shape.fields.find((f) => f.name === field);
|
|
3860
|
+
if (data) {
|
|
3861
|
+
answer = data.type;
|
|
3862
|
+
read = (receiver) => ({
|
|
3863
|
+
kind: "recordGet",
|
|
3864
|
+
obj: receiver,
|
|
3865
|
+
shapeId: arm.shapeId,
|
|
3866
|
+
field,
|
|
3867
|
+
type: data.type,
|
|
3868
|
+
loc: locOf(expr),
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3871
|
+
else {
|
|
3872
|
+
const getter = shape.fields.find((f) => f.name === getterName);
|
|
3873
|
+
if (!getter || getter.type.kind !== "func")
|
|
3874
|
+
return null;
|
|
3875
|
+
anyAccessor = true;
|
|
3876
|
+
answer = getter.type.ret;
|
|
3877
|
+
read = (receiver) => lowerer.coerceToExpected({
|
|
3878
|
+
kind: "callValue",
|
|
3879
|
+
callee: {
|
|
3880
|
+
kind: "recordGet",
|
|
3881
|
+
obj: receiver,
|
|
3882
|
+
shapeId: arm.shapeId,
|
|
3883
|
+
field: getterName,
|
|
3884
|
+
type: getter.type,
|
|
3885
|
+
loc: locOf(expr),
|
|
3886
|
+
},
|
|
3887
|
+
args: [],
|
|
3888
|
+
type: getter.type.kind === "func" ? getter.type.ret : DYN,
|
|
3889
|
+
loc: locOf(expr),
|
|
3890
|
+
}, answer);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
else if (arm.kind === "object") {
|
|
3894
|
+
const info = lowerer.classes.get(arm.className) ?? null;
|
|
3895
|
+
const slot = info?.fields.get(field);
|
|
3896
|
+
if (slot !== undefined) {
|
|
3897
|
+
answer = slot;
|
|
3898
|
+
read = (receiver) => ({
|
|
3899
|
+
kind: "fieldGet",
|
|
3900
|
+
obj: receiver,
|
|
3901
|
+
className: arm.className,
|
|
3902
|
+
field,
|
|
3903
|
+
type: slot,
|
|
3904
|
+
loc: locOf(expr),
|
|
3905
|
+
});
|
|
3906
|
+
}
|
|
3907
|
+
else {
|
|
3908
|
+
const getter = lowerer.findMethodOn(info, getterName);
|
|
3909
|
+
if (!getter || getter.sig.ret.kind === "void")
|
|
3910
|
+
return null;
|
|
3911
|
+
anyAccessor = true;
|
|
3912
|
+
answer = getter.sig.ret;
|
|
3913
|
+
read = (receiver) => lowerer.fieldGetExpr({
|
|
3914
|
+
container: "accessor",
|
|
3915
|
+
obj: receiver,
|
|
3916
|
+
className: arm.className,
|
|
3917
|
+
field,
|
|
3918
|
+
fieldType: getter.sig.ret,
|
|
3919
|
+
}, locOf(expr), expr);
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
else {
|
|
3923
|
+
return null;
|
|
3924
|
+
}
|
|
3925
|
+
if (answer.kind === "void" || isUnitType(answer))
|
|
3926
|
+
return null;
|
|
3927
|
+
if (type !== null && !typeEquals(type, answer))
|
|
3928
|
+
return null;
|
|
3929
|
+
type = answer;
|
|
3930
|
+
arms.push({ tag, read });
|
|
3931
|
+
}
|
|
3932
|
+
if (!anyAccessor || type === null || arms.length < 2)
|
|
3933
|
+
return null;
|
|
3934
|
+
return perArmUnionRead(lowerer, expr, unionId, value, type, "%unionMember", (_arm, tag, receiver) => {
|
|
3935
|
+
const entry = arms.find((a) => a.tag === tag);
|
|
3936
|
+
if (!entry)
|
|
3937
|
+
throw new InternalCompilerError("lowerer bug: accessor arm missing");
|
|
3938
|
+
return entry.read(receiver);
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
/** A LITERAL-key read on a union receiver whose stored arm is a scalar
|
|
3942
|
+
* primitive the property does not exist on. Lowering erases flow
|
|
3943
|
+
* narrowing, so the value keeps arms the checker ruled out
|
|
3944
|
+
* (`{ url?: string } | "pending"` read as `x?.url` after the guard); JS
|
|
3945
|
+
* boxes a primitive and answers undefined for a name its prototype chain
|
|
3946
|
+
* does not carry, which is exactly what the unit and missing-field arms
|
|
3947
|
+
* answer. A name the primitive DOES declare (`length`, `toUpperCase`)
|
|
3948
|
+
* leaves the read to its own lowering/refusal — `{ n: number } | string`
|
|
3949
|
+
* must keep answering the string's own member, not undefined. */
|
|
3950
|
+
function primitiveArmLacksMember(lowerer, arm, field) {
|
|
3951
|
+
// `"abc"[0]` is an element read (JS indexes a string by position), not a
|
|
3952
|
+
// missing property: canonical numeric keys keep their own lowering.
|
|
3953
|
+
if (/^(?:0|[1-9]\d*)$/.test(field))
|
|
3954
|
+
return false;
|
|
3955
|
+
const checker = lowerer.checker;
|
|
3956
|
+
let primitive;
|
|
3957
|
+
switch (arm.kind) {
|
|
3958
|
+
case "string":
|
|
3959
|
+
primitive = checker.getStringType();
|
|
3960
|
+
break;
|
|
3961
|
+
case "f64":
|
|
3962
|
+
primitive = checker.getNumberType();
|
|
3963
|
+
break;
|
|
3964
|
+
case "bool":
|
|
3965
|
+
primitive = checker.getBooleanType();
|
|
3966
|
+
break;
|
|
3967
|
+
case "bigint":
|
|
3968
|
+
primitive = checker.getBigIntType();
|
|
3969
|
+
break;
|
|
3970
|
+
default:
|
|
3971
|
+
return false;
|
|
3972
|
+
}
|
|
3973
|
+
return checker.getPropertyOfType(primitive, field) === undefined;
|
|
3310
3974
|
}
|
|
3311
3975
|
/** The unionDisc generalization: a keyed read on a union receiver whose
|
|
3312
3976
|
* arms answer DIFFERENT (but joinable) types. Each arm contributes its
|
|
@@ -3325,6 +3989,15 @@ export function lowerUnionKeyedRead(lowerer, expr, unionId, value, key, literalF
|
|
|
3325
3989
|
const def = lowerer.unions.get(unionId);
|
|
3326
3990
|
if (!def)
|
|
3327
3991
|
return null;
|
|
3992
|
+
// A JavaScript-source read on a dyn-convertible receiver already has a
|
|
3993
|
+
// dynamic fallback at every call site (`dynKeyGet`), so the primitive
|
|
3994
|
+
// arm's undefined answer would REPLACE a read that compiles today and
|
|
3995
|
+
// change a working program's IR. Keep that fallback: the static answer
|
|
3996
|
+
// exists to replace a refusal, which is the TypeScript-source case.
|
|
3997
|
+
const keepsDynamicFallback = isJsSourceFile(ts.getSourceFileOfNode(expr)) && lowerer.dynConvertible(value.type);
|
|
3998
|
+
const primitiveArmAnswers = (arm) => literalField !== null &&
|
|
3999
|
+
!keepsDynamicFallback &&
|
|
4000
|
+
primitiveArmLacksMember(lowerer, arm, literalField);
|
|
3328
4001
|
// Pass 1: per-arm declared answers, joined into the result type.
|
|
3329
4002
|
const joinArms = [];
|
|
3330
4003
|
const seen = new Set();
|
|
@@ -3359,8 +4032,13 @@ export function lowerUnionKeyedRead(lowerer, expr, unionId, value, key, literalF
|
|
|
3359
4032
|
return null;
|
|
3360
4033
|
continue;
|
|
3361
4034
|
}
|
|
3362
|
-
if (arm.kind !== "record")
|
|
4035
|
+
if (arm.kind !== "record") {
|
|
4036
|
+
if (primitiveArmAnswers(arm)) {
|
|
4037
|
+
push(UNDEFINED_T);
|
|
4038
|
+
continue;
|
|
4039
|
+
}
|
|
3363
4040
|
return null;
|
|
4041
|
+
}
|
|
3364
4042
|
const shape = lowerer.shapes.get(arm.shapeId);
|
|
3365
4043
|
if (!shape || shape.tuple)
|
|
3366
4044
|
return null;
|
|
@@ -3423,8 +4101,16 @@ export function lowerUnionKeyedRead(lowerer, expr, unionId, value, key, literalF
|
|
|
3423
4101
|
return null;
|
|
3424
4102
|
continue;
|
|
3425
4103
|
}
|
|
3426
|
-
if (arm.kind !== "record")
|
|
4104
|
+
if (arm.kind !== "record") {
|
|
4105
|
+
if (primitiveArmAnswers(arm)) {
|
|
4106
|
+
// The primitive's answer above must surface as the join's
|
|
4107
|
+
// undefined arm (the backend's missing-key path stores it).
|
|
4108
|
+
if (!(type.kind === "union" && lowerer.armTag(type.unionId, UNDEFINED_T) >= 0))
|
|
4109
|
+
return null;
|
|
4110
|
+
continue;
|
|
4111
|
+
}
|
|
3427
4112
|
return null;
|
|
4113
|
+
}
|
|
3428
4114
|
const shape = lowerer.shapes.get(arm.shapeId);
|
|
3429
4115
|
if (!shape)
|
|
3430
4116
|
return null;
|
|
@@ -3556,6 +4242,92 @@ function checkedDynamicValue(expr) {
|
|
|
3556
4242
|
return expr;
|
|
3557
4243
|
return expr.kind === "dynCheck" && expr.value.type.kind === "dyn" ? expr.value : null;
|
|
3558
4244
|
}
|
|
4245
|
+
/** A GENERIC receiver type: a type parameter, or a narrowing of one that
|
|
4246
|
+
* intersects it (`"k" in options` refines a type variable to
|
|
4247
|
+
* `T & Record<"k", unknown>`). Its stored layout is whatever the call site
|
|
4248
|
+
* instantiated it with, and the CONSTRAINT's members are not necessarily
|
|
4249
|
+
* stored there. */
|
|
4250
|
+
function typeParameterReceiver(t) {
|
|
4251
|
+
try {
|
|
4252
|
+
if ((t.flags & ts.TypeFlags.TypeParameter) !== 0)
|
|
4253
|
+
return true;
|
|
4254
|
+
return ((t.flags & ts.TypeFlags.Intersection) !== 0 &&
|
|
4255
|
+
ts.constituentTypes(t).some((part) => (part.flags & ts.TypeFlags.TypeParameter) !== 0));
|
|
4256
|
+
}
|
|
4257
|
+
catch (e) {
|
|
4258
|
+
if (ts.isUnreadableConstituentsPanic(e))
|
|
4259
|
+
return false;
|
|
4260
|
+
throw e;
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
/** Whether `access` is only READ (not the target of an assignment, a
|
|
4264
|
+
* delete, or an increment). The left operand of `??`, `===` or `&&`, and
|
|
4265
|
+
* the operand of `!`, `-` or `typeof`, are reads. */
|
|
4266
|
+
function readOnlyAccess(access) {
|
|
4267
|
+
const parent = access.parent;
|
|
4268
|
+
if (parent === undefined)
|
|
4269
|
+
return true;
|
|
4270
|
+
if (ts.isBinaryExpression(parent) &&
|
|
4271
|
+
parent.left === access &&
|
|
4272
|
+
parent.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
4273
|
+
parent.operatorToken.kind <= ts.SyntaxKind.LastAssignment)
|
|
4274
|
+
return false;
|
|
4275
|
+
if (ts.isDeleteExpression(parent))
|
|
4276
|
+
return false;
|
|
4277
|
+
if (ts.isPostfixUnaryExpression(parent))
|
|
4278
|
+
return false;
|
|
4279
|
+
return (!ts.isPrefixUnaryExpression(parent) ||
|
|
4280
|
+
(parent.operator !== ts.SyntaxKind.PlusPlusToken &&
|
|
4281
|
+
parent.operator !== ts.SyntaxKind.MinusMinusToken));
|
|
4282
|
+
}
|
|
4283
|
+
/** The operand a member WRITE addresses through a chain of type assertions:
|
|
4284
|
+
* `(p as View).x = v` names `p`. Node erases a type assertion, so a write
|
|
4285
|
+
* mutates the very object the operand names; the assertion only decides what
|
|
4286
|
+
* the checker accepts. Null when no `as`/`<T>` wraps the receiver (a write
|
|
4287
|
+
* there keeps the ordinary lowering). */
|
|
4288
|
+
function assertionOperand(access) {
|
|
4289
|
+
let node = access.expression;
|
|
4290
|
+
let asserted = false;
|
|
4291
|
+
for (;;) {
|
|
4292
|
+
if (ts.isParenthesizedExpression(node)) {
|
|
4293
|
+
node = node.expression;
|
|
4294
|
+
continue;
|
|
4295
|
+
}
|
|
4296
|
+
if (ts.isAsExpression(node) || ts.isTypeAssertion(node)) {
|
|
4297
|
+
node = node.expression;
|
|
4298
|
+
asserted = true;
|
|
4299
|
+
continue;
|
|
4300
|
+
}
|
|
4301
|
+
break;
|
|
4302
|
+
}
|
|
4303
|
+
return asserted ? node : null;
|
|
4304
|
+
}
|
|
4305
|
+
/** The unasserted value a member write addresses, when its OWN stored
|
|
4306
|
+
* layout holds the member at the asserted type — the erased write of Node.
|
|
4307
|
+
* The asserted view's conversion may instead build a fresh width record
|
|
4308
|
+
* (`%rec.width`), and a write into that temporary is dropped, so a view
|
|
4309
|
+
* that adds a member to a record has nothing to write and the caller
|
|
4310
|
+
* refuses. Only a RECORD operand converts like that: a dyn value's cast is
|
|
4311
|
+
* a checked, identity-preserving view (`dyn-literal-identity.ts`), and the
|
|
4312
|
+
* ordinary lowering already writes through it. The static type decides, so
|
|
4313
|
+
* the operand is lowered exactly once even when it has side effects. */
|
|
4314
|
+
function assertedWrite(lowerer, access, operand, fieldType, assertedType) {
|
|
4315
|
+
if (lowerer.mapTypeOf(lowerer.typeOf(operand))?.kind !== "record") {
|
|
4316
|
+
return { receiver: null, refuse: false };
|
|
4317
|
+
}
|
|
4318
|
+
const value = lowerer.lowerExpr(operand);
|
|
4319
|
+
if (value.type.kind === "record") {
|
|
4320
|
+
const field = lowerer.shapes
|
|
4321
|
+
.get(value.type.shapeId)
|
|
4322
|
+
?.fields.find((f) => f.name === access.name.text);
|
|
4323
|
+
return field && typeEquals(field.type, fieldType)
|
|
4324
|
+
? { receiver: value, refuse: false }
|
|
4325
|
+
: { receiver: null, refuse: true };
|
|
4326
|
+
}
|
|
4327
|
+
// The value stayed non-record (a generic body, an aliased layout): keep
|
|
4328
|
+
// the assertion's conversion over the value already lowered.
|
|
4329
|
+
return { receiver: lowerer.coerceInto(access.expression, value, assertedType), refuse: false };
|
|
4330
|
+
}
|
|
3559
4331
|
export function fieldTarget(lowerer, access) {
|
|
3560
4332
|
if (lowerer.cjsLocalModuleBindingOf(access.expression))
|
|
3561
4333
|
return null;
|
|
@@ -3647,11 +4419,94 @@ export function fieldTarget(lowerer, access) {
|
|
|
3647
4419
|
if (receiverIr?.kind === "union" && hasClassPayload(lowerer, receiverIr)) {
|
|
3648
4420
|
return representedClassFieldTarget(lowerer, access.expression, access.name.text, lowerer.lowerExpr(access.expression));
|
|
3649
4421
|
}
|
|
4422
|
+
// A member the checker ADMITS on a receiver that has no static layout: a
|
|
4423
|
+
// write through an assertion on a checked-dynamic value (a caught binding
|
|
4424
|
+
// — `(error as { headers?: Headers }).headers = undefined`). Node erases
|
|
4425
|
+
// the assertion, so the write lands on the runtime object as an own
|
|
4426
|
+
// property; the checked-dynamic keyed write sets exactly that, and the
|
|
4427
|
+
// class-typed value converts at the write like every other dyn→static edge.
|
|
4428
|
+
if (receiverIr?.kind === "dyn" && !readOnlyAccess(access)) {
|
|
4429
|
+
// The assertion itself may be unrepresentable (a class member on a
|
|
4430
|
+
// structural view); it is erased at runtime, so address the operand.
|
|
4431
|
+
const writeOperand = assertionOperand(access);
|
|
4432
|
+
const admitted = lowerer.mapTypeOf(lowerer.typeOf(access));
|
|
4433
|
+
if (writeOperand && admitted && admitted.kind !== "void")
|
|
4434
|
+
return {
|
|
4435
|
+
container: "dynamic",
|
|
4436
|
+
obj: lowerer.coerceToExpected(lowerer.lowerExpr(writeOperand), DYN),
|
|
4437
|
+
field: access.name.text,
|
|
4438
|
+
fieldType: admitted,
|
|
4439
|
+
};
|
|
4440
|
+
}
|
|
4441
|
+
// A member the checker ADMITS but the stored layout cannot hold. The
|
|
4442
|
+
// constraint of a type parameter declares it (a generic options bag read
|
|
4443
|
+
// through an `"sessionId" in options` guard, or `options?.apiKey` with the
|
|
4444
|
+
// guarded spelling), and so does a cast that intersects the member onto a
|
|
4445
|
+
// record (`options as Omit<T, "k"> & ProviderRequestOptions<M>`), while the
|
|
4446
|
+
// record the value was STORED as has no such slot: the call site omitted the
|
|
4447
|
+
// optional member, the instantiation is a union of option shapes, or the cast
|
|
4448
|
+
// added a member its source layout never declared. Node reads the property
|
|
4449
|
+
// off the object it actually has — undefined when the object lacks it, the
|
|
4450
|
+
// value when the value kept one — so the read is the checked-dynamic keyed
|
|
4451
|
+
// read of the stored value, entering the static code at the type the checker
|
|
4452
|
+
// gave the read (a failed conversion throws; it never diverges).
|
|
4453
|
+
//
|
|
4454
|
+
// Inside a `?.` chain this lowering runs on the re-dispatch, with the
|
|
4455
|
+
// receiver node bound to the chain's present (non-nullish) arm, so the
|
|
4456
|
+
// stored value is already the record and the chain supplies the guard.
|
|
4457
|
+
if ((!access.questionDotToken || lowerer.chainHandled.has(access)) && readOnlyAccess(access)) {
|
|
4458
|
+
const storedIr = stored ?? narrowed;
|
|
4459
|
+
const present = storedIr?.kind === "union" ? lowerer.stripUndefinedArm(storedIr) : storedIr;
|
|
4460
|
+
const arms = present?.kind === "union"
|
|
4461
|
+
? (lowerer.unions.get(present.unionId)?.arms ?? [present])
|
|
4462
|
+
: present
|
|
4463
|
+
? [present]
|
|
4464
|
+
: [];
|
|
4465
|
+
// Every arm is a plain record layout with no slot for the member.
|
|
4466
|
+
const layoutMissing = arms.length > 0 &&
|
|
4467
|
+
arms.every((arm) => {
|
|
4468
|
+
if (arm.kind !== "record")
|
|
4469
|
+
return false;
|
|
4470
|
+
const shape = lowerer.shapes.get(arm.shapeId);
|
|
4471
|
+
return (shape !== undefined &&
|
|
4472
|
+
!shape.tuple &&
|
|
4473
|
+
!shape.indexValue &&
|
|
4474
|
+
!shape.fields.some((f) => f.name === access.name.text));
|
|
4475
|
+
});
|
|
4476
|
+
const admitted = lowerer.mapTypeOf(lowerer.typeOf(access));
|
|
4477
|
+
const checkerHolds = typeParameterReceiver(lowerer.typeOf(access.expression)) ||
|
|
4478
|
+
narrowed === null ||
|
|
4479
|
+
(narrowed.kind === "record" &&
|
|
4480
|
+
(lowerer.shapes.get(narrowed.shapeId)?.fields.some((f) => f.name === access.name.text) ??
|
|
4481
|
+
false));
|
|
4482
|
+
if (layoutMissing && checkerHolds && admitted && admitted.kind !== "void") {
|
|
4483
|
+
let obj = lowerer.lowerExpr(access.expression);
|
|
4484
|
+
if (obj.type.kind === "union" && lowerer.armTag(obj.type.unionId, UNDEFINED_T) >= 0) {
|
|
4485
|
+
const presentType = lowerer.stripUndefinedArm(obj.type);
|
|
4486
|
+
obj =
|
|
4487
|
+
presentType.kind === "record"
|
|
4488
|
+
? (lowerer.runtimeOptionalPropertyReceiver(access.expression, obj, presentType, access.name.text) ?? obj)
|
|
4489
|
+
: lowerer.maybeNarrow(obj, access.expression);
|
|
4490
|
+
}
|
|
4491
|
+
if (!lowerer.dynConvertible(obj.type))
|
|
4492
|
+
return null;
|
|
4493
|
+
return {
|
|
4494
|
+
container: "dynamic",
|
|
4495
|
+
obj: lowerer.coerceToExpected(obj, DYN),
|
|
4496
|
+
field: access.name.text,
|
|
4497
|
+
fieldType: admitted,
|
|
4498
|
+
};
|
|
4499
|
+
}
|
|
4500
|
+
}
|
|
3650
4501
|
if (receiverIr?.kind === "record") {
|
|
3651
4502
|
const shape = lowerer.shapes.get(receiverIr.shapeId);
|
|
3652
4503
|
const fieldType = shape?.fields.find((f) => f.name === access.name.text)?.type;
|
|
3653
4504
|
if (fieldType) {
|
|
3654
|
-
|
|
4505
|
+
const writeOperand = readOnlyAccess(access) ? null : assertionOperand(access);
|
|
4506
|
+
const write = writeOperand === null
|
|
4507
|
+
? null
|
|
4508
|
+
: assertedWrite(lowerer, access, writeOperand, fieldType, receiverIr);
|
|
4509
|
+
let obj = write?.receiver ?? lowerer.lowerExpr(access.expression);
|
|
3655
4510
|
const nominal = representedClassFieldTarget(lowerer, access.expression, access.name.text, obj);
|
|
3656
4511
|
if (nominal)
|
|
3657
4512
|
return nominal;
|
|
@@ -3683,6 +4538,13 @@ export function fieldTarget(lowerer, access) {
|
|
|
3683
4538
|
}
|
|
3684
4539
|
if (obj.type.kind !== "record")
|
|
3685
4540
|
return null;
|
|
4541
|
+
// A write through a type assertion that the value's own layout cannot
|
|
4542
|
+
// host would land on the assertion's converted copy (`%rec.width.<id>`)
|
|
4543
|
+
// and be dropped. Node erases the assertion and mutates the object the
|
|
4544
|
+
// operand names, so refuse rather than diverge silently.
|
|
4545
|
+
if (write?.refuse === true) {
|
|
4546
|
+
lowerer.unsupported("SC1090", access, `writing '${access.name.text}' through a type assertion to a member the value's own layout does not hold (the write would land on a converted copy; declare the member on the value's type)`);
|
|
4547
|
+
}
|
|
3686
4548
|
const actualShape = lowerer.shapes.get(obj.type.shapeId);
|
|
3687
4549
|
const actualField = actualShape?.fields.find((f) => f.name === access.name.text);
|
|
3688
4550
|
return {
|
|
@@ -3875,6 +4737,21 @@ export function fieldGetExpr(lowerer, target, loc, blame) {
|
|
|
3875
4737
|
// construction), typed as the index value armed with undefined
|
|
3876
4738
|
// (mirroring lowerRecordKeyRead).
|
|
3877
4739
|
if (target.container === "recordOvf") {
|
|
4740
|
+
// A dot read through a value HELD from process.env (`const env =
|
|
4741
|
+
// process.env; env.X`): the hold aliases the live table, so the read is
|
|
4742
|
+
// the same getenv the direct spelling lowers to.
|
|
4743
|
+
if (ts.isPropertyAccessExpression(blame)) {
|
|
4744
|
+
const live = heldEnvValueType(lowerer, blame.expression);
|
|
4745
|
+
if (live !== null) {
|
|
4746
|
+
return {
|
|
4747
|
+
kind: "libCall",
|
|
4748
|
+
fn: "process.envGet",
|
|
4749
|
+
args: [{ kind: "strLit", value: target.field, type: STRING, loc }],
|
|
4750
|
+
type: live,
|
|
4751
|
+
loc,
|
|
4752
|
+
};
|
|
4753
|
+
}
|
|
4754
|
+
}
|
|
3878
4755
|
let obj = target.obj;
|
|
3879
4756
|
if (obj.type.kind === "union" && ts.isPropertyAccessExpression(blame)) {
|
|
3880
4757
|
const present = lowerer.stripUndefinedArm(obj.type);
|
|
@@ -3958,6 +4835,23 @@ export function fieldGetExpr(lowerer, target, loc, blame) {
|
|
|
3958
4835
|
}
|
|
3959
4836
|
return read;
|
|
3960
4837
|
}
|
|
4838
|
+
// A field some partial record assertion leaves unwritten (a partial
|
|
4839
|
+
// record view, partial-assertions.ts): a read of an absent field throws
|
|
4840
|
+
// the catchable TypeError instead of reading a slot the view lacks.
|
|
4841
|
+
if (partialAssertionFields(lowerer, target.shapeId).has(target.field)) {
|
|
4842
|
+
const obj = target.obj;
|
|
4843
|
+
if (isSafeToRepeat(obj))
|
|
4844
|
+
return partialFieldRead(lowerer, obj, target.shapeId, target.field, target.fieldType, loc);
|
|
4845
|
+
const stable = lowerer.declareHiddenLocal("%partialRecv", obj.type);
|
|
4846
|
+
const ref = varRef(stable.id, obj.type, loc);
|
|
4847
|
+
return {
|
|
4848
|
+
kind: "seqExpr",
|
|
4849
|
+
stmts: [{ kind: "varDecl", localId: stable.id, init: obj, loc }],
|
|
4850
|
+
result: partialFieldRead(lowerer, ref, target.shapeId, target.field, target.fieldType, loc),
|
|
4851
|
+
type: target.fieldType,
|
|
4852
|
+
loc,
|
|
4853
|
+
};
|
|
4854
|
+
}
|
|
3961
4855
|
return {
|
|
3962
4856
|
kind: "recordGet",
|
|
3963
4857
|
obj: target.obj,
|
|
@@ -4010,7 +4904,10 @@ const ERROR_CONSTRUCTOR_VALUES = new Set([
|
|
|
4010
4904
|
* constructor, and dynamic values answer `.constructor` with the same one,
|
|
4011
4905
|
* so `o.constructor === Object` and `err.constructor === TypeError` are
|
|
4012
4906
|
* exact identity tests, and `err.constructor.name` is the constructor's
|
|
4013
|
-
* name.
|
|
4907
|
+
* name. SharedArrayBuffer, DataView, BigInt64Array, BigUint64Array and
|
|
4908
|
+
* Proxy have values with Node's name, length and instanceof answers;
|
|
4909
|
+
* calling one throws Node's TypeError, and constructing through the value
|
|
4910
|
+
* is fenced. */
|
|
4014
4911
|
const GLOBAL_CONSTRUCTOR_VALUES = new Set([
|
|
4015
4912
|
"Object",
|
|
4016
4913
|
"Function",
|
|
@@ -4022,6 +4919,11 @@ const GLOBAL_CONSTRUCTOR_VALUES = new Set([
|
|
|
4022
4919
|
"WeakMap",
|
|
4023
4920
|
"WeakSet",
|
|
4024
4921
|
"FinalizationRegistry",
|
|
4922
|
+
"SharedArrayBuffer",
|
|
4923
|
+
"DataView",
|
|
4924
|
+
"BigInt64Array",
|
|
4925
|
+
"BigUint64Array",
|
|
4926
|
+
"Proxy",
|
|
4025
4927
|
...ERROR_CONSTRUCTOR_VALUES,
|
|
4026
4928
|
]);
|
|
4027
4929
|
/** The builtin global functions JavaScript sources read as interned
|
|
@@ -4102,7 +5004,8 @@ export function builtinGlobalValueAt(lowerer, expr, canonical, loc, js) {
|
|
|
4102
5004
|
return namespace;
|
|
4103
5005
|
if (readsBuiltinGlobalMembers(expr))
|
|
4104
5006
|
return null;
|
|
4105
|
-
const value = builtinGlobalValue(canonical, loc, js)
|
|
5007
|
+
const value = builtinGlobalValue(canonical, loc, js) ??
|
|
5008
|
+
(js ? globalFunctionValue(lowerer, canonical, loc) : null);
|
|
4106
5009
|
if (value === null)
|
|
4107
5010
|
return null;
|
|
4108
5011
|
let node = expr;
|
|
@@ -4190,6 +5093,94 @@ const OBJECT_PROTOTYPE_VALUE_READS = new Set([
|
|
|
4190
5093
|
"hasOwnProperty",
|
|
4191
5094
|
"propertyIsEnumerable",
|
|
4192
5095
|
]);
|
|
5096
|
+
/** The method names each weak collection's prototype declares. */
|
|
5097
|
+
const WEAK_COLLECTION_METHOD_NAMES = {
|
|
5098
|
+
WeakMap: new Set(["get", "set", "has", "delete"]),
|
|
5099
|
+
WeakSet: new Set(["add", "has", "delete"]),
|
|
5100
|
+
};
|
|
5101
|
+
/** A weak-collection method read as a VALUE (`wm.has`, the
|
|
5102
|
+
* `map.has.call(x, k)` brand-check tests): the runtime's interned prototype
|
|
5103
|
+
* function for that name, which applies the method to its own receiver and
|
|
5104
|
+
* throws Node's brand-check TypeError when that receiver is not a
|
|
5105
|
+
* WeakMap/WeakSet. A receiver typed `WeakMap | WeakSet` picks the function by
|
|
5106
|
+
* the collection the value holds, and one that admits `null`/`undefined`
|
|
5107
|
+
* throws the property-read TypeError the read itself throws in Node. Only
|
|
5108
|
+
* JavaScript sources take this path: a typed source keeps its refusal (the
|
|
5109
|
+
* checker's signature has no value form). The receiver expression still runs
|
|
5110
|
+
* for its effects. */
|
|
5111
|
+
function weakCollectionMethodValue(lowerer, expr, prototypes, nullable, name) {
|
|
5112
|
+
const loc = locOf(expr);
|
|
5113
|
+
const method = (prototype) => WEAK_COLLECTION_METHOD_NAMES[prototype].has(name)
|
|
5114
|
+
? {
|
|
5115
|
+
kind: "libCall",
|
|
5116
|
+
fn: "dyn.builtinMethod",
|
|
5117
|
+
args: [
|
|
5118
|
+
{ kind: "strLit", value: prototype, type: STRING, loc },
|
|
5119
|
+
{ kind: "strLit", value: name, type: STRING, loc: locOf(expr.name) },
|
|
5120
|
+
],
|
|
5121
|
+
type: DYN,
|
|
5122
|
+
loc,
|
|
5123
|
+
}
|
|
5124
|
+
: // The collection without the method reads it as undefined.
|
|
5125
|
+
dynUndefinedExpr(loc);
|
|
5126
|
+
const receiver = lowerer.lowerExpr(expr.expression);
|
|
5127
|
+
if (!nullable && prototypes.length === 1) {
|
|
5128
|
+
const value = method(prototypes[0]);
|
|
5129
|
+
return isSafeToDiscard(receiver)
|
|
5130
|
+
? value
|
|
5131
|
+
: {
|
|
5132
|
+
kind: "seqExpr",
|
|
5133
|
+
stmts: [{ kind: "exprStmt", expr: receiver, loc: locOf(expr.expression) }],
|
|
5134
|
+
result: value,
|
|
5135
|
+
type: DYN,
|
|
5136
|
+
loc,
|
|
5137
|
+
};
|
|
5138
|
+
}
|
|
5139
|
+
// The receiver answers the kind and unit tests below, so it waits in a
|
|
5140
|
+
// hidden local.
|
|
5141
|
+
const held = lowerer.declareHiddenLocal("%weakRecv", DYN);
|
|
5142
|
+
const ref = () => varRef(held.id, DYN, loc);
|
|
5143
|
+
let value = method(prototypes[0]);
|
|
5144
|
+
if (prototypes.length > 1)
|
|
5145
|
+
value = {
|
|
5146
|
+
kind: "ternary",
|
|
5147
|
+
cond: { kind: "libCall", fn: "weakMap.is", args: [ref()], type: BOOL, loc },
|
|
5148
|
+
then: method("WeakMap"),
|
|
5149
|
+
else_: method("WeakSet"),
|
|
5150
|
+
type: DYN,
|
|
5151
|
+
loc,
|
|
5152
|
+
};
|
|
5153
|
+
if (nullable)
|
|
5154
|
+
value = {
|
|
5155
|
+
kind: "ternary",
|
|
5156
|
+
cond: { kind: "dynTest", test: "nullish", value: ref(), type: BOOL, loc },
|
|
5157
|
+
// Node throws from the read itself, naming the unit and the member.
|
|
5158
|
+
then: {
|
|
5159
|
+
kind: "dynKeyGet",
|
|
5160
|
+
value: ref(),
|
|
5161
|
+
key: { kind: "strLit", value: name, type: STRING, loc },
|
|
5162
|
+
type: DYN,
|
|
5163
|
+
loc,
|
|
5164
|
+
},
|
|
5165
|
+
else_: value,
|
|
5166
|
+
type: DYN,
|
|
5167
|
+
loc,
|
|
5168
|
+
};
|
|
5169
|
+
return {
|
|
5170
|
+
kind: "seqExpr",
|
|
5171
|
+
stmts: [
|
|
5172
|
+
{
|
|
5173
|
+
kind: "varDecl",
|
|
5174
|
+
localId: held.id,
|
|
5175
|
+
init: lowerer.coerceInto(expr.expression, receiver, DYN),
|
|
5176
|
+
loc,
|
|
5177
|
+
},
|
|
5178
|
+
],
|
|
5179
|
+
result: value,
|
|
5180
|
+
type: DYN,
|
|
5181
|
+
loc,
|
|
5182
|
+
};
|
|
5183
|
+
}
|
|
4193
5184
|
/** Whether `expr` is the callee of a call (`o.toString()`), which keeps its
|
|
4194
5185
|
* call lowering rather than reading the member as a value. */
|
|
4195
5186
|
function isCalleeOf(expr) {
|
|
@@ -4388,4 +5379,67 @@ function globalThisWrittenNames(lowerer, globalType) {
|
|
|
4388
5379
|
}
|
|
4389
5380
|
return names;
|
|
4390
5381
|
}
|
|
5382
|
+
/** `Number.prototype` / `Boolean.prototype` in a JavaScript source: the
|
|
5383
|
+
* prototype object the checked-dynamic world builds (with its methods), or
|
|
5384
|
+
* one of its members read as a value. Typed sources keep their own
|
|
5385
|
+
* lowering, so no typed program links the unit that builds it. */
|
|
5386
|
+
function jsPrimitivePrototypeValue(lowerer, expr) {
|
|
5387
|
+
if (!isJsSourceFile(ts.getSourceFileOfNode(expr)))
|
|
5388
|
+
return null;
|
|
5389
|
+
const loc = locOf(expr);
|
|
5390
|
+
const value = (kind) => kind === "Boolean"
|
|
5391
|
+
? // The wrapper unit's Boolean.prototype is the object Boolean
|
|
5392
|
+
// instances inherit from, so its valueOf/toString are the interned
|
|
5393
|
+
// members and accept a primitive boolean or a Boolean wrapper
|
|
5394
|
+
// receiver (the dyn.builtinPrototype builder takes only the kind's
|
|
5395
|
+
// primitives).
|
|
5396
|
+
{
|
|
5397
|
+
kind: "libCall",
|
|
5398
|
+
fn: "wrapper.booleanPrototype",
|
|
5399
|
+
args: [wrapperConstructors(lowerer, loc)[2]],
|
|
5400
|
+
type: DYN,
|
|
5401
|
+
loc,
|
|
5402
|
+
}
|
|
5403
|
+
: {
|
|
5404
|
+
kind: "libCall",
|
|
5405
|
+
fn: "dyn.builtinPrototype",
|
|
5406
|
+
args: [{ kind: "strLit", value: kind, type: STRING, loc }],
|
|
5407
|
+
type: DYN,
|
|
5408
|
+
loc,
|
|
5409
|
+
};
|
|
5410
|
+
const receiver = expr.expression;
|
|
5411
|
+
if (ts.isPropertyAccessExpression(receiver) && receiver.name.text === "prototype") {
|
|
5412
|
+
const kind = primitivePrototypeKind(lowerer, receiver);
|
|
5413
|
+
if (!kind)
|
|
5414
|
+
return null;
|
|
5415
|
+
return {
|
|
5416
|
+
kind: "dynKeyGet",
|
|
5417
|
+
value: value(kind),
|
|
5418
|
+
key: { kind: "strLit", value: expr.name.text, type: STRING, loc: locOf(expr.name) },
|
|
5419
|
+
type: DYN,
|
|
5420
|
+
loc,
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
const kind = primitivePrototypeKind(lowerer, expr);
|
|
5424
|
+
return kind ? value(kind) : null;
|
|
5425
|
+
}
|
|
5426
|
+
/** Whether `expr` names `Number.prototype` or `Boolean.prototype` in a
|
|
5427
|
+
* JavaScript source, which lowers to the prototype object above rather than
|
|
5428
|
+
* to the wrapper interface's numeric/boolean value. */
|
|
5429
|
+
export function isPrimitivePrototypeRead(lowerer, expr) {
|
|
5430
|
+
return primitivePrototypeKind(lowerer, expr) !== null;
|
|
5431
|
+
}
|
|
5432
|
+
/** The kind whose prototype `expr` names (`Number.prototype`) in a
|
|
5433
|
+
* JavaScript source, if any. */
|
|
5434
|
+
function primitivePrototypeKind(lowerer, expr) {
|
|
5435
|
+
if (!ts.isPropertyAccessExpression(expr) || expr.name.text !== "prototype")
|
|
5436
|
+
return null;
|
|
5437
|
+
if (!isJsSourceFile(ts.getSourceFileOfNode(expr)))
|
|
5438
|
+
return null;
|
|
5439
|
+
if (lowerer.stdlibGlobalMember(expr, "Number") === "prototype")
|
|
5440
|
+
return "Number";
|
|
5441
|
+
if (lowerer.stdlibGlobalMember(expr, "Boolean") === "prototype")
|
|
5442
|
+
return "Boolean";
|
|
5443
|
+
return null;
|
|
5444
|
+
}
|
|
4391
5445
|
//# sourceMappingURL=property-access.js.map
|