@scriptc/compiler 0.2.5 → 0.2.7
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 +62 -48
- package/dist/backend/cycle-analysis.d.ts +21 -9
- package/dist/backend/cycle-analysis.js +139 -67
- package/dist/backend/cycle-analysis.js.map +1 -1
- package/dist/backend/cycle-analysis.test.js +283 -3
- package/dist/backend/cycle-analysis.test.js.map +1 -1
- package/dist/backend/cycle-mutability.d.ts +39 -0
- package/dist/backend/cycle-mutability.js +205 -0
- package/dist/backend/cycle-mutability.js.map +1 -0
- package/dist/backend/executable-features.js +1 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +4 -1
- package/dist/backend/link-plan-core.js +16 -3
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +3 -1
- package/dist/backend/link-plan.js +3 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +40 -0
- package/dist/backend/llvm/alloc.js +205 -0
- package/dist/backend/llvm/alloc.js.map +1 -0
- package/dist/backend/llvm/alloc.test.d.ts +1 -0
- package/dist/backend/llvm/alloc.test.js +102 -0
- package/dist/backend/llvm/alloc.test.js.map +1 -0
- package/dist/backend/llvm/byte-numbers.js +32 -4
- package/dist/backend/llvm/byte-numbers.js.map +1 -1
- package/dist/backend/llvm/byte-windows.d.ts +31 -0
- package/dist/backend/llvm/byte-windows.js +334 -0
- package/dist/backend/llvm/byte-windows.js.map +1 -0
- package/dist/backend/llvm/byte-windows.test.d.ts +1 -0
- package/dist/backend/llvm/byte-windows.test.js +244 -0
- package/dist/backend/llvm/byte-windows.test.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.d.ts +17 -5
- package/dist/backend/llvm/call-lifetimes.js +58 -24
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +170 -0
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +18 -2
- package/dist/backend/llvm/classes.js +115 -41
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.d.ts +1 -0
- package/dist/backend/llvm/classes.test.js +132 -0
- package/dist/backend/llvm/classes.test.js.map +1 -0
- package/dist/backend/llvm/common.d.ts +13 -0
- package/dist/backend/llvm/common.js +30 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.d.ts +27 -0
- package/dist/backend/llvm/constant-callbacks.js +450 -0
- package/dist/backend/llvm/constant-callbacks.js.map +1 -0
- package/dist/backend/llvm/constant-callbacks.test.d.ts +1 -0
- package/dist/backend/llvm/constant-callbacks.test.js +261 -0
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -0
- package/dist/backend/llvm/dense-array-access.d.ts +29 -0
- package/dist/backend/llvm/dense-array-access.js +335 -0
- package/dist/backend/llvm/dense-array-access.js.map +1 -0
- package/dist/backend/llvm/dense-array-access.test.d.ts +1 -0
- package/dist/backend/llvm/dense-array-access.test.js +149 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +35 -1
- package/dist/backend/llvm/dyn.js +196 -35
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +143 -4
- package/dist/backend/llvm/emitter.js +882 -136
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +82 -14
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +58 -4
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.d.ts +1 -0
- package/dist/backend/llvm/expr-async.test.js +62 -0
- package/dist/backend/llvm/expr-async.test.js.map +1 -0
- package/dist/backend/llvm/expr-bytes.js +11 -0
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +151 -25
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +37 -14
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +92 -2
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +2 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +210 -28
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +58 -23
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +1 -1
- package/dist/backend/llvm/expr-records.js +3 -3
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +59 -2
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/integer-remainder.d.ts +18 -0
- package/dist/backend/llvm/integer-remainder.js +117 -0
- package/dist/backend/llvm/integer-remainder.js.map +1 -0
- package/dist/backend/llvm/layouts.d.ts +2 -1
- package/dist/backend/llvm/layouts.js +4 -3
- package/dist/backend/llvm/layouts.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.d.ts +16 -0
- package/dist/backend/llvm/lazy-captures.js +96 -0
- package/dist/backend/llvm/lazy-captures.js.map +1 -0
- package/dist/backend/llvm/lazy-captures.test.d.ts +1 -0
- package/dist/backend/llvm/lazy-captures.test.js +78 -0
- package/dist/backend/llvm/lazy-captures.test.js.map +1 -0
- package/dist/backend/llvm/lib-abi.js +7 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +7 -22
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +3 -4
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +15 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.d.ts +13 -3
- package/dist/backend/llvm/local-array-reads.js +159 -77
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +105 -4
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +5 -1
- package/dist/backend/llvm/local-union-storage.js +48 -6
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +91 -4
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +11 -0
- package/dist/backend/llvm/loop-array-borrows.js +70 -0
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.d.ts +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.js +145 -0
- package/dist/backend/llvm/loop-array-borrows.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/map-read-lifetimes.js +20 -5
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +1 -1
- package/dist/backend/llvm/nullable-fields.d.ts +28 -0
- package/dist/backend/llvm/nullable-fields.js +45 -0
- package/dist/backend/llvm/nullable-fields.js.map +1 -0
- package/dist/backend/llvm/nullable-fields.test.d.ts +1 -0
- package/dist/backend/llvm/nullable-fields.test.js +48 -0
- package/dist/backend/llvm/nullable-fields.test.js.map +1 -0
- package/dist/backend/llvm/reference-effects.d.ts +2 -1
- package/dist/backend/llvm/reference-effects.js +7 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.d.ts +1 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js +52 -0
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +73 -3
- package/dist/backend/llvm/shapes.js +281 -34
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +114 -5
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/split-loops.d.ts +48 -0
- package/dist/backend/llvm/split-loops.js +183 -0
- package/dist/backend/llvm/split-loops.js.map +1 -0
- package/dist/backend/llvm/split.js +0 -7
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +66 -2
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/stack-callbacks.d.ts +14 -0
- package/dist/backend/llvm/stack-callbacks.js +72 -0
- package/dist/backend/llvm/stack-callbacks.js.map +1 -0
- package/dist/backend/llvm/stack-captures.d.ts +27 -0
- package/dist/backend/llvm/stack-captures.js +152 -0
- package/dist/backend/llvm/stack-captures.js.map +1 -0
- package/dist/backend/llvm/stack-unions.test.js +38 -1
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-key-hash.d.ts +8 -0
- package/dist/backend/llvm/string-key-hash.js +59 -0
- package/dist/backend/llvm/string-key-hash.js.map +1 -0
- package/dist/backend/llvm/string-key-hash.test.d.ts +1 -0
- package/dist/backend/llvm/string-key-hash.test.js +34 -0
- package/dist/backend/llvm/string-key-hash.test.js.map +1 -0
- package/dist/backend/llvm/string-lifetimes.test.js +48 -7
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-slices.d.ts +20 -0
- package/dist/backend/llvm/string-slices.js +87 -0
- package/dist/backend/llvm/string-slices.js.map +1 -0
- package/dist/backend/llvm/string-slices.test.d.ts +1 -0
- package/dist/backend/llvm/string-slices.test.js +98 -0
- package/dist/backend/llvm/string-slices.test.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.js +1 -1
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +2 -2
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +4 -14
- package/dist/backend/llvm/walkers.js +53 -311
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +4 -1
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +1 -1
- package/dist/backend/native/cache-warm.d.ts +2 -1
- package/dist/backend/native/cache-warm.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +5 -2
- package/dist/backend/native/contracts.js.map +1 -1
- package/dist/backend/native/executable.js +12 -4
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +3 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +7 -0
- package/dist/backend/native-codegen-core.js +21 -0
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +9 -0
- package/dist/backend/native-codegen.js +38 -18
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +70 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +4 -2
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.d.ts +2 -1
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +2 -2
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +6 -2
- package/dist/backend/native-tools.js +6 -5
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/optimization.d.ts +25 -0
- package/dist/backend/optimization.js +21 -0
- package/dist/backend/optimization.js.map +1 -0
- package/dist/backend/optimization.test.d.ts +1 -0
- package/dist/backend/optimization.test.js +24 -0
- package/dist/backend/optimization.test.js.map +1 -0
- 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 +16 -4
- package/dist/backend/runtime-pack-core.js +31 -13
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.d.ts +7 -3
- package/dist/backend/runtime-pack-native.js +0 -3
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +41 -4
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +20 -2
- package/dist/backend/runtime-pack.js +23 -0
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +125 -2
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/backend/targets.d.ts +2 -1
- package/dist/backend/targets.js +1 -1
- package/dist/backend/targets.js.map +1 -1
- package/dist/cli/command.js +5 -4
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +2 -1
- package/dist/cli/usage.d.ts +1 -1
- package/dist/cli/usage.js +5 -2
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +5 -2
- package/dist/diagnostics/diagnostic.js +10 -8
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -2
- package/dist/executable/executable-cache.js +8 -4
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +35 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/fork-target.d.ts +5 -0
- package/dist/frontend/fork-target.js +40 -8
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.d.ts +1 -0
- package/dist/frontend/fork-target.test.js +59 -0
- package/dist/frontend/fork-target.test.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.js +5 -49
- package/dist/frontend/lowering/abstract-equality.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +23 -0
- package/dist/frontend/lowering/array-values.js +129 -0
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.js +2 -2
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +2 -11
- package/dist/frontend/lowering/builtins/atomics.js +64 -28
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.js +17 -2
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +3 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +51 -4
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +6 -1
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +6 -17
- package/dist/frontend/lowering/builtins/process.js +56 -29
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.d.ts +5 -0
- package/dist/frontend/lowering/builtins/workers.js +65 -0
- package/dist/frontend/lowering/builtins/workers.js.map +1 -0
- package/dist/frontend/lowering/caught-value-dispatch.d.ts +11 -0
- package/dist/frontend/lowering/caught-value-dispatch.js +87 -0
- package/dist/frontend/lowering/caught-value-dispatch.js.map +1 -0
- package/dist/frontend/lowering/class-assertions.d.ts +11 -0
- package/dist/frontend/lowering/class-assertions.js +104 -0
- package/dist/frontend/lowering/class-assertions.js.map +1 -0
- package/dist/frontend/lowering/class-callbacks.d.ts +3 -3
- package/dist/frontend/lowering/class-callbacks.js +18 -5
- package/dist/frontend/lowering/class-callbacks.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +1 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +4 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.d.ts +5 -0
- package/dist/frontend/lowering/class-method-mutations.js +472 -0
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -0
- package/dist/frontend/lowering/class-method-values.js +25 -5
- package/dist/frontend/lowering/class-method-values.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +17 -0
- package/dist/frontend/lowering/class-protocols.js +126 -0
- package/dist/frontend/lowering/class-protocols.js.map +1 -0
- package/dist/frontend/lowering/class-prototypes.js +8 -2
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-unions.d.ts +16 -0
- package/dist/frontend/lowering/class-unions.js +127 -0
- package/dist/frontend/lowering/class-unions.js.map +1 -0
- package/dist/frontend/lowering/coercions/builders.js +8 -1
- package/dist/frontend/lowering/coercions/builders.js.map +1 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +2 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/identity.d.ts +7 -0
- package/dist/frontend/lowering/coercions/identity.js +26 -0
- package/dist/frontend/lowering/coercions/identity.js.map +1 -0
- package/dist/frontend/lowering/coercions/structural.js +9 -6
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/collection-narrowing.d.ts +6 -0
- package/dist/frontend/lowering/collection-narrowing.js +31 -0
- package/dist/frontend/lowering/collection-narrowing.js.map +1 -0
- package/dist/frontend/lowering/containers/array-callback-call.d.ts +7 -0
- package/dist/frontend/lowering/containers/array-callback-call.js +52 -0
- package/dist/frontend/lowering/containers/array-callback-call.js.map +1 -0
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -12
- package/dist/frontend/lowering/containers/array-callbacks.js +415 -136
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-concat.d.ts +7 -0
- package/dist/frontend/lowering/containers/array-concat.js +130 -0
- package/dist/frontend/lowering/containers/array-concat.js.map +1 -0
- package/dist/frontend/lowering/containers/array-construction.d.ts +2 -0
- package/dist/frontend/lowering/containers/array-construction.js +95 -3
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.d.ts +1 -11
- package/dist/frontend/lowering/containers/array-methods.js +43 -132
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +12 -34
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +10 -1
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +56 -70
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +22 -3
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +41 -0
- package/dist/frontend/lowering/cycle-initialization.js +277 -0
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -0
- package/dist/frontend/lowering/expressions/evaluation-safety.js +4 -0
- package/dist/frontend/lowering/expressions/evaluation-safety.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +140 -38
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-field-write.d.ts +4 -4
- package/dist/frontend/lowering/expressions/union-field-write.js +54 -44
- package/dist/frontend/lowering/expressions/union-field-write.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +2 -5
- package/dist/frontend/lowering/generic-functions.js +13 -10
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/instantiation-path.d.ts +8 -0
- package/dist/frontend/lowering/instantiation-path.js +10 -0
- package/dist/frontend/lowering/instantiation-path.js.map +1 -0
- package/dist/frontend/lowering/instantiation-path.test.d.ts +1 -0
- package/dist/frontend/lowering/instantiation-path.test.js +23 -0
- package/dist/frontend/lowering/instantiation-path.test.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.d.ts +20 -0
- package/dist/frontend/lowering/iterator-adapters.js +605 -0
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +1 -1
- package/dist/frontend/lowering/lower-array-sort.js +44 -5
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-array-sort.test.js +31 -0
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -0
- package/dist/frontend/lowering/lower-assert.js +7 -0
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +12 -7
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +3 -3
- package/dist/frontend/lowering/lower-calls.js +198 -124
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +7 -0
- package/dist/frontend/lowering/lower-classes.js +166 -96
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +9 -2
- package/dist/frontend/lowering/lower-exprs.js +421 -167
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.d.ts +1 -1
- package/dist/frontend/lowering/lower-functions.js +33 -20
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +26 -2
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +1 -1
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -0
- package/dist/frontend/lowering/lower-modules.js +54 -11
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +59 -69
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -1
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +50 -1
- package/dist/frontend/lowering/lowerer.js +333 -26
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/native-ffi.js +3 -1
- package/dist/frontend/lowering/native-ffi.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +15 -0
- package/dist/frontend/lowering/runtime-optional-provenance.js +40 -0
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -0
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/split-consumers.d.ts +7 -0
- package/dist/frontend/lowering/split-consumers.js +64 -0
- package/dist/frontend/lowering/split-consumers.js.map +1 -0
- package/dist/frontend/lowering/strict-equality.d.ts +9 -0
- package/dist/frontend/lowering/strict-equality.js +116 -0
- package/dist/frontend/lowering/strict-equality.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -4
- package/dist/frontend/lowering/surfaces.js +38 -7
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-comparison.d.ts +5 -0
- package/dist/frontend/lowering/union-comparison.js +47 -0
- package/dist/frontend/lowering/union-comparison.js.map +1 -0
- package/dist/frontend/module-source-candidates.d.ts +10 -0
- package/dist/frontend/module-source-candidates.js +40 -0
- package/dist/frontend/module-source-candidates.js.map +1 -0
- package/dist/frontend/module-source-candidates.test.d.ts +1 -0
- package/dist/frontend/module-source-candidates.test.js +53 -0
- package/dist/frontend/module-source-candidates.test.js.map +1 -0
- package/dist/frontend/pipeline.js +2 -2
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +2 -0
- package/dist/frontend/program-analysis.js +2 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.d.ts +38 -2
- package/dist/frontend/program.js +457 -88
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +59 -6
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/ts7/ast-node.js +6 -8
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +42 -1
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +4 -0
- package/dist/frontend/ts7/ast-wire.js +28 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast.d.ts +2 -1
- package/dist/frontend/ts7/ast.js +8 -4
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +8 -2
- package/dist/frontend/ts7/checker.js +41 -5
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +42 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +7 -0
- package/dist/frontend/ts7/program-host.js +26 -2
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +29 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +4 -1
- package/dist/frontend/type-mapper.js +133 -16
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/type-mapper.test.js +15 -3
- package/dist/frontend/type-mapper.test.js.map +1 -1
- package/dist/frontend/worker-target.d.ts +6 -0
- package/dist/frontend/worker-target.js +108 -0
- package/dist/frontend/worker-target.js.map +1 -0
- package/dist/frontend/worker-target.test.d.ts +1 -0
- package/dist/frontend/worker-target.test.js +71 -0
- package/dist/frontend/worker-target.test.js.map +1 -0
- package/dist/index.js +47 -14
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +3 -1
- package/dist/ir/analysis.js +4 -0
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/builtin-effects.js +12 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +15 -15
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/ir.d.ts +85 -23
- package/dist/ir/ir.js +20 -6
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +8 -0
- package/dist/ir/numeric-call-specialization.js +198 -0
- package/dist/ir/numeric-call-specialization.js.map +1 -0
- package/dist/ir/runtime-features.js +4 -3
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +3 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/traverse.js +8 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +207 -43
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +356 -8
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/ir-policy.js +2 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.test.js +5 -5
- package/dist/library/library-profile.d.ts +2 -1
- package/dist/library/library-profile.js +4 -3
- package/dist/library/library-profile.js.map +1 -1
- package/dist/native/compiler.js +24 -11
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +7 -3
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/library.d.ts +2 -1
- package/dist/native/library.js.map +1 -1
- package/dist/native/prepare.js +29 -3
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.d.ts +3 -2
- package/dist/native/sanitizer.js +3 -13
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +1 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +37 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { extendInstantiationPath, MAX_INSTANTIATION_RECURSION } from "./instantiation-path.js";
|
|
3
|
+
test("independent declarations and roots do not consume a recursive budget", () => {
|
|
4
|
+
const declaration = {};
|
|
5
|
+
for (let i = 0; i < MAX_INSTANTIATION_RECURSION * 2; i++)
|
|
6
|
+
expect(extendInstantiationPath(null, declaration)).not.toBeNull();
|
|
7
|
+
let path = extendInstantiationPath(null, declaration);
|
|
8
|
+
for (let i = 0; i < MAX_INSTANTIATION_RECURSION * 2; i++)
|
|
9
|
+
path = extendInstantiationPath(path, {});
|
|
10
|
+
expect(extendInstantiationPath(path, declaration)).not.toBeNull();
|
|
11
|
+
});
|
|
12
|
+
test("bounds fresh recursive demands across intervening declarations", () => {
|
|
13
|
+
const first = {};
|
|
14
|
+
const second = {};
|
|
15
|
+
let path = extendInstantiationPath(null, first);
|
|
16
|
+
for (let i = 1; i < MAX_INSTANTIATION_RECURSION; i++) {
|
|
17
|
+
path = extendInstantiationPath(path, second);
|
|
18
|
+
path = extendInstantiationPath(path, first);
|
|
19
|
+
}
|
|
20
|
+
expect(extendInstantiationPath(path, first)).toBeNull();
|
|
21
|
+
expect(extendInstantiationPath(path.parent, second)).not.toBeNull();
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=instantiation-path.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instantiation-path.test.js","sourceRoot":"","sources":["../../../src/frontend/lowering/instantiation-path.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE/F,IAAI,CAAC,sEAAsE,EAAE,GAAG,EAAE;IAChF,MAAM,WAAW,GAAG,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,2BAA2B,GAAG,CAAC,EAAE,CAAC,EAAE;QACtD,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACpE,IAAI,IAAI,GAAG,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAE,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,2BAA2B,GAAG,CAAC,EAAE,CAAC,EAAE;QACtD,IAAI,GAAG,uBAAuB,CAAC,IAAI,EAAE,EAAE,CAAE,CAAC;IAC5C,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACpE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gEAAgE,EAAE,GAAG,EAAE;IAC1E,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,IAAI,GAAG,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAE,CAAC;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,2BAA2B,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,GAAG,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAE,CAAC;QAC9C,IAAI,GAAG,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAE,CAAC;IAC/C,CAAC;IACD,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxD,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AACtE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type IrExpr, type IrType, type SrcLoc } from "../../ir/ir.js";
|
|
2
|
+
import type { Lowerer } from "./lowerer.js";
|
|
3
|
+
/** The conversion into an iterator-typed slot (a generator type): a
|
|
4
|
+
* checked-dynamic iterator or a generator with other channel types steps
|
|
5
|
+
* through an interned adapter generator. Null when neither applies. */
|
|
6
|
+
export declare function iteratorSlotAdapter(lowerer: Lowerer, expr: IrExpr, expected: IrType & {
|
|
7
|
+
kind: "generator";
|
|
8
|
+
}): IrExpr | null;
|
|
9
|
+
/** Drain a synchronous generator into a fresh `elem[]` — the eager
|
|
10
|
+
* consumers of an iterator (`[...it]`, `Array.from(it)`). Each step resumes
|
|
11
|
+
* the generator once and appends its value; completion stops the drain
|
|
12
|
+
* without appending the return value, as in JS. Null when the yielded
|
|
13
|
+
* values cannot be extracted into the element type. */
|
|
14
|
+
export declare function generatorDrain(lowerer: Lowerer, source: IrExpr, elem: IrType, loc: SrcLoc): IrExpr | null;
|
|
15
|
+
/** `list.values()`, `list.keys()` and `list.entries()` as values: a
|
|
16
|
+
* generator over the live array. Each step compares the index with the
|
|
17
|
+
* current length and reads the current element, so elements appended
|
|
18
|
+
* during iteration are visited and completion is final, as with the
|
|
19
|
+
* native array iterator. `type` is the call's generator type. */
|
|
20
|
+
export declare function lowerArrayIteratorValue(lowerer: Lowerer, receiver: IrExpr, method: "values" | "keys" | "entries", type: IrType, loc: SrcLoc): IrExpr | null;
|
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import { dynUndefinedExpr, varRef } from "../../ir/build.js";
|
|
2
|
+
import { BOOL, DYN, F64, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
|
|
3
|
+
import { streamTypedRefEligible } from "../../ir/analysis.js";
|
|
4
|
+
import { typeKey, genResultRecord } from "../type-mapper.js";
|
|
5
|
+
import { extractIteratorValue } from "./lower-generators.js";
|
|
6
|
+
import { lowerSafeIndexRead } from "./array-values.js";
|
|
7
|
+
/** The conversion into an iterator-typed slot (a generator type): a
|
|
8
|
+
* checked-dynamic iterator or a generator with other channel types steps
|
|
9
|
+
* through an interned adapter generator. Null when neither applies. */
|
|
10
|
+
export function iteratorSlotAdapter(lowerer, expr, expected) {
|
|
11
|
+
if (expr.type.kind === "dyn")
|
|
12
|
+
return dynIteratorAdapter(lowerer, expr, expected);
|
|
13
|
+
if (expr.type.kind === "generator")
|
|
14
|
+
return generatorRetypeAdapter(lowerer, expr, expected);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/** `resumed.0 = value` — the adapters' early-exit marker around a yield. */
|
|
18
|
+
function setResumed(value, loc) {
|
|
19
|
+
return {
|
|
20
|
+
kind: "assign",
|
|
21
|
+
localId: "resumed.0",
|
|
22
|
+
value: { kind: "boolLit", value, type: BOOL, loc },
|
|
23
|
+
loc,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** A yield expression's type: a valueless next channel resumes with void. */
|
|
27
|
+
function resumeType(nextT) {
|
|
28
|
+
return nextT.kind === "undefinedT" ? VOID : nextT;
|
|
29
|
+
}
|
|
30
|
+
/** Convert a stepped value into a channel type. Records and arrays box into
|
|
31
|
+
* checked values by reference, so consumers observe the same objects. */
|
|
32
|
+
function intoChannel(lowerer, value, target) {
|
|
33
|
+
const coerced = lowerer.coerceToExpected(value, target);
|
|
34
|
+
if (!typeEquals(coerced.type, target))
|
|
35
|
+
return null;
|
|
36
|
+
if (coerced.kind === "dynFrom" &&
|
|
37
|
+
streamTypedRefEligible(coerced.value.type) &&
|
|
38
|
+
coerced.value.type.kind !== "bytes")
|
|
39
|
+
coerced.liveRef = true;
|
|
40
|
+
return coerced;
|
|
41
|
+
}
|
|
42
|
+
/** A checked-dynamic iterator (a Map, Set or array iterator, or any other
|
|
43
|
+
* object following the iterator protocol) flowing into a generator-typed
|
|
44
|
+
* slot (`IterableIterator<T>`, `Iterator<T>`, `Generator<T>`). The interned
|
|
45
|
+
* adapter is a generator over the source: each `next()` steps the source
|
|
46
|
+
* once and forwards its value, so iteration stays lazy and observes the
|
|
47
|
+
* collection live, exactly like the source iterator. Values convert into
|
|
48
|
+
* the slot's channel types with the usual checked extraction. Null when
|
|
49
|
+
* the slot is not a synchronous generator with a yielding channel. */
|
|
50
|
+
function dynIteratorAdapter(lowerer, expr, expected) {
|
|
51
|
+
if (expected.async || expected.yieldT.kind === "void")
|
|
52
|
+
return null;
|
|
53
|
+
const resultType = genResultRecord(expected.yieldT, expected.retT, lowerer.shapes, lowerer.unions);
|
|
54
|
+
if (!resultType)
|
|
55
|
+
return null;
|
|
56
|
+
const loc = expr.loc;
|
|
57
|
+
const key = `iterAdapt:${typeKey(expected)}`;
|
|
58
|
+
let name = lowerer.valueHelpers.get(key);
|
|
59
|
+
if (!name) {
|
|
60
|
+
name = `%iter.adapt.${lowerer.valueHelpers.size}`;
|
|
61
|
+
lowerer.valueHelpers.set(key, name);
|
|
62
|
+
const locals = [];
|
|
63
|
+
const local = (id, type, mutable = false) => {
|
|
64
|
+
locals.push({ id, name: id.slice(0, id.indexOf(".")), type, mutable });
|
|
65
|
+
return varRef(id, type, loc);
|
|
66
|
+
};
|
|
67
|
+
const source = local("source.0", DYN);
|
|
68
|
+
const iterator = local("iterator.0", DYN);
|
|
69
|
+
const next = local("next.0", DYN);
|
|
70
|
+
const step = local("step.0", DYN, true);
|
|
71
|
+
const forwards = expected.nextT.kind === "dyn";
|
|
72
|
+
const sent = forwards ? local("sent.0", DYN, true) : null;
|
|
73
|
+
const get = (value, field) => ({
|
|
74
|
+
kind: "dynKeyGet",
|
|
75
|
+
value,
|
|
76
|
+
key: { kind: "strLit", value: field, type: STRING, loc },
|
|
77
|
+
type: DYN,
|
|
78
|
+
loc,
|
|
79
|
+
});
|
|
80
|
+
const advance = (args) => ({
|
|
81
|
+
kind: "libCall",
|
|
82
|
+
fn: "dyn.iteratorResult",
|
|
83
|
+
args: [
|
|
84
|
+
{
|
|
85
|
+
kind: "dynCall",
|
|
86
|
+
callee: next,
|
|
87
|
+
receiver: iterator,
|
|
88
|
+
calleeName: "iterator.next",
|
|
89
|
+
args,
|
|
90
|
+
type: DYN,
|
|
91
|
+
loc,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
type: DYN,
|
|
95
|
+
loc,
|
|
96
|
+
});
|
|
97
|
+
const returned = expected.retT.kind === "void"
|
|
98
|
+
? null
|
|
99
|
+
: intoChannel(lowerer, get(step, "value"), expected.retT);
|
|
100
|
+
const yielded = () => intoChannel(lowerer, get(step, "value"), expected.yieldT);
|
|
101
|
+
if ((expected.retT.kind !== "void" && !returned) || !yielded()) {
|
|
102
|
+
lowerer.valueHelpers.delete(key);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const finish = { kind: "return", value: returned, loc };
|
|
106
|
+
// One suspension: yield the current value and take the resume value.
|
|
107
|
+
const suspend = () => {
|
|
108
|
+
const resumed = {
|
|
109
|
+
kind: "yieldExpr",
|
|
110
|
+
value: yielded(),
|
|
111
|
+
type: resumeType(expected.nextT),
|
|
112
|
+
loc,
|
|
113
|
+
};
|
|
114
|
+
return sent
|
|
115
|
+
? { kind: "assign", localId: "sent.0", value: resumed, loc }
|
|
116
|
+
: { kind: "exprStmt", expr: resumed, loc };
|
|
117
|
+
};
|
|
118
|
+
const resumedFlag = local("resumed.0", BOOL, true);
|
|
119
|
+
const closer = local("closer.0", DYN);
|
|
120
|
+
const stepOnce = () => ({
|
|
121
|
+
kind: "assign",
|
|
122
|
+
localId: "step.0",
|
|
123
|
+
value: advance(sent ? [sent] : []),
|
|
124
|
+
loc,
|
|
125
|
+
});
|
|
126
|
+
// An early exit from a consumer's loop closes the adapter. JS calls the
|
|
127
|
+
// source's own return() then; a source without one (the native Map, Set
|
|
128
|
+
// and array iterators) stays open, so the adapter suspends again on the
|
|
129
|
+
// same value instead of completing, and later steps resume the source.
|
|
130
|
+
const closeOrPark = {
|
|
131
|
+
kind: "if",
|
|
132
|
+
cond: { kind: "unary", op: "!", operand: resumedFlag, type: BOOL, loc },
|
|
133
|
+
then: [
|
|
134
|
+
{ kind: "varDecl", localId: "closer.0", init: get(iterator, "return"), loc },
|
|
135
|
+
{
|
|
136
|
+
kind: "if",
|
|
137
|
+
cond: { kind: "dynTest", test: "nullish", value: closer, type: BOOL, loc },
|
|
138
|
+
then: [suspend(), stepOnce(), { kind: "continue", loc }],
|
|
139
|
+
else_: [
|
|
140
|
+
{
|
|
141
|
+
kind: "exprStmt",
|
|
142
|
+
expr: {
|
|
143
|
+
kind: "libCall",
|
|
144
|
+
fn: "dyn.iteratorResult",
|
|
145
|
+
args: [
|
|
146
|
+
{
|
|
147
|
+
kind: "dynCall",
|
|
148
|
+
callee: closer,
|
|
149
|
+
receiver: iterator,
|
|
150
|
+
calleeName: "iterator.return",
|
|
151
|
+
args: [],
|
|
152
|
+
type: DYN,
|
|
153
|
+
loc,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
type: DYN,
|
|
157
|
+
loc,
|
|
158
|
+
},
|
|
159
|
+
loc,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
loc,
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
else_: null,
|
|
166
|
+
loc,
|
|
167
|
+
};
|
|
168
|
+
const body = [
|
|
169
|
+
{
|
|
170
|
+
kind: "varDecl",
|
|
171
|
+
localId: "iterator.0",
|
|
172
|
+
init: {
|
|
173
|
+
kind: "libCall",
|
|
174
|
+
fn: "dyn.iteratorResult",
|
|
175
|
+
args: [
|
|
176
|
+
{
|
|
177
|
+
kind: "libCall",
|
|
178
|
+
fn: "dyn.iterator",
|
|
179
|
+
args: [source, { kind: "strLit", value: "value is not iterable", type: STRING, loc }],
|
|
180
|
+
type: DYN,
|
|
181
|
+
loc,
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
type: DYN,
|
|
185
|
+
loc,
|
|
186
|
+
},
|
|
187
|
+
loc,
|
|
188
|
+
},
|
|
189
|
+
{ kind: "varDecl", localId: "next.0", init: get(iterator, "next"), loc },
|
|
190
|
+
{ kind: "varDecl", localId: "step.0", init: advance([]), loc },
|
|
191
|
+
...(sent
|
|
192
|
+
? [{ kind: "varDecl", localId: "sent.0", init: dynUndefinedExpr(loc), loc }]
|
|
193
|
+
: []),
|
|
194
|
+
{
|
|
195
|
+
kind: "varDecl",
|
|
196
|
+
localId: "resumed.0",
|
|
197
|
+
init: { kind: "boolLit", value: false, type: BOOL, loc },
|
|
198
|
+
loc,
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
kind: "while",
|
|
202
|
+
cond: { kind: "boolLit", value: true, type: BOOL, loc },
|
|
203
|
+
body: [
|
|
204
|
+
{
|
|
205
|
+
kind: "if",
|
|
206
|
+
cond: { kind: "dynTest", test: "truthy", value: get(step, "done"), type: BOOL, loc },
|
|
207
|
+
then: [finish],
|
|
208
|
+
else_: null,
|
|
209
|
+
loc,
|
|
210
|
+
},
|
|
211
|
+
setResumed(false, loc),
|
|
212
|
+
{
|
|
213
|
+
kind: "tryCatch",
|
|
214
|
+
tryBody: [suspend(), setResumed(true, loc)],
|
|
215
|
+
catchBody: null,
|
|
216
|
+
catchLocalId: null,
|
|
217
|
+
finallyBody: [closeOrPark],
|
|
218
|
+
loc,
|
|
219
|
+
},
|
|
220
|
+
stepOnce(),
|
|
221
|
+
],
|
|
222
|
+
loc,
|
|
223
|
+
},
|
|
224
|
+
];
|
|
225
|
+
lowerer.liftedFns.push({
|
|
226
|
+
name,
|
|
227
|
+
params: [{ localId: "source.0", name: "source", type: DYN }],
|
|
228
|
+
returnType: expected.retT,
|
|
229
|
+
locals,
|
|
230
|
+
body,
|
|
231
|
+
generator: { yieldT: expected.yieldT, nextT: expected.nextT, resultType },
|
|
232
|
+
loc,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return { kind: "call", callee: name, args: [expr], type: expected, loc };
|
|
236
|
+
}
|
|
237
|
+
/** A generator flowing into a slot with other channel types (a
|
|
238
|
+
* `Generator<number, void, undefined>` returned through an
|
|
239
|
+
* `IterableIterator<number>` annotation). The interned adapter generator
|
|
240
|
+
* resumes the source once per step and converts each value between the
|
|
241
|
+
* channel types, so iteration stays lazy. Null when a channel has no
|
|
242
|
+
* conversion. */
|
|
243
|
+
function generatorRetypeAdapter(lowerer, expr, expected) {
|
|
244
|
+
const from = expr.type;
|
|
245
|
+
if (from.kind !== "generator" || from.async || expected.async)
|
|
246
|
+
return null;
|
|
247
|
+
if (from.yieldT.kind === "void" || expected.yieldT.kind === "void")
|
|
248
|
+
return null;
|
|
249
|
+
const fromResult = genResultRecord(from.yieldT, from.retT, lowerer.shapes, lowerer.unions);
|
|
250
|
+
const toResult = genResultRecord(expected.yieldT, expected.retT, lowerer.shapes, lowerer.unions);
|
|
251
|
+
const fromShape = fromResult ? lowerer.shapes.get(fromResult.shapeId) : undefined;
|
|
252
|
+
const valueT = fromShape?.fields.find((field) => field.name === "value")?.type;
|
|
253
|
+
if (!fromResult || !toResult || !valueT)
|
|
254
|
+
return null;
|
|
255
|
+
const loc = expr.loc;
|
|
256
|
+
const key = `genRetype:${typeKey(from)}:${typeKey(expected)}`;
|
|
257
|
+
let name = lowerer.valueHelpers.get(key);
|
|
258
|
+
if (!name) {
|
|
259
|
+
const source = varRef("source.0", from, loc);
|
|
260
|
+
const step = varRef("step.0", fromResult, loc);
|
|
261
|
+
const field = (f, type) => ({
|
|
262
|
+
kind: "recordGet",
|
|
263
|
+
obj: step,
|
|
264
|
+
shapeId: fromResult.shapeId,
|
|
265
|
+
field: f,
|
|
266
|
+
type,
|
|
267
|
+
loc,
|
|
268
|
+
});
|
|
269
|
+
const extracted = extractIteratorValue(lowerer, from.yieldT, valueT, field("value", valueT), loc);
|
|
270
|
+
const yielded = extracted ? intoChannel(lowerer, extracted, expected.yieldT) : null;
|
|
271
|
+
if (!yielded)
|
|
272
|
+
return null;
|
|
273
|
+
// The completion value: the source's return value, or undefined.
|
|
274
|
+
let returned = null;
|
|
275
|
+
if (expected.retT.kind !== "void") {
|
|
276
|
+
returned =
|
|
277
|
+
from.retT.kind === "void"
|
|
278
|
+
? intoChannel(lowerer, { kind: "unitLit", unit: "undefined", type: UNDEFINED_T, loc }, expected.retT)
|
|
279
|
+
: intoChannel(lowerer, field("value", valueT), expected.retT);
|
|
280
|
+
if (!returned)
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
// The resume value: forwarded when both sides carry one.
|
|
284
|
+
const forwards = expected.nextT.kind !== "undefinedT" && from.nextT.kind !== "undefinedT";
|
|
285
|
+
const sentRef = varRef("sent.0", expected.nextT, loc);
|
|
286
|
+
const sent = forwards ? intoChannel(lowerer, sentRef, from.nextT) : null;
|
|
287
|
+
if (forwards && !sent)
|
|
288
|
+
return null;
|
|
289
|
+
if (!forwards && from.nextT.kind !== "undefinedT" && from.nextT.kind !== "dyn")
|
|
290
|
+
return null;
|
|
291
|
+
const resume = (arg) => ({
|
|
292
|
+
kind: "genResume",
|
|
293
|
+
mode: "next",
|
|
294
|
+
gen: source,
|
|
295
|
+
arg,
|
|
296
|
+
type: fromResult,
|
|
297
|
+
loc,
|
|
298
|
+
});
|
|
299
|
+
const resumed = {
|
|
300
|
+
kind: "yieldExpr",
|
|
301
|
+
value: yielded,
|
|
302
|
+
type: resumeType(expected.nextT),
|
|
303
|
+
loc,
|
|
304
|
+
};
|
|
305
|
+
name = `%gen.retype.${lowerer.valueHelpers.size}`;
|
|
306
|
+
lowerer.valueHelpers.set(key, name);
|
|
307
|
+
lowerer.liftedFns.push({
|
|
308
|
+
name,
|
|
309
|
+
params: [{ localId: "source.0", name: "source", type: from }],
|
|
310
|
+
returnType: expected.retT,
|
|
311
|
+
locals: [
|
|
312
|
+
{ id: "source.0", name: "source", type: from, mutable: false },
|
|
313
|
+
{ id: "step.0", name: "step", type: fromResult, mutable: true },
|
|
314
|
+
...(forwards ? [{ id: "sent.0", name: "sent", type: expected.nextT, mutable: true }] : []),
|
|
315
|
+
{ id: "resumed.0", name: "resumed", type: BOOL, mutable: true },
|
|
316
|
+
],
|
|
317
|
+
body: [
|
|
318
|
+
{ kind: "varDecl", localId: "step.0", init: resume(null), loc },
|
|
319
|
+
...(forwards ? [{ kind: "varDecl", localId: "sent.0", init: null, loc }] : []),
|
|
320
|
+
{
|
|
321
|
+
kind: "varDecl",
|
|
322
|
+
localId: "resumed.0",
|
|
323
|
+
init: { kind: "boolLit", value: false, type: BOOL, loc },
|
|
324
|
+
loc,
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
kind: "while",
|
|
328
|
+
cond: { kind: "boolLit", value: true, type: BOOL, loc },
|
|
329
|
+
body: [
|
|
330
|
+
{
|
|
331
|
+
kind: "if",
|
|
332
|
+
cond: field("done", BOOL),
|
|
333
|
+
then: [{ kind: "return", value: returned, loc }],
|
|
334
|
+
else_: null,
|
|
335
|
+
loc,
|
|
336
|
+
},
|
|
337
|
+
setResumed(false, loc),
|
|
338
|
+
{
|
|
339
|
+
kind: "tryCatch",
|
|
340
|
+
tryBody: [
|
|
341
|
+
forwards
|
|
342
|
+
? { kind: "assign", localId: "sent.0", value: resumed, loc }
|
|
343
|
+
: { kind: "exprStmt", expr: resumed, loc },
|
|
344
|
+
setResumed(true, loc),
|
|
345
|
+
],
|
|
346
|
+
catchBody: null,
|
|
347
|
+
catchLocalId: null,
|
|
348
|
+
// Closing the adapter early closes the source generator too.
|
|
349
|
+
finallyBody: [
|
|
350
|
+
{
|
|
351
|
+
kind: "if",
|
|
352
|
+
cond: {
|
|
353
|
+
kind: "unary",
|
|
354
|
+
op: "!",
|
|
355
|
+
operand: varRef("resumed.0", BOOL, loc),
|
|
356
|
+
type: BOOL,
|
|
357
|
+
loc,
|
|
358
|
+
},
|
|
359
|
+
then: [
|
|
360
|
+
{
|
|
361
|
+
kind: "exprStmt",
|
|
362
|
+
expr: {
|
|
363
|
+
kind: "genResume",
|
|
364
|
+
mode: "return",
|
|
365
|
+
gen: source,
|
|
366
|
+
arg: null,
|
|
367
|
+
type: fromResult,
|
|
368
|
+
loc,
|
|
369
|
+
},
|
|
370
|
+
loc,
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
else_: null,
|
|
374
|
+
loc,
|
|
375
|
+
},
|
|
376
|
+
],
|
|
377
|
+
loc,
|
|
378
|
+
},
|
|
379
|
+
{ kind: "assign", localId: "step.0", value: resume(sent), loc },
|
|
380
|
+
],
|
|
381
|
+
loc,
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
generator: { yieldT: expected.yieldT, nextT: expected.nextT, resultType: toResult },
|
|
385
|
+
loc,
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
return { kind: "call", callee: name, args: [expr], type: expected, loc };
|
|
389
|
+
}
|
|
390
|
+
/** Drain a synchronous generator into a fresh `elem[]` — the eager
|
|
391
|
+
* consumers of an iterator (`[...it]`, `Array.from(it)`). Each step resumes
|
|
392
|
+
* the generator once and appends its value; completion stops the drain
|
|
393
|
+
* without appending the return value, as in JS. Null when the yielded
|
|
394
|
+
* values cannot be extracted into the element type. */
|
|
395
|
+
export function generatorDrain(lowerer, source, elem, loc) {
|
|
396
|
+
const gen = source.type;
|
|
397
|
+
if (gen.kind !== "generator" || gen.async || gen.yieldT.kind === "void")
|
|
398
|
+
return null;
|
|
399
|
+
const resultType = genResultRecord(gen.yieldT, gen.retT, lowerer.shapes, lowerer.unions);
|
|
400
|
+
const shape = resultType ? lowerer.shapes.get(resultType.shapeId) : undefined;
|
|
401
|
+
const valueT = shape?.fields.find((field) => field.name === "value")?.type;
|
|
402
|
+
if (!resultType || !valueT)
|
|
403
|
+
return null;
|
|
404
|
+
const arrT = { kind: "array", elem };
|
|
405
|
+
const key = `genDrain:${typeKey(gen)}:${typeKey(elem)}`;
|
|
406
|
+
let name = lowerer.valueHelpers.get(key);
|
|
407
|
+
if (!name) {
|
|
408
|
+
const genRef = varRef("gen.0", gen, loc);
|
|
409
|
+
const outRef = varRef("out.0", arrT, loc);
|
|
410
|
+
const stepRef = varRef("step.0", resultType, loc);
|
|
411
|
+
const raw = extractIteratorValue(lowerer, gen.yieldT, valueT, {
|
|
412
|
+
kind: "recordGet",
|
|
413
|
+
obj: stepRef,
|
|
414
|
+
shapeId: resultType.shapeId,
|
|
415
|
+
field: "value",
|
|
416
|
+
type: valueT,
|
|
417
|
+
loc,
|
|
418
|
+
}, loc);
|
|
419
|
+
if (!raw)
|
|
420
|
+
return null;
|
|
421
|
+
const value = lowerer.coerceToExpected(raw, elem);
|
|
422
|
+
if (!typeEquals(value.type, elem))
|
|
423
|
+
return null;
|
|
424
|
+
name = `%gen.drain.${lowerer.valueHelpers.size}`;
|
|
425
|
+
lowerer.valueHelpers.set(key, name);
|
|
426
|
+
lowerer.liftedFns.push({
|
|
427
|
+
name,
|
|
428
|
+
params: [{ localId: "gen.0", name: "gen", type: gen }],
|
|
429
|
+
returnType: arrT,
|
|
430
|
+
locals: [
|
|
431
|
+
{ id: "gen.0", name: "gen", type: gen, mutable: false },
|
|
432
|
+
{ id: "out.0", name: "out", type: arrT, mutable: false },
|
|
433
|
+
{ id: "step.0", name: "step", type: resultType, mutable: false },
|
|
434
|
+
],
|
|
435
|
+
body: [
|
|
436
|
+
{
|
|
437
|
+
kind: "varDecl",
|
|
438
|
+
localId: "out.0",
|
|
439
|
+
init: { kind: "arrayLit", elems: [], type: arrT, loc },
|
|
440
|
+
loc,
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
kind: "while",
|
|
444
|
+
cond: { kind: "boolLit", value: true, type: BOOL, loc },
|
|
445
|
+
body: [
|
|
446
|
+
{
|
|
447
|
+
kind: "varDecl",
|
|
448
|
+
localId: "step.0",
|
|
449
|
+
init: {
|
|
450
|
+
kind: "genResume",
|
|
451
|
+
mode: "next",
|
|
452
|
+
gen: genRef,
|
|
453
|
+
arg: null,
|
|
454
|
+
type: resultType,
|
|
455
|
+
loc,
|
|
456
|
+
},
|
|
457
|
+
loc,
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
kind: "if",
|
|
461
|
+
cond: {
|
|
462
|
+
kind: "recordGet",
|
|
463
|
+
obj: stepRef,
|
|
464
|
+
shapeId: resultType.shapeId,
|
|
465
|
+
field: "done",
|
|
466
|
+
type: BOOL,
|
|
467
|
+
loc,
|
|
468
|
+
},
|
|
469
|
+
then: [{ kind: "break", loc }],
|
|
470
|
+
else_: null,
|
|
471
|
+
loc,
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
kind: "exprStmt",
|
|
475
|
+
expr: {
|
|
476
|
+
kind: "arrIntrinsic",
|
|
477
|
+
method: "push",
|
|
478
|
+
receiver: outRef,
|
|
479
|
+
args: [value],
|
|
480
|
+
type: F64,
|
|
481
|
+
loc,
|
|
482
|
+
},
|
|
483
|
+
loc,
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
loc,
|
|
487
|
+
},
|
|
488
|
+
{ kind: "return", value: outRef, loc },
|
|
489
|
+
],
|
|
490
|
+
loc,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
return { kind: "call", callee: name, args: [source], type: arrT, loc };
|
|
494
|
+
}
|
|
495
|
+
/** `list.values()`, `list.keys()` and `list.entries()` as values: a
|
|
496
|
+
* generator over the live array. Each step compares the index with the
|
|
497
|
+
* current length and reads the current element, so elements appended
|
|
498
|
+
* during iteration are visited and completion is final, as with the
|
|
499
|
+
* native array iterator. `type` is the call's generator type. */
|
|
500
|
+
export function lowerArrayIteratorValue(lowerer, receiver, method, type, loc) {
|
|
501
|
+
const arrT = receiver.type;
|
|
502
|
+
if (arrT.kind !== "array" || type.kind !== "generator")
|
|
503
|
+
return null;
|
|
504
|
+
const resultType = genResultRecord(type.yieldT, type.retT, lowerer.shapes, lowerer.unions);
|
|
505
|
+
if (!resultType || type.retT.kind !== "void" || type.nextT.kind !== "undefinedT")
|
|
506
|
+
return null;
|
|
507
|
+
const tuple = type.yieldT.kind === "record" ? lowerer.shapes.get(type.yieldT.shapeId) : undefined;
|
|
508
|
+
if (method === "entries" && (!tuple?.tuple || tuple.fields.length !== 2))
|
|
509
|
+
return null;
|
|
510
|
+
const key = `arrIter:${method}:${typeKey(arrT)}:${typeKey(type)}`;
|
|
511
|
+
let name = lowerer.valueHelpers.get(key);
|
|
512
|
+
if (!name) {
|
|
513
|
+
const list = varRef("list.0", arrT, loc);
|
|
514
|
+
const index = varRef("index.0", F64, loc);
|
|
515
|
+
const element = () => {
|
|
516
|
+
const read = lowerSafeIndexRead(lowerer, list, index, loc);
|
|
517
|
+
if (!read)
|
|
518
|
+
return null;
|
|
519
|
+
const target = method === "values" ? type.yieldT : tuple.fields.find((f) => f.name === "1").type;
|
|
520
|
+
const value = lowerer.coerceToExpected(read, target);
|
|
521
|
+
return typeEquals(value.type, target) ? value : null;
|
|
522
|
+
};
|
|
523
|
+
let yielded;
|
|
524
|
+
if (method === "keys")
|
|
525
|
+
yielded = index;
|
|
526
|
+
else if (method === "values")
|
|
527
|
+
yielded = element();
|
|
528
|
+
else {
|
|
529
|
+
const value = element();
|
|
530
|
+
yielded =
|
|
531
|
+
value === null
|
|
532
|
+
? null
|
|
533
|
+
: {
|
|
534
|
+
kind: "recordLit",
|
|
535
|
+
fields: [
|
|
536
|
+
{ name: "0", value: index },
|
|
537
|
+
{ name: "1", value },
|
|
538
|
+
],
|
|
539
|
+
type: type.yieldT,
|
|
540
|
+
loc,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
if (!yielded || !typeEquals(yielded.type, type.yieldT))
|
|
544
|
+
return null;
|
|
545
|
+
name = `%arr.iter.${lowerer.valueHelpers.size}`;
|
|
546
|
+
lowerer.valueHelpers.set(key, name);
|
|
547
|
+
lowerer.liftedFns.push({
|
|
548
|
+
name,
|
|
549
|
+
params: [{ localId: "list.0", name: "list", type: arrT }],
|
|
550
|
+
returnType: VOID,
|
|
551
|
+
locals: [
|
|
552
|
+
{ id: "list.0", name: "list", type: arrT, mutable: false },
|
|
553
|
+
{ id: "index.0", name: "index", type: F64, mutable: true },
|
|
554
|
+
],
|
|
555
|
+
body: [
|
|
556
|
+
{
|
|
557
|
+
kind: "varDecl",
|
|
558
|
+
localId: "index.0",
|
|
559
|
+
init: { kind: "numLit", value: 0, type: F64, loc },
|
|
560
|
+
loc,
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
kind: "while",
|
|
564
|
+
cond: {
|
|
565
|
+
kind: "bin",
|
|
566
|
+
op: "<",
|
|
567
|
+
left: index,
|
|
568
|
+
right: {
|
|
569
|
+
kind: "arrIntrinsic",
|
|
570
|
+
method: "length",
|
|
571
|
+
receiver: list,
|
|
572
|
+
args: [],
|
|
573
|
+
type: F64,
|
|
574
|
+
loc,
|
|
575
|
+
},
|
|
576
|
+
type: BOOL,
|
|
577
|
+
loc,
|
|
578
|
+
},
|
|
579
|
+
body: [
|
|
580
|
+
{ kind: "exprStmt", expr: { kind: "yieldExpr", value: yielded, type: VOID, loc }, loc },
|
|
581
|
+
{
|
|
582
|
+
kind: "assign",
|
|
583
|
+
localId: "index.0",
|
|
584
|
+
value: {
|
|
585
|
+
kind: "bin",
|
|
586
|
+
op: "+",
|
|
587
|
+
left: index,
|
|
588
|
+
right: { kind: "numLit", value: 1, type: F64, loc },
|
|
589
|
+
type: F64,
|
|
590
|
+
loc,
|
|
591
|
+
},
|
|
592
|
+
loc,
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
loc,
|
|
596
|
+
},
|
|
597
|
+
{ kind: "return", value: null, loc },
|
|
598
|
+
],
|
|
599
|
+
generator: { yieldT: type.yieldT, nextT: UNDEFINED_T, resultType },
|
|
600
|
+
loc,
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
return { kind: "call", callee: name, args: [receiver], type, loc };
|
|
604
|
+
}
|
|
605
|
+
//# sourceMappingURL=iterator-adapters.js.map
|