@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
package/dist/frontend/program.js
CHANGED
|
@@ -56,6 +56,8 @@ import { clearWorkspacePackages, isRelativeSpecifier, isWorkspacePackageName, np
|
|
|
56
56
|
import { ADOPTED_OPTIONS, isJsSourceFileName, JS_ANY_OPERATOR_CODES, JS_RELAXED_TSC_CODES, } from "./tsc-codes.js";
|
|
57
57
|
import { trackedFileExists, trackedReadFile, trackedRealpath } from "./input-tracker.js";
|
|
58
58
|
import { forkTargetPaths } from "./fork-target.js";
|
|
59
|
+
import { workerTargetPaths } from "./worker-target.js";
|
|
60
|
+
import { moduleSourceCandidates } from "./module-source-candidates.js";
|
|
59
61
|
import { inferredJsDiagnosticSuppressed } from "./inferred-js-diagnostics.js";
|
|
60
62
|
const BASE_OPTIONS = {
|
|
61
63
|
strict: true,
|
|
@@ -383,22 +385,21 @@ function externalTypeFileClosure7(program, externalTypes) {
|
|
|
383
385
|
* an explicit root, to a fixpoint, so the same TS 7 AST/checker world owns
|
|
384
386
|
* their exports and transitive graph. */
|
|
385
387
|
function createRequireProgramRoots7(program) {
|
|
386
|
-
const known = new Set(program.
|
|
388
|
+
const known = new Set(program.getSourceFileNames().map((name) => tsgoPath(resolve(name))));
|
|
387
389
|
const roots = new Set();
|
|
388
|
-
for (const sf of program.
|
|
390
|
+
for (const sf of program.getImplementationSourceFiles()) {
|
|
389
391
|
if (sf.isDeclarationFile || sf.fileName.endsWith(".json"))
|
|
390
392
|
continue;
|
|
391
393
|
const calls = [];
|
|
392
|
-
|
|
393
|
-
if (
|
|
394
|
-
node.questionDotToken !== undefined ||
|
|
394
|
+
for (const node of moduleSourceCandidates(program, sf).calls) {
|
|
395
|
+
if (node.questionDotToken !== undefined ||
|
|
395
396
|
node.arguments.length !== 1 ||
|
|
396
397
|
!ts.isStringLiteralLike(node.arguments[0]) ||
|
|
397
398
|
!ts.isIdentifier(node.expression)) {
|
|
398
|
-
|
|
399
|
+
continue;
|
|
399
400
|
}
|
|
400
401
|
calls.push({ callee: node.expression, spec: node.arguments[0].text });
|
|
401
|
-
}
|
|
402
|
+
}
|
|
402
403
|
// Root discovery only needs the callee's binding. A first-miss lookup
|
|
403
404
|
// otherwise fetches symbols and types for every identifier in the file,
|
|
404
405
|
// including all unreachable bodies in large published packages.
|
|
@@ -450,7 +451,7 @@ export function entryPackageFilePredicate(entryPath) {
|
|
|
450
451
|
function entryPackageProgramRoots7(program, entryPath) {
|
|
451
452
|
const belongsToEntry = entryPackageFilePredicate(entryPath);
|
|
452
453
|
const roots = new Set();
|
|
453
|
-
for (const sf of program.
|
|
454
|
+
for (const sf of program.getImplementationSourceFiles()) {
|
|
454
455
|
if (sf.isDeclarationFile ||
|
|
455
456
|
(!belongsToEntry(sf.fileName) && npmStaticPackageOfPath(sf.fileName) === null))
|
|
456
457
|
continue;
|
|
@@ -515,7 +516,8 @@ function loadProgram7(host, entryPath, externalTypes = new Map()) {
|
|
|
515
516
|
const candidates = [
|
|
516
517
|
...entryPackageProgramRoots7(program, entryPath),
|
|
517
518
|
...createRequireProgramRoots7(program),
|
|
518
|
-
...forkTargetPaths(program, program.
|
|
519
|
+
...forkTargetPaths(program, program.getImplementationSourceFiles()),
|
|
520
|
+
...workerTargetPaths(program, program.getImplementationSourceFiles()),
|
|
519
521
|
];
|
|
520
522
|
const extraRoots = candidates.filter((root, index) => !programRoots.includes(root) && candidates.indexOf(root) === index);
|
|
521
523
|
if (extraRoots.length === 0)
|
|
@@ -1609,6 +1611,18 @@ function inTypePosition7(node) {
|
|
|
1609
1611
|
* callback-invoking builtin, a getter, an iterator, or an implicit
|
|
1610
1612
|
* coercion of a user object) disqualifies the module's cycles. */
|
|
1611
1613
|
function nonInertTopLevel7(program, sf) {
|
|
1614
|
+
const nonInert = topLevelInertness7(program);
|
|
1615
|
+
for (const stmt of sf.statements) {
|
|
1616
|
+
const offence = nonInert(stmt);
|
|
1617
|
+
if (offence !== null)
|
|
1618
|
+
return offence;
|
|
1619
|
+
}
|
|
1620
|
+
return null;
|
|
1621
|
+
}
|
|
1622
|
+
/** The per-statement form of nonInertTopLevel7: answers, for one
|
|
1623
|
+
* top-level statement, the first construct that could execute user code
|
|
1624
|
+
* while the statement runs, or null when the statement is inert. */
|
|
1625
|
+
function topLevelInertness7(program) {
|
|
1612
1626
|
const checker = program.getTypeChecker();
|
|
1613
1627
|
const PRIM = ts.TypeFlags.StringLike |
|
|
1614
1628
|
ts.TypeFlags.NumberLike |
|
|
@@ -1777,7 +1791,7 @@ function nonInertTopLevel7(program, sf) {
|
|
|
1777
1791
|
}
|
|
1778
1792
|
return false;
|
|
1779
1793
|
};
|
|
1780
|
-
|
|
1794
|
+
return (stmt) => {
|
|
1781
1795
|
if (ts.isImportDeclaration(stmt) ||
|
|
1782
1796
|
ts.isExportDeclaration(stmt) ||
|
|
1783
1797
|
ts.isImportEqualsDeclaration(stmt) ||
|
|
@@ -1788,20 +1802,13 @@ function nonInertTopLevel7(program, sf) {
|
|
|
1788
1802
|
(ts.getCombinedModifierFlags(stmt) &
|
|
1789
1803
|
ts.ModifierFlags.Ambient) !==
|
|
1790
1804
|
0) {
|
|
1791
|
-
|
|
1805
|
+
return null;
|
|
1792
1806
|
}
|
|
1793
1807
|
if (ts.isEnumDeclaration(stmt)) {
|
|
1794
|
-
|
|
1795
|
-
if (bad !== undefined)
|
|
1796
|
-
return bad;
|
|
1797
|
-
continue;
|
|
1798
|
-
}
|
|
1799
|
-
if (ts.isClassDeclaration(stmt)) {
|
|
1800
|
-
const bad = inertClass(stmt);
|
|
1801
|
-
if (bad !== null)
|
|
1802
|
-
return bad;
|
|
1803
|
-
continue;
|
|
1808
|
+
return stmt.members.find((m) => m.initializer !== undefined && !inert(m.initializer)) ?? null;
|
|
1804
1809
|
}
|
|
1810
|
+
if (ts.isClassDeclaration(stmt))
|
|
1811
|
+
return inertClass(stmt);
|
|
1805
1812
|
if (ts.isVariableStatement(stmt)) {
|
|
1806
1813
|
for (const d of stmt.declarationList.declarations) {
|
|
1807
1814
|
if (!ts.isIdentifier(d.name))
|
|
@@ -1809,21 +1816,15 @@ function nonInertTopLevel7(program, sf) {
|
|
|
1809
1816
|
if (d.initializer !== undefined && !inert(d.initializer))
|
|
1810
1817
|
return d.initializer;
|
|
1811
1818
|
}
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1814
|
-
if (ts.isExpressionStatement(stmt)) {
|
|
1815
|
-
if (!inert(stmt.expression))
|
|
1816
|
-
return stmt;
|
|
1817
|
-
continue;
|
|
1819
|
+
return null;
|
|
1818
1820
|
}
|
|
1821
|
+
if (ts.isExpressionStatement(stmt))
|
|
1822
|
+
return inert(stmt.expression) ? null : stmt;
|
|
1819
1823
|
if (ts.isExportAssignment(stmt) && !stmt.isExportEquals) {
|
|
1820
|
-
|
|
1821
|
-
return stmt;
|
|
1822
|
-
continue;
|
|
1824
|
+
return inert(stmt.expression) ? null : stmt;
|
|
1823
1825
|
}
|
|
1824
1826
|
return stmt;
|
|
1825
|
-
}
|
|
1826
|
-
return null;
|
|
1827
|
+
};
|
|
1827
1828
|
}
|
|
1828
1829
|
/** The head of a property/element-access chain. */
|
|
1829
1830
|
function chainRoot7(e) {
|
|
@@ -1889,13 +1890,16 @@ function backEdgeUseOffence7(program, stmt, occurrences) {
|
|
|
1889
1890
|
* e.dep already mid-initialization in a depth-first walk), answers null
|
|
1890
1891
|
* to ADMIT the cycle — the guarded %init calls reproduce Node's cache-hit
|
|
1891
1892
|
* order and nothing can observe the partial initialization — or the
|
|
1892
|
-
* human-readable reason it keeps the SC1016 fence.
|
|
1893
|
+
* human-readable reason it keeps the SC1016 fence. Three admission chances:
|
|
1893
1894
|
* - the CHEAP PER-EDGE rule: the closing statement binds nothing (a
|
|
1894
1895
|
* side-effect import) or binds only namespace objects whose every use
|
|
1895
1896
|
* is a bare expression statement — no read crosses the edge at all;
|
|
1896
1897
|
* - the DECLARATION-ONLY INIT WINDOW rule (the admission block above):
|
|
1897
1898
|
* every cluster member is an ES module with an inert top level, and
|
|
1898
|
-
* the closing edge's bindings are used only in deferred positions
|
|
1899
|
+
* the closing edge's bindings are used only in deferred positions;
|
|
1900
|
+
* - the EXACT INITIALIZATION rule (exactCycleRefusal7): partial
|
|
1901
|
+
* initialization is observable, but every observation is modeled —
|
|
1902
|
+
* the lowering checks each binding cycleEarlyBindings reports.
|
|
1899
1903
|
* Tarjan SCCs (lazy, rooted at each queried importer) and cluster
|
|
1900
1904
|
* verdicts are memoized across calls, so `edgesOf` must answer the same
|
|
1901
1905
|
* edges for the same file every time. */
|
|
@@ -1946,10 +1950,11 @@ export function makeCycleAdmission(program, edgesOf) {
|
|
|
1946
1950
|
const nsf = node.getSourceFile();
|
|
1947
1951
|
return `${nsf.fileName}:${ts.getLineAndCharacterOfPosition(nsf, node.getStart(nsf)).line + 1}`;
|
|
1948
1952
|
};
|
|
1949
|
-
// Cluster verdict memo (keyed by the component array identity):
|
|
1950
|
-
//
|
|
1951
|
-
// member passes the inert-top-level bar.
|
|
1953
|
+
// Cluster verdict memo (keyed by the component array identity): true
|
|
1954
|
+
// when every member is an ES module passing the inert-top-level bar.
|
|
1952
1955
|
const sccVerdict = new Map();
|
|
1956
|
+
// The exact-initialization verdict, same keying (exactCycleRefusal7).
|
|
1957
|
+
const exactVerdict = new Map();
|
|
1953
1958
|
// A module can close many cycle edges, each importing many bindings.
|
|
1954
1959
|
// Index its identifiers once for this admission pass. ASTs are immutable;
|
|
1955
1960
|
// the pass owns the index so it cannot retain a disposed program.
|
|
@@ -1995,31 +2000,405 @@ export function makeCycleAdmission(program, edgesOf) {
|
|
|
1995
2000
|
return "the cycle's module cluster could not be analyzed";
|
|
1996
2001
|
}
|
|
1997
2002
|
if (!sccVerdict.has(comp)) {
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2003
|
+
sccVerdict.set(comp, comp.every((m) => !isCjsJsFile7(m, program) && nonInertTopLevel7(program, m) === null));
|
|
2004
|
+
}
|
|
2005
|
+
if (sccVerdict.get(comp) === true &&
|
|
2006
|
+
backEdgeUseOffence7(program, e.stmt, usesOf(importer)) === null) {
|
|
2007
|
+
return null;
|
|
2008
|
+
}
|
|
2009
|
+
// The EXACT INITIALIZATION rule: the cycle runs in Node's evaluation
|
|
2010
|
+
// order and every binding that can be observed before its declaration
|
|
2011
|
+
// runs carries an initialization check (cycleEarlyBindings).
|
|
2012
|
+
if (!exactVerdict.has(comp)) {
|
|
2013
|
+
const reason = exactCycleRefusal7(program, comp, lineOf);
|
|
2014
|
+
exactVerdict.set(comp, reason);
|
|
2015
|
+
if (reason === null) {
|
|
2016
|
+
let members = exactCycleMembers7.get(program);
|
|
2017
|
+
if (members === undefined) {
|
|
2018
|
+
members = new Set();
|
|
2019
|
+
exactCycleMembers7.set(program, members);
|
|
2008
2020
|
}
|
|
2021
|
+
for (const m of comp)
|
|
2022
|
+
members.add(m);
|
|
2009
2023
|
}
|
|
2010
|
-
sccVerdict.set(comp, reason);
|
|
2011
2024
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2025
|
+
return exactVerdict.get(comp) ?? null;
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
/* ── exact cyclic initialization ─────────────────────────────────────────
|
|
2029
|
+
* Cycles that fail the declaration-only rule still evaluate exactly like
|
|
2030
|
+
* Node when their shape is representable: the guarded %init calls already
|
|
2031
|
+
* run every module body in ES evaluation order (depth-first postorder,
|
|
2032
|
+
* a module mid-evaluation answered from the cache), function declarations
|
|
2033
|
+
* are callable from the start, and live bindings are shared globals. What
|
|
2034
|
+
* remains is the temporal dead zone: a let/const binding read before its
|
|
2035
|
+
* declaration ran throws ReferenceError. cycleEarlyBindings finds every
|
|
2036
|
+
* such binding whose read CAN run early; the lowering gives each one an
|
|
2037
|
+
* initialization flag and checks it at every read or write that can run
|
|
2038
|
+
* before the declaration. The shapes below have no such representation
|
|
2039
|
+
* and keep the SC1016 fence. */
|
|
2040
|
+
/** Program → the modules of every cycle the exact rule admitted. */
|
|
2041
|
+
const exactCycleMembers7 = new WeakMap();
|
|
2042
|
+
/** The modules of `program` whose import cycles were admitted by the
|
|
2043
|
+
* exact initialization rule (not the declaration-only rule). */
|
|
2044
|
+
export function exactCycleMembers(program) {
|
|
2045
|
+
return exactCycleMembers7.get(program) ?? new Set();
|
|
2046
|
+
}
|
|
2047
|
+
/** True when the module's top level (outside every function-like body)
|
|
2048
|
+
* contains `await` or `for await`. */
|
|
2049
|
+
function hasTopLevelAwait7(sf) {
|
|
2050
|
+
let found = false;
|
|
2051
|
+
ts.walkPreorder(sf, (node) => {
|
|
2052
|
+
if (found)
|
|
2053
|
+
return "stop";
|
|
2054
|
+
if (node !== sf && ts.isFunctionLike(node))
|
|
2055
|
+
return "skip";
|
|
2056
|
+
if (ts.isAwaitExpression(node) ||
|
|
2057
|
+
(ts.isForOfStatement(node) && node.awaitModifier !== undefined)) {
|
|
2058
|
+
found = true;
|
|
2059
|
+
return "stop";
|
|
2020
2060
|
}
|
|
2021
|
-
return
|
|
2061
|
+
return undefined;
|
|
2062
|
+
});
|
|
2063
|
+
return found;
|
|
2064
|
+
}
|
|
2065
|
+
/** The reason a strongly-connected module cluster cannot be initialized
|
|
2066
|
+
* exactly, or null when it can. */
|
|
2067
|
+
function exactCycleRefusal7(program, comp, lineOf) {
|
|
2068
|
+
const members = new Set(comp);
|
|
2069
|
+
const targetOf = (stmt) => {
|
|
2070
|
+
const spec = stmt.moduleSpecifier;
|
|
2071
|
+
if (spec === undefined || !ts.isStringLiteral(spec))
|
|
2072
|
+
return null;
|
|
2073
|
+
const sf = stmt.getSourceFile();
|
|
2074
|
+
return resolveImport7(program, sf, spec.text) ?? npmStaticDepSf7(program, sf, spec.text);
|
|
2022
2075
|
};
|
|
2076
|
+
for (const m of comp) {
|
|
2077
|
+
if (isCjsJsFile7(m, program) || /\.c[jt]s$/.test(m.fileName)) {
|
|
2078
|
+
return `${m.fileName} is a CommonJS module — cyclic initialization covers ES modules only`;
|
|
2079
|
+
}
|
|
2080
|
+
if (hasTopLevelAwait7(m)) {
|
|
2081
|
+
return `${m.fileName} uses top-level await inside the cycle`;
|
|
2082
|
+
}
|
|
2083
|
+
for (const stmt of m.statements) {
|
|
2084
|
+
if (ts.isExportAssignment(stmt) && !stmt.isExportEquals) {
|
|
2085
|
+
return `the default export expression at ${lineOf(stmt)} has no initialization state inside the cycle`;
|
|
2086
|
+
}
|
|
2087
|
+
if (ts.isExportDeclaration(stmt) &&
|
|
2088
|
+
!stmt.isTypeOnly &&
|
|
2089
|
+
(stmt.exportClause === undefined || ts.isNamespaceExport(stmt.exportClause))) {
|
|
2090
|
+
const dep = targetOf(stmt);
|
|
2091
|
+
if (dep !== null && members.has(dep)) {
|
|
2092
|
+
return `the namespace re-export at ${lineOf(stmt)} names a module of the cycle`;
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
if (ts.isImportDeclaration(stmt) &&
|
|
2096
|
+
stmt.importClause !== undefined &&
|
|
2097
|
+
!stmt.importClause.isTypeOnly &&
|
|
2098
|
+
stmt.importClause.namedBindings !== undefined &&
|
|
2099
|
+
ts.isNamespaceImport(stmt.importClause.namedBindings)) {
|
|
2100
|
+
const dep = targetOf(stmt);
|
|
2101
|
+
const nsName = stmt.importClause.namedBindings.name;
|
|
2102
|
+
if (dep !== null &&
|
|
2103
|
+
members.has(dep) &&
|
|
2104
|
+
!nsBindingUsesAreBareStatements7(program, m, nsName)) {
|
|
2105
|
+
return `the namespace import '${nsName.text}' at ${lineOf(stmt)} names a module of the cycle`;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
if (ts.isClassDeclaration(stmt) && stmt.name === undefined) {
|
|
2109
|
+
return `the anonymous default class at ${lineOf(stmt)} has no initialization state inside the cycle`;
|
|
2110
|
+
}
|
|
2111
|
+
const ambient = (ts.getCombinedModifierFlags(stmt) &
|
|
2112
|
+
ts.ModifierFlags.Ambient) !==
|
|
2113
|
+
0;
|
|
2114
|
+
if (ambient)
|
|
2115
|
+
continue;
|
|
2116
|
+
if (ts.isEnumDeclaration(stmt) &&
|
|
2117
|
+
(ts.getCombinedModifierFlags(stmt) & ts.ModifierFlags.Const) === 0) {
|
|
2118
|
+
return `the enum '${stmt.name.text}' at ${lineOf(stmt)} has no initialization state inside the cycle`;
|
|
2119
|
+
}
|
|
2120
|
+
if (ts.isModuleDeclaration(stmt) && !typeOnlyNamespace7(stmt)) {
|
|
2121
|
+
return `the namespace at ${lineOf(stmt)} has no initialization state inside the cycle`;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
return null;
|
|
2126
|
+
}
|
|
2127
|
+
/** Every binding of the program's exactly-initialized cycles that can be
|
|
2128
|
+
* observed before its declaration executes. `order` is the compiled module
|
|
2129
|
+
* order; `singleRoot` is false when more than one module graph root runs
|
|
2130
|
+
* (fork or worker entries), so a cycle can be entered at different
|
|
2131
|
+
* members. With one root and a purely ES-module graph the evaluation order
|
|
2132
|
+
* is static and the analysis is precise up to "user code may run": a
|
|
2133
|
+
* binding needs its check when its declaration completes after some
|
|
2134
|
+
* top-level code that can call user functions and a deferred position
|
|
2135
|
+
* (function body, parameter default, instance field) references it, or
|
|
2136
|
+
* when the top level of a cycle member evaluated before it reads it.
|
|
2137
|
+
* Otherwise every deferred reference and every top-level reference from
|
|
2138
|
+
* another member counts. */
|
|
2139
|
+
export function cycleEarlyBindings(program, entry, order, singleRoot) {
|
|
2140
|
+
const exact = exactCycleMembers7.get(program);
|
|
2141
|
+
if (exact === undefined || exact.size === 0)
|
|
2142
|
+
return [];
|
|
2143
|
+
// Every lowering pass of one compile asks with the same inputs.
|
|
2144
|
+
const key = `${entry.fileName}\0${order.map((sf) => sf.fileName).join("\0")}\0${singleRoot}`;
|
|
2145
|
+
const memo = earlyBindingsMemo7.get(program);
|
|
2146
|
+
if (memo !== undefined && memo.key === key)
|
|
2147
|
+
return memo.bindings;
|
|
2148
|
+
const bindings = computeCycleEarlyBindings7(program, entry, order, singleRoot, exact);
|
|
2149
|
+
earlyBindingsMemo7.set(program, { key, bindings });
|
|
2150
|
+
return bindings;
|
|
2151
|
+
}
|
|
2152
|
+
const earlyBindingsMemo7 = new WeakMap();
|
|
2153
|
+
function computeCycleEarlyBindings7(program, entry, order, singleRoot, exact) {
|
|
2154
|
+
const inOrder = new Set(order);
|
|
2155
|
+
const members = [...exact].filter((m) => inOrder.has(m));
|
|
2156
|
+
if (members.length === 0)
|
|
2157
|
+
return [];
|
|
2158
|
+
const memberSet = new Set(members);
|
|
2159
|
+
const depsOf = (sf) => orderedImportsOf(program, sf).flatMap(({ dep }) => dep !== null && dep !== sf && inOrder.has(dep) ? [dep] : []);
|
|
2160
|
+
// Strongly-connected components among the exactly-initialized members.
|
|
2161
|
+
const comps = [];
|
|
2162
|
+
{
|
|
2163
|
+
const index = new Map();
|
|
2164
|
+
const low = new Map();
|
|
2165
|
+
const onStack = new Set();
|
|
2166
|
+
const stack = [];
|
|
2167
|
+
let next = 0;
|
|
2168
|
+
const connect = (v) => {
|
|
2169
|
+
index.set(v, next);
|
|
2170
|
+
low.set(v, next);
|
|
2171
|
+
next++;
|
|
2172
|
+
stack.push(v);
|
|
2173
|
+
onStack.add(v);
|
|
2174
|
+
for (const w of depsOf(v)) {
|
|
2175
|
+
if (!memberSet.has(w))
|
|
2176
|
+
continue;
|
|
2177
|
+
if (!index.has(w)) {
|
|
2178
|
+
connect(w);
|
|
2179
|
+
low.set(v, Math.min(low.get(v), low.get(w)));
|
|
2180
|
+
}
|
|
2181
|
+
else if (onStack.has(w)) {
|
|
2182
|
+
low.set(v, Math.min(low.get(v), index.get(w)));
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
if (low.get(v) === index.get(v)) {
|
|
2186
|
+
const comp = [];
|
|
2187
|
+
for (;;) {
|
|
2188
|
+
const w = stack.pop();
|
|
2189
|
+
onStack.delete(w);
|
|
2190
|
+
comp.push(w);
|
|
2191
|
+
if (w === v)
|
|
2192
|
+
break;
|
|
2193
|
+
}
|
|
2194
|
+
if (comp.length > 1)
|
|
2195
|
+
comps.push(comp);
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
for (const m of members)
|
|
2199
|
+
if (!index.has(m))
|
|
2200
|
+
connect(m);
|
|
2201
|
+
}
|
|
2202
|
+
if (comps.length === 0)
|
|
2203
|
+
return [];
|
|
2204
|
+
// The static evaluation order: Node's depth-first postorder from the
|
|
2205
|
+
// entry over ES import edges. Known only for one root and a graph with
|
|
2206
|
+
// no CommonJS module (a require() evaluates its target mid-body).
|
|
2207
|
+
const position = new Map();
|
|
2208
|
+
if (singleRoot &&
|
|
2209
|
+
!order.some((sf) => isCjsJsFile7(sf, program) || /\.c[jt]s$/.test(sf.fileName))) {
|
|
2210
|
+
const seen = new Set();
|
|
2211
|
+
const visit = (sf) => {
|
|
2212
|
+
seen.add(sf);
|
|
2213
|
+
for (const dep of depsOf(sf))
|
|
2214
|
+
if (!seen.has(dep))
|
|
2215
|
+
visit(dep);
|
|
2216
|
+
position.set(sf, position.size);
|
|
2217
|
+
};
|
|
2218
|
+
visit(entry);
|
|
2219
|
+
}
|
|
2220
|
+
const checker = program.getTypeChecker();
|
|
2221
|
+
const nonInert = topLevelInertness7(program);
|
|
2222
|
+
const out = [];
|
|
2223
|
+
for (const comp of comps) {
|
|
2224
|
+
const known = comp.every((m) => position.has(m));
|
|
2225
|
+
const evaluation = known
|
|
2226
|
+
? comp.slice().sort((a, b) => position.get(a) - position.get(b))
|
|
2227
|
+
: comp.slice();
|
|
2228
|
+
const candidates = new Map();
|
|
2229
|
+
const names = new Set();
|
|
2230
|
+
let dirty = !known;
|
|
2231
|
+
evaluation.forEach((m, rank) => {
|
|
2232
|
+
for (const stmt of m.statements) {
|
|
2233
|
+
const offence = nonInert(stmt);
|
|
2234
|
+
const exposed = dirty || offence !== null;
|
|
2235
|
+
const declared = [];
|
|
2236
|
+
if (ts.isVariableStatement(stmt) &&
|
|
2237
|
+
(ts.getCombinedModifierFlags(stmt) &
|
|
2238
|
+
ts.ModifierFlags.Ambient) ===
|
|
2239
|
+
0) {
|
|
2240
|
+
const lexical = (stmt.declarationList.flags & (ts.NodeFlags.Let | ts.NodeFlags.Const)) !== 0;
|
|
2241
|
+
for (const d of stmt.declarationList.declarations) {
|
|
2242
|
+
for (const name of boundNames7(d.name)) {
|
|
2243
|
+
declared.push({ name, kind: lexical ? "lexical" : "var" });
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
else if (ts.isClassDeclaration(stmt) && stmt.name !== undefined) {
|
|
2248
|
+
declared.push({ name: stmt.name, kind: "class" });
|
|
2249
|
+
}
|
|
2250
|
+
for (const { name, kind } of declared) {
|
|
2251
|
+
const symbol = checker.getSymbolAtLocation(name);
|
|
2252
|
+
if (symbol === undefined)
|
|
2253
|
+
continue;
|
|
2254
|
+
candidates.set(symbol, {
|
|
2255
|
+
symbol,
|
|
2256
|
+
name,
|
|
2257
|
+
kind,
|
|
2258
|
+
module: m,
|
|
2259
|
+
exposed,
|
|
2260
|
+
rank,
|
|
2261
|
+
start: stmt.getStart(m),
|
|
2262
|
+
end: stmt.getEnd(),
|
|
2263
|
+
reference: null,
|
|
2264
|
+
folded: null,
|
|
2265
|
+
});
|
|
2266
|
+
names.add(name.text);
|
|
2267
|
+
}
|
|
2268
|
+
if (offence !== null)
|
|
2269
|
+
dirty = true;
|
|
2270
|
+
}
|
|
2271
|
+
});
|
|
2272
|
+
if (candidates.size === 0)
|
|
2273
|
+
continue;
|
|
2274
|
+
const rankOf = new Map(evaluation.map((m, i) => [m, i]));
|
|
2275
|
+
// References: every identifier spelled like a candidate, resolved
|
|
2276
|
+
// through import aliases to the declaration's symbol.
|
|
2277
|
+
for (const sf of order) {
|
|
2278
|
+
const refs = [];
|
|
2279
|
+
ts.walkPreorder(sf, (node) => {
|
|
2280
|
+
if (ts.isImportDeclaration(node))
|
|
2281
|
+
return "skip";
|
|
2282
|
+
if (ts.isIdentifier(node) && names.has(node.text))
|
|
2283
|
+
refs.push(node);
|
|
2284
|
+
return undefined;
|
|
2285
|
+
});
|
|
2286
|
+
if (refs.length === 0)
|
|
2287
|
+
continue;
|
|
2288
|
+
checker.prefetchSymbolNodesExact(refs);
|
|
2289
|
+
for (const ref of refs) {
|
|
2290
|
+
const parent = ref.parent;
|
|
2291
|
+
if (parent !== undefined && ts.isExportSpecifier(parent))
|
|
2292
|
+
continue;
|
|
2293
|
+
if (inTypePosition7(ref))
|
|
2294
|
+
continue;
|
|
2295
|
+
let symbol = checker.getSymbolAtLocation(ref);
|
|
2296
|
+
if (parent !== undefined &&
|
|
2297
|
+
ts.isShorthandPropertyAssignment(parent) &&
|
|
2298
|
+
parent.name === ref) {
|
|
2299
|
+
symbol = checker.getShorthandAssignmentValueSymbol(parent) ?? symbol;
|
|
2300
|
+
}
|
|
2301
|
+
if (symbol !== undefined && symbol.flags & ts.SymbolFlags.Alias) {
|
|
2302
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
2303
|
+
}
|
|
2304
|
+
const c = symbol === undefined ? undefined : candidates.get(symbol);
|
|
2305
|
+
if (c === undefined || ref === c.name)
|
|
2306
|
+
continue;
|
|
2307
|
+
if (c.folded === null && foldablePosition7(ref))
|
|
2308
|
+
c.folded = ref;
|
|
2309
|
+
if (c.reference !== null)
|
|
2310
|
+
continue;
|
|
2311
|
+
// A class body names its own inner binding, initialized throughout.
|
|
2312
|
+
if (c.kind === "class" &&
|
|
2313
|
+
sf === c.module &&
|
|
2314
|
+
ref.getStart(sf) >= c.start &&
|
|
2315
|
+
ref.getEnd() <= c.end)
|
|
2316
|
+
continue;
|
|
2317
|
+
let early;
|
|
2318
|
+
if (inDeferredPosition7(ref))
|
|
2319
|
+
early = c.exposed;
|
|
2320
|
+
else if (sf === c.module)
|
|
2321
|
+
early = ref.getStart(sf) < c.start;
|
|
2322
|
+
else if (!memberSet.has(sf) || !rankOf.has(sf))
|
|
2323
|
+
early = false;
|
|
2324
|
+
else
|
|
2325
|
+
early = !known || rankOf.get(sf) < c.rank;
|
|
2326
|
+
if (early)
|
|
2327
|
+
c.reference = ref;
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
for (const c of candidates.values()) {
|
|
2331
|
+
if (c.reference === null)
|
|
2332
|
+
continue;
|
|
2333
|
+
const settled = new Set(order.filter((sf) => !rankOf.has(sf)));
|
|
2334
|
+
if (known)
|
|
2335
|
+
for (const m of evaluation.slice(c.rank + 1))
|
|
2336
|
+
settled.add(m);
|
|
2337
|
+
out.push({
|
|
2338
|
+
symbol: c.symbol,
|
|
2339
|
+
name: c.name,
|
|
2340
|
+
kind: c.kind,
|
|
2341
|
+
module: c.module,
|
|
2342
|
+
reference: c.reference,
|
|
2343
|
+
...(c.folded !== null ? { folded: c.folded } : {}),
|
|
2344
|
+
settled,
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
return out;
|
|
2349
|
+
}
|
|
2350
|
+
/** True for a reference whose value the lowering can take from the
|
|
2351
|
+
* binding's checker type instead of its storage: a property key (element
|
|
2352
|
+
* access argument, computed name, `in` operand, through parentheses,
|
|
2353
|
+
* casts and template spans) or a `typeof` operand. */
|
|
2354
|
+
function foldablePosition7(ref) {
|
|
2355
|
+
let child = ref;
|
|
2356
|
+
for (let p = ref.parent; p !== undefined; p = p.parent) {
|
|
2357
|
+
if (ts.isParenthesizedExpression(p) ||
|
|
2358
|
+
ts.isAsExpression(p) ||
|
|
2359
|
+
ts.isSatisfiesExpression(p) ||
|
|
2360
|
+
ts.isNonNullExpression(p) ||
|
|
2361
|
+
ts.isTemplateSpan(p) ||
|
|
2362
|
+
ts.isTemplateExpression(p)) {
|
|
2363
|
+
child = p;
|
|
2364
|
+
continue;
|
|
2365
|
+
}
|
|
2366
|
+
if (ts.isTypeOfExpression(p))
|
|
2367
|
+
return true;
|
|
2368
|
+
if (ts.isElementAccessExpression(p))
|
|
2369
|
+
return p.argumentExpression === child;
|
|
2370
|
+
if (ts.isComputedPropertyName(p))
|
|
2371
|
+
return true;
|
|
2372
|
+
if (ts.isBinaryExpression(p))
|
|
2373
|
+
return p.operatorToken.kind === ts.SyntaxKind.InKeyword && p.left === child;
|
|
2374
|
+
return false;
|
|
2375
|
+
}
|
|
2376
|
+
return false;
|
|
2377
|
+
}
|
|
2378
|
+
/** The identifiers a binding name (identifier or destructuring pattern)
|
|
2379
|
+
* declares. */
|
|
2380
|
+
function boundNames7(name) {
|
|
2381
|
+
if (ts.isIdentifier(name))
|
|
2382
|
+
return [name];
|
|
2383
|
+
const out = [];
|
|
2384
|
+
for (const el of name.elements) {
|
|
2385
|
+
if (ts.isOmittedExpression(el) || el.name === undefined)
|
|
2386
|
+
continue;
|
|
2387
|
+
out.push(...boundNames7(el.name));
|
|
2388
|
+
}
|
|
2389
|
+
return out;
|
|
2390
|
+
}
|
|
2391
|
+
/** A namespace declaration whose body holds only types (interfaces, type
|
|
2392
|
+
* aliases, nested type-only namespaces) — no runtime object exists. */
|
|
2393
|
+
function typeOnlyNamespace7(decl) {
|
|
2394
|
+
let body = decl.body;
|
|
2395
|
+
while (body !== undefined && ts.isModuleDeclaration(body))
|
|
2396
|
+
body = body.body;
|
|
2397
|
+
if (body === undefined || !ts.isModuleBlock(body))
|
|
2398
|
+
return true;
|
|
2399
|
+
return body.statements.every((s) => ts.isInterfaceDeclaration(s) ||
|
|
2400
|
+
ts.isTypeAliasDeclaration(s) ||
|
|
2401
|
+
(ts.isModuleDeclaration(s) && typeOnlyNamespace7(s)));
|
|
2023
2402
|
}
|
|
2024
2403
|
/** Resolves an import specifier from `from` to a source file of the
|
|
2025
2404
|
* program, or null (unresolvable / outside the program). Exported (as
|
|
@@ -2175,26 +2554,11 @@ function preflight7(load) {
|
|
|
2175
2554
|
if (r !== null && r.workspaceDir !== undefined)
|
|
2176
2555
|
registerWorkspacePackage(r.packageName, r.workspaceDir);
|
|
2177
2556
|
};
|
|
2178
|
-
for (const sf of program.
|
|
2557
|
+
for (const sf of program.getImplementationSourceFiles()) {
|
|
2179
2558
|
if (sf.isDeclarationFile || sf.fileName.endsWith(".json"))
|
|
2180
2559
|
continue;
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
n.moduleSpecifier !== undefined &&
|
|
2184
|
-
ts.isStringLiteral(n.moduleSpecifier)) {
|
|
2185
|
-
probe(sf.fileName, n.moduleSpecifier.text);
|
|
2186
|
-
return "skip";
|
|
2187
|
-
}
|
|
2188
|
-
if (ts.isCallExpression(n)) {
|
|
2189
|
-
const arg = n.arguments[0];
|
|
2190
|
-
const isImportCall = n.expression.kind === ts.SyntaxKind.ImportKeyword;
|
|
2191
|
-
const isRequireCall = ts.isIdentifier(n.expression) && n.expression.text === "require";
|
|
2192
|
-
if ((isImportCall || isRequireCall) && arg !== undefined && ts.isStringLiteralLike(arg)) {
|
|
2193
|
-
probe(sf.fileName, arg.text);
|
|
2194
|
-
}
|
|
2195
|
-
}
|
|
2196
|
-
return undefined;
|
|
2197
|
-
});
|
|
2560
|
+
for (const specifier of moduleSourceCandidates(program, sf).specifiers)
|
|
2561
|
+
probe(sf.fileName, specifier);
|
|
2198
2562
|
}
|
|
2199
2563
|
}
|
|
2200
2564
|
const toPassthrough = (d) => {
|
|
@@ -2378,7 +2742,7 @@ function preflight7(load) {
|
|
|
2378
2742
|
// reachable bodies are added by lowering's worklists.
|
|
2379
2743
|
const ambient = ambientDtsPath();
|
|
2380
2744
|
const programFiles = program
|
|
2381
|
-
.
|
|
2745
|
+
.getImplementationSourceFiles()
|
|
2382
2746
|
.filter((sf) => sf.fileName !== ambient &&
|
|
2383
2747
|
!sf.isDeclarationFile &&
|
|
2384
2748
|
!sf.fileName.endsWith(".json") &&
|
|
@@ -2389,7 +2753,8 @@ function preflight7(load) {
|
|
|
2389
2753
|
const userFiles = npmStaticActive()
|
|
2390
2754
|
? planNpmStaticReexports(program, entry, programFiles, [
|
|
2391
2755
|
...createRequireProgramRoots7(program),
|
|
2392
|
-
...forkTargetPaths(program, program.
|
|
2756
|
+
...forkTargetPaths(program, program.getImplementationSourceFiles()),
|
|
2757
|
+
...workerTargetPaths(program, program.getImplementationSourceFiles()),
|
|
2393
2758
|
], (sf, spec, resolutionKind) => resolveImport7(program, sf, spec, resolutionKind) ??
|
|
2394
2759
|
npmStaticDepSf7(program, sf, spec, resolutionKind))
|
|
2395
2760
|
: programFiles;
|
|
@@ -2462,10 +2827,9 @@ function preflight7(load) {
|
|
|
2462
2827
|
// benign-cycle admission block above). Node evaluates such cycles
|
|
2463
2828
|
// benignly (the revisited module is a cache hit, and no binding read
|
|
2464
2829
|
// can hit TDZ or a stale slot), so the guarded %init calls reproduce
|
|
2465
|
-
// its order exactly. Cycles that fail both
|
|
2466
|
-
//
|
|
2467
|
-
//
|
|
2468
|
-
// static story does not model.
|
|
2830
|
+
// its order exactly. Cycles that fail both are judged by the exact
|
|
2831
|
+
// initialization rule: admitted when every early read is modeled by an
|
|
2832
|
+
// initialization check, fenced with SC1016 otherwise.
|
|
2469
2833
|
const edges = new Map();
|
|
2470
2834
|
const refusals = new Map();
|
|
2471
2835
|
const depPositions = new Map();
|
|
@@ -2939,9 +3303,10 @@ function preflight7(load) {
|
|
|
2939
3303
|
// Node's evaluation order: depth-first postorder from the entry, each
|
|
2940
3304
|
// module once, back-edges answered from the cache (a module already
|
|
2941
3305
|
// evaluating is skipped) — which the guarded %init calls reproduce
|
|
2942
|
-
// exactly. Cycles are admitted
|
|
2943
|
-
// semantics are UNOBSERVABLE (JS's partial
|
|
2944
|
-
// silent-misbehavior trap, so SC1016
|
|
3306
|
+
// exactly. Cycles are admitted where Node's partially-initialized
|
|
3307
|
+
// semantics are UNOBSERVABLE or exactly modeled (JS's partial
|
|
3308
|
+
// initialization is otherwise a silent-misbehavior trap, so SC1016
|
|
3309
|
+
// stays for the rest):
|
|
2945
3310
|
// - a DIRECT SELF-IMPORT (the package self-name reference resolving to
|
|
2946
3311
|
// the importing module itself — Node's self-reference rule): the
|
|
2947
3312
|
// imported bindings alias the module's OWN top-level bindings with
|
|
@@ -2953,7 +3318,11 @@ function preflight7(load) {
|
|
|
2953
3318
|
// benign-cycle admission block: every module of the cycle's
|
|
2954
3319
|
// strongly-connected component has an inert top level and the
|
|
2955
3320
|
// closing edge's bindings are used only in deferred positions, so no
|
|
2956
|
-
// read can execute before every member initialized)
|
|
3321
|
+
// read can execute before every member initialized);
|
|
3322
|
+
// - the EXACT INITIALIZATION rule: an ES-module cluster whose early
|
|
3323
|
+
// reads are all let/const bindings with module storage — the
|
|
3324
|
+
// lowering checks each one (cycleEarlyBindings) and throws Node's
|
|
3325
|
+
// ReferenceError on a read before the declaration ran.
|
|
2957
3326
|
const cycleAdmissionReason = makeCycleAdmission(program, (sf) => edges.get(sf) ?? []);
|
|
2958
3327
|
const order = [];
|
|
2959
3328
|
const state = new Map();
|
|
@@ -2969,9 +3338,9 @@ function preflight7(load) {
|
|
|
2969
3338
|
continue;
|
|
2970
3339
|
if (s === "visiting") {
|
|
2971
3340
|
// A back-edge: Node answers it from the cache (the module is
|
|
2972
|
-
// already evaluating) —
|
|
2973
|
-
//
|
|
2974
|
-
//
|
|
3341
|
+
// already evaluating) — admitted by the cheap per-edge rule, the
|
|
3342
|
+
// declaration-only init window rule, or the exact initialization
|
|
3343
|
+
// rule.
|
|
2975
3344
|
const reason = cycleAdmissionReason(sf, e);
|
|
2976
3345
|
if (reason !== null) {
|
|
2977
3346
|
const cycleStart = stack.indexOf(e.dep.fileName);
|