@scriptc/compiler 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +490 -39
- package/dist/backend/cycle-analysis.js +6 -1
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/llvm/alloc.js +24 -10
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +47 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/array-search.d.ts +8 -0
- package/dist/backend/llvm/array-search.js +52 -0
- package/dist/backend/llvm/array-search.js.map +1 -0
- package/dist/backend/llvm/array-search.test.d.ts +1 -0
- package/dist/backend/llvm/array-search.test.js +72 -0
- package/dist/backend/llvm/array-search.test.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.d.ts +8 -1
- package/dist/backend/llvm/call-lifetimes.js +33 -11
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +54 -0
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/classes.js +87 -36
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +1 -1
- package/dist/backend/llvm/common.js +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +5 -0
- package/dist/backend/llvm/dense-array-access.js +1 -1
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +73 -9
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +65 -14
- package/dist/backend/llvm/emitter.js +297 -81
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +26 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +52 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +11 -0
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +16 -2
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +8 -1
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +42 -15
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +19 -8
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +28 -30
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +8 -4
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +35 -32
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +13 -2
- package/dist/backend/llvm/expr-stream-callbacks.js +80 -5
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/inline-unions.d.ts +48 -0
- package/dist/backend/llvm/inline-unions.js +134 -0
- package/dist/backend/llvm/inline-unions.js.map +1 -0
- package/dist/backend/llvm/inline-unions.test.d.ts +1 -0
- package/dist/backend/llvm/inline-unions.test.js +124 -0
- package/dist/backend/llvm/inline-unions.test.js.map +1 -0
- package/dist/backend/llvm/integer-remainder.d.ts +28 -5
- package/dist/backend/llvm/integer-remainder.js +80 -9
- package/dist/backend/llvm/integer-remainder.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +163 -28
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +125 -7
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +9 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +2 -2
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +132 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +97 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +7 -3
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +6 -3
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +2 -0
- package/dist/backend/llvm/local-union-storage.js +5 -0
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +8 -2
- package/dist/backend/llvm/loop-array-borrows.js +93 -13
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +20 -0
- package/dist/backend/llvm/map-number-lookup.js +66 -0
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.d.ts +1 -0
- package/dist/backend/llvm/map-number-lookup.test.js +102 -0
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.js +1 -0
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +4 -0
- package/dist/backend/llvm/publish.js +3 -1
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +8 -5
- package/dist/backend/llvm/record-results.js +20 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +13 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +14 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regions.d.ts +1 -0
- package/dist/backend/llvm/regions.js +12 -7
- package/dist/backend/llvm/regions.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +2 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +56 -10
- package/dist/backend/llvm/shapes.js +178 -39
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +61 -3
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/stack-objects.js +16 -4
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/stack-objects.test.js +3 -0
- package/dist/backend/llvm/stack-objects.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +11 -0
- package/dist/backend/llvm/walkers.js +106 -10
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +9 -4
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +2 -2
- package/dist/backend/native/executable.js +14 -3
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +1 -1
- package/dist/backend/native-toolchain.test.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-targets.test.js +1 -1
- package/dist/backend/runtime-pack.test.js +1 -1
- package/dist/backend/target-diagnostics.js +4 -1
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +4 -1
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/compat/fetch-profile.js +4 -4
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/contracts/check.js +2 -0
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.js +1 -1
- package/dist/coverage/report.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +6 -5
- package/dist/diagnostics/diagnostic.js +7 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +1 -1
- package/dist/frontend/builtin-modules.js +1 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/comptime-node.js +2 -2
- package/dist/frontend/comptime-node.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +1 -1
- package/dist/frontend/lowering/binding-analysis.js +1 -1
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +8 -4
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/blob.d.ts +20 -0
- package/dist/frontend/lowering/builtins/blob.js +167 -0
- package/dist/frontend/lowering/builtins/blob.js.map +1 -0
- package/dist/frontend/lowering/builtins/child-process-async.d.ts +2 -2
- package/dist/frontend/lowering/builtins/child-process-async.js +2 -2
- package/dist/frontend/lowering/builtins/child-process-methods.js +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.js +3 -2
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +415 -120
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +10 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +89 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +16 -7
- package/dist/frontend/lowering/builtins/filesystem.js +97 -15
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-glob.d.ts +23 -0
- package/dist/frontend/lowering/builtins/fs-glob.js +224 -0
- package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -0
- package/dist/frontend/lowering/builtins/key-object.d.ts +13 -0
- package/dist/frontend/lowering/builtins/key-object.js +56 -0
- package/dist/frontend/lowering/builtins/key-object.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-calls.js +44 -11
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/performance.d.ts +25 -3
- package/dist/frontend/lowering/builtins/performance.js +340 -5
- package/dist/frontend/lowering/builtins/performance.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +2 -2
- package/dist/frontend/lowering/builtins/process.js +107 -14
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.d.ts +0 -7
- package/dist/frontend/lowering/builtins/properties.js +39 -11
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +23 -8
- package/dist/frontend/lowering/builtins/readline.js +266 -90
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.d.ts +8 -0
- package/dist/frontend/lowering/builtins/url.js +36 -0
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.js +1 -1
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.js +20 -2
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +2 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +105 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocol-dispatch.d.ts +45 -0
- package/dist/frontend/lowering/class-protocol-dispatch.js +516 -0
- package/dist/frontend/lowering/class-protocol-dispatch.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -1
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +3 -3
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/collation-repertoire.js +6 -5
- package/dist/frontend/lowering/collation-repertoire.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +4 -7
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.d.ts +0 -7
- package/dist/frontend/lowering/containers/array-methods.js +43 -2
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +38 -26
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/for-of.d.ts +1 -1
- package/dist/frontend/lowering/containers/for-of.js +5 -1
- package/dist/frontend/lowering/containers/for-of.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +77 -12
- package/dist/frontend/lowering/crypto-tables.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +10 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +16 -12
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +2 -2
- package/dist/frontend/lowering/generic-functions.js +2 -2
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/lower-array-sort.d.ts +12 -1
- package/dist/frontend/lowering/lower-array-sort.js +561 -191
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +4 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -2
- package/dist/frontend/lowering/lower-async-iteration.d.ts +6 -3
- package/dist/frontend/lowering/lower-async-iteration.js +248 -2
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +101 -9
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +8 -2
- package/dist/frontend/lowering/lower-classes.js +40 -9
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +1 -1
- package/dist/frontend/lowering/lower-comptime.js +4 -4
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-event-target.d.ts +63 -0
- package/dist/frontend/lowering/lower-event-target.js +362 -0
- package/dist/frontend/lowering/lower-event-target.js.map +1 -0
- package/dist/frontend/lowering/lower-expando.js +2 -2
- package/dist/frontend/lowering/lower-exprs.js +112 -22
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +129 -11
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -1
- package/dist/frontend/lowering/lower-modules.js +7 -3
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +2 -2
- package/dist/frontend/lowering/lower-namespaces.js +2 -2
- package/dist/frontend/lowering/lower-server.js +39 -14
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +7 -1
- package/dist/frontend/lowering/lower-stdlib.js +10 -3
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +2 -2
- package/dist/frontend/lowering/lower-stmts.js +46 -12
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +234 -22
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +23 -5
- package/dist/frontend/lowering/lowerer.js +245 -41
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.js +2 -2
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-records.d.ts +115 -0
- package/dist/frontend/lowering/runtime-optional-records.js +715 -0
- package/dist/frontend/lowering/runtime-optional-records.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-records.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-records.test.js +175 -0
- package/dist/frontend/lowering/runtime-optional-records.test.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +7 -3
- package/dist/frontend/lowering/surfaces.js +273 -22
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-syntax.d.ts +1 -1
- package/dist/frontend/module-syntax.js +1 -1
- package/dist/frontend/npm-static-prune.js +1 -1
- package/dist/frontend/npm-static-prune.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +4 -3
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/pipeline.js +1 -1
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +3 -3
- package/dist/frontend/program.js +19 -17
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.js +1 -1
- package/dist/frontend/ts7/adapter.js +1 -1
- package/dist/frontend/ts7/ast-bytes.d.ts +1 -1
- package/dist/frontend/ts7/ast-bytes.js +1 -1
- package/dist/frontend/ts7/semantic-json.d.ts +1 -1
- package/dist/frontend/ts7/semantic-json.js +1 -1
- package/dist/frontend/ts7/semantic-json.js.map +1 -1
- package/dist/frontend/ts7/world-check.js +1 -1
- package/dist/frontend/tsc-codes.js +2 -2
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +16 -1
- package/dist/frontend/type-mapper.js +143 -18
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +12 -6
- package/dist/ir/analysis.js +26 -10
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/analysis.test.js +15 -3
- package/dist/ir/analysis.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +79 -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 +291 -38
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/int32-slots.js +1 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/ir.d.ts +64 -16
- package/dist/ir/ir.js +37 -1
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.js +83 -6
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/serialize.js +1 -1
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +1 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +100 -9
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +60 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/fence-eval.d.ts +1 -1
- package/dist/library/fence-eval.js +5 -4
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/ir-policy.js +10 -4
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-profile.js +13 -13
- package/dist/library/library-profile.js.map +1 -1
- package/dist/library/prepare.js +1 -1
- package/dist/library/prepare.js.map +1 -1
- package/dist/library/sidecar.js +3 -3
- package/dist/library/sidecar.js.map +1 -1
- package/dist/native/prepare.js +3 -2
- package/dist/native/prepare.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +379 -142
|
@@ -9,6 +9,8 @@ import { isOptionalProcessStreamProperty } from "./builtins/process.js";
|
|
|
9
9
|
import { isSettledIteratorValueRead } from "./lower-generators.js";
|
|
10
10
|
import { concreteCollectionNarrow } from "./collection-narrowing.js";
|
|
11
11
|
import { lowerWorkerMetadata } from "./builtins/workers.js";
|
|
12
|
+
import { fenceStaticBlobMember, lowerBlobNew, lowerStaticBlobCall } from "./builtins/blob.js";
|
|
13
|
+
import { lowerKeyObjectCall } from "./builtins/key-object.js";
|
|
12
14
|
import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
|
|
13
15
|
import { iteratorSlotAdapter } from "./iterator-adapters.js";
|
|
14
16
|
import { lowerBuiltinCall } from "./builtin-calls.js";
|
|
@@ -26,6 +28,7 @@ import { NarrowingStability } from "./narrowing-stability.js";
|
|
|
26
28
|
import { ArrayElementStates } from "./runtime-optional-elements.js";
|
|
27
29
|
import { indexReadInBounds } from "./runtime-optional-bounds.js";
|
|
28
30
|
import { ArrayOwnership } from "./runtime-optional-ownership.js";
|
|
31
|
+
import { RecordFlowClasses } from "./runtime-optional-records.js";
|
|
29
32
|
import { StringIndexBounds } from "./string-index-bounds.js";
|
|
30
33
|
import { NanCodedReads } from "./nan-coded-reads.js";
|
|
31
34
|
import { RuntimeOptionalLocals } from "./runtime-optional-locals.js";
|
|
@@ -35,6 +38,7 @@ import { UnregisteredClassTypes } from "./unregistered-class-types.js";
|
|
|
35
38
|
import { bindingInContext, captureContextBinding, declareContextLocal, declareContextThis, } from "./function-context.js";
|
|
36
39
|
import { InternalCompilerError } from "../../errors.js";
|
|
37
40
|
import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
|
|
41
|
+
import {} from "./class-protocol-dispatch.js";
|
|
38
42
|
import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
|
|
39
43
|
import { ClassProtocols } from "./class-protocols.js";
|
|
40
44
|
import { earlyReadVarSymbols } from "./var-hoisting.js";
|
|
@@ -70,6 +74,7 @@ import { containsRecord, containsUnion, describeComponentBlocker, describeRecord
|
|
|
70
74
|
import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
|
|
71
75
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
72
76
|
import { prepareCjsModuleGraph } from "./lower-node-module.js";
|
|
77
|
+
import { registerBuiltinEventTargetClasses } from "./lower-event-target.js";
|
|
73
78
|
import { registerBuiltinErrorClasses, registerBuiltinEmitterClass, registerBuiltinStreamClasses, builtinErrorInfoOf, builtinEmitterInfoOf, builtinStreamInfoOf, analyzeClassDecoration, classIteratorDrainCall, classIteratorNextCall, classIteratorOf, classIteratorOpenCall, classIteratorRestDrainCall, classMemberNameOf, classValueRef, collectClassShape, exactClassOfReceiver, collectClassShapeInner, ctorAbiEquals, findMethodOn, findStaticOn, genericClassInstanceType, isSubclassOf, inHierarchy, overrideBelow, staticShadowBelow, upcastTo, lowerClassMembers, lowerClassCtor, lowerClassExpression, lowerClassExpressionInfo, lowerClassMethodMember, lowerClassValueProperty, lowerStaticMethod, throwingSetterFn, fieldInitStmts, lowerStaticFieldInits, lowerStaticFieldRead, lowerDerivedCtorBody, superCallStmt, lowerSuperMethodCall, superThisRef, lowerSuperAccessorRead, lowerSuperAccessorWrite, inheritsBuiltinErrorCtor, inheritsBuiltinEmitterCtor, errorConstructorArgs, lowerNew, accessorCall, } from "./lower-classes.js";
|
|
74
79
|
import { mixinCallClassInfoOf, mixinIntersectionInstanceType, } from "./lower-mixins.js";
|
|
75
80
|
import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
@@ -117,7 +122,7 @@ import { lowerDateCall } from "./builtins/dates.js";
|
|
|
117
122
|
import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
|
|
118
123
|
import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
|
|
119
124
|
import { lowerPromiseStaticCall } from "./builtins/promises.js";
|
|
120
|
-
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
125
|
+
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerLiveWebValue, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
121
126
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
|
|
122
127
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
123
128
|
import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
|
|
@@ -501,8 +506,8 @@ export function neverTaintedJsType(lowerer, node, t) {
|
|
|
501
506
|
* per-statement runtime fence would have thrown (message + "[code at
|
|
502
507
|
* file:line]"), rendered eagerly so the runtime can throw it verbatim
|
|
503
508
|
* (scr_throw_lowering_fence). The diagnostic joins the runtime-fence
|
|
504
|
-
* ledger exactly like a deferred statement fence
|
|
505
|
-
*
|
|
509
|
+
* ledger exactly like a deferred statement fence, so every fence appears
|
|
510
|
+
* on the coverage report. */
|
|
506
511
|
export function ladderFenceExpr(lowerer, surface, node, hint) {
|
|
507
512
|
const loc = locOf(node);
|
|
508
513
|
const d = noLoweringDiag(surface, loc, hint);
|
|
@@ -1107,6 +1112,9 @@ export class Lowerer {
|
|
|
1107
1112
|
requestInitPropMutatedSyms = null;
|
|
1108
1113
|
emitterEventTable = null;
|
|
1109
1114
|
emitterComputedPatterns = [];
|
|
1115
|
+
/** The EventTarget engine's handleEvent reader was lifted
|
|
1116
|
+
* (lower-event-target.ts noteEventListeners). */
|
|
1117
|
+
handleEventReader = false;
|
|
1110
1118
|
/** Locals widened beyond the checker's type because an inferred indexed
|
|
1111
1119
|
* read can be absent at runtime. Bare reads preserve that union until a
|
|
1112
1120
|
* surrounding JavaScript guard/default consumes it. */
|
|
@@ -1159,6 +1167,10 @@ export class Lowerer {
|
|
|
1159
1167
|
/** Record fields promoted to an undefined-armed union by an indexed-read
|
|
1160
1168
|
* value. The key is the concrete emitted shape and field name. */
|
|
1161
1169
|
runtimeOptionalFields = new Set();
|
|
1170
|
+
/** Record bindings whose flow class reaches storage outside the class:
|
|
1171
|
+
* they keep the declared layout, so an initializer from unchecked reads
|
|
1172
|
+
* converts once instead of the binding adopting the widened variant. */
|
|
1173
|
+
runtimeOptionalRecordsKeptDeclared = new Set();
|
|
1162
1174
|
/** Callback pattern parameters carry an optional source without making
|
|
1163
1175
|
* every name destructured from a present source optional. */
|
|
1164
1176
|
runtimeOptionalPatternTypes = new Map();
|
|
@@ -1174,6 +1186,9 @@ export class Lowerer {
|
|
|
1174
1186
|
/** for-of loops over arrays that can hold neither holes nor undefined:
|
|
1175
1187
|
* each pass reads the element payload directly. */
|
|
1176
1188
|
presentElementLoops = new Set();
|
|
1189
|
+
/** The fs/promises glob() call lowerForOf is lowering as a for await
|
|
1190
|
+
* head; other glob() calls have no lowering. */
|
|
1191
|
+
fspGlobHead = null;
|
|
1177
1192
|
/** Capture entries and their origin share one mutable box. Normalize each
|
|
1178
1193
|
* entry to the origin so writes and flow proofs stay synchronized. */
|
|
1179
1194
|
runtimeOptionalRoots = new Map();
|
|
@@ -1451,6 +1466,10 @@ export class Lowerer {
|
|
|
1451
1466
|
return type;
|
|
1452
1467
|
}
|
|
1453
1468
|
const shapeId = this.shapes.intern(shape.fields.map((f) => ({ name: f.name, type: f.name === field ? fieldType : f.type })), shape.tuple === true, shape.indexValue, shape.declaredOrder);
|
|
1469
|
+
// The widened shape keeps the fields this one already widened.
|
|
1470
|
+
for (const f of shape.fields)
|
|
1471
|
+
if (this.isRuntimeOptionalField(type.shapeId, f.name))
|
|
1472
|
+
this.runtimeOptionalFields.add(this.runtimeOptionalFieldKey(shapeId, f.name));
|
|
1454
1473
|
this.runtimeOptionalFields.add(this.runtimeOptionalFieldKey(shapeId, field));
|
|
1455
1474
|
return { kind: "record", shapeId };
|
|
1456
1475
|
}
|
|
@@ -1534,8 +1553,9 @@ export class Lowerer {
|
|
|
1534
1553
|
* runtime closure pointer: a coercion adapter allocates a different
|
|
1535
1554
|
* closure at the registration and release sites, so lowerFfiCall must
|
|
1536
1555
|
* refuse these forms at compile time (SC5003). Any new closure-minting
|
|
1537
|
-
* adapter helper MUST add its name here, or the identity guard
|
|
1538
|
-
*
|
|
1556
|
+
* adapter helper MUST add its name here, or the identity guard reopens
|
|
1557
|
+
* without a diagnostic and the mismatch surfaces as a runtime release
|
|
1558
|
+
* trap instead. */
|
|
1539
1559
|
freshClosureAdapters = new Set();
|
|
1540
1560
|
/** Symbols bound by `const process = globalThis.process` (and the other
|
|
1541
1561
|
* stdlib-global snapshot spellings): pure alias plumbing — receiver
|
|
@@ -1611,6 +1631,11 @@ export class Lowerer {
|
|
|
1611
1631
|
/** Named method slots observed before class collection need a callable
|
|
1612
1632
|
* ABI and shared prototype descriptors instead of call-site specialization. */
|
|
1613
1633
|
prototypeMethodAccesses = new Map();
|
|
1634
|
+
/** Typed calls through class-backed protocols, by signature; class
|
|
1635
|
+
* dynamic dispatch adds their native arms (class-protocol-dispatch.ts). */
|
|
1636
|
+
protocolDispatches = new Map();
|
|
1637
|
+
/** Bindings no other function assigns (class-protocol-dispatch.ts). */
|
|
1638
|
+
protocolOwnedBindings = new Map();
|
|
1614
1639
|
/** Field names whose complete source census stores only lexical arrows. */
|
|
1615
1640
|
receiverFreeCallbackFields = new Set();
|
|
1616
1641
|
/** Inferred JS methods participating in an override chain keep a vtable
|
|
@@ -2004,6 +2029,7 @@ export class Lowerer {
|
|
|
2004
2029
|
this.registerBuiltinErrorClasses();
|
|
2005
2030
|
registerBuiltinEmitterClass(this);
|
|
2006
2031
|
registerBuiltinStreamClasses(this);
|
|
2032
|
+
registerBuiltinEventTargetClasses(this);
|
|
2007
2033
|
}
|
|
2008
2034
|
registerBuiltinErrorClasses() {
|
|
2009
2035
|
return registerBuiltinErrorClasses(this);
|
|
@@ -3049,6 +3075,57 @@ export class Lowerer {
|
|
|
3049
3075
|
}
|
|
3050
3076
|
}
|
|
3051
3077
|
const mappedOrNull = (node) => panicSafe(() => this.mapTypeOf(this.typeOf(node)), null);
|
|
3078
|
+
const admitsUndefined = (type) => typeEquals(addUndefined(type), type);
|
|
3079
|
+
const plainRecordShape = (type) => {
|
|
3080
|
+
if (type?.kind !== "record")
|
|
3081
|
+
return null;
|
|
3082
|
+
const shape = this.shapes.get(type.shapeId);
|
|
3083
|
+
return shape && !shape.tuple && !shape.indexValue && shape.fields.length > 0
|
|
3084
|
+
? type.shapeId
|
|
3085
|
+
: null;
|
|
3086
|
+
};
|
|
3087
|
+
// Parameters and results read the signatures collected above; bindings
|
|
3088
|
+
// ask the checker, so the scan builds no layout of its own.
|
|
3089
|
+
const parameterType = (node) => {
|
|
3090
|
+
const parameter = node.parent;
|
|
3091
|
+
if (!parameter || !ts.isParameter(parameter))
|
|
3092
|
+
return null;
|
|
3093
|
+
const fn = parameter.parent;
|
|
3094
|
+
const symbol = (ts.isFunctionDeclaration(fn) || ts.isMethodDeclaration(fn)) && fn.name
|
|
3095
|
+
? symbolOf(fn.name)
|
|
3096
|
+
: null;
|
|
3097
|
+
const index = fn.parameters.indexOf(parameter);
|
|
3098
|
+
return (symbol && signatureBySymbol.get(symbol)?.params[index]?.type) ?? null;
|
|
3099
|
+
};
|
|
3100
|
+
const returnTypeOf = (fn) => {
|
|
3101
|
+
const symbol = fn.name ? symbolOf(fn.name) : null;
|
|
3102
|
+
return (symbol && signatureBySymbol.get(symbol)?.returnType) ?? null;
|
|
3103
|
+
};
|
|
3104
|
+
const recordFlows = new RecordFlowClasses(sourceFiles, {
|
|
3105
|
+
symbolOf,
|
|
3106
|
+
declarationOf: (symbol) => this.checker.valueDeclarationOf(symbol),
|
|
3107
|
+
mayBeRecord: (node) => {
|
|
3108
|
+
if (node.parent && ts.isParameter(node.parent))
|
|
3109
|
+
return plainRecordShape(parameterType(node)) !== null;
|
|
3110
|
+
const t = panicSafe(() => this.typeOf(node), null);
|
|
3111
|
+
return (t !== null &&
|
|
3112
|
+
(t.flags & ts.TypeFlags.Object) !== 0 &&
|
|
3113
|
+
!this.checker.isArrayType(t) &&
|
|
3114
|
+
this.checker.getCallSignatures(t).length === 0 &&
|
|
3115
|
+
this.checker.getConstructSignatures(t).length === 0);
|
|
3116
|
+
},
|
|
3117
|
+
prefetchTypes: (nodes) => this.checker.prefetchCollectionTypes(nodes),
|
|
3118
|
+
mayReturnRecord: (fn) => plainRecordShape(returnTypeOf(fn)) !== null,
|
|
3119
|
+
familyOf: (method) => familyBySymbol.get(method),
|
|
3120
|
+
recordShape: (node) => plainRecordShape(node.parent && ts.isParameter(node.parent) ? parameterType(node) : mappedOrNull(node)),
|
|
3121
|
+
returnShape: (fn) => plainRecordShape(returnTypeOf(fn)),
|
|
3122
|
+
isGlobal: (node, name) => this.isStdlibGlobal(node, name),
|
|
3123
|
+
});
|
|
3124
|
+
/** Optional fields of the records a visible function returns. */
|
|
3125
|
+
const returnFields = new Map();
|
|
3126
|
+
/** Record parameters that receive a value with optional fields, by the
|
|
3127
|
+
* parameter's own symbol. */
|
|
3128
|
+
const recordParameterSlots = new Map();
|
|
3052
3129
|
const nanCoded = new NanCodedReads({
|
|
3053
3130
|
symbolOf,
|
|
3054
3131
|
declarationOf: (symbol) => this.checker.valueDeclarationOf(symbol),
|
|
@@ -3327,10 +3404,8 @@ export class Lowerer {
|
|
|
3327
3404
|
if (op === ts.SyntaxKind.AmpersandAmpersandToken)
|
|
3328
3405
|
return mayBeOptional(e.left) || mayBeOptional(e.right);
|
|
3329
3406
|
}
|
|
3330
|
-
if (ts.isPropertyAccessExpression(e)
|
|
3331
|
-
|
|
3332
|
-
const fields = symbol === null ? undefined : optionalFields.get(symbol);
|
|
3333
|
-
return fields?.has(fieldName(e)) ?? false;
|
|
3407
|
+
if (ts.isPropertyAccessExpression(e)) {
|
|
3408
|
+
return fieldsOfValue(e.expression)?.has(fieldName(e)) ?? false;
|
|
3334
3409
|
}
|
|
3335
3410
|
return false;
|
|
3336
3411
|
};
|
|
@@ -3439,10 +3514,40 @@ export class Lowerer {
|
|
|
3439
3514
|
// a spread or a parameter receives the source's optional fields.
|
|
3440
3515
|
const fieldsOfValue = (node) => {
|
|
3441
3516
|
const e = peel(node);
|
|
3442
|
-
if (
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3517
|
+
if (ts.isIdentifier(e)) {
|
|
3518
|
+
const symbol = symbolOf(e);
|
|
3519
|
+
// A binding whose class reaches other storage keeps the declared
|
|
3520
|
+
// layout, so its fields read as present.
|
|
3521
|
+
return symbol === null || recordFlows.opened(symbol)
|
|
3522
|
+
? undefined
|
|
3523
|
+
: optionalFields.get(symbol);
|
|
3524
|
+
}
|
|
3525
|
+
// A fresh literal carries the fields its values can leave undefined.
|
|
3526
|
+
if (ts.isObjectLiteralExpression(e)) {
|
|
3527
|
+
const out = spreadFieldsOf(e);
|
|
3528
|
+
for (const prop of e.properties) {
|
|
3529
|
+
if (!ts.isPropertyAssignment(prop) && !ts.isShorthandPropertyAssignment(prop))
|
|
3530
|
+
continue;
|
|
3531
|
+
const name = prop.name;
|
|
3532
|
+
if (!(ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isNumericLiteral(name)))
|
|
3533
|
+
continue;
|
|
3534
|
+
const value = ts.isPropertyAssignment(prop) ? prop.initializer : name;
|
|
3535
|
+
if (mayBeOptional(value))
|
|
3536
|
+
out.add(name.text);
|
|
3537
|
+
}
|
|
3538
|
+
return out.size > 0 ? out : undefined;
|
|
3539
|
+
}
|
|
3540
|
+
if (ts.isCallExpression(e) &&
|
|
3541
|
+
(ts.isIdentifier(e.expression) || ts.isPropertyAccessExpression(e.expression))) {
|
|
3542
|
+
const symbol = symbolOf(ts.isIdentifier(e.expression) ? e.expression : e.expression.name);
|
|
3543
|
+
return symbol === null ? undefined : returnFields.get(symbol);
|
|
3544
|
+
}
|
|
3545
|
+
if (ts.isConditionalExpression(e)) {
|
|
3546
|
+
const a = fieldsOfValue(e.whenTrue);
|
|
3547
|
+
const b = fieldsOfValue(e.whenFalse);
|
|
3548
|
+
return a && b ? new Set([...a, ...b]) : (a ?? b);
|
|
3549
|
+
}
|
|
3550
|
+
return undefined;
|
|
3446
3551
|
};
|
|
3447
3552
|
const noteFieldsFrom = (symbol, source) => {
|
|
3448
3553
|
const fields = fieldsOfValue(source);
|
|
@@ -4470,23 +4575,21 @@ export class Lowerer {
|
|
|
4470
4575
|
const bound = symbolOf(parameter.name);
|
|
4471
4576
|
if (!bound)
|
|
4472
4577
|
continue;
|
|
4473
|
-
|
|
4578
|
+
const declared = this.shapes.get(parameterShape.type.shapeId);
|
|
4579
|
+
// The parameter's layout settles with its flow class once
|
|
4580
|
+
// the fixed point ends. A literal or call argument only adds
|
|
4581
|
+
// fields the declaration calls present.
|
|
4582
|
+
const fresh = !ts.isIdentifier(peel(arg));
|
|
4474
4583
|
for (const field of fields) {
|
|
4475
|
-
const
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
if (
|
|
4479
|
-
|
|
4480
|
-
}
|
|
4481
|
-
if (noteFieldSymbol(bound, field))
|
|
4584
|
+
const slot = declared?.fields.find((f) => f.name === field);
|
|
4585
|
+
if (!slot || (fresh && admitsUndefined(slot.type)))
|
|
4586
|
+
continue;
|
|
4587
|
+
if (noteFieldSymbol(bound, field)) {
|
|
4588
|
+
provenance?.note("record-parameter", parameter, arg);
|
|
4482
4589
|
changed = true;
|
|
4590
|
+
}
|
|
4483
4591
|
}
|
|
4484
|
-
|
|
4485
|
-
parameterShape.type = promoted;
|
|
4486
|
-
this.runtimeOptionalBindingTypes.set(bound, promoted);
|
|
4487
|
-
provenance?.note("record-parameter", parameter, arg);
|
|
4488
|
-
changed = true;
|
|
4489
|
-
}
|
|
4592
|
+
recordParameterSlots.set(bound, { target, index: i });
|
|
4490
4593
|
}
|
|
4491
4594
|
}
|
|
4492
4595
|
if (ts.isSpreadElement(arg) || !shape)
|
|
@@ -4570,7 +4673,27 @@ export class Lowerer {
|
|
|
4570
4673
|
};
|
|
4571
4674
|
const scanReturns = (symbol, decl) => {
|
|
4572
4675
|
let changed = false;
|
|
4676
|
+
const recordReturn = recordFlows.returnClass(symbol) !== null;
|
|
4677
|
+
const returned = signatureBySymbol.get(symbol)?.returnType;
|
|
4678
|
+
const returnedShape = returned?.kind === "record" ? this.shapes.get(returned.shapeId) : null;
|
|
4573
4679
|
for (const expression of returnsOf(decl)) {
|
|
4680
|
+
const fields = recordReturn ? fieldsOfValue(expression) : undefined;
|
|
4681
|
+
if (fields) {
|
|
4682
|
+
for (const field of fields) {
|
|
4683
|
+
// A result field that already admits undefined keeps the
|
|
4684
|
+
// checker's narrowing.
|
|
4685
|
+
const slot = returnedShape?.fields.find((f) => f.name === field);
|
|
4686
|
+
if (slot && admitsUndefined(slot.type))
|
|
4687
|
+
continue;
|
|
4688
|
+
const set = returnFields.get(symbol) ?? new Set();
|
|
4689
|
+
if (set.has(field))
|
|
4690
|
+
continue;
|
|
4691
|
+
set.add(field);
|
|
4692
|
+
returnFields.set(symbol, set);
|
|
4693
|
+
provenance?.note("record-return", decl.name ?? decl, expression);
|
|
4694
|
+
changed = true;
|
|
4695
|
+
}
|
|
4696
|
+
}
|
|
4574
4697
|
if (mayBeOptional(expression) && !optionalReturns.has(symbol)) {
|
|
4575
4698
|
optionalReturns.add(symbol);
|
|
4576
4699
|
provenance?.note("return", decl.name ?? decl, expression);
|
|
@@ -4749,6 +4872,72 @@ export class Lowerer {
|
|
|
4749
4872
|
this.runtimeOptionalGlobals.add(global);
|
|
4750
4873
|
}
|
|
4751
4874
|
}
|
|
4875
|
+
// Record layouts settle per flow class: a closed class widens every
|
|
4876
|
+
// member to the union of its members' optional fields, and a class that
|
|
4877
|
+
// reaches other storage keeps the declared layout for every member.
|
|
4878
|
+
const classFields = new Map();
|
|
4879
|
+
const addClassFields = (id, fields) => {
|
|
4880
|
+
if (id === null)
|
|
4881
|
+
return;
|
|
4882
|
+
const set = classFields.get(id) ?? new Set();
|
|
4883
|
+
for (const field of fields)
|
|
4884
|
+
set.add(field);
|
|
4885
|
+
classFields.set(id, set);
|
|
4886
|
+
};
|
|
4887
|
+
for (const [symbol, fields] of optionalFields)
|
|
4888
|
+
addClassFields(recordFlows.bindingClass(symbol), fields);
|
|
4889
|
+
for (const [symbol, fields] of returnFields)
|
|
4890
|
+
addClassFields(recordFlows.returnClass(symbol), fields);
|
|
4891
|
+
const settledFields = (id, own) => id === null
|
|
4892
|
+
? own
|
|
4893
|
+
: classFields.has(id) && recordFlows.closed(id)
|
|
4894
|
+
? classFields.get(id)
|
|
4895
|
+
: undefined;
|
|
4896
|
+
const widenRecordFields = (type, fields) => {
|
|
4897
|
+
let promoted = type;
|
|
4898
|
+
for (const field of fields) {
|
|
4899
|
+
const source = promoted.kind === "record"
|
|
4900
|
+
? this.shapes.get(promoted.shapeId)?.fields.find((f) => f.name === field)
|
|
4901
|
+
: undefined;
|
|
4902
|
+
if (source)
|
|
4903
|
+
promoted = this.runtimeOptionalRecordField(promoted, field, addUndefined(source.type));
|
|
4904
|
+
}
|
|
4905
|
+
return promoted;
|
|
4906
|
+
};
|
|
4907
|
+
for (const [symbol, id] of recordFlows.bindings())
|
|
4908
|
+
if (classFields.has(id) && !recordFlows.closed(id))
|
|
4909
|
+
this.runtimeOptionalRecordsKeptDeclared.add(symbol);
|
|
4910
|
+
// Every tracked parameter settles with its class, including one that
|
|
4911
|
+
// only receives plain records. An untracked one (a function used as a
|
|
4912
|
+
// value, a method another member name or view can reach) widens to the
|
|
4913
|
+
// fields its own arguments carry.
|
|
4914
|
+
for (const { symbol, fn, index } of recordFlows.parameters())
|
|
4915
|
+
recordParameterSlots.set(symbol, { target: fn, index });
|
|
4916
|
+
for (const [bound, { target, index }] of recordParameterSlots) {
|
|
4917
|
+
const shape = signatureBySymbol.get(target)?.params[index];
|
|
4918
|
+
if (!shape || shape.type.kind !== "record")
|
|
4919
|
+
continue;
|
|
4920
|
+
const fields = settledFields(recordFlows.bindingClass(bound), optionalFields.get(bound));
|
|
4921
|
+
if (!fields)
|
|
4922
|
+
continue;
|
|
4923
|
+
const promoted = widenRecordFields(shape.type, fields);
|
|
4924
|
+
if (typeEquals(promoted, shape.type))
|
|
4925
|
+
continue;
|
|
4926
|
+
shape.type = promoted;
|
|
4927
|
+
this.runtimeOptionalBindingTypes.set(bound, promoted);
|
|
4928
|
+
}
|
|
4929
|
+
for (const [symbol, sig] of signatureBySymbol) {
|
|
4930
|
+
const id = recordFlows.returnClass(symbol);
|
|
4931
|
+
const fields = id === null ? undefined : settledFields(id, undefined);
|
|
4932
|
+
if (fields && sig.returnType.kind === "record") {
|
|
4933
|
+
const next = widenRecordFields(sig.returnType, fields);
|
|
4934
|
+
sig.returnType = next;
|
|
4935
|
+
if (sig.top)
|
|
4936
|
+
sig.top.returnType = next;
|
|
4937
|
+
if (sig.method)
|
|
4938
|
+
sig.method.ret = next;
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4752
4941
|
for (const [symbol, sig] of signatureBySymbol) {
|
|
4753
4942
|
const params = optionalParams.get(symbol);
|
|
4754
4943
|
if (params) {
|
|
@@ -4832,7 +5021,7 @@ export class Lowerer {
|
|
|
4832
5021
|
global.type = promoted;
|
|
4833
5022
|
}
|
|
4834
5023
|
}
|
|
4835
|
-
const fields = optionalFields.get(symbol);
|
|
5024
|
+
const fields = settledFields(recordFlows.bindingClass(symbol), optionalFields.get(symbol));
|
|
4836
5025
|
if (!dynamicObjectEntryRows.has(symbol) && !optionalSymbols.has(symbol) && !fields)
|
|
4837
5026
|
return;
|
|
4838
5027
|
const current = this.mapTypeOf(this.typeOf(node.name));
|
|
@@ -4851,16 +5040,8 @@ export class Lowerer {
|
|
|
4851
5040
|
};
|
|
4852
5041
|
}
|
|
4853
5042
|
}
|
|
4854
|
-
if (fields && promoted.kind === "record")
|
|
4855
|
-
|
|
4856
|
-
const source = promoted.kind === "record"
|
|
4857
|
-
? this.shapes.get(promoted.shapeId)?.fields.find((f) => f.name === field)
|
|
4858
|
-
: undefined;
|
|
4859
|
-
if (!source)
|
|
4860
|
-
continue;
|
|
4861
|
-
promoted = this.runtimeOptionalRecordField(promoted, field, addUndefined(source.type));
|
|
4862
|
-
}
|
|
4863
|
-
}
|
|
5043
|
+
if (fields && promoted.kind === "record")
|
|
5044
|
+
promoted = widenRecordFields(promoted, fields);
|
|
4864
5045
|
if (!typeEquals(promoted, current)) {
|
|
4865
5046
|
this.runtimeOptionalBindingTypes.set(symbol, promoted);
|
|
4866
5047
|
const global = ts.isIdentifier(node.name)
|
|
@@ -5803,7 +5984,7 @@ export class Lowerer {
|
|
|
5803
5984
|
: diag;
|
|
5804
5985
|
const pending = this.pendingFlushes.get(diag);
|
|
5805
5986
|
// Deferred collection: the wrapper decides whether these ever report
|
|
5806
|
-
// (a reference flushes them; unreferenced declarations
|
|
5987
|
+
// (a reference flushes them; unreferenced declarations report nothing in
|
|
5807
5988
|
// builds and report under coverage's unreached group).
|
|
5808
5989
|
if (this.diagSink) {
|
|
5809
5990
|
if (pending && d !== diag)
|
|
@@ -6017,7 +6198,7 @@ export class Lowerer {
|
|
|
6017
6198
|
return stdlibMemberFence(this, access);
|
|
6018
6199
|
}
|
|
6019
6200
|
fenceStaticResponseMember(access, use) {
|
|
6020
|
-
return fenceStaticResponseMember(this, access, use);
|
|
6201
|
+
return fenceStaticResponseMember(this, access, use) ?? fenceStaticBlobMember(this, access, use);
|
|
6021
6202
|
}
|
|
6022
6203
|
fenceUnsupportedFetchConstructorMember(access) {
|
|
6023
6204
|
return fenceUnsupportedFetchConstructorMember(this, access);
|
|
@@ -6774,6 +6955,21 @@ export class Lowerer {
|
|
|
6774
6955
|
return this.checkedNarrowCall(helper, expr, expected, expr.loc);
|
|
6775
6956
|
}
|
|
6776
6957
|
}
|
|
6958
|
+
// A record arm beside unit arms flowing into another layout of that
|
|
6959
|
+
// record (`R | undefined` into the runtime-optional variant of R): the
|
|
6960
|
+
// same checked extraction of the record arm, then the record's width
|
|
6961
|
+
// lift into the destination layout.
|
|
6962
|
+
if (expr.type.kind === "union" && expected.kind === "record") {
|
|
6963
|
+
const arms = this.unions.get(expr.type.unionId)?.arms ?? [];
|
|
6964
|
+
const records = arms.filter((arm) => !isUnitType(arm));
|
|
6965
|
+
const arm = records.length === 1 && records[0].kind === "record" ? records[0] : null;
|
|
6966
|
+
const lift = arm ? this.widthLiftPlan(arm, expected) : null;
|
|
6967
|
+
const helper = arm && lift ? this.narrowedArmHelper(expr.type.unionId, arm, expr.loc) : null;
|
|
6968
|
+
if (arm && lift && helper) {
|
|
6969
|
+
const narrowed = this.checkedNarrowCall(helper, expr, arm, expr.loc);
|
|
6970
|
+
return this.applyWidthLift(lift, narrowed, expected, expr.loc);
|
|
6971
|
+
}
|
|
6972
|
+
}
|
|
6777
6973
|
if (!typeEquals(expr.type, expected)) {
|
|
6778
6974
|
const w = this.widthCoerce(expr, expected);
|
|
6779
6975
|
if (w)
|
|
@@ -7372,6 +7568,8 @@ export class Lowerer {
|
|
|
7372
7568
|
builtinOption("RequestInit") ||
|
|
7373
7569
|
builtinOption("ErrorOptions") ||
|
|
7374
7570
|
builtinOption("SpawnOptions") ||
|
|
7571
|
+
builtinOption("UrlObject") ||
|
|
7572
|
+
builtinOption("URLFormatOptions") ||
|
|
7375
7573
|
!this.mapTypeOf(this.typeOf(x))) {
|
|
7376
7574
|
return lowerDynObjectLiteral(this, x);
|
|
7377
7575
|
}
|
|
@@ -8695,7 +8893,7 @@ export class Lowerer {
|
|
|
8695
8893
|
* lowered — set by lowerLabeled around lowering the labeled construct,
|
|
8696
8894
|
* consumed exactly once by the construct's own lowering (takeLabels).
|
|
8697
8895
|
* A lowering that never consumes them signals lowerLabeled to fence:
|
|
8698
|
-
*
|
|
8896
|
+
* dropping a label without a diagnostic would compile `break lbl` wrong. */
|
|
8699
8897
|
pendingLabels = null;
|
|
8700
8898
|
takeLabels() {
|
|
8701
8899
|
const labels = this.pendingLabels;
|
|
@@ -8902,6 +9100,9 @@ export class Lowerer {
|
|
|
8902
9100
|
lowerElementWrite(expr) {
|
|
8903
9101
|
return lowerElementWrite(this, expr);
|
|
8904
9102
|
}
|
|
9103
|
+
lowerLiveWebValue(node) {
|
|
9104
|
+
return lowerLiveWebValue(this, node);
|
|
9105
|
+
}
|
|
8905
9106
|
ensureString(e, node) {
|
|
8906
9107
|
return ensureString(this, e, node);
|
|
8907
9108
|
}
|
|
@@ -9053,6 +9254,8 @@ export class Lowerer {
|
|
|
9053
9254
|
lowerStaticReadableStreamControllerCall(this, expr) ??
|
|
9054
9255
|
lowerStaticReadableStreamReaderCall(this, expr) ??
|
|
9055
9256
|
lowerStaticResponseCall(this, expr) ??
|
|
9257
|
+
lowerStaticBlobCall(this, expr) ??
|
|
9258
|
+
lowerKeyObjectCall(this, expr) ??
|
|
9056
9259
|
lowerFetchElementMethodCall(this, expr) ??
|
|
9057
9260
|
lowerDynamicImportCall(this, expr) ??
|
|
9058
9261
|
lowerCall(this, expr));
|
|
@@ -9184,6 +9387,7 @@ export class Lowerer {
|
|
|
9184
9387
|
lowerEventTargetNew(this, expr) ??
|
|
9185
9388
|
lowerFetchWebNew(this, expr) ??
|
|
9186
9389
|
lowerResponseNew(this, expr) ??
|
|
9390
|
+
lowerBlobNew(this, expr) ??
|
|
9187
9391
|
lowerStaticReadableStreamNew(this, expr) ??
|
|
9188
9392
|
lowerConsoleNew(this, expr);
|
|
9189
9393
|
return (builtin ?? this.withRuntimeOptionalClassValue(expr.expression, () => lowerNew(this, expr)));
|