@scriptc/compiler 0.4.7 → 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 +23 -5
- package/ambient/node-fallback/fs.d.ts +3 -2
- package/ambient/node-fallback/http.d.ts +23 -17
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +6 -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/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +37 -7
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +11 -3
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +17 -6
- 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 +9 -2
- package/dist/backend/linker.js +190 -32
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +8 -4
- package/dist/backend/lld.js +19 -13
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +3 -1
- 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/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +31 -7
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +12 -3
- package/dist/backend/llvm/dyn.js +31 -7
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +67 -4
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +90 -39
- 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 +99 -15
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +113 -8
- package/dist/backend/llvm/emitter.js +438 -67
- 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.js +18 -2
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +31 -10
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +31 -3
- 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.js +17 -0
- package/dist/backend/llvm/expr-stream-bridges.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 +19 -1
- package/dist/backend/llvm/js-ic.js +96 -23
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +132 -1
- package/dist/backend/llvm/lib-dispatch.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 +44 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +69 -2
- package/dist/backend/llvm/lib-shared.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-state.js +7 -2
- 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.test.js +6 -6
- 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/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.js +12 -6
- package/dist/backend/llvm/record-views.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 +3 -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 +33 -3
- package/dist/backend/llvm/shapes.js +183 -13
- package/dist/backend/llvm/shapes.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/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +46 -2
- 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 +48 -8
- package/dist/backend/native/executable.js +55 -13
- 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 +9 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +4 -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 +27 -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 +37 -8
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +17 -2
- package/dist/backend/runtime-pack-core.js +18 -3
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +211 -2
- 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 +5 -1
- package/dist/backend/vendor-archives.js +51 -7
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +25 -4
- package/dist/backend/vendor-inputs.js +68 -4
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +35 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +1 -1
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.js +2 -2
- 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/diagnostics/codes.d.ts +8 -0
- package/dist/diagnostics/codes.js +8 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +27 -9
- package/dist/diagnostics/diagnostic.js +60 -19
- package/dist/diagnostics/diagnostic.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 +21 -2
- package/dist/executable/executable-cache.js +21 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +123 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +199 -248
- 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 +12 -2
- package/dist/frontend/early-errors.js +535 -4
- package/dist/frontend/early-errors.js.map +1 -1
- package/dist/frontend/early-errors.test.js +165 -0
- package/dist/frontend/early-errors.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- 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.js +21 -3
- 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 +4 -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 +24 -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.js +2 -2
- 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 +560 -27
- 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/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
- package/dist/frontend/lowering/builtins/filesystem-calls.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 +3 -1
- package/dist/frontend/lowering/builtins/module-calls.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 +6 -3
- package/dist/frontend/lowering/builtins/operating-system.js +96 -16
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +2 -2
- package/dist/frontend/lowering/builtins/process.js +103 -8
- 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/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +180 -36
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +35 -12
- package/dist/frontend/lowering/builtins/url.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 +103 -0
- package/dist/frontend/lowering/call-signatures.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 +9 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
- 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-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 +20 -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/coercions/function-adapters.js +9 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +8 -0
- package/dist/frontend/lowering/coercions/state.js +17 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +10 -1
- 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.js +156 -62
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +21 -3
- 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 +14 -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 +446 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +21 -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/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 +10 -0
- package/dist/frontend/lowering/expressions/array-literals.js +62 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +115 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +151 -7
- 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 +31 -2
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +175 -22
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +173 -11
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
- package/dist/frontend/lowering/expressions/property-access.js +379 -109
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +237 -7
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +8 -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 +74 -55
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +37 -10
- 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 +27 -1
- package/dist/frontend/lowering/generic-functions.js +432 -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 +6 -4
- package/dist/frontend/lowering/global-values.js +24 -10
- package/dist/frontend/lowering/global-values.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.js +43 -22
- 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 +11 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +30 -15
- 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.js +11 -1
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +25 -0
- package/dist/frontend/lowering/lower-calls.js +929 -227
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.js +59 -16
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +20 -0
- package/dist/frontend/lowering/lower-classes.js +468 -44
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
- package/dist/frontend/lowering/lower-event-emitter.js +253 -83
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
- package/dist/frontend/lowering/lower-exprs.js +71 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +25 -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 +638 -64
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +48 -2
- 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.js +16 -6
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +303 -87
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +45 -0
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
- package/dist/frontend/lowering/lower-stmts.js +270 -52
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +110 -27
- 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 +227 -21
- package/dist/frontend/lowering/lowerer.js +651 -92
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +18 -0
- 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/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/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 +0 -3
- package/dist/frontend/lowering/partial-assertions.js +9 -15
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- 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.js +1 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- 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/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-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 +15 -1
- package/dist/frontend/lowering/surfaces.js +78 -10
- 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 +8 -0
- package/dist/frontend/lowering/unit-journal.js +14 -0
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +36 -1
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-static.js +78 -9
- 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/pipeline.d.ts +5 -4
- package/dist/frontend/pipeline.js +94 -31
- 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.d.ts +62 -2
- package/dist/frontend/program.js +695 -422
- 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/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/shape-inference/overlay.js +68 -2
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- 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/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +935 -150
- 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 +91 -9
- package/dist/frontend/type-mapper.js +622 -181
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +80 -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/builtin-effects.js +43 -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 +242 -16
- 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.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +724 -648
- package/dist/ir/codec.generated.js.map +1 -1
- 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 +11 -2
- package/dist/ir/fields.generated.js +8 -0
- package/dist/ir/fields.generated.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 +5 -4
- package/dist/ir/function-references.js +7 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +7 -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-views.js +1 -0
- package/dist/ir/inline-array-views.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/ir.d.ts +59 -4
- 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.js +30 -5
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +27 -1
- package/dist/ir/js-ic.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 -4
- package/dist/ir/parameter-versions.js +63 -42
- 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/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 +87 -12
- package/dist/ir/runtime-features.js +263 -160
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +109 -139
- 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 +4 -2
- package/dist/ir/saturating-loop-jams.js +11 -10
- package/dist/ir/saturating-loop-jams.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 +32 -27
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/serialize.d.ts +6 -1
- package/dist/ir/serialize.js +87 -23
- 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 +88 -18
- package/dist/ir/validate.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 +1 -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 +47 -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 +1 -1
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +18 -3
- 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 +43 -26
- 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 +10 -1
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +12 -0
- package/dist/node-islands/boundary.js +38 -6
- 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 +9 -0
- package/dist/node-islands/detect.js +110 -0
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +24 -0
- package/dist/node-islands/detect.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/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 +2 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +5 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +11 -2
- package/dist/node-islands/scan.js +61 -9
- package/dist/node-islands/scan.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 +184 -117
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isJsIteratorGlobal, iteratorPrototypeExpr, lowerIteratorNew, } from "./iterator-prototype.js";
|
|
1
2
|
import { lowerWrapperNew } from "./primitive-wrappers.js";
|
|
2
3
|
import { lowerAsyncLocalStorageOptions } from "./builtins/async-context.js";
|
|
3
4
|
import { shapeOverlayAnnotated } from "../shape-inference/index.js";
|
|
@@ -9,7 +10,8 @@ import { keyedHelperName } from "./stable-names.js";
|
|
|
9
10
|
import { lowerValueReturningConstructorNew } from "./js-dynamic-objects.js";
|
|
10
11
|
import { adaptPromiseExecutor } from "./promise-executor-adapter.js";
|
|
11
12
|
import { dynUndefinedExpr, nodeThrowExpr, strLit, varRef } from "../../ir/build.js";
|
|
12
|
-
import {
|
|
13
|
+
import { isBuiltinIdentityToken, isPrimitiveValueType, staticallyPrimitive, throwAfterEach, throwTypeError, } from "./primitive-throws.js";
|
|
14
|
+
import { constructedFromValue, constructedValue, constructorPrimitiveFlag, superIntoResultSlot, } from "./constructor-returns.js";
|
|
13
15
|
import { checkedIterableSpread } from "./checked-iterable-spread.js";
|
|
14
16
|
import { lowerReadlineInterfaceNew, lowerReadlineUiNew } from "./builtins/readline.js";
|
|
15
17
|
import { builtinMemberBindingTarget, builtinMemberRequireDecl, } from "./builtins/module-bindings.js";
|
|
@@ -29,15 +31,15 @@ import { lowerZlibStreamNew, zlibClassName, zlibStreamModeOf } from "./builtins/
|
|
|
29
31
|
import { everyStmtList } from "../../ir/traverse.js";
|
|
30
32
|
import { builtinClassAliasOf, builtinClassRefOf, } from "./builtins/class-values.js";
|
|
31
33
|
import { inlineNamespaceRequireOf, lowerWithInlineRequireInit } from "./cjs-inline-require.js";
|
|
32
|
-
import { BOOL, BYTES_U8, canDynCheckTo, DATE_T, DYN, F64, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, classValueConstructor, UNDEFINED_T, VOID, arrayOf, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
34
|
+
import { BIGINT_BYTES_NAMES, BOOL, BYTES_U8, canDynCheckTo, DATE_T, DYN, F64, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, classValueConstructor, UNDEFINED_T, VOID, arrayOf, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
33
35
|
import { genericCallInstance, implicitAnyParamSymbolsOf, implicitCallInstance, implicitMonoFile, genericLocalClassResult, } from "./generic-functions.js";
|
|
34
36
|
import { extendInstantiationPath, MAX_INSTANTIATION_RECURSION, } from "./instantiation-path.js";
|
|
35
37
|
import { appendImplicitUndefinedReturn, hasExplicitJsDocReturn } from "./function-returns.js";
|
|
36
38
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
37
39
|
import { errorNameAfterField, errorViewFields } from "./error-name-order.js";
|
|
38
|
-
import { checkedJsDocumentedParameter, documentedParameter, generatorMeta, } from "./call-signatures.js";
|
|
40
|
+
import { checkedJsDocumentedParameter, documentedParameter, generatorMeta, generatorParamsBindAtCall, } from "./call-signatures.js";
|
|
39
41
|
import { omittedArgFor } from "./call-arguments.js";
|
|
40
|
-
import { checkerTypeDescription, isGenericCallableMemberType, jsOpenObjectType, typeKey, withUnitArm, X509_DER_FIELD, X509_PUBLIC_KEY_FIELD, } from "../type-mapper.js";
|
|
42
|
+
import { checkerTypeDescription, isGenericCallableMemberType, jsOpenObjectType, noteScopeSensitiveMapping, typeKey, withUnitArm, X509_DER_FIELD, X509_PUBLIC_KEY_FIELD, } from "../type-mapper.js";
|
|
41
43
|
import { canonicalBuiltinModule, cjsClassExprWholeExportOf, isCjsJsFile, isJsSourceFile, isModuleExportsAccess, locOf, requireSpecOf, } from "../program.js";
|
|
42
44
|
import { PoisonError, dynFallbackType, jsFuncNameOf, newFnCtx, own } from "./lowerer.js";
|
|
43
45
|
import { islandValueOrigin } from "../node-api-import.js";
|
|
@@ -62,6 +64,7 @@ import { declSymbolOf } from "./lower-modules.js";
|
|
|
62
64
|
import { INSPECT_CUSTOM_MEMBER, classSymbolKeyOf, classSymbolKeyOfSymbol, symbolFieldDisplayName, } from "./symbol-fields.js";
|
|
63
65
|
import { lowerHttpAgentNew, lowerHttpServerNew, lowerTlsSocketNew } from "./lower-server.js";
|
|
64
66
|
import { ambientNsRootOf, ambientUndefReadType, ambientUndefVarRootOf, ambientUndefinedFnSymbolOf, contextualUndefReadType, fenceEarlyAliasUse, fenceEarlyNsMemberRef, nsMemberIdentOf, nsUndefRead, } from "./lower-namespaces.js";
|
|
67
|
+
import { hostGlobalNameOfRead } from "./host-globals.js";
|
|
65
68
|
import { mixinResultBindingClassOf } from "./lower-mixins.js";
|
|
66
69
|
import { hasLexicalPrivateReference, hasStaticThis, rejectStaticThis } from "./static-this.js";
|
|
67
70
|
import { lowerUrlNew } from "./lower-url.js";
|
|
@@ -73,8 +76,8 @@ import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
|
73
76
|
import { lowerInstanceConstructorNew } from "./class-instance-constructor.js";
|
|
74
77
|
import { classPrototypeData, reflectClassPrototype } from "./class-prototypes.js";
|
|
75
78
|
import { constructionEscape } from "./construction-escapes.js";
|
|
76
|
-
import { checkedClassConstruction, checkedClassConstructionPacked } from "./class-construction.js";
|
|
77
|
-
import { initializeRuntimeStatics, hasRuntimeStatics } from "./class-runtime-statics.js";
|
|
79
|
+
import { checkedClassConstruction, checkedClassConstructionPacked, primitiveCheckedConstruction, } from "./class-construction.js";
|
|
80
|
+
import { initializeRuntimeStatics, hasRuntimeStatics, runtimeStaticDefines, } from "./class-runtime-statics.js";
|
|
78
81
|
import { reflectedClassMethodValue, reflectedClassStaticMethodValue, } from "./class-method-values.js";
|
|
79
82
|
import { identifierReadSymbol } from "./surfaces.js";
|
|
80
83
|
export function returnsOnlyThis(member) {
|
|
@@ -167,6 +170,59 @@ function perInstanceMember(node) {
|
|
|
167
170
|
return false;
|
|
168
171
|
return !ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword);
|
|
169
172
|
}
|
|
173
|
+
/** `Symbol.hasInstance` over the standard global. */
|
|
174
|
+
export function isSymbolHasInstanceKey(lowerer, key) {
|
|
175
|
+
let e = key;
|
|
176
|
+
while (ts.isParenthesizedExpression(e))
|
|
177
|
+
e = e.expression;
|
|
178
|
+
return (ts.isPropertyAccessExpression(e) &&
|
|
179
|
+
!e.questionDotToken &&
|
|
180
|
+
ts.isIdentifier(e.expression) &&
|
|
181
|
+
lowerer.isStdlibGlobal(e.expression, "Symbol") &&
|
|
182
|
+
ts.isIdentifier(e.name) &&
|
|
183
|
+
e.name.text === "hasInstance");
|
|
184
|
+
}
|
|
185
|
+
/** The static members keyed by `Symbol.hasInstance`
|
|
186
|
+
* (`static [Symbol.hasInstance](v) { … }`): defining them on the class
|
|
187
|
+
* value's own-property table gives `instanceof` its hook (the runtime
|
|
188
|
+
* consults that table, scr_dyn_has_instance_hook). */
|
|
189
|
+
export function staticHasInstanceHookMembers(lowerer, decl) {
|
|
190
|
+
return decl.members.nodes.filter((member) => {
|
|
191
|
+
const name = member.name;
|
|
192
|
+
return (name !== undefined &&
|
|
193
|
+
ts.isComputedPropertyName(name) &&
|
|
194
|
+
ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) ===
|
|
195
|
+
true &&
|
|
196
|
+
isSymbolHasInstanceKey(lowerer, name.expression));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/** Whether `info` or an ancestor declares a static `Symbol.hasInstance`
|
|
200
|
+
* member. Node's `instanceof` asks the hook on the constructor (inherited
|
|
201
|
+
* through the static prototype chain) and uses OrdinaryHasInstance only
|
|
202
|
+
* when no hook exists. */
|
|
203
|
+
export function classDeclaresHasInstanceHook(info) {
|
|
204
|
+
for (let current = info; current; current = current.base) {
|
|
205
|
+
if (current.hasInstanceHook === true)
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
/** Whether `expression` reads an element of a JavaScript array whose
|
|
211
|
+
* compiled storage is checked-dynamic (`const classes = [A, B]`; the
|
|
212
|
+
* array literal of several class constructors lowers as the checked
|
|
213
|
+
* array, and an unannotated file-scope binding keeps that layout). */
|
|
214
|
+
function jsCheckedDynamicArrayElement(lowerer, expression) {
|
|
215
|
+
if (!ts.isElementAccessExpression(expression))
|
|
216
|
+
return false;
|
|
217
|
+
if (!isJsSourceFile(ts.getSourceFileOfNode(expression)))
|
|
218
|
+
return false;
|
|
219
|
+
if (!ts.isIdentifier(expression.expression))
|
|
220
|
+
return false;
|
|
221
|
+
const stored = lowerer.peekLocal(expression.expression) ?? lowerer.globalOf(expression.expression);
|
|
222
|
+
if (!stored)
|
|
223
|
+
return false;
|
|
224
|
+
return (stored.type.kind === "dyn" || (stored.type.kind === "array" && stored.type.elem.kind === "dyn"));
|
|
225
|
+
}
|
|
170
226
|
export function storedClassValueType(lowerer, expression, visiting = new Set()) {
|
|
171
227
|
if (visiting.has(expression))
|
|
172
228
|
return null;
|
|
@@ -212,6 +268,12 @@ export function storedClassValueType(lowerer, expression, visiting = new Set())
|
|
|
212
268
|
}
|
|
213
269
|
const type = lowerer.typeOf(expression);
|
|
214
270
|
const mapped = lowerer.mapTypeOf(type);
|
|
271
|
+
// An element of a CHECKED-DYNAMIC JavaScript array (`const classes =
|
|
272
|
+
// [A, B]`, `both[1]`): the storage holds whichever constructor the array
|
|
273
|
+
// holds, so tsc's inferred element type — best common type spells the
|
|
274
|
+
// first — does not name the class the slot holds at run time.
|
|
275
|
+
if (mapped?.kind === "classval" && jsCheckedDynamicArrayElement(lowerer, expression))
|
|
276
|
+
return null;
|
|
215
277
|
if (mapped?.kind === "classval" && !lowerer.classes.has(mapped.className)) {
|
|
216
278
|
for (const signature of lowerer.checker.getConstructSignatures(type)) {
|
|
217
279
|
const constructor = signature.declaration;
|
|
@@ -1416,6 +1478,15 @@ mixin) {
|
|
|
1416
1478
|
const adoptCallableBase = (expression) => {
|
|
1417
1479
|
if (familyMode || inst || mixin)
|
|
1418
1480
|
return false;
|
|
1481
|
+
if (isJsIteratorGlobal(lowerer, expression)) {
|
|
1482
|
+
callableBase = {
|
|
1483
|
+
expression,
|
|
1484
|
+
constructorId: `%g.${className}.base`,
|
|
1485
|
+
prototypeId: `%g.${className}.basePrototype`,
|
|
1486
|
+
iterator: true,
|
|
1487
|
+
};
|
|
1488
|
+
return true;
|
|
1489
|
+
}
|
|
1419
1490
|
if (lowerer.computedCallableBases.has(decl)) {
|
|
1420
1491
|
callableBase = {
|
|
1421
1492
|
expression,
|
|
@@ -3537,7 +3608,18 @@ mixin) {
|
|
|
3537
3608
|
bodyReadsArguments(ctor)) {
|
|
3538
3609
|
ctorParams.push({ type: DYN, mode: "arguments" });
|
|
3539
3610
|
}
|
|
3611
|
+
// A static `Symbol.hasInstance` member of a class that otherwise keeps
|
|
3612
|
+
// its statics in module storage: the hook only exists if the CLASS
|
|
3613
|
+
// VALUE carries it, so the member joins the runtime property table
|
|
3614
|
+
// (initializeRuntimeStatics). Only the hook members are added; every
|
|
3615
|
+
// other static keeps its current representation.
|
|
3616
|
+
const hasInstanceHooks = staticHasInstanceHookMembers(lowerer, decl);
|
|
3617
|
+
for (const member of hasInstanceHooks) {
|
|
3618
|
+
if (!runtimeStatics.includes(member))
|
|
3619
|
+
runtimeStatics.push(member);
|
|
3620
|
+
}
|
|
3540
3621
|
const info = {
|
|
3622
|
+
...(hasInstanceHooks.length ? { hasInstanceHook: true } : {}),
|
|
3541
3623
|
...(runtimeStatics.length || checkedStatics ? { runtimeStatics } : {}),
|
|
3542
3624
|
...(runtimePrototypeMembers.length ? { runtimePrototypeMembers } : {}),
|
|
3543
3625
|
def: {
|
|
@@ -3801,6 +3883,9 @@ export function genericClassInstanceType(lowerer, decl, ref, mapArgument) {
|
|
|
3801
3883
|
// body (`this.v = v` types the receiver as `this`, not a reference).
|
|
3802
3884
|
// Inside an instantiation the CURRENT bindings are the arguments;
|
|
3803
3885
|
// anywhere else the reference is honestly unmappable.
|
|
3886
|
+
// The current instance's bindings ARE the arguments: the mapping
|
|
3887
|
+
// belongs to that instance.
|
|
3888
|
+
noteScopeSensitiveMapping();
|
|
3804
3889
|
for (const tp of gci.typeParams) {
|
|
3805
3890
|
const b = lowerer.typeParamBindings?.get(tp);
|
|
3806
3891
|
if (!b)
|
|
@@ -4134,16 +4219,23 @@ function lowerStaticFieldInitsInner(lowerer, info) {
|
|
|
4134
4219
|
}, {
|
|
4135
4220
|
kind: "assign",
|
|
4136
4221
|
localId: prototypeId,
|
|
4137
|
-
value:
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4222
|
+
value: info.callableBase.iterator
|
|
4223
|
+
? iteratorPrototypeExpr(loc)
|
|
4224
|
+
: {
|
|
4225
|
+
kind: "libCall",
|
|
4226
|
+
fn: "dyn.classBasePrototype",
|
|
4227
|
+
args: [{ kind: "varRef", localId: constructorId, type: DYN, loc }],
|
|
4228
|
+
type: DYN,
|
|
4229
|
+
loc,
|
|
4230
|
+
},
|
|
4144
4231
|
loc,
|
|
4145
4232
|
});
|
|
4146
|
-
|
|
4233
|
+
// An iterator subclass's instances are driven by the runtime's helpers,
|
|
4234
|
+
// which read `next` and `return` (methods or accessors) through the
|
|
4235
|
+
// instance's view: its prototype holds every member.
|
|
4236
|
+
const prototype = info.callableBase.iterator && info.decl
|
|
4237
|
+
? reflectClassPrototype(lowerer, info, loc, classValueRef(lowerer, info, info.decl))
|
|
4238
|
+
: classPrototypeData(lowerer, info, loc);
|
|
4147
4239
|
if (prototype)
|
|
4148
4240
|
out.push({ kind: "exprStmt", expr: prototype, loc });
|
|
4149
4241
|
out.push({
|
|
@@ -4169,10 +4261,14 @@ function lowerStaticFieldInitsInner(lowerer, info) {
|
|
|
4169
4261
|
});
|
|
4170
4262
|
}
|
|
4171
4263
|
const items = [
|
|
4172
|
-
// A runtime-statics class initializes
|
|
4173
|
-
// its other initializers
|
|
4264
|
+
// A runtime-statics class initializes the private static fields its
|
|
4265
|
+
// property table carries with its other initializers
|
|
4266
|
+
// (initializeRuntimeStatics). One whose table carries only its
|
|
4267
|
+
// `Symbol.hasInstance` hook keeps its native initializers here.
|
|
4174
4268
|
...info.staticFields
|
|
4175
|
-
.filter((f) => !(info.runtimeStatics &&
|
|
4269
|
+
.filter((f) => !(info.runtimeStatics &&
|
|
4270
|
+
f.name.startsWith("#") &&
|
|
4271
|
+
runtimeStaticDefines(lowerer, info, f.name)))
|
|
4176
4272
|
.map((f) => ({
|
|
4177
4273
|
pos: ts.tokenStartOfNode(f.initializer),
|
|
4178
4274
|
kind: "field",
|
|
@@ -4785,7 +4881,13 @@ export function lowerClassStaticRead(lowerer, info, name, receiver, site) {
|
|
|
4785
4881
|
["now", "parse", "UTC"].includes(name) &&
|
|
4786
4882
|
!(ts.isCallExpression(site.parent) && site.parent.expression === site))
|
|
4787
4883
|
lowerer.noLowering(`Date.${name} read through a class that extends Date`, site);
|
|
4788
|
-
|
|
4884
|
+
// A statically known member that the class value's table does not carry
|
|
4885
|
+
// (a class whose only runtime static is its `Symbol.hasInstance` hook)
|
|
4886
|
+
// reads its own storage, as it would without the hook.
|
|
4887
|
+
if (hasRuntimeStatics(info) &&
|
|
4888
|
+
!found?.field &&
|
|
4889
|
+
!name.startsWith("#") &&
|
|
4890
|
+
(!found || runtimeStaticDefines(lowerer, info, name)))
|
|
4789
4891
|
return {
|
|
4790
4892
|
kind: "dynKeyGet",
|
|
4791
4893
|
value: lowerer.coerceToExpected(classValueRef(lowerer, info, receiver), DYN),
|
|
@@ -4887,6 +4989,15 @@ function namedEvaluationName(expr) {
|
|
|
4887
4989
|
return p.name.text;
|
|
4888
4990
|
if (ts.isParameter(p) && ts.isIdentifier(p.name))
|
|
4889
4991
|
return p.name.text;
|
|
4992
|
+
// A destructuring default: `const [c = class {}] = []` and
|
|
4993
|
+
// `({ c = class {} } = o)` name the class after the bound identifier. An
|
|
4994
|
+
// array-literal element that is not a pattern element stays unnamed.
|
|
4995
|
+
if (ts.isBindingElement(p) && p.initializer !== undefined && ts.isIdentifier(p.name))
|
|
4996
|
+
return p.name.text;
|
|
4997
|
+
if (ts.isShorthandPropertyAssignment(p) &&
|
|
4998
|
+
p.objectAssignmentInitializer !== undefined &&
|
|
4999
|
+
ts.isIdentifier(p.name))
|
|
5000
|
+
return p.name.text;
|
|
4890
5001
|
return "";
|
|
4891
5002
|
}
|
|
4892
5003
|
/** Each evaluation of a function-local class creates fresh private names,
|
|
@@ -5225,7 +5336,15 @@ function lowerClassValue(lowerer, expr, info, binding) {
|
|
|
5225
5336
|
fn: "dyn.classPrototype",
|
|
5226
5337
|
args: [
|
|
5227
5338
|
boxed,
|
|
5228
|
-
|
|
5339
|
+
info.callableBase.iterator
|
|
5340
|
+
? iteratorPrototypeExpr(loc)
|
|
5341
|
+
: {
|
|
5342
|
+
kind: "libCall",
|
|
5343
|
+
fn: "dyn.classBasePrototype",
|
|
5344
|
+
args: [baseRef],
|
|
5345
|
+
type: DYN,
|
|
5346
|
+
loc,
|
|
5347
|
+
},
|
|
5229
5348
|
],
|
|
5230
5349
|
type: DYN,
|
|
5231
5350
|
loc,
|
|
@@ -5604,12 +5723,15 @@ function staticCallOn(lowerer, call, access, info, throughValue) {
|
|
|
5604
5723
|
if (date)
|
|
5605
5724
|
return date;
|
|
5606
5725
|
}
|
|
5726
|
+
const staticMember = findStaticOn(lowerer, info, access.name.text);
|
|
5727
|
+
// A statically known member that the class value's table does not carry
|
|
5728
|
+
// (a class whose only runtime static is its `Symbol.hasInstance` hook)
|
|
5729
|
+
// calls its own function, as it would without the hook.
|
|
5607
5730
|
if ((hasRuntimeStatics(info) &&
|
|
5608
5731
|
!access.name.text.startsWith("#") &&
|
|
5609
|
-
!
|
|
5610
|
-
(info.
|
|
5611
|
-
|
|
5612
|
-
!findGenericStaticOn(lowerer, info, access.name.text)))
|
|
5732
|
+
!staticMember?.field &&
|
|
5733
|
+
(!staticMember || runtimeStaticDefines(lowerer, info, access.name.text))) ||
|
|
5734
|
+
(info.callableBase && !staticMember && !findGenericStaticOn(lowerer, info, access.name.text)))
|
|
5613
5735
|
return {
|
|
5614
5736
|
kind: "dynInvoke",
|
|
5615
5737
|
recv: lowerer.lowerExprExpecting(access.expression, DYN),
|
|
@@ -5797,9 +5919,12 @@ function directRuntimeStaticCall(lowerer, call, access, info, throughValue) {
|
|
|
5797
5919
|
c.staticMethods?.has(name) === true ||
|
|
5798
5920
|
c.genericStatics?.has(name) === true)
|
|
5799
5921
|
return null;
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5922
|
+
// A computed name defines the key it folds to, so `static ['m']` in
|
|
5923
|
+
// this class answers for `m` and hides the inherited method.
|
|
5924
|
+
const runtime = c.runtimeStatics?.find((element) => {
|
|
5925
|
+
const elementName = element.name;
|
|
5926
|
+
return elementName !== undefined && classMemberNameOf(lowerer, elementName) === name;
|
|
5927
|
+
});
|
|
5803
5928
|
if (runtime) {
|
|
5804
5929
|
if (!ts.isMethodDeclaration(runtime) || !runtime.body)
|
|
5805
5930
|
return null;
|
|
@@ -5991,11 +6116,16 @@ export function lowerClassValueProperty(lowerer, expr) {
|
|
|
5991
6116
|
// its other statics (`Error.stackTraceLimit`) keep their own lowerings.
|
|
5992
6117
|
if (info?.def.runtime && member !== "name")
|
|
5993
6118
|
return null;
|
|
6119
|
+
const storedMember = info ? findStaticOn(lowerer, info, member) : undefined;
|
|
6120
|
+
// A statically known member that the class value's table does not carry
|
|
6121
|
+
// (a class whose only runtime static is its `Symbol.hasInstance` hook)
|
|
6122
|
+
// reads its own storage, as it would without the hook.
|
|
5994
6123
|
if (info &&
|
|
5995
6124
|
((hasRuntimeStatics(info) &&
|
|
5996
6125
|
!member.startsWith("#") &&
|
|
5997
|
-
!
|
|
5998
|
-
(
|
|
6126
|
+
!storedMember?.field &&
|
|
6127
|
+
(!storedMember || runtimeStaticDefines(lowerer, info, member))) ||
|
|
6128
|
+
(info.callableBase && !storedMember)))
|
|
5999
6129
|
return {
|
|
6000
6130
|
kind: "dynKeyGet",
|
|
6001
6131
|
value: lowerer.lowerExprExpecting(expr.expression, DYN),
|
|
@@ -6837,6 +6967,20 @@ function lowerClassCtorInner(lowerer, info) {
|
|
|
6837
6967
|
const thisLocal = lowerer.declareThis(thisType);
|
|
6838
6968
|
const params = [{ localId: thisLocal.id, name: "this", type: thisType }];
|
|
6839
6969
|
const body = [];
|
|
6970
|
+
// A derived constructor that can return a primitive records the pending
|
|
6971
|
+
// TypeError for the construction site to raise. Drop a stale record on
|
|
6972
|
+
// entry: a `finally` that throws after the return abandons the
|
|
6973
|
+
// construction before any site reads it.
|
|
6974
|
+
const pendingPrimitive = constructorPrimitiveFlag(lowerer, info);
|
|
6975
|
+
if (pendingPrimitive !== null) {
|
|
6976
|
+
const clearLoc = locOf(info.ctor ?? info.decl);
|
|
6977
|
+
body.push({
|
|
6978
|
+
kind: "assign",
|
|
6979
|
+
localId: pendingPrimitive.id,
|
|
6980
|
+
value: { kind: "boolLit", value: false, type: BOOL, loc: clearLoc },
|
|
6981
|
+
loc: clearLoc,
|
|
6982
|
+
});
|
|
6983
|
+
}
|
|
6840
6984
|
// The construction-relevant base: generic families are transparent
|
|
6841
6985
|
// (an instantiation of a base-less generic class IS a base class —
|
|
6842
6986
|
// its source has no super()).
|
|
@@ -7510,7 +7654,16 @@ function lowerClassMethodBody(lowerer, info, fnLike, fnName, sig) {
|
|
|
7510
7654
|
if (shape.mode === "arguments")
|
|
7511
7655
|
fnCtx.argumentsLocal = local;
|
|
7512
7656
|
}
|
|
7513
|
-
|
|
7657
|
+
// See lowerFunction: a generator binds its parameters at the CALL
|
|
7658
|
+
// (FunctionDeclarationInstantiation runs before GeneratorStart) exactly
|
|
7659
|
+
// when that is observable — a destructuring or rest pattern, a default
|
|
7660
|
+
// that evaluates anything, or a body that reads `arguments`.
|
|
7661
|
+
const bindsAtCall = genCh !== null && declared.prologue.length > 0 && generatorParamsBindAtCall(fnLike);
|
|
7662
|
+
const body = [
|
|
7663
|
+
...declared.prologue,
|
|
7664
|
+
...(bindsAtCall ? [{ kind: "genBindBarrier", loc: locOf(fnLike) }] : []),
|
|
7665
|
+
...lowerer.lowerStmts(fnLike.body.statements.nodes),
|
|
7666
|
+
];
|
|
7514
7667
|
appendImplicitUndefinedReturn(lowerer, body, bodyReturn, locOf(fnLike));
|
|
7515
7668
|
const fn = {
|
|
7516
7669
|
name: fnName,
|
|
@@ -7524,7 +7677,7 @@ function lowerClassMethodBody(lowerer, info, fnLike, fnName, sig) {
|
|
|
7524
7677
|
if (isAsync)
|
|
7525
7678
|
fn.async = true;
|
|
7526
7679
|
if (genCh !== null)
|
|
7527
|
-
fn.generator = genCh;
|
|
7680
|
+
fn.generator = bindsAtCall ? { ...genCh, bindAtCall: true } : genCh;
|
|
7528
7681
|
return fn;
|
|
7529
7682
|
}
|
|
7530
7683
|
finally {
|
|
@@ -7570,7 +7723,14 @@ export function lowerStaticMethod(lowerer, info, name) {
|
|
|
7570
7723
|
declared.params.push({ localId: local.id, name: "%arguments", type: DYN });
|
|
7571
7724
|
fnCtx.argumentsLocal = local;
|
|
7572
7725
|
}
|
|
7573
|
-
|
|
7726
|
+
// See lowerFunction: a generator binds its parameters at the CALL
|
|
7727
|
+
// exactly when that is observable.
|
|
7728
|
+
const bindsAtCall = genCh !== null && declared.prologue.length > 0 && generatorParamsBindAtCall(entry.member);
|
|
7729
|
+
const body = [
|
|
7730
|
+
...declared.prologue,
|
|
7731
|
+
...(bindsAtCall ? [{ kind: "genBindBarrier", loc: locOf(entry.member) }] : []),
|
|
7732
|
+
...lowerer.lowerStmts(entry.member.body.statements.nodes),
|
|
7733
|
+
];
|
|
7574
7734
|
appendImplicitUndefinedReturn(lowerer, body, bodyReturn, locOf(entry.member));
|
|
7575
7735
|
const fn = {
|
|
7576
7736
|
name: `%${info.def.name}.static:${name}`,
|
|
@@ -7583,7 +7743,7 @@ export function lowerStaticMethod(lowerer, info, name) {
|
|
|
7583
7743
|
if (isAsync)
|
|
7584
7744
|
fn.async = true;
|
|
7585
7745
|
if (genCh !== null)
|
|
7586
|
-
fn.generator = genCh;
|
|
7746
|
+
fn.generator = bindsAtCall ? { ...genCh, bindAtCall: true } : genCh;
|
|
7587
7747
|
return fn;
|
|
7588
7748
|
}
|
|
7589
7749
|
catch (e) {
|
|
@@ -7988,6 +8148,10 @@ export function superCallStmt(lowerer, info, thisLocal, args, loc) {
|
|
|
7988
8148
|
return dateSuperCall(thisRef, info, args[0], loc);
|
|
7989
8149
|
if (info.extendsArray)
|
|
7990
8150
|
return arraySuperCall(info, thisRef, args[0], loc);
|
|
8151
|
+
// super() into %Iterator%: NewTarget is the subclass, so the abstract
|
|
8152
|
+
// constructor only creates the receiver the derived constructor made.
|
|
8153
|
+
if (info.callableBase?.iterator)
|
|
8154
|
+
return { kind: "exprStmt", expr: args[0], loc };
|
|
7991
8155
|
if (info.callableBase)
|
|
7992
8156
|
return {
|
|
7993
8157
|
kind: "exprStmt",
|
|
@@ -8620,13 +8784,162 @@ function checkedElementConstruction(lowerer, info, narrowed, args, loc) {
|
|
|
8620
8784
|
loc,
|
|
8621
8785
|
};
|
|
8622
8786
|
}
|
|
8787
|
+
/** `new x.someLibMethod(...)`: a built-in method is not a constructor.
|
|
8788
|
+
* Node evaluates the receiver, reads the member, evaluates the arguments,
|
|
8789
|
+
* then throws `TypeError: <callee> is not a constructor` (V8 prints an
|
|
8790
|
+
* anonymous intermediate value as `(intermediate value)`). On a typed
|
|
8791
|
+
* receiver and on %Iterator.prototype% the member is the built-in method.
|
|
8792
|
+
* Any other checked-dynamic receiver may hold any value: the read throws
|
|
8793
|
+
* Node's TypeError for undefined and null before any argument evaluates
|
|
8794
|
+
* and runs an accessor, and a function it answers constructs as for any
|
|
8795
|
+
* dynamic callee. Null otherwise. */
|
|
8796
|
+
function lowerNonConstructorNew(lowerer, expr) {
|
|
8797
|
+
let callee = expr.expression;
|
|
8798
|
+
while (ts.isParenthesizedExpression(callee))
|
|
8799
|
+
callee = callee.expression;
|
|
8800
|
+
if (!ts.isPropertyAccessExpression(callee) || callee.questionDotToken)
|
|
8801
|
+
return null;
|
|
8802
|
+
if (!lowerer.isStdlibMember(callee))
|
|
8803
|
+
return null;
|
|
8804
|
+
const symbol = lowerer.checker.getSymbolAtLocation(callee.name);
|
|
8805
|
+
const method = symbol?.declarations?.some((decl) => ts.isMethodSignatureDeclaration(decl) || ts.isMethodDeclaration(decl));
|
|
8806
|
+
if (!method)
|
|
8807
|
+
return null;
|
|
8808
|
+
const args = expr.arguments?.nodes ?? [];
|
|
8809
|
+
if (args.some(ts.isSpreadElement))
|
|
8810
|
+
return null;
|
|
8811
|
+
const loc = locOf(expr);
|
|
8812
|
+
let receiver = callee.expression;
|
|
8813
|
+
while (ts.isParenthesizedExpression(receiver))
|
|
8814
|
+
receiver = receiver.expression;
|
|
8815
|
+
const left = ts.isClassExpression(receiver) ||
|
|
8816
|
+
ts.isFunctionExpression(receiver) ||
|
|
8817
|
+
ts.isArrowFunction(receiver)
|
|
8818
|
+
? "(intermediate value)"
|
|
8819
|
+
: ts.getTextOfNode(receiver);
|
|
8820
|
+
const message = `${left}.${callee.name.text} is not a constructor`;
|
|
8821
|
+
const recv = lowerer.lowerExpr(receiver);
|
|
8822
|
+
// %Iterator.prototype% (scr_js_iterator.c) holds the runtime's helpers.
|
|
8823
|
+
const intrinsic = recv.kind === "libCall" && recv.fn === "iterator.prototype";
|
|
8824
|
+
if (intrinsic || (recv.type.kind !== "dyn" && recv.type.kind !== "union")) {
|
|
8825
|
+
const stmts = [
|
|
8826
|
+
{ kind: "exprStmt", expr: recv, loc: locOf(receiver) },
|
|
8827
|
+
...args.map((arg) => ({
|
|
8828
|
+
kind: "exprStmt",
|
|
8829
|
+
expr: lowerer.lowerExpr(arg),
|
|
8830
|
+
loc: locOf(arg),
|
|
8831
|
+
})),
|
|
8832
|
+
];
|
|
8833
|
+
return {
|
|
8834
|
+
kind: "seqExpr",
|
|
8835
|
+
stmts,
|
|
8836
|
+
result: nodeThrowExpr(1, "", message, DYN, loc),
|
|
8837
|
+
type: DYN,
|
|
8838
|
+
loc,
|
|
8839
|
+
};
|
|
8840
|
+
}
|
|
8841
|
+
const member = lowerer.declareHiddenLocal("%newMember", DYN);
|
|
8842
|
+
const stmts = [
|
|
8843
|
+
{
|
|
8844
|
+
kind: "varDecl",
|
|
8845
|
+
localId: member.id,
|
|
8846
|
+
init: {
|
|
8847
|
+
kind: "dynKeyGet",
|
|
8848
|
+
key: strLit(callee.name.text, loc),
|
|
8849
|
+
value: lowerer.coerceToExpected(recv, DYN),
|
|
8850
|
+
type: DYN,
|
|
8851
|
+
loc: locOf(callee),
|
|
8852
|
+
},
|
|
8853
|
+
loc: locOf(callee),
|
|
8854
|
+
},
|
|
8855
|
+
];
|
|
8856
|
+
const argRefs = args.map((arg) => {
|
|
8857
|
+
const local = lowerer.declareHiddenLocal("%newArg", DYN);
|
|
8858
|
+
stmts.push({
|
|
8859
|
+
kind: "varDecl",
|
|
8860
|
+
localId: local.id,
|
|
8861
|
+
init: lowerer.coerceToExpected(lowerer.lowerExpr(arg), DYN),
|
|
8862
|
+
loc: locOf(arg),
|
|
8863
|
+
});
|
|
8864
|
+
return varRef(local.id, DYN, loc);
|
|
8865
|
+
});
|
|
8866
|
+
return {
|
|
8867
|
+
kind: "seqExpr",
|
|
8868
|
+
stmts,
|
|
8869
|
+
result: {
|
|
8870
|
+
kind: "ternary",
|
|
8871
|
+
cond: {
|
|
8872
|
+
kind: "dynTest",
|
|
8873
|
+
test: "function",
|
|
8874
|
+
value: varRef(member.id, DYN, loc),
|
|
8875
|
+
type: BOOL,
|
|
8876
|
+
loc,
|
|
8877
|
+
},
|
|
8878
|
+
then: checkedClassConstruction(lowerer, varRef(member.id, DYN, loc), argRefs, loc, `${left}.${callee.name.text}`),
|
|
8879
|
+
else_: nodeThrowExpr(1, "", message, DYN, loc),
|
|
8880
|
+
type: DYN,
|
|
8881
|
+
loc,
|
|
8882
|
+
},
|
|
8883
|
+
type: DYN,
|
|
8884
|
+
loc,
|
|
8885
|
+
};
|
|
8886
|
+
}
|
|
8623
8887
|
/** Map, Set and the error classes construct in lowerNew's identifier
|
|
8624
8888
|
* branch, which a module member alias of one (`new mod.M()`) also takes. */
|
|
8625
8889
|
function isCollectionOrErrorClass(ref) {
|
|
8626
8890
|
return ref?.kind === "collection" || ref?.kind === "error";
|
|
8627
8891
|
}
|
|
8892
|
+
/** `new url.URL(...)` / `new url.URLSearchParams(...)`: the member of a
|
|
8893
|
+
* node:url binding (a namespace import, a require result, or an import=
|
|
8894
|
+
* alias) resolves to the stdlib class symbol the named import binds, so the
|
|
8895
|
+
* construction takes the same lowering. A binding that holds the class
|
|
8896
|
+
* (`const U = url.URL`) follows its initializer to the same symbol. */
|
|
8897
|
+
function stdlibUrlClassOf(lowerer, callee) {
|
|
8898
|
+
const classNamed = (sym) => {
|
|
8899
|
+
if (!sym || !lowerer.isStdlibSymbol(sym))
|
|
8900
|
+
return null;
|
|
8901
|
+
const name = ts.symbolName(sym);
|
|
8902
|
+
return name === "URL" || name === "URLSearchParams" ? name : null;
|
|
8903
|
+
};
|
|
8904
|
+
const aliased = (raw) => raw && raw.flags & ts.SymbolFlags.Alias ? lowerer.checker.getAliasedSymbol(raw) : raw;
|
|
8905
|
+
let selected = callee;
|
|
8906
|
+
for (let hops = 0; hops < 4; hops++) {
|
|
8907
|
+
while (ts.isParenthesizedExpression(selected))
|
|
8908
|
+
selected = selected.expression;
|
|
8909
|
+
if (ts.isPropertyAccessExpression(selected) && !selected.questionDotToken) {
|
|
8910
|
+
return classNamed(aliased(lowerer.checker.getSymbolAtLocation(selected.name)));
|
|
8911
|
+
}
|
|
8912
|
+
if (!ts.isIdentifier(selected))
|
|
8913
|
+
return null;
|
|
8914
|
+
const sym = aliased(lowerer.checker.getSymbolAtLocation(selected));
|
|
8915
|
+
if (!sym)
|
|
8916
|
+
return null;
|
|
8917
|
+
const known = classNamed(sym);
|
|
8918
|
+
if (known !== null)
|
|
8919
|
+
return known;
|
|
8920
|
+
const decl = sym.valueDeclaration;
|
|
8921
|
+
if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)
|
|
8922
|
+
return null;
|
|
8923
|
+
let next = decl.initializer;
|
|
8924
|
+
while (ts.isParenthesizedExpression(next))
|
|
8925
|
+
next = next.expression;
|
|
8926
|
+
if (next === selected)
|
|
8927
|
+
return null;
|
|
8928
|
+
selected = next;
|
|
8929
|
+
}
|
|
8930
|
+
return null;
|
|
8931
|
+
}
|
|
8628
8932
|
export function lowerNew(lowerer, expr) {
|
|
8629
8933
|
const loc = locOf(expr);
|
|
8934
|
+
// Constructing a Node 24 global the native runtime does not provide
|
|
8935
|
+
// (WebSocket, FormData, …): the value a read answers refuses construction
|
|
8936
|
+
// (host-global-values.ts), so the construction is that refusal — SC2020,
|
|
8937
|
+
// which a JavaScript source defers to the throw at this statement.
|
|
8938
|
+
{
|
|
8939
|
+
const hostGlobal = hostGlobalNameOfRead(lowerer, expr.expression);
|
|
8940
|
+
if (hostGlobal !== null)
|
|
8941
|
+
lowerer.hostGlobalFence(hostGlobal, expr.expression);
|
|
8942
|
+
}
|
|
8630
8943
|
// The deprecated `new Buffer(...)` (containers/bytes.ts).
|
|
8631
8944
|
{
|
|
8632
8945
|
const buffer = lowerBufferConstruct(lowerer, expr);
|
|
@@ -8654,9 +8967,25 @@ export function lowerNew(lowerer, expr) {
|
|
|
8654
8967
|
return lowerWithInlineRequireInit(lowerer, req, () => lowerNew(lowerer, expr));
|
|
8655
8968
|
}
|
|
8656
8969
|
}
|
|
8970
|
+
// `new url.URL(input)` / `new url.URLSearchParams(init?)`: the node:url
|
|
8971
|
+
// member names the same class the named import does, so both take the
|
|
8972
|
+
// class's own lowering (including its argument diagnostics).
|
|
8973
|
+
{
|
|
8974
|
+
const urlClass = stdlibUrlClassOf(lowerer, expr.expression);
|
|
8975
|
+
if (urlClass === "URL")
|
|
8976
|
+
return lowerUrlNew(lowerer, expr);
|
|
8977
|
+
if (urlClass === "URLSearchParams")
|
|
8978
|
+
return lowerSearchParamsNew(lowerer, expr, loc);
|
|
8979
|
+
}
|
|
8657
8980
|
const wrapper = lowerWrapperNew(lowerer, expr);
|
|
8658
8981
|
if (wrapper)
|
|
8659
8982
|
return wrapper;
|
|
8983
|
+
const abstractIterator = lowerIteratorNew(lowerer, expr);
|
|
8984
|
+
if (abstractIterator)
|
|
8985
|
+
return abstractIterator;
|
|
8986
|
+
const nonConstructor = lowerNonConstructorNew(lowerer, expr);
|
|
8987
|
+
if (nonConstructor)
|
|
8988
|
+
return nonConstructor;
|
|
8660
8989
|
const worker = lowerWorkerNew(lowerer, expr);
|
|
8661
8990
|
if (worker)
|
|
8662
8991
|
return worker;
|
|
@@ -9177,7 +9506,21 @@ export function lowerNew(lowerer, expr) {
|
|
|
9177
9506
|
if (args.some(ts.isSpreadElement))
|
|
9178
9507
|
lowerer.noLowering("new RegExp with spread arguments", expr);
|
|
9179
9508
|
const values = args.map((arg) => lowerer.lowerExpr(arg));
|
|
9180
|
-
|
|
9509
|
+
// The statically spelled form below needs a string or undefined in
|
|
9510
|
+
// each slot. Every other value — a `dyn` or `regex` argument, and
|
|
9511
|
+
// any primitive or object the static form cannot spell, such as a
|
|
9512
|
+
// boolean, number or null flags argument — reaches the runtime's
|
|
9513
|
+
// JavaScript ToString, exactly the coercion the spec's RegExp
|
|
9514
|
+
// builtin performs, so an invalid flags string throws Node's
|
|
9515
|
+
// SyntaxError at construction instead of refusing the build.
|
|
9516
|
+
const stringSlot = (value) => value.type.kind === "string" ||
|
|
9517
|
+
value.type.kind === "undefinedT" ||
|
|
9518
|
+
(value.type.kind === "union" &&
|
|
9519
|
+
(lowerer.unions
|
|
9520
|
+
.get(value.type.unionId)
|
|
9521
|
+
?.arms.every((arm) => arm.kind === "string" || arm.kind === "undefinedT") ??
|
|
9522
|
+
false));
|
|
9523
|
+
if (values.some((value) => value.type.kind === "dyn" || value.type.kind === "regex" || !stringSlot(value))) {
|
|
9181
9524
|
const checked = [0, 1].map((index) => values[index]
|
|
9182
9525
|
? lowerer.coerceInto(args[index], values[index], DYN)
|
|
9183
9526
|
: dynUndefinedExpr(loc));
|
|
@@ -9189,7 +9532,9 @@ export function lowerNew(lowerer, expr) {
|
|
|
9189
9532
|
loc,
|
|
9190
9533
|
};
|
|
9191
9534
|
}
|
|
9192
|
-
|
|
9535
|
+
// Every slot reaches here as a string or a nullish cover of one: the
|
|
9536
|
+
// checked path above took every other value.
|
|
9537
|
+
const strArg = (a) => {
|
|
9193
9538
|
if (!a)
|
|
9194
9539
|
return { kind: "strLit", value: "", type: STRING, loc };
|
|
9195
9540
|
const v = values[args.indexOf(a)];
|
|
@@ -9205,19 +9550,13 @@ export function lowerNew(lowerer, expr) {
|
|
|
9205
9550
|
loc,
|
|
9206
9551
|
};
|
|
9207
9552
|
}
|
|
9208
|
-
if (v.type.kind === "union"
|
|
9209
|
-
lowerer.unions
|
|
9210
|
-
.get(v.type.unionId)
|
|
9211
|
-
?.arms.every((arm) => arm.kind === "string" || arm.kind === "undefinedT")) {
|
|
9553
|
+
if (v.type.kind === "union") {
|
|
9212
9554
|
return { kind: "nullish", left: v, right: empty, type: STRING, loc: locOf(a) };
|
|
9213
9555
|
}
|
|
9214
|
-
if (v.type.kind !== "string") {
|
|
9215
|
-
lowerer.noLowering(`new RegExp with a '${lowerer.fmt(v.type)}' ${what}`, a, "string or undefined arguments are the lowered form (a RegExp copy or ToString coercion has no lowering)");
|
|
9216
|
-
}
|
|
9217
9556
|
return v;
|
|
9218
9557
|
};
|
|
9219
|
-
const pattern = strArg(args[0]
|
|
9220
|
-
const flags = strArg(args[1]
|
|
9558
|
+
const pattern = strArg(args[0]);
|
|
9559
|
+
const flags = strArg(args[1]);
|
|
9221
9560
|
// Node accepts the 'd' flag the engine does not have; a literal
|
|
9222
9561
|
// flags string refuses here like the literal regex form.
|
|
9223
9562
|
if (flags.kind === "strLit" && args[1] !== undefined && flags.value.includes("d")) {
|
|
@@ -9749,7 +10088,16 @@ export function lowerNew(lowerer, expr) {
|
|
|
9749
10088
|
// TextEncoder, ...) typechecks and reports SC2020 here. The named
|
|
9750
10089
|
// families carry pointed hints: each states WHY no honest static
|
|
9751
10090
|
// lowering exists (or what to use instead).
|
|
9752
|
-
|
|
10091
|
+
// `new BigInt64Array(...)` / `new BigUint64Array(...)` are exempt where
|
|
10092
|
+
// the checked-dynamic tier exists: the typed IR has no BigInt element
|
|
10093
|
+
// kind, so these construct through the typed-array constructor VALUE
|
|
10094
|
+
// (the checked-construction fallback below, whose runtime build reads and
|
|
10095
|
+
// stores BigInt elements). Static code keeps the refusal.
|
|
10096
|
+
const bigintBytesCtor = ts.isIdentifier(identifier) &&
|
|
10097
|
+
symbol != null &&
|
|
10098
|
+
BIGINT_BYTES_NAMES.has(ts.symbolName(symbol)) &&
|
|
10099
|
+
isJsSourceFile(ts.getSourceFileOfNode(expr));
|
|
10100
|
+
if (!bigintBytesCtor && lowerer.isStdlibSymbol(symbol ?? undefined)) {
|
|
9753
10101
|
const ctorHints = {
|
|
9754
10102
|
RegExp: "use a regex literal (/pattern/flags) — constructed regexes have no lowering",
|
|
9755
10103
|
String: "boxed wrapper objects have no lowering — use the string primitive (the box is only distinguishable via typeof/identity, which nothing here can honor)",
|
|
@@ -9990,6 +10338,31 @@ export function lowerNew(lowerer, expr) {
|
|
|
9990
10338
|
}
|
|
9991
10339
|
// Checked construction supports emitted classes and builtin typed arrays.
|
|
9992
10340
|
const callee = tryLowerExpression(lowerer, expr.expression);
|
|
10341
|
+
// A callee whose VALUE is a primitive (`new (null)()`, `new (5)()`, and a
|
|
10342
|
+
// union whose arms are all primitives): JavaScript's IsConstructor step
|
|
10343
|
+
// throws Node's TypeError, which names the constructed expression. V8
|
|
10344
|
+
// evaluates the callee, then every argument, and only then checks, so the
|
|
10345
|
+
// arguments lower for their effects ahead of the throw.
|
|
10346
|
+
if (callee &&
|
|
10347
|
+
isPrimitiveValueType(callee.type) &&
|
|
10348
|
+
!isBuiltinIdentityToken(lowerer, expr.expression, callee)) {
|
|
10349
|
+
return primitiveCalleeThrow(lowerer, expr, callee, loc);
|
|
10350
|
+
}
|
|
10351
|
+
if (callee && callee.type.kind === "union") {
|
|
10352
|
+
const arms = lowerer.unions.get(callee.type.unionId)?.arms ?? [];
|
|
10353
|
+
if (arms.length > 0 && arms.every(isPrimitiveValueType)) {
|
|
10354
|
+
return primitiveCalleeThrow(lowerer, expr, callee, loc);
|
|
10355
|
+
}
|
|
10356
|
+
}
|
|
10357
|
+
// A callee the CHECKER types as a primitive that still lowers to a
|
|
10358
|
+
// dynamic slot (`const n = null`, or a property whose initializer was
|
|
10359
|
+
// null): the same Node TypeError, but the value decides at run time,
|
|
10360
|
+
// because a JavaScript property keeps its initializer's type through a
|
|
10361
|
+
// later assignment (`reg.ctor = Foo; new reg.ctor()`). A typed
|
|
10362
|
+
// construction site and an `any` callee keep the lowering they had.
|
|
10363
|
+
if (callee && callee.type.kind === "dyn" && staticallyPrimitive(lowerer, expr.expression)) {
|
|
10364
|
+
return primitiveCheckedNew(lowerer, expr, callee, loc);
|
|
10365
|
+
}
|
|
9993
10366
|
if (callee &&
|
|
9994
10367
|
(callee.type.kind === "dyn" ||
|
|
9995
10368
|
((callee.type.kind === "func" || callee.type.kind === "classval") &&
|
|
@@ -10016,6 +10389,57 @@ function lowerCheckedConstructor(lowerer, expr, callee) {
|
|
|
10016
10389
|
}
|
|
10017
10390
|
return checkedClassConstruction(lowerer, callee, args.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), loc);
|
|
10018
10391
|
}
|
|
10392
|
+
/** A checker-primitive callee whose value is a dynamic slot: the callee and
|
|
10393
|
+
* every argument evaluate, then the runtime primitive check throws Node's
|
|
10394
|
+
* "<callee> is not a constructor" — or, when the slot holds something else
|
|
10395
|
+
* after all, constructs it as a dynamic `new` always did. */
|
|
10396
|
+
function primitiveCheckedNew(lowerer, expr, callee, loc) {
|
|
10397
|
+
const message = `${constructorSpelling(expr.expression)} is not a constructor`;
|
|
10398
|
+
const args = expr.arguments?.nodes ?? [];
|
|
10399
|
+
if (args.some(ts.isSpreadElement)) {
|
|
10400
|
+
const packed = lowerer.completeArgs(args, [{ type: DYN, mode: "dynRest" }], loc, expr)[0];
|
|
10401
|
+
return primitiveCheckedConstruction(lowerer, callee, message, [], loc, packed);
|
|
10402
|
+
}
|
|
10403
|
+
return primitiveCheckedConstruction(lowerer, callee, message, args.map((arg) => lowerer.lowerExprExpecting(arg, DYN)), loc);
|
|
10404
|
+
}
|
|
10405
|
+
/** The always-throwing construction of a provably primitive callee. */
|
|
10406
|
+
function primitiveCalleeThrow(lowerer, expr, callee, loc) {
|
|
10407
|
+
const args = expr.arguments?.nodes ?? [];
|
|
10408
|
+
const effects = [callee];
|
|
10409
|
+
if (args.some(ts.isSpreadElement)) {
|
|
10410
|
+
effects.push(lowerer.completeArgs(args, [{ type: DYN, mode: "dynRest" }], loc, expr)[0]);
|
|
10411
|
+
}
|
|
10412
|
+
else {
|
|
10413
|
+
for (const arg of args)
|
|
10414
|
+
effects.push(lowerer.lowerExpr(arg));
|
|
10415
|
+
}
|
|
10416
|
+
return throwAfterEach(effects, throwTypeError(strLit(`${constructorSpelling(expr.expression)} is not a constructor`, loc), DYN, loc), loc);
|
|
10417
|
+
}
|
|
10418
|
+
/** The constructed expression as V8 names it in "is not a constructor": its
|
|
10419
|
+
* source text, without the parentheses that only group it (`new (null)()`
|
|
10420
|
+
* reports "null is not a constructor") and with a call's argument list
|
|
10421
|
+
* abbreviated to "..." (`new (factory(null))()` reports "factory(...)",
|
|
10422
|
+
* `new (factory(o).f)()` "factory(...).f", `new o["f"]()` "o.f"). A comma
|
|
10423
|
+
* expression keeps V8's own "(a , b)" spelling. */
|
|
10424
|
+
function constructorSpelling(node) {
|
|
10425
|
+
let spelled = node;
|
|
10426
|
+
while (ts.isParenthesizedExpression(spelled))
|
|
10427
|
+
spelled = spelled.expression;
|
|
10428
|
+
if (ts.isCallExpression(spelled))
|
|
10429
|
+
return `${constructorSpelling(spelled.expression)}(...)`;
|
|
10430
|
+
if (ts.isPropertyAccessExpression(spelled)) {
|
|
10431
|
+
return `${constructorSpelling(spelled.expression)}.${spelled.name.text}`;
|
|
10432
|
+
}
|
|
10433
|
+
if (ts.isElementAccessExpression(spelled) &&
|
|
10434
|
+
ts.isStringLiteralLike(spelled.argumentExpression) &&
|
|
10435
|
+
/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(spelled.argumentExpression.text)) {
|
|
10436
|
+
return `${constructorSpelling(spelled.expression)}.${spelled.argumentExpression.text}`;
|
|
10437
|
+
}
|
|
10438
|
+
if (ts.isBinaryExpression(spelled) && spelled.operatorToken.kind === ts.SyntaxKind.CommaToken) {
|
|
10439
|
+
return `(${constructorSpelling(spelled.left)} , ${constructorSpelling(spelled.right)})`;
|
|
10440
|
+
}
|
|
10441
|
+
return spelled.getText();
|
|
10442
|
+
}
|
|
10019
10443
|
/** A getter/setter invocation over an accessor target's receiver — the
|
|
10020
10444
|
* same whole-program devirtualization as method calls: a virtualCall
|
|
10021
10445
|
* when some strict subclass of the receiver's static class overrides
|