@scriptc/compiler 0.2.9 → 0.3.0
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 +2 -36
- package/ambient/scriptc-overrides.d.ts +1 -25
- package/ambient/scriptc.d.ts +1 -9
- package/dist/backend/cycle-analysis.d.ts +56 -0
- package/dist/backend/cycle-analysis.js +175 -14
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +95 -2
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +3 -7
- package/dist/backend/cycle-mutability.js +4 -30
- package/dist/backend/cycle-mutability.js.map +1 -1
- package/dist/backend/executable-features.d.ts +1 -1
- package/dist/backend/executable-features.js +3 -8
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +57 -0
- package/dist/backend/immutability.js +178 -0
- package/dist/backend/immutability.js.map +1 -0
- package/dist/backend/immutability.test.js +131 -0
- package/dist/backend/immutability.test.js.map +1 -0
- package/dist/backend/library-pack.js +0 -2
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/linker.js +1 -1
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/llvm/borrowed-inputs.d.ts +9 -2
- package/dist/backend/llvm/borrowed-inputs.js +31 -3
- package/dist/backend/llvm/borrowed-inputs.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/classes.d.ts +28 -0
- package/dist/backend/llvm/classes.js +48 -14
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +134 -6
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +13 -0
- package/dist/backend/llvm/common.js +13 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +1 -1
- package/dist/backend/llvm/constant-callbacks.js +3 -3
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +1 -1
- package/dist/backend/llvm/dense-array-access.js +5 -4
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +10 -2
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +2 -1
- package/dist/backend/llvm/dyn.js +3 -76
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +67 -19
- package/dist/backend/llvm/emitter.js +443 -226
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +21 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-calls.js +14 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +41 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +4 -107
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.d.ts +1 -2
- package/dist/backend/llvm/expr-dispatch.js +0 -41
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.d.ts +1 -1
- package/dist/backend/llvm/expr-dynamic.js +13 -27
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +30 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +4 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/lib-dispatch.js +0 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +0 -13
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +0 -8
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +3 -3
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +5 -2
- package/dist/backend/llvm/loop-array-borrows.js +27 -8
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +14 -0
- package/dist/backend/llvm/map-number-lookup.js +33 -2
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/map-read-lifetimes.js +20 -4
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +25 -3
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +124 -0
- package/dist/backend/llvm/reference-writes.js +1090 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +8 -5
- package/dist/backend/llvm/shapes.js +37 -13
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +3 -3
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +40 -11
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +3 -0
- package/dist/backend/llvm/string-reads.js +31 -0
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.d.ts +2 -2
- package/dist/backend/llvm/switch-dispatch.js +35 -22
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +29 -11
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/walk-borrows.d.ts +8 -1
- package/dist/backend/llvm/walk-borrows.js +15 -4
- package/dist/backend/llvm/walk-borrows.js.map +1 -1
- package/dist/backend/may-throw.d.ts +36 -2
- package/dist/backend/may-throw.js +308 -21
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +147 -2
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/artifact-stamps.js +0 -2
- package/dist/backend/native/artifact-stamps.js.map +1 -1
- package/dist/backend/native/cache-warm.d.ts +1 -1
- package/dist/backend/native/cache-warm.js +2 -3
- package/dist/backend/native/cache-warm.js.map +1 -1
- package/dist/backend/native/compiler-fingerprint.d.ts +1 -1
- package/dist/backend/native/compiler-fingerprint.js +4 -7
- package/dist/backend/native/compiler-fingerprint.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +3 -28
- package/dist/backend/native/driver.js +1 -3
- package/dist/backend/native/driver.js.map +1 -1
- package/dist/backend/native/executable.d.ts +0 -15
- package/dist/backend/native/executable.js +17 -172
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/tool-identity.js +0 -1
- package/dist/backend/native/tool-identity.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-link-info-core.d.ts +0 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +23 -33
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/publication.d.ts +5 -0
- package/dist/backend/publication.js +10 -0
- package/dist/backend/publication.js.map +1 -1
- package/dist/backend/publication.test.js +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -2
- package/dist/backend/runtime-pack-core.js +5 -14
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -8
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +22 -19
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.d.ts +0 -5
- package/dist/backend/target-diagnostics.js +1 -11
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/vendor-archives.d.ts +1 -7
- package/dist/backend/vendor-archives.js +9 -189
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +0 -1
- package/dist/backend/vendor-inputs.js +0 -1
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -5
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +4 -8
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +1 -1
- package/dist/cli/usage.d.ts +1 -5
- package/dist/cli/usage.js +4 -9
- package/dist/cli/usage.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +2 -2
- package/dist/compat/fetch-profile.js +16 -25
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +2 -17
- package/dist/contracts/check.d.ts +8 -0
- package/dist/contracts/check.js +1573 -0
- package/dist/contracts/check.js.map +1 -0
- package/dist/coverage/report.d.ts +5 -22
- package/dist/coverage/report.js +12 -76
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.d.ts +3 -3
- package/dist/coverage/surface-manifest.js +22 -27
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +1 -3
- package/dist/coverage/verdict-cache.js +2 -7
- package/dist/coverage/verdict-cache.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -60
- package/dist/diagnostics/diagnostic.js +39 -118
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +3 -4
- package/dist/diagnostics/envelope.js +0 -9
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/diagnostics/envelope.test.js +1 -1
- package/dist/diagnostics/envelope.test.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +0 -3
- package/dist/executable/executable-cache.js +2 -4
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +0 -4
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +14 -2
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +10 -10
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/cjs-syntax.js +0 -88
- package/dist/frontend/cjs-syntax.js.map +1 -1
- package/dist/frontend/contract-types.d.ts +50 -0
- package/dist/frontend/contract-types.js +232 -0
- package/dist/frontend/contract-types.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +1 -1
- package/dist/frontend/dts-paths.js +1 -1
- package/dist/frontend/lowering/abstract-equality.js +1 -4
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.js +4 -11
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/arguments.js +0 -13
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +0 -4
- package/dist/frontend/lowering/builtins/crypto.js +0 -4
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +1 -39
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +0 -15
- package/dist/frontend/lowering/builtins/module-resolution.js +5 -44
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +0 -6
- package/dist/frontend/lowering/builtins/numbers.js +6 -57
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +4 -67
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.js +1 -1
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +1 -37
- package/dist/frontend/lowering/call-arguments.js +11 -94
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +1 -6
- package/dist/frontend/lowering/call-signatures.js +16 -68
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +19 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.js +168 -98
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +44 -4
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +0 -2
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +1 -1
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +5 -35
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +0 -1
- package/dist/frontend/lowering/coercions/state.js +0 -1
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +2 -4
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +2 -12
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +12 -0
- package/dist/frontend/lowering/coercions/unions.js +63 -1
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +9 -28
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +2 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +10 -54
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +0 -1
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +2 -10
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +1 -6
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +0 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +0 -6
- package/dist/frontend/lowering/containers/string-and-regexp.js +2 -10
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/evaluation-safety.js +0 -3
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js +1 -1
- package/dist/frontend/lowering/expressions/native-proxy.js.map +1 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js +0 -1
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +0 -8
- package/dist/frontend/lowering/expressions/object-literals.js +8 -35
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +0 -4
- package/dist/frontend/lowering/expressions/optional-chains.js +7 -67
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/function-context.js +0 -1
- package/dist/frontend/lowering/function-context.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.js +0 -1
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +10 -77
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.js +1 -10
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +2 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +2 -3
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.js +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +2 -27
- package/dist/frontend/lowering/lower-calls.js +56 -465
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +11 -49
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.js +2 -3
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.js +5 -8
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +3 -4
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-expando.js +3 -5
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +0 -8
- package/dist/frontend/lowering/lower-exprs.js +133 -908
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -5
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +1 -50
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +0 -43
- package/dist/frontend/lowering/lower-modules.js +25 -329
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.test.js +5 -5
- package/dist/frontend/lowering/lower-modules.test.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +0 -30
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +98 -0
- package/dist/frontend/lowering/{lower-island.js → lower-stdlib.js} +97 -1160
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -0
- package/dist/frontend/lowering/lower-stmts.d.ts +0 -16
- package/dist/frontend/lowering/lower-stmts.js +58 -1016
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js +1 -1
- package/dist/frontend/lowering/lower-stmts.test.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -3
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +26 -151
- package/dist/frontend/lowering/lowerer.js +120 -770
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +4 -51
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/narrowing-stability.d.ts +100 -0
- package/dist/frontend/lowering/narrowing-stability.js +1174 -0
- package/dist/frontend/lowering/narrowing-stability.js.map +1 -0
- package/dist/frontend/lowering/narrowing-stability.test.js +150 -0
- package/dist/frontend/lowering/narrowing-stability.test.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.js +0 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/strict-equality.js +1 -1
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +6 -45
- package/dist/frontend/lowering/surfaces.js +5 -65
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-syntax.d.ts +0 -3
- package/dist/frontend/module-syntax.js.map +1 -1
- package/dist/frontend/npm-node.d.ts +0 -7
- package/dist/frontend/npm-node.js +0 -7
- package/dist/frontend/npm-node.js.map +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.d.ts +1 -1
- package/dist/frontend/npm-static-rewrite-syntax.js +6 -82
- package/dist/frontend/npm-static-rewrite-syntax.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +1 -1
- package/dist/frontend/npm-static.js +6 -71
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +3 -319
- package/dist/frontend/npm.js +6 -1007
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +2 -197
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/pipeline-native.js +1 -2
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +3 -11
- package/dist/frontend/pipeline.js +37 -56
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +12 -6
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program.d.ts +0 -34
- package/dist/frontend/program.js +13 -98
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-core.d.ts +0 -4
- package/dist/frontend/provenance-core.js +4 -37
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -4
- package/dist/frontend/provenance-registry.js +0 -20
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/resolve.d.ts +0 -12
- package/dist/frontend/resolve.js +0 -34
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/runtime-resolve.js +2 -2
- package/dist/frontend/runtime-resolve.js.map +1 -1
- package/dist/frontend/services-node.js +2 -3
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services.d.ts +1 -8
- package/dist/frontend/services.js +2 -22
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +0 -38
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/tsc-codes.js +0 -11
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +2 -27
- package/dist/frontend/type-mapper.js +85 -153
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -10
- package/dist/index.js.map +1 -1
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/builtin-effects.js +0 -5
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +1 -55
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-globals.test.js +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/final-fields.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/int32-slots.d.ts +29 -3
- package/dist/ir/int32-slots.js +152 -66
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +1 -1
- package/dist/ir/integer-loops.js +3 -0
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/integer-loops.test.js +26 -1
- package/dist/ir/integer-loops.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +20 -0
- package/dist/ir/integer-ranges.js +178 -21
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +148 -3
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +44 -284
- package/dist/ir/ir.js +10 -259
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +2 -7
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +3 -30
- package/dist/ir/runtime-features.js +5 -41
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +6 -2
- package/dist/ir/serialize.js +11 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +0 -21
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/unshare.d.ts +14 -0
- package/dist/ir/unshare.js +60 -0
- package/dist/ir/unshare.js.map +1 -0
- package/dist/ir/unshare.test.js +115 -0
- package/dist/ir/unshare.test.js.map +1 -0
- package/dist/ir/validate.js +9 -207
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +6 -6
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/prepare.js +14 -20
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cli.js +0 -2
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.test.js +2 -4
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.js +2 -4
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.js +2 -16
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +0 -3
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/startup-cache.js +0 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +80 -88
- package/dist/backend/llvm/expr-island.d.ts +0 -15
- package/dist/backend/llvm/expr-island.js +0 -709
- package/dist/backend/llvm/expr-island.js.map +0 -1
- package/dist/frontend/lowering/coercions/island.d.ts +0 -37
- package/dist/frontend/lowering/coercions/island.js +0 -350
- package/dist/frontend/lowering/coercions/island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.d.ts +0 -229
- package/dist/frontend/lowering/lower-island.js.map +0 -1
- package/dist/frontend/lowering/lower-island.test.js +0 -56
- package/dist/frontend/lowering/lower-island.test.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.d.ts +0 -17
- package/dist/frontend/npm-fetch-analysis.js +0 -109
- package/dist/frontend/npm-fetch-analysis.js.map +0 -1
- package/dist/frontend/npm-fetch-analysis.test.js +0 -130
- package/dist/frontend/npm-fetch-analysis.test.js.map +0 -1
- package/dist/frontend/npm-fetch-node.d.ts +0 -2
- package/dist/frontend/npm-fetch-node.js +0 -12
- package/dist/frontend/npm-fetch-node.js.map +0 -1
- package/dist/frontend/npm-fetch-syntax.d.ts +0 -6
- package/dist/frontend/npm-fetch-syntax.js +0 -202
- package/dist/frontend/npm-fetch-syntax.js.map +0 -1
- package/dist/native/runtime-typescript.d.ts +0 -4
- package/dist/native/runtime-typescript.js +0 -74
- package/dist/native/runtime-typescript.js.map +0 -1
- package/dist/native/runtime-typescript.test.js +0 -41
- package/dist/native/runtime-typescript.test.js.map +0 -1
- /package/dist/{frontend/lowering/lower-island.test.d.ts → backend/immutability.test.d.ts} +0 -0
- /package/dist/frontend/{npm-fetch-analysis.test.d.ts → lowering/narrowing-stability.test.d.ts} +0 -0
- /package/dist/{native/runtime-typescript.test.d.ts → ir/unshare.test.d.ts} +0 -0
|
@@ -13,8 +13,8 @@ import { bindingSource } from "../binding-source.js";
|
|
|
13
13
|
import { arrayValueRead, arrayValueStore, arrayValueType, unionArrayValueRead, lowerSafeIndexRead, } from "./array-values.js";
|
|
14
14
|
import { lowerForAwaitGenerator, lowerForOfGenerator, lowerYieldStarStatement, } from "./lower-generators.js";
|
|
15
15
|
import { lowerForAwaitBuiltin } from "./lower-async-iteration.js";
|
|
16
|
-
import { BOOL, BYTES_U8, CAUGHT, DYN, F64,
|
|
17
|
-
import { PoisonError, boundIdentifiersOf, dynFallbackType,
|
|
16
|
+
import { BOOL, BYTES_U8, CAUGHT, DYN, F64, STRING, UNDEFINED_T, VOID, arrayOf, isDynTypedRefType, isUnitType, shapeHasAccessorSlots, typeEquals, } from "../../ir/ir.js";
|
|
17
|
+
import { PoisonError, boundIdentifiersOf, dynFallbackType, neverTaintedJsType, staticImportNamespaceType, } from "./lowerer.js";
|
|
18
18
|
import { enforceLibBoundary, lowerSurplusCalls } from "./lib-boundary.js";
|
|
19
19
|
import { cjsExportAssignmentOf, cjsExportDiscardReason, cjsExportTargetLiteral, isCjsJsFile, isEsModuleStamp, isJsSourceFile, isNodeEsmFile, locOf, requireSpecOf, } from "../program.js";
|
|
20
20
|
import { COMPOUND_ASSIGN_OPS, STR_METHODS, UNSUPPORTED_STMT, isStdlibMember, sideEffectFreeOptionValue, stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf, } from "./surfaces.js";
|
|
@@ -51,7 +51,7 @@ import { lowerEnvironmentKey, lowerNativeFunctionAssignment } from "./lower-expr
|
|
|
51
51
|
import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
|
|
52
52
|
import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
53
53
|
import { lowerUnionFieldWrite } from "./expressions/union-fields.js";
|
|
54
|
-
import { UNSUPPORTED, checkerPanicDiag, isCheckerPanic,
|
|
54
|
+
import { UNSUPPORTED, checkerPanicDiag, isCheckerPanic, unsupportedNativeExecutionDiag, } from "../../diagnostics/diagnostic.js";
|
|
55
55
|
import { isParseArgsDynTypeName, isUnitOnlyTsType, jsOpenObjectType, unitOnlyUnion, } from "../type-mapper.js";
|
|
56
56
|
import { canonicalBuiltinModule } from "../builtin-modules.js";
|
|
57
57
|
import { isRelativeSpecifier } from "../workspace-registry.js";
|
|
@@ -489,15 +489,6 @@ export function lowerStmts(lowerer, stmts) {
|
|
|
489
489
|
if (!appended)
|
|
490
490
|
out.push(...rewritten);
|
|
491
491
|
}
|
|
492
|
-
// Island accounting (--dynamic coverage): a statement that lowered
|
|
493
|
-
// but carries island constructs compiles DYNAMICALLY — its work
|
|
494
|
-
// runs in the embedded engine, and the report says so instead of
|
|
495
|
-
// counting it as static.
|
|
496
|
-
if (!lowerer.suppressStats && lowered && stmtUsesIsland(lowered)) {
|
|
497
|
-
lowerer.stats.statementsIsland++;
|
|
498
|
-
if (sf !== undefined)
|
|
499
|
-
lowerer.bumpFileStat(sf.fileName, "island");
|
|
500
|
-
}
|
|
501
492
|
// A JS statement that lowered CLEAN can still have flushed
|
|
502
493
|
// DEFERRED collection diagnostics (a symbol lookup on an alias
|
|
503
494
|
// resolves through flushDeferred — informational here, not a
|
|
@@ -573,16 +564,6 @@ export function lowerStmts(lowerer, stmts) {
|
|
|
573
564
|
}
|
|
574
565
|
return out;
|
|
575
566
|
}
|
|
576
|
-
/** The TDZ kinds: pointer-backed representations, where the box's empty
|
|
577
|
-
* NULL slot IS the not-yet-initialized sentinel — plus the scalars
|
|
578
|
-
* (f64/bool), whose TDZ boxes store a one-element ARRAY cell so the
|
|
579
|
-
* empty-slot sentinel still works (a scalar slot has no spare state:
|
|
580
|
-
* every bit pattern is a legal value — the setTimeout-handle shape,
|
|
581
|
-
* `clearTimeout(timer)` captured above `const timer = setTimeout(...)`).
|
|
582
|
-
* Checked-dynamic values use ref boxes with their own retain/release;
|
|
583
|
-
* a NULL payload remains distinct from the allocated undefined value.
|
|
584
|
-
* caught/jsval keep their existing capture fences. Unit-only types
|
|
585
|
-
* never carry a useful forward capture. */
|
|
586
567
|
const TDZ_KINDS = new Set([
|
|
587
568
|
"func",
|
|
588
569
|
"string",
|
|
@@ -812,22 +793,7 @@ function varBindingType(lowerer, nameNode) {
|
|
|
812
793
|
}
|
|
813
794
|
if (!type)
|
|
814
795
|
type = dynFallbackType(lowerer, nameNode, lowerer.typeOf(nameNode));
|
|
815
|
-
|
|
816
|
-
// the island promise/handle — the import expression's only production
|
|
817
|
-
// (lowerVarDecl's rule for block-scoped bindings).
|
|
818
|
-
if (lowerer.dynamic &&
|
|
819
|
-
ts.isVariableDeclaration(nameNode.parent) &&
|
|
820
|
-
nameNode.parent.name === nameNode) {
|
|
821
|
-
type =
|
|
822
|
-
importCallHandleType(nameNode.parent.initializer) ??
|
|
823
|
-
// An unchecked-overload call result stores the handle, exactly the
|
|
824
|
-
// let/const rule (see uncheckedOverloadHandleCall).
|
|
825
|
-
(uncheckedOverloadHandleCall(lowerer, nameNode.parent.initializer) ? JSVAL : null) ??
|
|
826
|
-
type;
|
|
827
|
-
}
|
|
828
|
-
if (!lowerer.dynamic &&
|
|
829
|
-
ts.isVariableDeclaration(nameNode.parent) &&
|
|
830
|
-
nameNode.parent.name === nameNode) {
|
|
796
|
+
if (ts.isVariableDeclaration(nameNode.parent) && nameNode.parent.name === nameNode) {
|
|
831
797
|
type = staticImportNamespaceType(lowerer, nameNode.parent.initializer) ?? type;
|
|
832
798
|
}
|
|
833
799
|
if (!type || type.kind === "void")
|
|
@@ -885,7 +851,6 @@ function hoistVarBinding(lowerer, symbol, nameNode) {
|
|
|
885
851
|
lowerer.ctx.scopes[0].set(symbol, local);
|
|
886
852
|
// A checked-dynamic slot holds the dyn undefined (a NULL dyn is a
|
|
887
853
|
// trap); everything else rides unassignedSlotInit (interned union arm,
|
|
888
|
-
// engine undefined for jsval).
|
|
889
854
|
const wrapped = type.kind === "dyn"
|
|
890
855
|
? dynUndefinedExpr(locOf(nameNode))
|
|
891
856
|
: lowerer.unassignedSlotInit(type, locOf(nameNode));
|
|
@@ -933,10 +898,8 @@ export function predeclareForwardVar(lowerer, symbol) {
|
|
|
933
898
|
const ctx = owner.ctx;
|
|
934
899
|
if (ctx.hoistedVars.has(symbol))
|
|
935
900
|
return false; // would have resolved
|
|
936
|
-
// Only a slot that can hold `undefined` can carry
|
|
937
|
-
//
|
|
938
|
-
// a checked-dynamic binding (the dyn undefined), or a jsval 'any'
|
|
939
|
-
// binding (the engine's undefined).
|
|
901
|
+
// Only a slot that can hold `undefined` can carry pre-initialization
|
|
902
|
+
// reads: an undefined-armed union or a native checked-value binding.
|
|
940
903
|
const type = varBindingType(lowerer, nameNode);
|
|
941
904
|
if (!type)
|
|
942
905
|
return false;
|
|
@@ -1562,19 +1525,12 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
1562
1525
|
lowerer.lowerExpr(decl.initializer);
|
|
1563
1526
|
const parseArgsDynObject = init.type.kind === "dyn" &&
|
|
1564
1527
|
isParseArgsDynCheckerType(lowerer, lowerer.typeOf(decl.initializer));
|
|
1565
|
-
//
|
|
1566
|
-
//
|
|
1567
|
-
// value — the checked-dynamic tree has no destructure): JS reads the properties off
|
|
1568
|
-
// whatever the value is (a number answers undefined) — engine
|
|
1569
|
-
// semantics, the dynamic-family fence. Record and array sources fall
|
|
1570
|
-
// through to their lowerings, island handles to theirs (--dynamic
|
|
1571
|
-
// owns this construct), and JS files keep their per-site runtime
|
|
1572
|
-
// fences unchanged.
|
|
1528
|
+
// An `any`-origin source needs a represented record or array shape for
|
|
1529
|
+
// destructuring. JS files retain their per-site runtime fences.
|
|
1573
1530
|
if (lowerer.anyOrigin(decl.initializer) &&
|
|
1574
1531
|
!isJsSourceFile(decl.getSourceFile()) &&
|
|
1575
1532
|
init.type.kind !== "record" &&
|
|
1576
|
-
init.type.kind !== "array"
|
|
1577
|
-
init.type.kind !== "jsval") {
|
|
1533
|
+
init.type.kind !== "array") {
|
|
1578
1534
|
lowerer.anyOpFence("destructuring", decl);
|
|
1579
1535
|
}
|
|
1580
1536
|
// An IR-string source the CHECKER does not type as a string is a
|
|
@@ -1591,36 +1547,19 @@ export function lowerDestructuringDecl(lowerer, decl, isLet) {
|
|
|
1591
1547
|
? `array destructuring of non-array values (the source is '${lowerer.checker.typeToString(lowerer.typeOf(decl.initializer))}'-typed)`
|
|
1592
1548
|
: `object destructuring of non-record values (the source is '${lowerer.checker.typeToString(lowerer.typeOf(decl.initializer))}'-typed)`);
|
|
1593
1549
|
}
|
|
1594
|
-
//
|
|
1595
|
-
//
|
|
1596
|
-
// through its wrapper object — prototype members included — or throws
|
|
1597
|
-
// its TypeError on null/undefined; both live in the engine. When the
|
|
1598
|
-
// pattern has an engine form, --dynamic marshals the value in and
|
|
1599
|
-
// runs the REAL pattern (lowerJsvalBindingPattern); a static build
|
|
1600
|
-
// reports the dynamic-family choice instead of the dead-end type
|
|
1601
|
-
// recitation. STRING sources whose pattern the static path claims
|
|
1602
|
-
// whole (staticStringPattern — code-point positions, `length`
|
|
1603
|
-
// bindings) skip the gate in STATIC builds: lowerBindingPattern's
|
|
1604
|
-
// string branches are exact there, and the diagnostic would report a
|
|
1605
|
-
// dynamic-engine dependency the program does not have. --dynamic
|
|
1606
|
-
// keeps the engine route for every string pattern — the engine binds
|
|
1607
|
-
// undefined past the last code point where the static chars array
|
|
1608
|
-
// inherits the array divergence's trap.
|
|
1550
|
+
// Primitive destructuring requires JS wrapper coercion. Only string
|
|
1551
|
+
// patterns fully handled by staticStringPattern have native lowering.
|
|
1609
1552
|
if ((init.type.kind === "f64" ||
|
|
1610
1553
|
init.type.kind === "bool" ||
|
|
1611
1554
|
init.type.kind === "string" ||
|
|
1612
1555
|
isUnitType(init.type)) &&
|
|
1613
1556
|
!isJsSourceFile(decl.getSourceFile()) &&
|
|
1614
|
-
!(
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
null) {
|
|
1619
|
-
if (!lowerer.dynamic) {
|
|
1620
|
-
lowerer.pushDiag(requiresDynamicDiag(`destructuring '${lowerer.fmt(init.type)}' values (the engine reads through JS's wrapper coercion)`, locOf(decl)));
|
|
1557
|
+
!(init.type.kind === "string" &&
|
|
1558
|
+
staticStringPattern(lowerer, decl.name))) {
|
|
1559
|
+
{
|
|
1560
|
+
lowerer.pushDiag(unsupportedNativeExecutionDiag(`destructuring '${lowerer.fmt(init.type)}' values through JavaScript wrapper coercion`, locOf(decl)));
|
|
1621
1561
|
throw new PoisonError();
|
|
1622
1562
|
}
|
|
1623
|
-
init = lowerer.coerceToExpected(init, JSVAL);
|
|
1624
1563
|
}
|
|
1625
1564
|
const out = [];
|
|
1626
1565
|
// JS: a union source with exactly ONE destructurable arm beside unit
|
|
@@ -2513,13 +2452,6 @@ function patternBindingType(lowerer, name) {
|
|
|
2513
2452
|
return (lowerer.mapTypeOf(type) ??
|
|
2514
2453
|
(isJsSourceFile(name.getSourceFile()) ? dynFallbackType(lowerer, name, type) : null));
|
|
2515
2454
|
}
|
|
2516
|
-
/** The STATIC property name of a destructuring key: identifiers spell
|
|
2517
|
-
* themselves, string/numeric-literal keys and COMPUTED keys fold through
|
|
2518
|
-
* foldedStringKeyOf — pure single-name expressions only (`{ [k]: v }`
|
|
2519
|
-
* where k's checker type spells one property name; tsc late-bound the
|
|
2520
|
-
* source's field under exactly that name, and pure keys make skipping
|
|
2521
|
-
* the evaluation exact). Null for runtime-valued keys — the callers
|
|
2522
|
-
* fence, or route island sources to the engine pattern. */
|
|
2523
2455
|
function patternKeyNameOf(lowerer, prop) {
|
|
2524
2456
|
if (ts.isIdentifier(prop) || ts.isPrivateIdentifier(prop))
|
|
2525
2457
|
return prop.text;
|
|
@@ -2576,16 +2508,6 @@ function checkerStringSource(lowerer, e) {
|
|
|
2576
2508
|
};
|
|
2577
2509
|
return stringLike(lowerer.typeOf(e));
|
|
2578
2510
|
}
|
|
2579
|
-
/** True when a pattern over a STRING source lowers statically whole —
|
|
2580
|
-
* every element a form the chars-array/wrapper-read desugars carry.
|
|
2581
|
-
* Array patterns take positions, holes, defaults, rest (a nested rest
|
|
2582
|
-
* pattern must be an ARRAY pattern — it destructures the packed
|
|
2583
|
-
* string[]), and nested patterns, whose elements are single code
|
|
2584
|
-
* points and recurse through this same test. Object patterns take
|
|
2585
|
-
* `length` bindings — shorthand, renamed, or (dead-)defaulted.
|
|
2586
|
-
* Anything else — wrapper methods, computed keys, rest over the
|
|
2587
|
-
* wrapper — keeps the engine gate (--dynamic runs the real pattern;
|
|
2588
|
-
* a static build reports the dynamic-family choice). */
|
|
2589
2511
|
function staticStringPattern(lowerer, pattern) {
|
|
2590
2512
|
if (ts.isArrayBindingPattern(pattern)) {
|
|
2591
2513
|
return pattern.elements.every((el) => {
|
|
@@ -3190,373 +3112,14 @@ function classInstanceRestValue(lowerer, blame, srcRef, srcType, info, consumed,
|
|
|
3190
3112
|
});
|
|
3191
3113
|
return { kind: "recordLit", fields, type: restT, loc };
|
|
3192
3114
|
}
|
|
3193
|
-
/** The fences the island's element-wise object path shares: no rest
|
|
3194
|
-
* (surplus packing over a handle) and no defaults (an engine undefined
|
|
3195
|
-
* test) — the static positions now take both through their own
|
|
3196
|
-
* machinery above. */
|
|
3197
3115
|
export function checkBindingElement(lowerer, el, allowDefault = false) {
|
|
3198
3116
|
if (el.dotDotDotToken) {
|
|
3199
|
-
lowerer.unsupported("SC1031", el, "rest elements in destructuring patterns over
|
|
3117
|
+
lowerer.unsupported("SC1031", el, "rest elements in destructuring patterns over checked-value sources");
|
|
3200
3118
|
}
|
|
3201
3119
|
if (el.initializer && !allowDefault) {
|
|
3202
|
-
lowerer.unsupported("SC1031", el, "defaults in destructuring positions over
|
|
3120
|
+
lowerer.unsupported("SC1031", el, "defaults in destructuring positions over checked-value sources");
|
|
3203
3121
|
}
|
|
3204
3122
|
}
|
|
3205
|
-
/** The JS source text for a pattern default the ENGINE can evaluate —
|
|
3206
|
-
* side-effect-free literal data whose value cannot depend on compiled
|
|
3207
|
-
* scope: numeric/string/boolean/null literals (unary minus included),
|
|
3208
|
-
* provably-undefined expressions, and array/object literals of those.
|
|
3209
|
-
* Null for everything else (a default referencing compiled bindings or
|
|
3210
|
-
* calling functions has no honest engine form). */
|
|
3211
|
-
function transportableDefaultText(lowerer, e) {
|
|
3212
|
-
while (ts.isParenthesizedExpression(e))
|
|
3213
|
-
e = e.expression;
|
|
3214
|
-
if (ts.isNumericLiteral(e))
|
|
3215
|
-
return e.text;
|
|
3216
|
-
if (ts.isPrefixUnaryExpression(e) &&
|
|
3217
|
-
e.operator === ts.SyntaxKind.MinusToken &&
|
|
3218
|
-
ts.isNumericLiteral(e.operand)) {
|
|
3219
|
-
return `-${e.operand.text}`;
|
|
3220
|
-
}
|
|
3221
|
-
if (ts.isStringLiteral(e) || ts.isNoSubstitutionTemplateLiteral(e))
|
|
3222
|
-
return JSON.stringify(e.text);
|
|
3223
|
-
if (e.kind === ts.SyntaxKind.TrueKeyword)
|
|
3224
|
-
return "true";
|
|
3225
|
-
if (e.kind === ts.SyntaxKind.FalseKeyword)
|
|
3226
|
-
return "false";
|
|
3227
|
-
if (e.kind === ts.SyntaxKind.NullKeyword)
|
|
3228
|
-
return "null";
|
|
3229
|
-
// Any pure identifier whose CHECKER type is the undefined type holds
|
|
3230
|
-
// undefined (shadowing included — a value of type undefined is
|
|
3231
|
-
// undefined).
|
|
3232
|
-
if (ts.isIdentifier(e) && (lowerer.typeOf(e).flags & ts.TypeFlags.Undefined) !== 0)
|
|
3233
|
-
return "(void 0)";
|
|
3234
|
-
if (ts.isArrayLiteralExpression(e)) {
|
|
3235
|
-
const parts = [];
|
|
3236
|
-
for (const elem of e.elements) {
|
|
3237
|
-
if (ts.isOmittedExpression(elem)) {
|
|
3238
|
-
parts.push("");
|
|
3239
|
-
continue;
|
|
3240
|
-
}
|
|
3241
|
-
const t = transportableDefaultText(lowerer, elem);
|
|
3242
|
-
if (t === null)
|
|
3243
|
-
return null;
|
|
3244
|
-
parts.push(t);
|
|
3245
|
-
}
|
|
3246
|
-
return `[${parts.join(",")}]`;
|
|
3247
|
-
}
|
|
3248
|
-
if (ts.isObjectLiteralExpression(e)) {
|
|
3249
|
-
const parts = [];
|
|
3250
|
-
for (const prop of e.properties) {
|
|
3251
|
-
if (!ts.isPropertyAssignment(prop))
|
|
3252
|
-
return null;
|
|
3253
|
-
let key;
|
|
3254
|
-
if (ts.isIdentifier(prop.name) ||
|
|
3255
|
-
ts.isStringLiteral(prop.name) ||
|
|
3256
|
-
ts.isNumericLiteral(prop.name)) {
|
|
3257
|
-
key = JSON.stringify(prop.name.text);
|
|
3258
|
-
}
|
|
3259
|
-
else {
|
|
3260
|
-
return null;
|
|
3261
|
-
}
|
|
3262
|
-
const t = transportableDefaultText(lowerer, prop.initializer);
|
|
3263
|
-
if (t === null)
|
|
3264
|
-
return null;
|
|
3265
|
-
parts.push(`[${key}]:${t}`);
|
|
3266
|
-
}
|
|
3267
|
-
return `{${parts.join(",")}}`;
|
|
3268
|
-
}
|
|
3269
|
-
return null;
|
|
3270
|
-
}
|
|
3271
|
-
/** A declaration pattern rebuilt as ENGINE source with every bound name
|
|
3272
|
-
* renamed __0..__n (pattern order): holes, nesting, rest, and
|
|
3273
|
-
* transportable defaults all survive verbatim, so the engine runs the
|
|
3274
|
-
* REAL pattern — the iterator protocol on array patterns,
|
|
3275
|
-
* RequireObjectCoercible on object patterns, JS's own default rule.
|
|
3276
|
-
* Null when any element has no engine form (computed keys — a compiled
|
|
3277
|
-
* expression the pattern text cannot carry — or untransportable
|
|
3278
|
-
* defaults). */
|
|
3279
|
-
function enginePatternSpec(lowerer, pattern) {
|
|
3280
|
-
const binds = [];
|
|
3281
|
-
const extras = [];
|
|
3282
|
-
// Every name the pattern itself binds, by text: a default referencing
|
|
3283
|
-
// one is JS's earlier-element-in-scope (or TDZ) rule, which the
|
|
3284
|
-
// pre-evaluated extras below cannot honor — those defaults have no
|
|
3285
|
-
// engine form here.
|
|
3286
|
-
const ownNames = new Set();
|
|
3287
|
-
const collectOwn = (p) => {
|
|
3288
|
-
for (const el of p.elements) {
|
|
3289
|
-
if (ts.isOmittedExpression(el) || el.name === undefined)
|
|
3290
|
-
continue;
|
|
3291
|
-
if (ts.isIdentifier(el.name))
|
|
3292
|
-
ownNames.add(el.name.text);
|
|
3293
|
-
else
|
|
3294
|
-
collectOwn(el.name);
|
|
3295
|
-
}
|
|
3296
|
-
};
|
|
3297
|
-
collectOwn(pattern);
|
|
3298
|
-
// A key or default with no literal engine text but a COMPILED-SCOPE
|
|
3299
|
-
// form the engine can run exactly:
|
|
3300
|
-
// - a plain identifier the pattern does not itself bind (`{ p: {} =
|
|
3301
|
-
// a } = a` with `a: any`) passes in as an extra parameter —
|
|
3302
|
-
// pre-evaluation of a bare variable read is unobservable (no side
|
|
3303
|
-
// effects, and the engine call is atomic);
|
|
3304
|
-
// - an identifier bound by an EARLIER element of this pattern spells
|
|
3305
|
-
// its own temp (`[{ ...a }, b = a]` — the engine's mid-pattern
|
|
3306
|
-
// scope IS JS's, so the reference reads the just-bound value);
|
|
3307
|
-
// same-element and later names have no honest form (TDZ vs the
|
|
3308
|
-
// temps' var-undefined) and bail;
|
|
3309
|
-
// - a CALL of such an identifier over transportable arguments
|
|
3310
|
-
// (`{ [order(1)]: x } = order(0)` — the evaluation-order corpus)
|
|
3311
|
-
// spells the call itself, so the engine runs it at exactly JS's
|
|
3312
|
-
// pattern position: keys in pattern order, defaults lazily. The
|
|
3313
|
-
// callee marshals through the host-function trampoline.
|
|
3314
|
-
// `boundBefore` is the bind count when the current element's key/
|
|
3315
|
-
// default began — the earlier-element boundary.
|
|
3316
|
-
const tempIndexOf = (name, boundBefore) => {
|
|
3317
|
-
for (let i = 0; i < boundBefore; i++) {
|
|
3318
|
-
if (binds[i].text === name)
|
|
3319
|
-
return i;
|
|
3320
|
-
}
|
|
3321
|
-
return -1;
|
|
3322
|
-
};
|
|
3323
|
-
const exprText = (init, boundBefore) => {
|
|
3324
|
-
const t = transportableDefaultText(lowerer, init);
|
|
3325
|
-
if (t !== null)
|
|
3326
|
-
return t;
|
|
3327
|
-
let e = init;
|
|
3328
|
-
while (ts.isParenthesizedExpression(e))
|
|
3329
|
-
e = e.expression;
|
|
3330
|
-
if (ts.isIdentifier(e)) {
|
|
3331
|
-
if (ownNames.has(e.text)) {
|
|
3332
|
-
const idx = tempIndexOf(e.text, boundBefore);
|
|
3333
|
-
return idx >= 0 ? `__${idx}` : null;
|
|
3334
|
-
}
|
|
3335
|
-
extras.push(e);
|
|
3336
|
-
return `__d${extras.length - 1}`;
|
|
3337
|
-
}
|
|
3338
|
-
if (ts.isCallExpression(e) &&
|
|
3339
|
-
!e.questionDotToken &&
|
|
3340
|
-
ts.isIdentifier(e.expression) &&
|
|
3341
|
-
e.typeArguments === undefined) {
|
|
3342
|
-
const callee = exprText(e.expression, boundBefore);
|
|
3343
|
-
if (callee === null)
|
|
3344
|
-
return null;
|
|
3345
|
-
const args = [];
|
|
3346
|
-
for (const a of e.arguments) {
|
|
3347
|
-
if (ts.isSpreadElement(a))
|
|
3348
|
-
return null;
|
|
3349
|
-
const at = exprText(a, boundBefore);
|
|
3350
|
-
if (at === null)
|
|
3351
|
-
return null;
|
|
3352
|
-
args.push(at);
|
|
3353
|
-
}
|
|
3354
|
-
return `${callee}(${args.join(",")})`;
|
|
3355
|
-
}
|
|
3356
|
-
return null;
|
|
3357
|
-
};
|
|
3358
|
-
const target = (name) => {
|
|
3359
|
-
if (ts.isIdentifier(name)) {
|
|
3360
|
-
binds.push(name);
|
|
3361
|
-
return `__${binds.length - 1}`;
|
|
3362
|
-
}
|
|
3363
|
-
return build(name);
|
|
3364
|
-
};
|
|
3365
|
-
const build = (p) => {
|
|
3366
|
-
if (ts.isArrayBindingPattern(p)) {
|
|
3367
|
-
const parts = [];
|
|
3368
|
-
for (const el of p.elements) {
|
|
3369
|
-
if (ts.isOmittedExpression(el) || el.name === undefined) {
|
|
3370
|
-
parts.push("");
|
|
3371
|
-
continue;
|
|
3372
|
-
}
|
|
3373
|
-
const boundBefore = binds.length;
|
|
3374
|
-
let sub = target(el.name);
|
|
3375
|
-
if (sub === null)
|
|
3376
|
-
return null;
|
|
3377
|
-
if (el.initializer) {
|
|
3378
|
-
const d = exprText(el.initializer, boundBefore);
|
|
3379
|
-
if (d === null)
|
|
3380
|
-
return null;
|
|
3381
|
-
sub = sub + `=${d}`;
|
|
3382
|
-
}
|
|
3383
|
-
parts.push(el.dotDotDotToken ? `...${sub}` : sub);
|
|
3384
|
-
}
|
|
3385
|
-
return `[${parts.join(",")}]`;
|
|
3386
|
-
}
|
|
3387
|
-
const parts = [];
|
|
3388
|
-
for (const el of p.elements) {
|
|
3389
|
-
if (el.name === undefined)
|
|
3390
|
-
continue;
|
|
3391
|
-
if (el.dotDotDotToken) {
|
|
3392
|
-
const sub = target(el.name);
|
|
3393
|
-
if (sub === null)
|
|
3394
|
-
return null;
|
|
3395
|
-
parts.push(`...${sub}`);
|
|
3396
|
-
continue;
|
|
3397
|
-
}
|
|
3398
|
-
const boundBefore = binds.length;
|
|
3399
|
-
const prop = el.propertyName ?? el.name;
|
|
3400
|
-
let key = null;
|
|
3401
|
-
if (ts.isIdentifier(prop) || ts.isPrivateIdentifier(prop)) {
|
|
3402
|
-
key = JSON.stringify(prop.text);
|
|
3403
|
-
}
|
|
3404
|
-
else if (ts.isStringLiteral(prop) ||
|
|
3405
|
-
ts.isNumericLiteral(prop) ||
|
|
3406
|
-
ts.isNoSubstitutionTemplateLiteral(prop)) {
|
|
3407
|
-
key = JSON.stringify(prop.text);
|
|
3408
|
-
}
|
|
3409
|
-
else if (ts.isComputedPropertyName(prop)) {
|
|
3410
|
-
// A computed key: a FOLDABLE one (pure single-name expression)
|
|
3411
|
-
// spells its static name; anything else takes the transportable
|
|
3412
|
-
// form — extras for compiled-scope identifiers, temps for
|
|
3413
|
-
// earlier-bound names, calls run at exactly JS's key position
|
|
3414
|
-
// (pattern order, before the element's read).
|
|
3415
|
-
const folded = lowerer.foldedStringKeyOf(prop.expression);
|
|
3416
|
-
key = folded !== null ? JSON.stringify(folded) : exprText(prop.expression, boundBefore);
|
|
3417
|
-
}
|
|
3418
|
-
if (key === null) {
|
|
3419
|
-
return null; // an unfoldable computed key with no engine form
|
|
3420
|
-
}
|
|
3421
|
-
let sub = target(el.name);
|
|
3422
|
-
if (sub === null)
|
|
3423
|
-
return null;
|
|
3424
|
-
if (el.initializer) {
|
|
3425
|
-
const d = exprText(el.initializer, boundBefore);
|
|
3426
|
-
if (d === null)
|
|
3427
|
-
return null;
|
|
3428
|
-
sub = sub + `=${d}`;
|
|
3429
|
-
}
|
|
3430
|
-
parts.push(`[${key}]:${sub}`);
|
|
3431
|
-
}
|
|
3432
|
-
return `{${parts.join(",")}}`;
|
|
3433
|
-
};
|
|
3434
|
-
const text = build(pattern);
|
|
3435
|
-
return text === null ? null : { text, binds, extras };
|
|
3436
|
-
}
|
|
3437
|
-
/** Declaration-position destructuring over an ISLAND source: the ENGINE
|
|
3438
|
-
* runs the real pattern — a synthesized strict-mode
|
|
3439
|
-
* `new Function("v", ...)` exactly like the assignment chain's
|
|
3440
|
-
* (lowerJsvalDestructuringChain) — and the extracted values bind the
|
|
3441
|
-
* declared names: a name whose declared type is a primitive exits
|
|
3442
|
-
* eagerly (the island property-read rule), everything else stays a
|
|
3443
|
-
* HANDLE whose use sites dispatch to engine ops. Holes, nesting, empty
|
|
3444
|
-
* patterns (the object coercion check and the array iterator get+close
|
|
3445
|
-
* both run — destructuring undefined throws Node's TypeError at Node's
|
|
3446
|
-
* exit), rest, and transportable defaults all ride. False when the
|
|
3447
|
-
* pattern has no engine form (the caller fences). */
|
|
3448
|
-
export function lowerJsvalBindingPattern(lowerer, pattern, srcRef, isLet, out) {
|
|
3449
|
-
const spec = enginePatternSpec(lowerer, pattern);
|
|
3450
|
-
if (!spec)
|
|
3451
|
-
return false;
|
|
3452
|
-
const loc = locOf(pattern);
|
|
3453
|
-
const temps = spec.binds.map((_, i) => `__${i}`);
|
|
3454
|
-
const body = `"use strict";` +
|
|
3455
|
-
(temps.length > 0 ? `var ${temps.join(",")};` : "") +
|
|
3456
|
-
`(${spec.text} = v);return [${temps.join(",")}];`;
|
|
3457
|
-
// Compiled-scope defaults (enginePatternSpec's extras) enter the
|
|
3458
|
-
// synthesized function as additional parameters __d0..__dn, their
|
|
3459
|
-
// values evaluated here and marshaled across.
|
|
3460
|
-
const paramNames = ["v", ...spec.extras.map((_, i) => `__d${i}`)];
|
|
3461
|
-
const helper = {
|
|
3462
|
-
kind: "jsOp",
|
|
3463
|
-
op: "construct",
|
|
3464
|
-
args: [
|
|
3465
|
-
{ kind: "jsOp", op: "globalGet", name: "Function", args: [], type: JSVAL, loc },
|
|
3466
|
-
...paramNames.map((p) => ({
|
|
3467
|
-
kind: "jsMarshal",
|
|
3468
|
-
value: { kind: "strLit", value: p, type: STRING, loc },
|
|
3469
|
-
type: JSVAL,
|
|
3470
|
-
loc,
|
|
3471
|
-
})),
|
|
3472
|
-
{
|
|
3473
|
-
kind: "jsMarshal",
|
|
3474
|
-
value: { kind: "strLit", value: body, type: STRING, loc },
|
|
3475
|
-
type: JSVAL,
|
|
3476
|
-
loc,
|
|
3477
|
-
},
|
|
3478
|
-
],
|
|
3479
|
-
type: JSVAL,
|
|
3480
|
-
loc,
|
|
3481
|
-
};
|
|
3482
|
-
const extraArgs = spec.extras.map((e) => lowerer.jsvalIn(lowerer.lowerExpr(e), e));
|
|
3483
|
-
const run = {
|
|
3484
|
-
kind: "jsOp",
|
|
3485
|
-
op: "callFn",
|
|
3486
|
-
args: [helper, srcRef(), ...extraArgs],
|
|
3487
|
-
type: JSVAL,
|
|
3488
|
-
loc,
|
|
3489
|
-
};
|
|
3490
|
-
if (spec.binds.length === 0) {
|
|
3491
|
-
out.push({ kind: "exprStmt", expr: run, loc });
|
|
3492
|
-
return true;
|
|
3493
|
-
}
|
|
3494
|
-
const res = lowerer.declareHiddenLocal("%dres", JSVAL);
|
|
3495
|
-
out.push({ kind: "varDecl", localId: res.id, init: run, loc });
|
|
3496
|
-
spec.binds.forEach((name, i) => {
|
|
3497
|
-
const bindLoc = locOf(name);
|
|
3498
|
-
const read = {
|
|
3499
|
-
kind: "jsOp",
|
|
3500
|
-
op: "getIdx",
|
|
3501
|
-
args: [
|
|
3502
|
-
{ kind: "varRef", localId: res.id, type: JSVAL, loc: bindLoc },
|
|
3503
|
-
{
|
|
3504
|
-
kind: "jsMarshal",
|
|
3505
|
-
value: { kind: "numLit", value: i, type: F64, loc: bindLoc },
|
|
3506
|
-
type: JSVAL,
|
|
3507
|
-
loc: bindLoc,
|
|
3508
|
-
},
|
|
3509
|
-
],
|
|
3510
|
-
type: JSVAL,
|
|
3511
|
-
loc: bindLoc,
|
|
3512
|
-
};
|
|
3513
|
-
// The island property-read stance: a name the checker declares as a
|
|
3514
|
-
// primitive exits eagerly to the static type; everything else stays
|
|
3515
|
-
// a handle.
|
|
3516
|
-
const declared = lowerer.mapTypeOf(lowerer.typeOf(name));
|
|
3517
|
-
const primitive = declared &&
|
|
3518
|
-
(declared.kind === "f64" || declared.kind === "bool" || declared.kind === "string");
|
|
3519
|
-
const value = primitive
|
|
3520
|
-
? { kind: "jsExit", value: read, type: declared, loc: bindLoc }
|
|
3521
|
-
: read;
|
|
3522
|
-
const symbol = lowerer.checker.getSymbolAtLocation(name);
|
|
3523
|
-
const g = symbol ? lowerer.globalsBySymbol.get(symbol) : undefined;
|
|
3524
|
-
if (g) {
|
|
3525
|
-
out.push({
|
|
3526
|
-
kind: "assign",
|
|
3527
|
-
localId: g.id,
|
|
3528
|
-
value: lowerer.coerceInto(name, value, g.type),
|
|
3529
|
-
...(g.tdz ? { initializes: true } : {}),
|
|
3530
|
-
loc: bindLoc,
|
|
3531
|
-
});
|
|
3532
|
-
return;
|
|
3533
|
-
}
|
|
3534
|
-
if (symbol && hostVariableDeclarationOf(name) !== null && isVarDeclared(name)) {
|
|
3535
|
-
const hoisted = hoistVarBinding(lowerer, symbol, name);
|
|
3536
|
-
out.push({
|
|
3537
|
-
kind: "assign",
|
|
3538
|
-
localId: hoisted.id,
|
|
3539
|
-
value: lowerer.coerceInto(name, value, hoisted.type),
|
|
3540
|
-
loc: bindLoc,
|
|
3541
|
-
});
|
|
3542
|
-
return;
|
|
3543
|
-
}
|
|
3544
|
-
const local = lowerer.declareLocal(name, name.text, value.type, isLet);
|
|
3545
|
-
out.push({ kind: "varDecl", localId: local.id, init: value, loc: bindLoc });
|
|
3546
|
-
});
|
|
3547
|
-
return true;
|
|
3548
|
-
}
|
|
3549
|
-
/** Binds one destructured name to its value — the identifier tail of
|
|
3550
|
-
* lowerVarDecl (module-global assignment for pre-registered file-scope
|
|
3551
|
-
* names, declareLocal otherwise), or a nested pattern through its own
|
|
3552
|
-
* hidden temp. */
|
|
3553
|
-
/** An island-world ('any'-flavored) checker spelling: bare jsval or an
|
|
3554
|
-
* array of jsvals (`(string | object)[]` absorbed by its jsval arm) —
|
|
3555
|
-
* the shapes the runtime-world local rule keeps DYN when the value
|
|
3556
|
-
* lowered checked-dynamic. */
|
|
3557
|
-
function jsvalFlavoredType(t) {
|
|
3558
|
-
return t.kind === "jsval" || (t.kind === "array" && t.elem.kind === "jsval");
|
|
3559
|
-
}
|
|
3560
3123
|
export function bindPatternTarget(lowerer, name, value, isLet, out, allowDynObject = false) {
|
|
3561
3124
|
const loc = value.loc;
|
|
3562
3125
|
if (ts.isIdentifier(name)) {
|
|
@@ -3588,19 +3151,12 @@ export function bindPatternTarget(lowerer, name, value, isLet, out, allowDynObje
|
|
|
3588
3151
|
});
|
|
3589
3152
|
return;
|
|
3590
3153
|
}
|
|
3591
|
-
//
|
|
3592
|
-
//
|
|
3593
|
-
// where the checker spells an island-world type (`function f({
|
|
3594
|
-
// plugins = [] } = {})` over a JSDoc '(string | object)[]=' member —
|
|
3595
|
-
// the read is a dyn keyed read whose members may be wrapped island
|
|
3596
|
-
// values) or a type with no mapping at all (the varDecl rule's
|
|
3597
|
-
// unmappable-declared-type stance, `string | object` bindings
|
|
3598
|
-
// included). Marshaling here would fence or deep-copy; the value's
|
|
3599
|
-
// world is the honest dispatch.
|
|
3154
|
+
// Preserve checked-value pattern bindings when the inferred type
|
|
3155
|
+
// cannot represent them without a refusal or an alias-breaking copy.
|
|
3600
3156
|
const dynStays = value.type.kind === "dyn" &&
|
|
3601
3157
|
(() => {
|
|
3602
3158
|
const mapped = lowerer.mapTypeOf(lowerer.typeOf(name));
|
|
3603
|
-
return mapped === null
|
|
3159
|
+
return mapped === null;
|
|
3604
3160
|
})();
|
|
3605
3161
|
let type = dynStays
|
|
3606
3162
|
? DYN
|
|
@@ -3742,11 +3298,7 @@ function inferredEvolvingLetType(lowerer, decl) {
|
|
|
3742
3298
|
return "stop";
|
|
3743
3299
|
}
|
|
3744
3300
|
const mapped = lowerer.mapTypeOf(lowerer.typeOf(node.right));
|
|
3745
|
-
if (!mapped ||
|
|
3746
|
-
mapped.kind === "dyn" ||
|
|
3747
|
-
mapped.kind === "jsval" ||
|
|
3748
|
-
mapped.kind === "void" ||
|
|
3749
|
-
isUnitType(mapped)) {
|
|
3301
|
+
if (!mapped || mapped.kind === "dyn" || mapped.kind === "void" || isUnitType(mapped)) {
|
|
3750
3302
|
invalid = true;
|
|
3751
3303
|
return "stop";
|
|
3752
3304
|
}
|
|
@@ -4002,9 +3554,8 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4002
3554
|
// a loop — must NOT reset the persisting binding.
|
|
4003
3555
|
if (isVarDeclared(decl))
|
|
4004
3556
|
return null;
|
|
4005
|
-
// Checked-
|
|
4006
|
-
//
|
|
4007
|
-
// unassignedSlotInit's arms.
|
|
3557
|
+
// Checked-value globals hold native undefined; typed slots use
|
|
3558
|
+
// unassignedSlotInit's union arms.
|
|
4008
3559
|
const wrapped = g.type.kind === "dyn"
|
|
4009
3560
|
? dynUndefinedExpr(locOf(decl))
|
|
4010
3561
|
: lowerer.unassignedSlotInit(g.type, locOf(decl));
|
|
@@ -4092,9 +3643,7 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4092
3643
|
lowerer.badType(decl.name, lowerer.typeOf(decl.name));
|
|
4093
3644
|
const local = lowerer.declareLocal(decl.name, decl.name.text, type, isLet);
|
|
4094
3645
|
// tsc's definite-assignment analysis never guards `any` reads, so
|
|
4095
|
-
// uninitialized bindings must hold
|
|
4096
|
-
// NULL: unions the interned arm, dyn the dyn undefined, jsval the
|
|
4097
|
-
// engine's — all readable immediately, exactly Node.
|
|
3646
|
+
// uninitialized checked-value bindings must hold native undefined.
|
|
4098
3647
|
const init = type.kind === "dyn"
|
|
4099
3648
|
? dynUndefinedExpr(locOf(decl))
|
|
4100
3649
|
: lowerer.unassignedSlotInit(type, locOf(decl));
|
|
@@ -4154,41 +3703,11 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4154
3703
|
// `any`, which a static build cannot hold): the VALUE is a dyn
|
|
4155
3704
|
// subtree, so the local stays dyn — later narrowing tests and checked
|
|
4156
3705
|
// casts read it like any JSON.parse result.
|
|
4157
|
-
// `const
|
|
4158
|
-
// island promise/handle is the import expression's only production —
|
|
4159
|
-
// the binding holds it, whatever the checker's namespace type mapped
|
|
4160
|
-
// to (the island-HANDLE local story). Below that: a never-tainted JS
|
|
4161
|
-
// binding type (`const cmd = ['pwd', []]` infers (string | never[])[])
|
|
3706
|
+
// A binding type (`const cmd = ['pwd', []]` infers (string | never[])[])
|
|
4162
3707
|
// is inference residue, not element information — unmappable, so the
|
|
4163
3708
|
// dyn initializer keeps the binding checked-dynamic.
|
|
4164
3709
|
const bindingTainted = neverTaintedJsType(lowerer, decl.name, lowerer.typeOf(decl.name));
|
|
4165
|
-
let type = (lowerer.
|
|
4166
|
-
(init.type.kind === "jsval" ||
|
|
4167
|
-
(init.type.kind === "promise" && init.type.inner.kind === "jsval"))
|
|
4168
|
-
? (importCallHandleType(decl.initializer) ??
|
|
4169
|
-
// An unchecked-overload call result (the resolved overload's
|
|
4170
|
-
// return type was never checked against the jsval-returning
|
|
4171
|
-
// implementation): the binding stores the handle — see
|
|
4172
|
-
// uncheckedOverloadHandleCall.
|
|
4173
|
-
(init.type.kind === "jsval" && uncheckedOverloadHandleCall(lowerer, decl.initializer)
|
|
4174
|
-
? JSVAL
|
|
4175
|
-
: null))
|
|
4176
|
-
: null) ??
|
|
4177
|
-
// The runtime-world local rule, dyn side (383(d)'s dispatch stance —
|
|
4178
|
-
// the island-HANDLE local rule's mirror): a binding whose
|
|
4179
|
-
// INITIALIZER lowered checked-dynamic stays dyn even where the
|
|
4180
|
-
// checker spells 'any' (`const parsers = options.parsers ?? {}` over
|
|
4181
|
-
// an 'object'-typed bag — the read is a dyn keyed read). Marshaling
|
|
4182
|
-
// into the engine here would deep-copy data and sever aliasing; the
|
|
4183
|
-
// value's world is the honest dispatch, and every use site already
|
|
4184
|
-
// handles dyn (validated exits, routed engine ops for wrapped
|
|
4185
|
-
// island members).
|
|
4186
|
-
(lowerer.dynamic &&
|
|
4187
|
-
init.type.kind === "dyn" &&
|
|
4188
|
-
jsvalFlavoredType(lowerer.mapTypeOf(lowerer.typeOf(decl.name)) ?? DYN)
|
|
4189
|
-
? DYN
|
|
4190
|
-
: null) ??
|
|
4191
|
-
(bindingTainted ? null : lowerer.mapTypeOf(lowerer.typeOf(decl.name))) ??
|
|
3710
|
+
let type = (bindingTainted ? null : lowerer.mapTypeOf(lowerer.typeOf(decl.name))) ??
|
|
4192
3711
|
staticImportNamespaceType(lowerer, decl.initializer) ??
|
|
4193
3712
|
(init.type.kind === "moduleNs" ? init.type : null) ??
|
|
4194
3713
|
(init.type.kind === "dyn" ? DYN : null);
|
|
@@ -4376,7 +3895,6 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4376
3895
|
(type === null && isJsSourceFile(decl.getSourceFile()))) &&
|
|
4377
3896
|
init.type.kind !== "void" &&
|
|
4378
3897
|
init.type.kind !== "caught" &&
|
|
4379
|
-
init.type.kind !== "jsval" &&
|
|
4380
3898
|
!isUnitType(init.type)) {
|
|
4381
3899
|
type = init.type;
|
|
4382
3900
|
}
|
|
@@ -4456,39 +3974,6 @@ export function lowerVarDecl(lowerer, decl, isLet) {
|
|
|
4456
3974
|
}
|
|
4457
3975
|
if (settledType.kind === "void")
|
|
4458
3976
|
lowerer.badType(decl.name, lowerer.typeOf(decl.name));
|
|
4459
|
-
// A PACKAGE promise stored in a local stays an island HANDLE — the
|
|
4460
|
-
// engine's promise has no static promise value to coerce into. Awaits
|
|
4461
|
-
// and .catch/.finally chains on the local bridge per use site (each
|
|
4462
|
-
// bridge is an independent observer of the same settlement).
|
|
4463
|
-
if (init.type.kind === "jsval" && settledType.kind === "promise")
|
|
4464
|
-
settledType = JSVAL;
|
|
4465
|
-
// An island value under an `any[]`-declared LOCAL spelling stays an
|
|
4466
|
-
// island HANDLE too (the runtime-world rule): the jsval-element-array
|
|
4467
|
-
// exit is a CALL-boundary conversion (the loadPlugins param ABI) —
|
|
4468
|
-
// converting a local would strand the engine's own prototypes
|
|
4469
|
-
// (join/map/... on a native handle-element array), where the handle
|
|
4470
|
-
// routes every use engine-side.
|
|
4471
|
-
if (init.type.kind === "jsval" &&
|
|
4472
|
-
settledType.kind === "array" &&
|
|
4473
|
-
settledType.elem.kind === "jsval") {
|
|
4474
|
-
settledType = JSVAL;
|
|
4475
|
-
}
|
|
4476
|
-
// A STATIC array of island HANDLES under an unannotated declared type
|
|
4477
|
-
// spelling evolved elements (`const kept = fns.filter(...)` over an
|
|
4478
|
-
// evolving-`any` receiver — the handle-element lowering keeps the
|
|
4479
|
-
// elements jsval, while tsc's evolving-array analysis types the
|
|
4480
|
-
// result by the pushed elements): the value's element type is the
|
|
4481
|
-
// truth, so the binding keeps the handle-element array (the
|
|
4482
|
-
// island-HANDLE local story, one level down) and later method calls
|
|
4483
|
-
// ride the handle-element lowering. Explicit annotations keep the
|
|
4484
|
-
// validated-boundary fence.
|
|
4485
|
-
if (!decl.type &&
|
|
4486
|
-
init.type.kind === "array" &&
|
|
4487
|
-
init.type.elem.kind === "jsval" &&
|
|
4488
|
-
settledType.kind === "array" &&
|
|
4489
|
-
settledType.elem.kind !== "jsval") {
|
|
4490
|
-
settledType = init.type;
|
|
4491
|
-
}
|
|
4492
3977
|
// `const runner = options.runner || defaultRunner`: the checker types
|
|
4493
3978
|
// the || as the union/merge of two structurally-compatible function
|
|
4494
3979
|
// types — a signature whose RETURN is the arms' union, or the
|
|
@@ -5720,7 +5205,7 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
5720
5205
|
if (arrayType?.kind === "array") {
|
|
5721
5206
|
const arr = lowerer.lowerExpr(expr.left.expression);
|
|
5722
5207
|
if (arr.type.kind !== "array") {
|
|
5723
|
-
lowerer.unsupported("SC1090", expr.left.expression, "writing the length of an array-typed value
|
|
5208
|
+
lowerer.unsupported("SC1090", expr.left.expression, "writing the length of an array-typed value without native array storage");
|
|
5724
5209
|
}
|
|
5725
5210
|
const length = lowerer.lowerExprExpecting(expr.right, F64);
|
|
5726
5211
|
return { kind: "arraySetLength", arr, length, loc: locOf(expr) };
|
|
@@ -5754,47 +5239,6 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
5754
5239
|
// this method's own `this` — super dispatch is static in JS.
|
|
5755
5240
|
return lowerer.lowerSuperAccessorWrite(expr.left, expr.right, locOf(expr));
|
|
5756
5241
|
}
|
|
5757
|
-
if (lowerer.isIslandExpr(expr.left.expression)) {
|
|
5758
|
-
// o.x = v on an island receiver: engine property write; the
|
|
5759
|
-
// value marshals in (a static RHS crosses by value/copy).
|
|
5760
|
-
const obj = lowerer.lowerExpr(expr.left.expression);
|
|
5761
|
-
const loc = locOf(expr);
|
|
5762
|
-
// Dispatch follows the RUNTIME world (383(d)): a checker-'any'
|
|
5763
|
-
// receiver whose value LOWERED checked-dynamic (`bag.nested.x
|
|
5764
|
-
// = v` behind an 'object'-typed bag) takes the dyn keyed
|
|
5765
|
-
// write — the routed JSVAL arm lands it on the real engine
|
|
5766
|
-
// object.
|
|
5767
|
-
if (obj.type.kind === "dyn") {
|
|
5768
|
-
const key = {
|
|
5769
|
-
kind: "strLit",
|
|
5770
|
-
value: expr.left.name.text,
|
|
5771
|
-
type: STRING,
|
|
5772
|
-
loc: locOf(expr.left.name),
|
|
5773
|
-
};
|
|
5774
|
-
const value = lowerer.coerceToExpected(lowerer.lowerExpr(expr.right), DYN);
|
|
5775
|
-
if (value.type.kind !== "dyn") {
|
|
5776
|
-
lowerer.unsupported("SC1100", expr.right, `assigning '${lowerer.fmt(value.type)}' values through 'unknown' receivers`);
|
|
5777
|
-
}
|
|
5778
|
-
return {
|
|
5779
|
-
kind: "exprStmt",
|
|
5780
|
-
expr: { kind: "libCall", fn: "dyn.keySet", args: [obj, key, value], type: VOID, loc },
|
|
5781
|
-
loc,
|
|
5782
|
-
};
|
|
5783
|
-
}
|
|
5784
|
-
const value = lowerer.jsvalIn(lowerer.lowerExpr(expr.right), expr.right);
|
|
5785
|
-
return {
|
|
5786
|
-
kind: "exprStmt",
|
|
5787
|
-
expr: {
|
|
5788
|
-
kind: "jsOp",
|
|
5789
|
-
op: "setProp",
|
|
5790
|
-
name: expr.left.name.text,
|
|
5791
|
-
args: [obj, value],
|
|
5792
|
-
type: VOID,
|
|
5793
|
-
loc,
|
|
5794
|
-
},
|
|
5795
|
-
loc,
|
|
5796
|
-
};
|
|
5797
|
-
}
|
|
5798
5242
|
// wrapper.close = fn — the net.Server close-override idiom
|
|
5799
5243
|
// (routed to lower-server; the generic fences stay for
|
|
5800
5244
|
// everything else).
|
|
@@ -6095,15 +5539,6 @@ export function lowerExprStatement(lowerer, expr) {
|
|
|
6095
5539
|
}
|
|
6096
5540
|
}
|
|
6097
5541
|
if (ts.isObjectLiteralExpression(expr.left) || ts.isArrayLiteralExpression(expr.left)) {
|
|
6098
|
-
// Destructuring assignment (chains included) whose SOURCE is an
|
|
6099
|
-
// island value: the ENGINE runs the pattern (JS-exact coercions
|
|
6100
|
-
// — RequireObjectCoercible on object patterns, the iterator
|
|
6101
|
-
// protocol on array patterns) and hands the extracted values
|
|
6102
|
-
// back for the compiled targets. Static sources fall through to
|
|
6103
|
-
// the general assignment lowering below.
|
|
6104
|
-
const viaIsland = lowerJsvalDestructuringChain(lowerer, expr);
|
|
6105
|
-
if (viaIsland)
|
|
6106
|
-
return viaIsland;
|
|
6107
5542
|
// Destructuring ASSIGNMENT to existing bindings:
|
|
6108
5543
|
// `({ dir, port } = await discoverState());`, `[a, b = 0, ...rest] = t` —
|
|
6109
5544
|
// the RHS evaluates once into a hidden temp, then each target
|
|
@@ -6307,198 +5742,6 @@ function lowerCompoundToTarget(lowerer, expr, compound, target) {
|
|
|
6307
5742
|
loc: locOf(expr),
|
|
6308
5743
|
};
|
|
6309
5744
|
}
|
|
6310
|
-
/** One destructuring-assignment pattern the island can run: empty object/
|
|
6311
|
-
* array patterns and flat identifier targets — shorthand `{ x }`,
|
|
6312
|
-
* renamed `{ a: x }`, FOLDED computed keys `{ [k]: x }` (2105's
|
|
6313
|
-
* static-fold rule: a pure key expression whose checker type spells one
|
|
6314
|
-
* property name — skipping its evaluation is exact), array elements
|
|
6315
|
-
* `[x, y]`. Answers the source FIELD key (object patterns) and the
|
|
6316
|
-
* target identifier per binding, in pattern order; null for any other
|
|
6317
|
-
* pattern form (defaults, rest, nesting, holes, non-identifier targets,
|
|
6318
|
-
* runtime-valued keys — the existing fences own those). */
|
|
6319
|
-
function islandRunnablePattern(lowerer, pattern) {
|
|
6320
|
-
if (ts.isObjectLiteralExpression(pattern)) {
|
|
6321
|
-
const binds = [];
|
|
6322
|
-
for (const prop of pattern.properties) {
|
|
6323
|
-
if (ts.isShorthandPropertyAssignment(prop)) {
|
|
6324
|
-
if (prop.objectAssignmentInitializer)
|
|
6325
|
-
return null;
|
|
6326
|
-
// 7 types the shorthand's name as PropertyName; the grammar
|
|
6327
|
-
// allows nothing but an Identifier there (lowerShorthandValue).
|
|
6328
|
-
const name = prop.name;
|
|
6329
|
-
binds.push({ field: name.text, target: name, shorthand: prop });
|
|
6330
|
-
}
|
|
6331
|
-
else if (ts.isPropertyAssignment(prop) &&
|
|
6332
|
-
ts.isIdentifier(prop.name) &&
|
|
6333
|
-
ts.isIdentifier(prop.initializer)) {
|
|
6334
|
-
binds.push({ field: prop.name.text, target: prop.initializer, shorthand: null });
|
|
6335
|
-
}
|
|
6336
|
-
else if (ts.isPropertyAssignment(prop) &&
|
|
6337
|
-
ts.isComputedPropertyName(prop.name) &&
|
|
6338
|
-
ts.isIdentifier(prop.initializer)) {
|
|
6339
|
-
const key = lowerer.foldedStringKeyOf(prop.name.expression);
|
|
6340
|
-
if (key === null)
|
|
6341
|
-
return null;
|
|
6342
|
-
binds.push({ field: key, target: prop.initializer, shorthand: null });
|
|
6343
|
-
}
|
|
6344
|
-
else {
|
|
6345
|
-
return null;
|
|
6346
|
-
}
|
|
6347
|
-
}
|
|
6348
|
-
return { kind: "object", binds };
|
|
6349
|
-
}
|
|
6350
|
-
const binds = [];
|
|
6351
|
-
for (let i = 0; i < pattern.elements.length; i++) {
|
|
6352
|
-
const el = pattern.elements[i];
|
|
6353
|
-
if (!ts.isIdentifier(el))
|
|
6354
|
-
return null; // holes, spreads, nesting
|
|
6355
|
-
binds.push({ field: i, target: el, shorthand: null });
|
|
6356
|
-
}
|
|
6357
|
-
return { kind: "array", binds };
|
|
6358
|
-
}
|
|
6359
|
-
/** `({} = {x, y} = a);` — destructuring assignment (chains included) from
|
|
6360
|
-
* an ISLAND source, statement position (--dynamic). The ENGINE runs each
|
|
6361
|
-
* pattern over the source value — a synthesized
|
|
6362
|
-
* `new Function("v", "\"use strict\"; var __0…; (<pattern> = v); return [__0…]")`
|
|
6363
|
-
* — so the coercions are JS-exact: object patterns RequireObjectCoercible
|
|
6364
|
-
* (destructuring undefined throws Node's TypeError), array patterns run
|
|
6365
|
-
* the real iterator protocol (empty patterns get-and-close). The
|
|
6366
|
-
* extracted values come back as an engine array and assign the compiled
|
|
6367
|
-
* targets in pattern order, inner assignment first (JS's right-
|
|
6368
|
-
* associativity). Null when the innermost source is not jsval-typed or
|
|
6369
|
-
* any pattern is outside the island-runnable set — the existing
|
|
6370
|
-
* record-source path and fences own those. */
|
|
6371
|
-
function lowerJsvalDestructuringChain(lowerer, expr) {
|
|
6372
|
-
if (!lowerer.dynamic)
|
|
6373
|
-
return null;
|
|
6374
|
-
const strip = (e) => {
|
|
6375
|
-
while (ts.isParenthesizedExpression(e))
|
|
6376
|
-
e = e.expression;
|
|
6377
|
-
return e;
|
|
6378
|
-
};
|
|
6379
|
-
const patterns = [];
|
|
6380
|
-
let node = expr;
|
|
6381
|
-
for (;;) {
|
|
6382
|
-
const s = strip(node);
|
|
6383
|
-
if (ts.isBinaryExpression(s) &&
|
|
6384
|
-
s.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
|
|
6385
|
-
(ts.isObjectLiteralExpression(strip(s.left)) || ts.isArrayLiteralExpression(strip(s.left)))) {
|
|
6386
|
-
patterns.push(strip(s.left));
|
|
6387
|
-
node = s.right;
|
|
6388
|
-
}
|
|
6389
|
-
else {
|
|
6390
|
-
break;
|
|
6391
|
-
}
|
|
6392
|
-
}
|
|
6393
|
-
if (patterns.length === 0)
|
|
6394
|
-
return null;
|
|
6395
|
-
// A single pattern over a PLAIN-VARIABLE island source takes the
|
|
6396
|
-
// general assignment lowering below, whose island arm throws V8's
|
|
6397
|
-
// exact destructure TypeErrors — the spelling embeds the source
|
|
6398
|
-
// text, which only a plain variable survives (corpus 2074). Chains
|
|
6399
|
-
// and non-variable sources ride the engine here (corpus 2054); the
|
|
6400
|
-
// general path fences those with SC1031.
|
|
6401
|
-
if (patterns.length === 1 && ts.isIdentifier(strip(node)))
|
|
6402
|
-
return null;
|
|
6403
|
-
const shapes = [];
|
|
6404
|
-
for (const p of patterns) {
|
|
6405
|
-
const s = islandRunnablePattern(lowerer, p);
|
|
6406
|
-
if (!s)
|
|
6407
|
-
return null;
|
|
6408
|
-
shapes.push(s);
|
|
6409
|
-
}
|
|
6410
|
-
// Checker-type gate BEFORE lowering the source (a declined claim must
|
|
6411
|
-
// not leave a discarded lowering behind): only island sources ride
|
|
6412
|
-
// the engine; record/array sources keep their existing paths.
|
|
6413
|
-
if (lowerer.mapTypeOf(lowerer.typeOf(node))?.kind !== "jsval")
|
|
6414
|
-
return null;
|
|
6415
|
-
const source = lowerer.lowerExpr(node);
|
|
6416
|
-
if (source.type.kind !== "jsval")
|
|
6417
|
-
return null;
|
|
6418
|
-
const loc = locOf(expr);
|
|
6419
|
-
const tmp = lowerer.declareHiddenLocal("%dsrc", JSVAL);
|
|
6420
|
-
const out = [{ kind: "varDecl", localId: tmp.id, init: source, loc }];
|
|
6421
|
-
const srcRef = () => ({ kind: "varRef", localId: tmp.id, type: JSVAL, loc });
|
|
6422
|
-
// Inner pattern first: `A = B = v` runs B's destructure before A's.
|
|
6423
|
-
for (let p = patterns.length - 1; p >= 0; p--) {
|
|
6424
|
-
const shape = shapes[p];
|
|
6425
|
-
const temps = shape.binds.map((_, i) => `__${i}`);
|
|
6426
|
-
const patternSrc = shape.kind === "object"
|
|
6427
|
-
? `({${shape.binds.map((b, i) => `[${JSON.stringify(String(b.field))}]: __${i}`).join(",")}} = v)`
|
|
6428
|
-
: `([${temps.join(",")}] = v)`;
|
|
6429
|
-
const body = `"use strict";` +
|
|
6430
|
-
(temps.length > 0 ? `var ${temps.join(",")};` : "") +
|
|
6431
|
-
`${patternSrc};return [${temps.join(",")}];`;
|
|
6432
|
-
const helper = {
|
|
6433
|
-
kind: "jsOp",
|
|
6434
|
-
op: "construct",
|
|
6435
|
-
args: [
|
|
6436
|
-
{ kind: "jsOp", op: "globalGet", name: "Function", args: [], type: JSVAL, loc },
|
|
6437
|
-
{
|
|
6438
|
-
kind: "jsMarshal",
|
|
6439
|
-
value: { kind: "strLit", value: "v", type: STRING, loc },
|
|
6440
|
-
type: JSVAL,
|
|
6441
|
-
loc,
|
|
6442
|
-
},
|
|
6443
|
-
{
|
|
6444
|
-
kind: "jsMarshal",
|
|
6445
|
-
value: { kind: "strLit", value: body, type: STRING, loc },
|
|
6446
|
-
type: JSVAL,
|
|
6447
|
-
loc,
|
|
6448
|
-
},
|
|
6449
|
-
],
|
|
6450
|
-
type: JSVAL,
|
|
6451
|
-
loc,
|
|
6452
|
-
};
|
|
6453
|
-
const run = { kind: "jsOp", op: "callFn", args: [helper, srcRef()], type: JSVAL, loc };
|
|
6454
|
-
if (shape.binds.length === 0) {
|
|
6455
|
-
out.push({ kind: "exprStmt", expr: run, loc });
|
|
6456
|
-
continue;
|
|
6457
|
-
}
|
|
6458
|
-
const res = lowerer.declareHiddenLocal("%dres", JSVAL);
|
|
6459
|
-
out.push({ kind: "varDecl", localId: res.id, init: run, loc });
|
|
6460
|
-
shape.binds.forEach((b, i) => {
|
|
6461
|
-
// Shorthand names resolve to the PROPERTY symbol at their
|
|
6462
|
-
// location; the VALUE symbol comes from the checker's shorthand
|
|
6463
|
-
// query (lowerDestructuringAssign's rule).
|
|
6464
|
-
let target;
|
|
6465
|
-
if (b.shorthand) {
|
|
6466
|
-
const valueSymbol = lowerer.checker.getShorthandAssignmentValueSymbol(b.shorthand) ?? null;
|
|
6467
|
-
const local = valueSymbol ? lowerer.resolveKey(valueSymbol, b.target) : null;
|
|
6468
|
-
const g = valueSymbol ? lowerer.globalsBySymbol.get(valueSymbol) : undefined;
|
|
6469
|
-
target = local ? { id: local.id, type: local.type } : g ? { id: g.id, type: g.type } : null;
|
|
6470
|
-
}
|
|
6471
|
-
else {
|
|
6472
|
-
target = lowerer.resolveWritable(b.target);
|
|
6473
|
-
}
|
|
6474
|
-
if (!target) {
|
|
6475
|
-
lowerer.rejectUnresolved(b.target, `assignment to '${b.target.text}' (not a writable local or module global)`);
|
|
6476
|
-
}
|
|
6477
|
-
const read = {
|
|
6478
|
-
kind: "jsOp",
|
|
6479
|
-
op: "getIdx",
|
|
6480
|
-
args: [
|
|
6481
|
-
{ kind: "varRef", localId: res.id, type: JSVAL, loc },
|
|
6482
|
-
{
|
|
6483
|
-
kind: "jsMarshal",
|
|
6484
|
-
value: { kind: "numLit", value: i, type: F64, loc },
|
|
6485
|
-
type: JSVAL,
|
|
6486
|
-
loc,
|
|
6487
|
-
},
|
|
6488
|
-
],
|
|
6489
|
-
type: JSVAL,
|
|
6490
|
-
loc,
|
|
6491
|
-
};
|
|
6492
|
-
out.push({
|
|
6493
|
-
kind: "assign",
|
|
6494
|
-
localId: target.id,
|
|
6495
|
-
value: lowerer.coerceInto(b.target, read, target.type),
|
|
6496
|
-
loc,
|
|
6497
|
-
});
|
|
6498
|
-
});
|
|
6499
|
-
}
|
|
6500
|
-
return { kind: "block", body: out, loc };
|
|
6501
|
-
}
|
|
6502
5745
|
/** `({ a, b: x } = e);`, `[a, b = 0, ...rest] = xs;` — destructuring
|
|
6503
5746
|
* assignment to EXISTING writable bindings, statement position, from a
|
|
6504
5747
|
* PRE-LOWERED source: for-of expression heads hand the per-iteration
|
|
@@ -6611,12 +5854,10 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
|
|
|
6611
5854
|
lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc);
|
|
6612
5855
|
return { stmts: out, value };
|
|
6613
5856
|
}
|
|
6614
|
-
if (init.type.kind === "dyn"
|
|
6615
|
-
// Checked-dynamic and island sources: RequireObjectCoercible with
|
|
5857
|
+
if (init.type.kind === "dyn") {
|
|
6616
5858
|
// V8's exact destructuring TypeError (it names the SOURCE and, for
|
|
6617
5859
|
// non-empty patterns, the first property), then keyed reads — GetV
|
|
6618
|
-
// answers undefined for absent members and primitive receivers
|
|
6619
|
-
// alike (the engine's own property semantics on the island side).
|
|
5860
|
+
// answers undefined for absent members and primitive receivers.
|
|
6620
5861
|
// An RHS that is ITSELF a destructuring assignment (`({} = {x} = a)`)
|
|
6621
5862
|
// already proved the value coercible — its own pattern threw first
|
|
6622
5863
|
// if it wasn't — so the outer check is dead code and needs no
|
|
@@ -6659,31 +5900,14 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
|
|
|
6659
5900
|
});
|
|
6660
5901
|
}
|
|
6661
5902
|
for (const prop of target.properties) {
|
|
6662
|
-
const piece = destructAssignPiece(lowerer, prop
|
|
6663
|
-
const read =
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
}
|
|
6671
|
-
: init.type.kind === "jsval"
|
|
6672
|
-
? {
|
|
6673
|
-
kind: "jsOp",
|
|
6674
|
-
op: "getProp",
|
|
6675
|
-
name: piece.field,
|
|
6676
|
-
args: [tmpRef()],
|
|
6677
|
-
type: JSVAL,
|
|
6678
|
-
loc: locOf(prop),
|
|
6679
|
-
}
|
|
6680
|
-
: {
|
|
6681
|
-
kind: "dynKeyGet",
|
|
6682
|
-
key: { kind: "strLit", value: piece.field, type: STRING, loc: locOf(prop) },
|
|
6683
|
-
value: tmpRef(),
|
|
6684
|
-
type: DYN,
|
|
6685
|
-
loc: locOf(prop),
|
|
6686
|
-
};
|
|
5903
|
+
const piece = destructAssignPiece(lowerer, prop);
|
|
5904
|
+
const read = {
|
|
5905
|
+
kind: "dynKeyGet",
|
|
5906
|
+
key: { kind: "strLit", value: piece.field, type: STRING, loc: locOf(prop) },
|
|
5907
|
+
value: tmpRef(),
|
|
5908
|
+
type: DYN,
|
|
5909
|
+
loc: locOf(prop),
|
|
5910
|
+
};
|
|
6687
5911
|
out.push({
|
|
6688
5912
|
kind: "assign",
|
|
6689
5913
|
localId: piece.target.id,
|
|
@@ -7060,21 +6284,6 @@ function destructuringAssignInto(lowerer, target, init, rhs, blame, loc) {
|
|
|
7060
6284
|
}
|
|
7061
6285
|
return { stmts: out, value };
|
|
7062
6286
|
}
|
|
7063
|
-
/** A destructuring-ASSIGNMENT target that is not a plain variable:
|
|
7064
|
-
* PROPERTY targets (`({ a: this.x } = o)`, `[c.x, c.y] = t` — the
|
|
7065
|
-
* receiver evaluates into a hidden temp at the element's pattern
|
|
7066
|
-
* position, BEFORE the element's value read, JS's get-the-reference-
|
|
7067
|
-
* then-GetV order), ELEMENT targets over arrays (runtime f64 index)
|
|
7068
|
-
* and tuples/records (literal keys) with the same receiver/key temp
|
|
7069
|
-
* discipline, and NESTED patterns (`({ p: { q } } = o)`, `[[a], b] = t`
|
|
7070
|
-
* — the element's value destructures through the same assignment
|
|
7071
|
-
* machinery, its own hidden temp included). `valueOf` builds the
|
|
7072
|
-
* (defaulted) source value at the target's own type; it receives null
|
|
7073
|
-
* exactly for nested patterns, which have no single binding type —
|
|
7074
|
-
* defaults there keep a fence (JS would need the pattern's implied
|
|
7075
|
-
* type to test against). Optional-chain targets are not assignment
|
|
7076
|
-
* targets in JS at all; index-signature runtime keys and island/dyn
|
|
7077
|
-
* receivers keep the fence below. */
|
|
7078
6287
|
function lowerAssignTargetInto(lowerer, out, targetNode, blame, dflt, valueOf) {
|
|
7079
6288
|
let t = targetNode;
|
|
7080
6289
|
while (ts.isParenthesizedExpression(t))
|
|
@@ -7152,14 +6361,8 @@ function lowerAssignTargetInto(lowerer, out, targetNode, blame, dflt, valueOf) {
|
|
|
7152
6361
|
}
|
|
7153
6362
|
lowerer.unsupported("SC1031", targetNode, "destructuring assignment to targets with no static write form (assign a variable, then write the parts out)");
|
|
7154
6363
|
}
|
|
7155
|
-
|
|
7156
|
-
* the source FIELD name (or, over ISLAND sources, a runtime KEY
|
|
7157
|
-
* expression the engine indexes with) and the resolved writable target.
|
|
7158
|
-
* Shorthand (`{ a }`) and renamed (`{ a: x }`) identifier targets only —
|
|
7159
|
-
* the record path's rules, shared fences. */
|
|
7160
|
-
function destructAssignPiece(lowerer, prop, islandSource) {
|
|
6364
|
+
function destructAssignPiece(lowerer, prop) {
|
|
7161
6365
|
let fieldName;
|
|
7162
|
-
let keyExpr;
|
|
7163
6366
|
let bindTo;
|
|
7164
6367
|
if (ts.isShorthandPropertyAssignment(prop)) {
|
|
7165
6368
|
if (prop.objectAssignmentInitializer) {
|
|
@@ -7169,20 +6372,10 @@ function destructAssignPiece(lowerer, prop, islandSource) {
|
|
|
7169
6372
|
bindTo = prop.name;
|
|
7170
6373
|
}
|
|
7171
6374
|
else if (ts.isPropertyAssignment(prop)) {
|
|
7172
|
-
// Identifier
|
|
7173
|
-
// keys resolve statically (the record path's rule) — the keyed read
|
|
7174
|
-
// below takes the folded name. A RUNTIME-valued key over an ISLAND
|
|
7175
|
-
// source reads through the engine's own indexing at the element's
|
|
7176
|
-
// pattern position (`({ [key]: w } = src)`); over the checked-dynamic tree the fence
|
|
7177
|
-
// stays.
|
|
6375
|
+
// Identifier, literal, and foldable computed keys resolve statically.
|
|
7178
6376
|
const folded = patternKeyNameOf(lowerer, prop.name);
|
|
7179
6377
|
if (folded === null) {
|
|
7180
|
-
|
|
7181
|
-
keyExpr = prop.name.expression;
|
|
7182
|
-
}
|
|
7183
|
-
else {
|
|
7184
|
-
lowerer.unsupported("SC1031", prop, "destructuring assignment with computed keys that do not fold to one property name");
|
|
7185
|
-
}
|
|
6378
|
+
lowerer.unsupported("SC1031", prop, "destructuring assignment with computed keys that do not fold to one property name");
|
|
7186
6379
|
}
|
|
7187
6380
|
fieldName = folded ?? "";
|
|
7188
6381
|
bindTo = prop.initializer;
|
|
@@ -7206,7 +6399,7 @@ function destructAssignPiece(lowerer, prop, islandSource) {
|
|
|
7206
6399
|
if (!target) {
|
|
7207
6400
|
lowerer.rejectUnresolved(bindTo, `assignment to '${bindTo.text}' (not a writable local or module global)`);
|
|
7208
6401
|
}
|
|
7209
|
-
return { field: fieldName,
|
|
6402
|
+
return { field: fieldName, target };
|
|
7210
6403
|
}
|
|
7211
6404
|
/** The ARRAY half of destructuring assignment: element assigns from a
|
|
7212
6405
|
* tuple/array/checked-dynamic source pushed into `out` (see
|
|
@@ -7253,10 +6446,9 @@ function lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc) {
|
|
|
7253
6446
|
const shape = srcType.kind === "record" ? lowerer.shapes.get(srcType.shapeId) : undefined;
|
|
7254
6447
|
const isTuple = shape?.tuple === true;
|
|
7255
6448
|
let elemsRef = null;
|
|
7256
|
-
if (srcType.kind === "dyn"
|
|
7257
|
-
//
|
|
7258
|
-
//
|
|
7259
|
-
// side); the empty pattern is pure validation.
|
|
6449
|
+
if (srcType.kind === "dyn") {
|
|
6450
|
+
// Read the pattern's width through the native iterator with Node's
|
|
6451
|
+
// TypeErrors. The empty pattern only validates iterability.
|
|
7260
6452
|
const iterTmp = lowerer.declareHiddenLocal("%destrIter", srcType);
|
|
7261
6453
|
out.push({
|
|
7262
6454
|
kind: "varDecl",
|
|
@@ -7279,16 +6471,6 @@ function lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc) {
|
|
|
7279
6471
|
const elemRead = (i, at) => {
|
|
7280
6472
|
if (elemsRef) {
|
|
7281
6473
|
const elems = elemsRef();
|
|
7282
|
-
if (elems.type.kind === "jsval") {
|
|
7283
|
-
const key = { kind: "numLit", value: i, type: F64, loc: locOf(at) };
|
|
7284
|
-
return {
|
|
7285
|
-
kind: "jsOp",
|
|
7286
|
-
op: "getIdx",
|
|
7287
|
-
args: [elems, lowerer.jsvalIn(key, at)],
|
|
7288
|
-
type: JSVAL,
|
|
7289
|
-
loc: locOf(at),
|
|
7290
|
-
};
|
|
7291
|
-
}
|
|
7292
6474
|
return {
|
|
7293
6475
|
kind: "dynKeyGet",
|
|
7294
6476
|
key: { kind: "strLit", value: String(i), type: STRING, loc: locOf(at) },
|
|
@@ -7334,8 +6516,8 @@ function lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc) {
|
|
|
7334
6516
|
if (ts.isSpreadElement(el)) {
|
|
7335
6517
|
// `[a, ...rest]`: the tail packs FRESH (JS's surplus packing
|
|
7336
6518
|
// builds a new array) — array slices, tuple tails under the
|
|
7337
|
-
// target's own type. Checked-
|
|
7338
|
-
//
|
|
6519
|
+
// target's own type. Checked-value sources keep the fence because
|
|
6520
|
+
// this path has no native array drain.
|
|
7339
6521
|
if (elemsRef) {
|
|
7340
6522
|
lowerer.unsupported("SC1031", el, "rest elements in destructuring assignment from checked-dynamic sources (collect with .slice() instead)");
|
|
7341
6523
|
}
|
|
@@ -7394,7 +6576,7 @@ function lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc) {
|
|
|
7394
6576
|
// undefined where the plain read would trap).
|
|
7395
6577
|
let read = elemRead(i, el);
|
|
7396
6578
|
if (defaultNode !== null) {
|
|
7397
|
-
if (read.type.kind === "dyn"
|
|
6579
|
+
if (read.type.kind === "dyn") {
|
|
7398
6580
|
const boundary = read.type;
|
|
7399
6581
|
const elemTmp = lowerer.declareHiddenLocal("%destrElem", boundary);
|
|
7400
6582
|
out.push({ kind: "varDecl", localId: elemTmp.id, init: read, loc: locOf(el) });
|
|
@@ -7404,31 +6586,18 @@ function lowerArrayAssignInto(lowerer, out, target, tmpRef, blame, loc) {
|
|
|
7404
6586
|
type: boundary,
|
|
7405
6587
|
loc: locOf(el),
|
|
7406
6588
|
});
|
|
7407
|
-
const isUndef =
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
],
|
|
7415
|
-
type: BOOL,
|
|
7416
|
-
loc: locOf(el),
|
|
7417
|
-
}
|
|
7418
|
-
: {
|
|
7419
|
-
kind: "dynTest",
|
|
7420
|
-
test: "undefined",
|
|
7421
|
-
value: elemVar(),
|
|
7422
|
-
type: BOOL,
|
|
7423
|
-
loc: locOf(el),
|
|
7424
|
-
};
|
|
6589
|
+
const isUndef = {
|
|
6590
|
+
kind: "dynTest",
|
|
6591
|
+
test: "undefined",
|
|
6592
|
+
value: elemVar(),
|
|
6593
|
+
type: BOOL,
|
|
6594
|
+
loc: locOf(el),
|
|
6595
|
+
};
|
|
7425
6596
|
const dflt = lowerer.lowerExpr(defaultNode);
|
|
7426
6597
|
read = {
|
|
7427
6598
|
kind: "ternary",
|
|
7428
6599
|
cond: isUndef,
|
|
7429
|
-
then:
|
|
7430
|
-
? lowerer.jsvalIn(dflt, defaultNode)
|
|
7431
|
-
: lowerer.coerceInto(defaultNode, dflt, DYN),
|
|
6600
|
+
then: lowerer.coerceInto(defaultNode, dflt, DYN),
|
|
7432
6601
|
else_: elemVar(),
|
|
7433
6602
|
type: boundary,
|
|
7434
6603
|
loc: locOf(el),
|
|
@@ -7732,19 +6901,9 @@ export function lowerForOf(lowerer, stmt) {
|
|
|
7732
6901
|
}
|
|
7733
6902
|
tupleSource = { shapeId: iterable.type.shapeId, fields, elem };
|
|
7734
6903
|
}
|
|
7735
|
-
// An ISLAND value (`for (const store of stores)` where stores is a
|
|
7736
|
-
// package-typed array — one engine handle): the engine's OWN
|
|
7737
|
-
// iterator protocol drives the loop — GetIterator through the
|
|
7738
|
-
// pinned prelude helper (V8's not-iterable TypeError on refusal),
|
|
7739
|
-
// next() through callMethod, done/value reads through getProp — so
|
|
7740
|
-
// engine arrays, Maps, Sets, generators, and Symbol.iterator
|
|
7741
|
-
// implementations all iterate exactly as Node runs them.
|
|
7742
|
-
if (iterable.type.kind === "jsval") {
|
|
7743
|
-
return lowerForOfIsland(lowerer, stmt, iterable, labels);
|
|
7744
|
-
}
|
|
7745
6904
|
// A CHECKED-DYNAMIC iterable (`unknown[]`, the collapsed
|
|
7746
|
-
// `(string | object)[]`, JSON-parsed values
|
|
7747
|
-
//
|
|
6905
|
+
// `(string | object)[]`, JSON-parsed values): a checked IteratorRecord
|
|
6906
|
+
// binds each yielded dyn value.
|
|
7748
6907
|
if (iterable.type.kind === "dyn") {
|
|
7749
6908
|
return lowerForOfDyn(lowerer, stmt, iterable, labels);
|
|
7750
6909
|
}
|
|
@@ -7760,7 +6919,6 @@ export function lowerForOf(lowerer, stmt) {
|
|
|
7760
6919
|
!privateSplit &&
|
|
7761
6920
|
!awaitArray &&
|
|
7762
6921
|
elementType.kind !== "dyn" &&
|
|
7763
|
-
elementType.kind !== "jsval" &&
|
|
7764
6922
|
lowerer.presentElementLoops.has(stmt);
|
|
7765
6923
|
const yieldedT = tupleSource === null && !privateSplit && !presentElements
|
|
7766
6924
|
? arrayValueType(lowerer, elementType)
|
|
@@ -7802,7 +6960,7 @@ export function lowerForOf(lowerer, stmt) {
|
|
|
7802
6960
|
};
|
|
7803
6961
|
if (promiseElem &&
|
|
7804
6962
|
yieldedT.kind === "union" &&
|
|
7805
|
-
!["void", "union", "dyn", "
|
|
6963
|
+
!["void", "union", "dyn", "undefinedT", "nullT"].includes(promiseElem.inner.kind)) {
|
|
7806
6964
|
awaitPromiseTag = lowerer.armTag(yieldedT.unionId, promiseElem);
|
|
7807
6965
|
elemValueT = lowerer.withUndefinedArm(promiseElem.inner);
|
|
7808
6966
|
}
|
|
@@ -8901,122 +8059,6 @@ function lowerForOfDyn(lowerer, stmt, iterable, labels) {
|
|
|
8901
8059
|
lowerer.scopes.pop();
|
|
8902
8060
|
}
|
|
8903
8061
|
}
|
|
8904
|
-
/** for-of over an ISLAND value (see lowerForOf's jsval arm): the
|
|
8905
|
-
* engine's iterator protocol desugared over jsOps —
|
|
8906
|
-
*
|
|
8907
|
-
* it = iterNew(v); // GetIterator (prelude; may throw)
|
|
8908
|
-
* while (true) {
|
|
8909
|
-
* r = it.next(); // callMethod
|
|
8910
|
-
* if (truthy(r.done)) break;
|
|
8911
|
-
* <bind loop var(s) from r.value> // getProp
|
|
8912
|
-
* ...body
|
|
8913
|
-
* }
|
|
8914
|
-
*
|
|
8915
|
-
* The loop variable's ELEMENT is an island handle (jsval — exactly what
|
|
8916
|
-
* the checker's package-typed element maps to); identifier heads bind
|
|
8917
|
-
* it per iteration, destructuring heads run the jsval pattern desugar,
|
|
8918
|
-
* pre-declared and var heads keep their fences (the array path's
|
|
8919
|
-
* stories don't carry over mechanically). IteratorClose on early exit
|
|
8920
|
-
* (break/return out of a partial iteration calling it.return()) is NOT
|
|
8921
|
-
* run — a divergence only a custom island iterator with a return()
|
|
8922
|
-
* method can observe. */
|
|
8923
|
-
function lowerForOfIsland(lowerer, stmt, iterable, labels) {
|
|
8924
|
-
const loc = locOf(stmt);
|
|
8925
|
-
if (!ts.isVariableDeclarationList(stmt.initializer)) {
|
|
8926
|
-
lowerer.unsupported("SC1090", stmt.initializer, "for-of over a package ('any') iterable with a pre-declared loop variable (declare it in the loop: for (const x of ...))");
|
|
8927
|
-
}
|
|
8928
|
-
const list = stmt.initializer;
|
|
8929
|
-
if ((list.flags & ts.NodeFlags.Using) !== 0) {
|
|
8930
|
-
lowerer.unsupported("SC1090", list, "'using' declarations (dispose-at-scope-exit semantics)");
|
|
8931
|
-
}
|
|
8932
|
-
const isLet = (list.flags & ts.NodeFlags.Let) !== 0 || (list.flags & ts.NodeFlags.BlockScoped) === 0;
|
|
8933
|
-
const decl = list.declarations[0];
|
|
8934
|
-
const itLocal = lowerer.declareHiddenLocal("%vofit", JSVAL);
|
|
8935
|
-
const rLocal = lowerer.declareHiddenLocal("%vofr", JSVAL);
|
|
8936
|
-
const itRef = { kind: "varRef", localId: itLocal.id, type: JSVAL, loc };
|
|
8937
|
-
const rRef = { kind: "varRef", localId: rLocal.id, type: JSVAL, loc };
|
|
8938
|
-
const valueOf = {
|
|
8939
|
-
kind: "jsOp",
|
|
8940
|
-
op: "getProp",
|
|
8941
|
-
name: "value",
|
|
8942
|
-
args: [rRef],
|
|
8943
|
-
type: JSVAL,
|
|
8944
|
-
loc,
|
|
8945
|
-
};
|
|
8946
|
-
lowerer.scopes.push(new Map());
|
|
8947
|
-
try {
|
|
8948
|
-
const binds = [];
|
|
8949
|
-
if (ts.isArrayBindingPattern(decl.name) || ts.isObjectBindingPattern(decl.name)) {
|
|
8950
|
-
const tmp = lowerer.declareHiddenLocal("%destr", JSVAL);
|
|
8951
|
-
binds.push({ kind: "varDecl", localId: tmp.id, init: valueOf, loc });
|
|
8952
|
-
lowerer.lowerBindingPattern(decl.name, () => ({ kind: "varRef", localId: tmp.id, type: JSVAL, loc }), JSVAL, isLet, binds);
|
|
8953
|
-
}
|
|
8954
|
-
else if (ts.isIdentifier(decl.name)) {
|
|
8955
|
-
if (forOfVarTarget(lowerer, decl)) {
|
|
8956
|
-
lowerer.unsupported("SC1090", decl.name, "for (var x of ...) over a package ('any') iterable (use const or let)");
|
|
8957
|
-
}
|
|
8958
|
-
const local = lowerer.declareLocal(decl.name, decl.name.text, JSVAL, isLet);
|
|
8959
|
-
binds.push({ kind: "varDecl", localId: local.id, init: valueOf, loc });
|
|
8960
|
-
}
|
|
8961
|
-
else {
|
|
8962
|
-
lowerer.unsupported("SC1031", decl.name);
|
|
8963
|
-
}
|
|
8964
|
-
const body = lowerer.inCtl("loop", () => lowerer.lowerScopedBlock(stmt.statement), labels);
|
|
8965
|
-
return {
|
|
8966
|
-
kind: "block",
|
|
8967
|
-
body: [
|
|
8968
|
-
{
|
|
8969
|
-
kind: "varDecl",
|
|
8970
|
-
localId: itLocal.id,
|
|
8971
|
-
init: { kind: "jsOp", op: "iterNew", args: [iterable], type: JSVAL, loc },
|
|
8972
|
-
loc,
|
|
8973
|
-
},
|
|
8974
|
-
{
|
|
8975
|
-
kind: "while",
|
|
8976
|
-
cond: { kind: "boolLit", value: true, type: BOOL, loc },
|
|
8977
|
-
body: [
|
|
8978
|
-
{
|
|
8979
|
-
kind: "varDecl",
|
|
8980
|
-
localId: rLocal.id,
|
|
8981
|
-
init: {
|
|
8982
|
-
kind: "jsOp",
|
|
8983
|
-
op: "callMethod",
|
|
8984
|
-
name: "next",
|
|
8985
|
-
args: [itRef],
|
|
8986
|
-
type: JSVAL,
|
|
8987
|
-
loc,
|
|
8988
|
-
},
|
|
8989
|
-
loc,
|
|
8990
|
-
},
|
|
8991
|
-
{
|
|
8992
|
-
kind: "if",
|
|
8993
|
-
cond: {
|
|
8994
|
-
kind: "jsOp",
|
|
8995
|
-
op: "truthy",
|
|
8996
|
-
args: [
|
|
8997
|
-
{ kind: "jsOp", op: "getProp", name: "done", args: [rRef], type: JSVAL, loc },
|
|
8998
|
-
],
|
|
8999
|
-
type: BOOL,
|
|
9000
|
-
loc,
|
|
9001
|
-
},
|
|
9002
|
-
then: [{ kind: "break", loc }],
|
|
9003
|
-
else_: null,
|
|
9004
|
-
loc,
|
|
9005
|
-
},
|
|
9006
|
-
...binds,
|
|
9007
|
-
...body,
|
|
9008
|
-
],
|
|
9009
|
-
...(labels && { labels }),
|
|
9010
|
-
loc,
|
|
9011
|
-
},
|
|
9012
|
-
],
|
|
9013
|
-
loc,
|
|
9014
|
-
};
|
|
9015
|
-
}
|
|
9016
|
-
finally {
|
|
9017
|
-
lowerer.scopes.pop();
|
|
9018
|
-
}
|
|
9019
|
-
}
|
|
9020
8062
|
function lowerForOfString(lowerer, stmt, iterable, labels) {
|
|
9021
8063
|
let exprTarget = null;
|
|
9022
8064
|
let exprTargetNode = null;
|