@scriptc/compiler 0.3.0 → 0.3.2
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 +346 -17
- package/dist/backend/executable-features.js +1 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/literals.d.ts +7 -0
- package/dist/backend/literals.js +32 -0
- package/dist/backend/literals.js.map +1 -1
- package/dist/backend/literals.test.js +17 -1
- package/dist/backend/literals.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -4
- package/dist/backend/llvm/alloc.js +39 -15
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +15 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/appended-array-literals.d.ts +2 -0
- package/dist/backend/llvm/appended-array-literals.js +109 -0
- package/dist/backend/llvm/appended-array-literals.js.map +1 -0
- package/dist/backend/llvm/appended-array-literals.test.d.ts +1 -0
- package/dist/backend/llvm/appended-array-literals.test.js +90 -0
- package/dist/backend/llvm/appended-array-literals.test.js.map +1 -0
- package/dist/backend/llvm/bigint-wrap.d.ts +4 -0
- package/dist/backend/llvm/bigint-wrap.js +590 -0
- package/dist/backend/llvm/bigint-wrap.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +2 -0
- package/dist/backend/llvm/blocks.js +4 -0
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +4 -1
- package/dist/backend/llvm/call-lifetimes.js +66 -7
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +14 -3
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.test.js +1 -1
- package/dist/backend/llvm/checked-narrows.test.js.map +1 -1
- package/dist/backend/llvm/classes.js +67 -14
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +6 -6
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +7 -5
- package/dist/backend/llvm/common.js +7 -5
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.js +10 -28
- package/dist/backend/llvm/constant-callbacks.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.js +146 -53
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +68 -3
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +15 -2
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +163 -8
- package/dist/backend/llvm/emitter.js +973 -100
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +14 -7
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +242 -49
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-async.test.js +1 -1
- package/dist/backend/llvm/expr-async.test.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +51 -36
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +8 -0
- package/dist/backend/llvm/expr-callbacks.js +153 -4
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +12 -1
- package/dist/backend/llvm/expr-calls.js +279 -78
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-calls.test.d.ts +1 -0
- package/dist/backend/llvm/expr-calls.test.js +132 -0
- package/dist/backend/llvm/expr-calls.test.js.map +1 -0
- package/dist/backend/llvm/expr-containers.d.ts +7 -0
- package/dist/backend/llvm/expr-containers.js +49 -5
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +4 -0
- package/dist/backend/llvm/expr-control.d.ts +8 -0
- package/dist/backend/llvm/expr-control.js +103 -69
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +3 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +28 -6
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +14 -0
- package/dist/backend/llvm/expr-primitives.js +110 -48
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +95 -5
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +9 -0
- package/dist/backend/llvm/expr-records.js +144 -16
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +9 -1
- package/dist/backend/llvm/expr-stream-bridges.js +152 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +98 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js.map +1 -1
- package/dist/backend/llvm/int32-abi.d.ts +47 -0
- package/dist/backend/llvm/int32-abi.js +83 -0
- package/dist/backend/llvm/int32-abi.js.map +1 -0
- package/dist/backend/llvm/int32-abi.test.d.ts +1 -0
- package/dist/backend/llvm/int32-abi.test.js +181 -0
- package/dist/backend/llvm/int32-abi.test.js.map +1 -0
- package/dist/backend/llvm/int32-locals.d.ts +30 -0
- package/dist/backend/llvm/int32-locals.js +95 -0
- package/dist/backend/llvm/int32-locals.js.map +1 -0
- package/dist/backend/llvm/integer-values.d.ts +4 -0
- package/dist/backend/llvm/integer-values.js +30 -1
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/integer-views.d.ts +8 -1
- package/dist/backend/llvm/integer-views.js +47 -2
- package/dist/backend/llvm/integer-views.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.d.ts +16 -0
- package/dist/backend/llvm/lazy-captures.js +88 -2
- package/dist/backend/llvm/lazy-captures.js.map +1 -1
- package/dist/backend/llvm/lazy-captures.test.js +48 -0
- package/dist/backend/llvm/lazy-captures.test.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +21 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +61 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +83 -9
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +26 -5
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +3 -2
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.d.ts +24 -2
- package/dist/backend/llvm/local-union-storage.js +127 -12
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +108 -3
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +2 -2
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +26 -0
- package/dist/backend/llvm/record-results.js +252 -0
- package/dist/backend/llvm/record-results.js.map +1 -0
- package/dist/backend/llvm/reference-effects.js +4 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.d.ts +3 -0
- package/dist/backend/llvm/reference-writes.js +25 -11
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/regex-matchers.d.ts +39 -0
- package/dist/backend/llvm/regex-matchers.js +1649 -0
- package/dist/backend/llvm/regex-matchers.js.map +1 -0
- package/dist/backend/llvm/regex-matchers.test.d.ts +1 -0
- package/dist/backend/llvm/regex-matchers.test.js +96 -0
- package/dist/backend/llvm/regex-matchers.test.js.map +1 -0
- package/dist/backend/llvm/regions.d.ts +67 -0
- package/dist/backend/llvm/regions.js +309 -0
- package/dist/backend/llvm/regions.js.map +1 -0
- package/dist/backend/llvm/regions.test.d.ts +1 -0
- package/dist/backend/llvm/regions.test.js +173 -0
- package/dist/backend/llvm/regions.test.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +70 -8
- package/dist/backend/llvm/shapes.js +157 -29
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +7 -6
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/split-loops.js +1 -1
- package/dist/backend/llvm/split-loops.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +29 -0
- package/dist/backend/llvm/stack-objects.js +130 -0
- package/dist/backend/llvm/stack-objects.js.map +1 -0
- package/dist/backend/llvm/stack-objects.test.d.ts +1 -0
- package/dist/backend/llvm/stack-objects.test.js +252 -0
- package/dist/backend/llvm/stack-objects.test.js.map +1 -0
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.test.js +2 -2
- package/dist/backend/llvm/string-construction.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +5 -5
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-literal-equality.d.ts +22 -0
- package/dist/backend/llvm/string-literal-equality.js +78 -0
- package/dist/backend/llvm/string-literal-equality.js.map +1 -0
- package/dist/backend/llvm/string-reads.d.ts +4 -1
- package/dist/backend/llvm/string-reads.js +89 -9
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.js +60 -13
- package/dist/backend/llvm/switch-dispatch.js.map +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js +71 -6
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/union-retype.test.d.ts +1 -0
- package/dist/backend/llvm/union-retype.test.js +229 -0
- package/dist/backend/llvm/union-retype.test.js.map +1 -0
- package/dist/backend/llvm/walkers.d.ts +2 -0
- package/dist/backend/llvm/walkers.js +4 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/llvm/wrapping-sums.d.ts +17 -0
- package/dist/backend/llvm/wrapping-sums.js +113 -0
- package/dist/backend/llvm/wrapping-sums.js.map +1 -0
- package/dist/backend/loop-polls.js +1 -0
- package/dist/backend/loop-polls.js.map +1 -1
- package/dist/backend/mangle.d.ts +9 -0
- package/dist/backend/mangle.js +15 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/may-throw.js +7 -3
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +5 -0
- package/dist/backend/native/executable.js +16 -1
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +1 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +2 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +1 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -0
- package/dist/backend/runtime-pack-core.js +1 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.test.js +1 -1
- package/dist/backend/target-diagnostics.js +14 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +13 -0
- package/dist/backend/target-diagnostics.test.js.map +1 -1
- package/dist/contracts/check.js +4 -0
- package/dist/contracts/check.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +1 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/frontend/experimental-import.d.ts +12 -0
- package/dist/frontend/experimental-import.js +63 -0
- package/dist/frontend/experimental-import.js.map +1 -0
- package/dist/frontend/lowering/array-values.d.ts +14 -0
- package/dist/frontend/lowering/array-values.js +29 -0
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtin-calls.d.ts +6 -1
- package/dist/frontend/lowering/builtin-calls.js +36 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/console.d.ts +16 -6
- package/dist/frontend/lowering/builtins/console.js +33 -9
- package/dist/frontend/lowering/builtins/console.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.js +20 -0
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.d.ts +2 -2
- package/dist/frontend/lowering/builtins/json.js +13 -4
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +16 -1
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +1 -0
- package/dist/frontend/lowering/builtins/numbers.js +17 -0
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +18 -0
- package/dist/frontend/lowering/builtins/operating-system.js +361 -1
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +15 -3
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +109 -2
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.d.ts +3 -4
- package/dist/frontend/lowering/builtins/text-codecs.js +3 -4
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/checked-promise-all.d.ts +10 -3
- package/dist/frontend/lowering/checked-promise-all.js +52 -6
- package/dist/frontend/lowering/checked-promise-all.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +6 -3
- package/dist/frontend/lowering/class-dynamic-dispatch.js +54 -31
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +74 -4
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +8 -4
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-pipelines.d.ts +54 -0
- package/dist/frontend/lowering/containers/array-pipelines.js +1827 -0
- package/dist/frontend/lowering/containers/array-pipelines.js.map +1 -0
- package/dist/frontend/lowering/containers/exec-result-uses.d.ts +10 -0
- package/dist/frontend/lowering/containers/exec-result-uses.js +88 -0
- package/dist/frontend/lowering/containers/exec-result-uses.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +106 -7
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/containers/string-replacement.d.ts +2 -1
- package/dist/frontend/lowering/containers/string-replacement.js +32 -136
- package/dist/frontend/lowering/containers/string-replacement.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +18 -2
- package/dist/frontend/lowering/cycle-initialization.js +166 -12
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.js +7 -2
- package/dist/frontend/lowering/deferred-module-initializers.js.map +1 -1
- package/dist/frontend/lowering/deferred-module-initializers.test.js +28 -0
- package/dist/frontend/lowering/deferred-module-initializers.test.js.map +1 -1
- package/dist/frontend/lowering/devirtualize.d.ts +33 -0
- package/dist/frontend/lowering/devirtualize.js +199 -0
- package/dist/frontend/lowering/devirtualize.js.map +1 -0
- package/dist/frontend/lowering/expressions/nullish-assignment.js +55 -7
- package/dist/frontend/lowering/expressions/nullish-assignment.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +5 -56
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +231 -10
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/identifier-uses.d.ts +7 -0
- package/dist/frontend/lowering/identifier-uses.js +23 -0
- package/dist/frontend/lowering/identifier-uses.js.map +1 -0
- package/dist/frontend/lowering/iterator-adapters.js +51 -3
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/lifetime-regions.d.ts +11 -0
- package/dist/frontend/lowering/lifetime-regions.js +216 -0
- package/dist/frontend/lowering/lifetime-regions.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +28 -2
- package/dist/frontend/lowering/lower-array-sort.js +112 -2
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +99 -2
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +135 -131
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -3
- package/dist/frontend/lowering/lower-classes.js +117 -13
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-console.d.ts +27 -0
- package/dist/frontend/lowering/lower-console.js +651 -0
- package/dist/frontend/lowering/lower-console.js.map +1 -0
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -0
- package/dist/frontend/lowering/lower-event-emitter.js +124 -38
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +272 -25
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +7 -3
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +25 -7
- package/dist/frontend/lowering/lower-generators.js +264 -113
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +8 -1
- package/dist/frontend/lowering/lower-inspect.js +119 -18
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +24 -14
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +4 -0
- package/dist/frontend/lowering/lower-stdlib.js +35 -1
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +66 -11
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +13 -10
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +47 -5
- package/dist/frontend/lowering/lowerer.js +235 -54
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +16 -0
- package/dist/frontend/lowering/nan-coded-reads.js +108 -1
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/regex-span-reads.d.ts +12 -0
- package/dist/frontend/lowering/regex-span-reads.js +164 -0
- package/dist/frontend/lowering/regex-span-reads.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-bounds.d.ts +4 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js +2 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-bounds.test.js +27 -0
- package/dist/frontend/lowering/runtime-optional-bounds.test.js.map +1 -1
- package/dist/frontend/lowering/split-consumers.js +2 -18
- package/dist/frontend/lowering/split-consumers.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +115 -18
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +6 -1
- package/dist/frontend/lowering/union-retag.js +64 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +46 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/var-hoisting.d.ts +3 -0
- package/dist/frontend/lowering/var-hoisting.js +261 -0
- package/dist/frontend/lowering/var-hoisting.js.map +1 -0
- package/dist/frontend/pipeline.js +5 -3
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +3 -2
- package/dist/frontend/program.js +23 -5
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +13 -0
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +13 -1
- package/dist/frontend/type-mapper.js +160 -14
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +31 -2
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +157 -16
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/function-references.d.ts +12 -0
- package/dist/ir/function-references.js +29 -0
- package/dist/ir/function-references.js.map +1 -0
- package/dist/ir/function-references.test.d.ts +1 -0
- package/dist/ir/function-references.test.js +277 -0
- package/dist/ir/function-references.test.js.map +1 -0
- package/dist/ir/int32-slots.d.ts +7 -4
- package/dist/ir/int32-slots.js +215 -49
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +38 -1
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +4 -4
- package/dist/ir/integer-ranges.js +89 -64
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +71 -9
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/intrinsic-signatures.js +3 -0
- package/dist/ir/intrinsic-signatures.js.map +1 -1
- package/dist/ir/ir.d.ts +111 -20
- package/dist/ir/ir.js +6 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +1 -0
- package/dist/ir/runtime-features.js +38 -3
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.js +1 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +201 -25
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +90 -7
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.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 +159 -17
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { lifetimeRegionType, lowerLifetimeRegionCall, lowerLifetimeRegionNew, } from "./lifetime-regions.js";
|
|
2
|
+
import { isExperimentalDeclarationFile } from "../experimental-import.js";
|
|
1
3
|
import { checkCycleBindingAccesses, refuseUncheckedCycleReads, } from "./cycle-initialization.js";
|
|
2
4
|
import { identityPreservingWidening } from "./coercions/identity.js";
|
|
3
5
|
import { scanDivergences } from "./divergences.js";
|
|
4
6
|
import { checkedClassAssertion } from "./class-assertions.js";
|
|
5
7
|
import { narrowStoredClassValue, narrowGenericClassValue } from "./class-unions.js";
|
|
6
8
|
import { isOptionalProcessStreamProperty } from "./builtins/process.js";
|
|
9
|
+
import { isSettledIteratorValueRead } from "./lower-generators.js";
|
|
7
10
|
import { concreteCollectionNarrow } from "./collection-narrowing.js";
|
|
8
11
|
import { lowerWorkerMetadata } from "./builtins/workers.js";
|
|
9
12
|
import { dynUndefinedExpr, nodeThrowExpr, numLit, varRef } from "../../ir/build.js";
|
|
@@ -15,7 +18,8 @@ import { widthCoerce, applyWidthLift, unionRecordWidthHelper, recordWidthHelper,
|
|
|
15
18
|
import { funcReturnWidthAdapter, coercibleValue, cleanFuncAdaptable, funcCoerceAdapter, spawnResFnAdapterPlan, spawnResFnAdapter, } from "./coercions/function-adapters.js";
|
|
16
19
|
import { unionRetagMappable, narrowedRetagHelper, strandedUnitTrap, strandedCoercionTrap, recordUnionWrapHelper, unionRetagHelper, narrowedArmHelper, checkedNarrowCall, checkedNarrowOperand, deferredReadHelper, } from "./coercions/unions.js";
|
|
17
20
|
import { lowerUtilTypeValue, pathModuleValue, utilTypesModuleValue, } from "./lower-builtin-values.js";
|
|
18
|
-
import {
|
|
21
|
+
import { devirtualizeVirtualCalls } from "./devirtualize.js";
|
|
22
|
+
import { foldRegexSpanReads } from "./regex-span-reads.js";
|
|
19
23
|
import { RuntimeOptionalProvenance } from "./runtime-optional-provenance.js";
|
|
20
24
|
import { presentAtUse, reassignedBindings } from "./runtime-optional-guards.js";
|
|
21
25
|
import { NarrowingStability } from "./narrowing-stability.js";
|
|
@@ -33,6 +37,8 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
33
37
|
import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
|
|
34
38
|
import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
|
|
35
39
|
import { ClassProtocols } from "./class-protocols.js";
|
|
40
|
+
import { earlyReadVarSymbols } from "./var-hoisting.js";
|
|
41
|
+
import { recordTextCodecClass } from "../../ir/ir.js";
|
|
36
42
|
import { DeferredModuleInitializers } from "./deferred-module-initializers.js";
|
|
37
43
|
import { finalizeClassMethodValues } from "./class-method-values.js";
|
|
38
44
|
export { newFnCtx } from "./function-context.js";
|
|
@@ -60,7 +66,7 @@ import { unsupportedAnyOperationDiag, blockedBindingUseDiag, checkerPanicDiag, c
|
|
|
60
66
|
import { arrayOf, BOOL, canAdaptDynFuncTo, canDynCheckTo, canConvertToDyn, DYN, DYN_HANDLE_KINDS, F64, isDynTypedRefType, isJsonSafeType, isJsonStringifySafeType, isPrimitiveCollectionKey, isSupportedMapKey, isSupportedMapValue, isUndefinedArmedUnion, isUnitType, NULL_T, RUNTIME_ERROR_CLASSES, STRING, typeEquals, UNDEFINED_T, VOID, } from "../../ir/ir.js";
|
|
61
67
|
import { provenanceActive } from "../provenance-registry.js";
|
|
62
68
|
import { ambientDtsPath, canonicalBuiltinModule, cjsExportAssignmentOf, cjsExportDiscardReason, fallbackDtsPath, isCjsExportTableLiteral, isCjsJsFile, isJsSourceFile, isNodeEsmFile, isNodeTypesPath, locOf, orderedImportsOf, overridesDtsPath, npmStaticDepSf7, requireSpecOf, resolveImport, workspacePackageOfPath, } from "../program.js";
|
|
63
|
-
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
69
|
+
import { containsRecord, containsUnion, describeComponentBlocker, describeRecordMemberBlocker, formatIrType, FETCH_AMBIENT_TYPES, isOsConstantsSymbol, isUnitOnlyTsType, isWorkerHandleType, jsOpenObjectType, mapType, ShapeRegistry, typeKey, UnionRegistry, withUndefinedArm as withUndefinedArmCanonical, } from "../type-mapper.js";
|
|
64
70
|
import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinFenceHintOf, builtinModuleFnOf, stdlibMemberFence, isStdlibMember, isStdlibSymbol, isStdlibGlobal, stdlibGlobalNameOf, stdlibGlobalMember, nodeTypesOnlySymbol, } from "./surfaces.js";
|
|
65
71
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
66
72
|
import { prepareCjsModuleGraph } from "./lower-node-module.js";
|
|
@@ -77,6 +83,7 @@ import { lowerCall, lowerPromiseMethodCall, lowerFilterNarrowCall } from "./lowe
|
|
|
77
83
|
import { lowerFfiCall, validateFfiImports } from "./native-ffi.js";
|
|
78
84
|
import { isTopLevelFnSymbol, lowerNestedFunctionDecl, lowerLambda, lowerFunction, } from "./lower-functions.js";
|
|
79
85
|
import { lowerArrayMethodCall } from "./containers/array-methods.js";
|
|
86
|
+
import { fuseArrayPipelines } from "./containers/array-pipelines.js";
|
|
80
87
|
import { lowerMapMethodCall, lowerMapForEachCall, lowerSetMethodCall, lowerSetForEachCall, } from "./containers/collection-methods.js";
|
|
81
88
|
import { lowerEnvToPairsHelper } from "./containers/indexed-objects.js";
|
|
82
89
|
import { lowerBufferStaticCall, lowerBytesMethodCall, lowerBytesNew } from "./containers/bytes.js";
|
|
@@ -103,13 +110,14 @@ import { lowerReadlineMethodCall } from "./builtins/readline.js";
|
|
|
103
110
|
import { lowerDiagnosticsChannelMethodCall, lowerDiagnosticsChannelProperty, lowerAsyncLocalStorageMethodCall, lowerTracingChannelMethodCall, lowerTracingChannelProperty, } from "./builtins/async-context.js";
|
|
104
111
|
import { lowerErrorCodeProperty } from "./builtins/errors.js";
|
|
105
112
|
import { lowerProcessProperty, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerProcessStreamProperty, } from "./builtins/process.js";
|
|
106
|
-
import { isConsoleLog,
|
|
113
|
+
import { consoleCallMember, consoleMethodMember, isConsoleLog, } from "./builtins/console.js";
|
|
114
|
+
import { lowerConsoleNew } from "./lower-console.js";
|
|
107
115
|
import { lowerNumberStaticCall, lowerNumberStaticProperty } from "./builtins/numbers.js";
|
|
108
116
|
import { lowerDateCall } from "./builtins/dates.js";
|
|
109
117
|
import { lowerFsConstantsProperty, lowerBuiltinConstantsProperty, builtinConstantBindingOf, builtinConstantsDestructureDecl, } from "./builtins/constants.js";
|
|
110
118
|
import { lowerStringStaticCall, lowerStringLastIndexOfCall } from "./builtins/strings.js";
|
|
111
119
|
import { lowerPromiseStaticCall } from "./builtins/promises.js";
|
|
112
|
-
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
120
|
+
import { fenceFetchObjectAssignment, fenceFetchObjectBinding, fenceStaticAbortControllerMemberRead, fenceStaticHeadersIteration, fenceStaticHeadersMember, fenceStaticReadableStreamMember, fenceStaticResponseMember, fenceUnsupportedFetchConstructorMember, refuseUnsupportedApi, stdlibGlobalFnOf, lowerAbortControllerNew, lowerEventTargetNew, lowerDynamicImportCall, lowerFetchCall, lowerFetchElementMethodCall, lowerResponseNew, lowerFetchWebNew, lowerStaticFetchCompanionCall, lowerStaticAbortControllerCall, lowerStaticAbortSignalListenerCall, lowerStaticReadableStreamCancelCall, lowerStaticReadableStreamControllerCall, lowerStaticReadableStreamNew, lowerStaticReadableStreamReaderCall, lowerStaticResponseCall, lowerStdlibMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol, } from "./lower-stdlib.js";
|
|
113
121
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty, lowerTlsRootCertificates, } from "./lower-server.js";
|
|
114
122
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
115
123
|
import { lowerNodeTestModuleCall, lowerTestDirectCall, lowerTestMethodCall, lowerTestCtxProperty, } from "./lower-test.js";
|
|
@@ -1114,6 +1122,9 @@ export class Lowerer {
|
|
|
1114
1122
|
/** All storage slots widened for runtime absence, including slots whose
|
|
1115
1123
|
* current control-flow branch has temporarily narrowed the value. */
|
|
1116
1124
|
runtimeOptionalStorageLocals = new Set();
|
|
1125
|
+
/** `var` bindings code can read before their first store
|
|
1126
|
+
* (var-hoisting.ts): their storage holds undefined until then. */
|
|
1127
|
+
earlyReadVars = new Set();
|
|
1117
1128
|
/** Globals whose checker-bare type was widened because an indexed read can
|
|
1118
1129
|
* carry undefined at runtime. Identifier reads keep the union tag so
|
|
1119
1130
|
* typeof and later boundaries observe the real value. */
|
|
@@ -1127,6 +1138,9 @@ export class Lowerer {
|
|
|
1127
1138
|
* prepass. This includes explicit annotations: unchecked TS annotations do
|
|
1128
1139
|
* not prove that an array property read produced a value. */
|
|
1129
1140
|
runtimeOptionalBindingTypes = new Map();
|
|
1141
|
+
/** Set when a match result lowers to execGroups/matchGroups, the inputs
|
|
1142
|
+
* of regex span folding. */
|
|
1143
|
+
regexGroupResults = false;
|
|
1130
1144
|
/** Bindings that receive an unchecked indexed read (or a value derived
|
|
1131
1145
|
* from one) through an initializer or assignment. The checker narrows a
|
|
1132
1146
|
* declared optional binding to that read's bare type, so presence tests
|
|
@@ -1471,6 +1485,9 @@ export class Lowerer {
|
|
|
1471
1485
|
/** Synthetic array-HOF loop functions (map/filter/forEach desugar),
|
|
1472
1486
|
* interned per method + element/callback-result type: key → fn name. */
|
|
1473
1487
|
arrHofHelpers = new Map();
|
|
1488
|
+
/** What each array-HOF helper computes, keyed by helper name: the chain
|
|
1489
|
+
* fusion pass reads it to recognize pipelines of helper calls. */
|
|
1490
|
+
arrHofInfo = new Map();
|
|
1474
1491
|
/** Per-arm calls through union-typed class receivers, interned by the
|
|
1475
1492
|
* receiver union, member, completed argument ABI, and result type. */
|
|
1476
1493
|
unionCallHelpers = new Map();
|
|
@@ -1650,6 +1667,12 @@ export class Lowerer {
|
|
|
1650
1667
|
workerTargets;
|
|
1651
1668
|
workerTargetIdByPath = new Map();
|
|
1652
1669
|
usesWorkers = false;
|
|
1670
|
+
/** The program constructs a LifetimeRegion (lifetime-regions.ts). */
|
|
1671
|
+
usesLifetimeRegions = false;
|
|
1672
|
+
/** Per-directory answers of experimental-import.ts's declaration-file test. */
|
|
1673
|
+
experimentalFiles = new Map();
|
|
1674
|
+
/** Interned LifetimeRegion.run helpers, by callback type key. */
|
|
1675
|
+
regionRunHelpers = new Map();
|
|
1653
1676
|
forkTargetIdByPath = new Map();
|
|
1654
1677
|
/** Namespace ModuleBlocks this program lowers, filled by splitFiles:
|
|
1655
1678
|
* "flattened" — an instantiated namespace whose body joined the file's
|
|
@@ -1756,6 +1779,9 @@ export class Lowerer {
|
|
|
1756
1779
|
/** Import-cycle bindings with an initialization flag, by global id, and
|
|
1757
1780
|
* the top-level statements declaring them (cycle-initialization.ts). */
|
|
1758
1781
|
cycleInitFlags = new Map();
|
|
1782
|
+
/** Initialization flags of classes reachable before their statement ran,
|
|
1783
|
+
* by class name (cycle-initialization.ts). */
|
|
1784
|
+
classInitFlags = new Map();
|
|
1759
1785
|
cycleInitDeclarations = new Map();
|
|
1760
1786
|
get ctx() {
|
|
1761
1787
|
const top = this.fnStack[this.fnStack.length - 1];
|
|
@@ -1776,6 +1802,12 @@ export class Lowerer {
|
|
|
1776
1802
|
* can contain any retained descendant, but importing its declaration
|
|
1777
1803
|
* alone does not make every descendant constructible. */
|
|
1778
1804
|
constructedClasses = null;
|
|
1805
|
+
/** Set while a subclass constructor's super() call notes its base
|
|
1806
|
+
* constructor edge: that edge does not instantiate the base exactly. */
|
|
1807
|
+
superConstructorEdge = false;
|
|
1808
|
+
/** Set when the async generator `return` being lowered awaited its
|
|
1809
|
+
* promise operand (returnedPromiseAwait). */
|
|
1810
|
+
returnAwaitedPromise = false;
|
|
1779
1811
|
virtualEdges = new Map();
|
|
1780
1812
|
classCanBeConstructed(info) {
|
|
1781
1813
|
return (this.constructedClasses === null ||
|
|
@@ -1955,6 +1987,9 @@ export class Lowerer {
|
|
|
1955
1987
|
// fileTag is filled just below; the hook is only ever CALLED during
|
|
1956
1988
|
// lowering, long after the constructor completes.
|
|
1957
1989
|
isProgramFile: (sf) => this.fileTag.has(sf),
|
|
1990
|
+
lifetimeRegionClass: (decl) => isExperimentalDeclarationFile(decl.getSourceFile(), this.experimentalFiles)
|
|
1991
|
+
? lifetimeRegionType(this)
|
|
1992
|
+
: null,
|
|
1958
1993
|
moduleNamespaceId: (type) => this.moduleNamespaceIdOfType(type),
|
|
1959
1994
|
};
|
|
1960
1995
|
// Modules reachable only through literal import() joined
|
|
@@ -2961,7 +2996,6 @@ export class Lowerer {
|
|
|
2961
2996
|
const signatureBySymbol = new Map();
|
|
2962
2997
|
const methodFamilies = new Map();
|
|
2963
2998
|
const familyBySymbol = new Map();
|
|
2964
|
-
const optionalMethodFamilies = new Set();
|
|
2965
2999
|
for (const [symbol, sig] of this.fnSigsBySymbol)
|
|
2966
3000
|
signatureBySymbol.set(symbol, { params: sig.params, returnType: sig.returnType, top: sig });
|
|
2967
3001
|
for (const decl of fnDecls) {
|
|
@@ -3002,6 +3036,17 @@ export class Lowerer {
|
|
|
3002
3036
|
familyBySymbol.set(symbol, family);
|
|
3003
3037
|
}
|
|
3004
3038
|
}
|
|
3039
|
+
// Static methods never share a dispatch slot: each is its own family.
|
|
3040
|
+
if (info.staticMethods) {
|
|
3041
|
+
for (const sig of info.staticMethods.values()) {
|
|
3042
|
+
const name = sig.member.name;
|
|
3043
|
+
if (!(ts.isIdentifier(name) || ts.isStringLiteral(name)))
|
|
3044
|
+
continue;
|
|
3045
|
+
const symbol = symbolOf(name);
|
|
3046
|
+
if (symbol && !signatureBySymbol.has(symbol))
|
|
3047
|
+
signatureBySymbol.set(symbol, { params: sig.params, returnType: sig.ret, method: sig });
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3005
3050
|
}
|
|
3006
3051
|
const mappedOrNull = (node) => panicSafe(() => this.mapTypeOf(this.typeOf(node)), null);
|
|
3007
3052
|
const nanCoded = new NanCodedReads({
|
|
@@ -3221,6 +3266,10 @@ export class Lowerer {
|
|
|
3221
3266
|
return true;
|
|
3222
3267
|
if (ts.isPropertyAccessExpression(e) && isOptionalProcessStreamProperty(this, e))
|
|
3223
3268
|
return true;
|
|
3269
|
+
if (ts.isPropertyAccessExpression(e) && isSettledIteratorValueRead(this, e))
|
|
3270
|
+
return true;
|
|
3271
|
+
if (ts.isPropertyAccessExpression(e) && isOsConstantsSymbol(symbolOf(e.expression), this))
|
|
3272
|
+
return true;
|
|
3224
3273
|
if (ts.isCallExpression(e) && this.runtimeOptionalReduceTypes.has(e))
|
|
3225
3274
|
return true;
|
|
3226
3275
|
if (ts.isCallExpression(e) &&
|
|
@@ -3252,6 +3301,11 @@ export class Lowerer {
|
|
|
3252
3301
|
const symbol = symbolOf(e.name);
|
|
3253
3302
|
if (symbol && optionalSymbols.has(symbol))
|
|
3254
3303
|
return true;
|
|
3304
|
+
// A getter read is a call of its body.
|
|
3305
|
+
if (symbol &&
|
|
3306
|
+
(symbol.flags & ts.SymbolFlags.GetAccessor) !== 0 &&
|
|
3307
|
+
optionalReturns.has(symbol))
|
|
3308
|
+
return true;
|
|
3255
3309
|
}
|
|
3256
3310
|
if (ts.isCallExpression(e) && ts.isIdentifier(e.expression)) {
|
|
3257
3311
|
const symbol = callableSymbolOf(e.expression);
|
|
@@ -3326,6 +3380,27 @@ export class Lowerer {
|
|
|
3326
3380
|
return null;
|
|
3327
3381
|
return { kind: "union", unionId: this.unions.intern([F64, STRING]) };
|
|
3328
3382
|
};
|
|
3383
|
+
/** The union of primitive result types, or null when any is missing or
|
|
3384
|
+
* not a number, string or boolean (or a union of them). */
|
|
3385
|
+
const joinPrimitiveTypes = (types) => {
|
|
3386
|
+
const arms = new Map();
|
|
3387
|
+
for (const type of types) {
|
|
3388
|
+
if (!type)
|
|
3389
|
+
return null;
|
|
3390
|
+
const parts = type.kind === "union" ? this.unions.get(type.unionId)?.arms : [type];
|
|
3391
|
+
if (!parts)
|
|
3392
|
+
return null;
|
|
3393
|
+
for (const arm of parts) {
|
|
3394
|
+
if (arm.kind !== "f64" && arm.kind !== "string" && arm.kind !== "bool")
|
|
3395
|
+
return null;
|
|
3396
|
+
arms.set(typeKey(arm), arm);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
const sorted = [...arms.entries()].sort(([a], [b]) => (a < b ? -1 : 1)).map(([, t]) => t);
|
|
3400
|
+
if (sorted.length === 1)
|
|
3401
|
+
return sorted[0];
|
|
3402
|
+
return { kind: "union", unionId: this.unions.intern(sorted) };
|
|
3403
|
+
};
|
|
3329
3404
|
const noteField = (decl, name) => {
|
|
3330
3405
|
if (!ts.isIdentifier(decl.name))
|
|
3331
3406
|
return false;
|
|
@@ -3487,6 +3562,19 @@ export class Lowerer {
|
|
|
3487
3562
|
found = true;
|
|
3488
3563
|
return found;
|
|
3489
3564
|
};
|
|
3565
|
+
/** A return of a var that code can read before its first store. */
|
|
3566
|
+
const returnsEarlyVar = (fn) => {
|
|
3567
|
+
const early = (e) => {
|
|
3568
|
+
const read = peel(e);
|
|
3569
|
+
if (!ts.isIdentifier(read))
|
|
3570
|
+
return false;
|
|
3571
|
+
const symbol = symbolOf(read);
|
|
3572
|
+
return symbol !== null && this.earlyReadVars.has(symbol);
|
|
3573
|
+
};
|
|
3574
|
+
if (fn.body && !ts.isBlock(fn.body))
|
|
3575
|
+
return early(fn.body);
|
|
3576
|
+
return returnsOf(fn).some(early);
|
|
3577
|
+
};
|
|
3490
3578
|
const jsLambdas = [];
|
|
3491
3579
|
// TypeScript lambdas keep the checker's inferred return type, which
|
|
3492
3580
|
// spells a missing read as its bare element type and `read ?? "text"`
|
|
@@ -4333,9 +4421,6 @@ export class Lowerer {
|
|
|
4333
4421
|
if (arg &&
|
|
4334
4422
|
(this.typeOf(arg).flags & (ts.TypeFlags.Undefined | ts.TypeFlags.Void)) === 0)
|
|
4335
4423
|
continue;
|
|
4336
|
-
const family = familyBySymbol.get(symbol);
|
|
4337
|
-
if (family)
|
|
4338
|
-
optionalMethodFamilies.add(family);
|
|
4339
4424
|
for (const target of familyBySymbol.get(symbol) ?? [symbol]) {
|
|
4340
4425
|
const shape = signatureBySymbol.get(target)?.params[i];
|
|
4341
4426
|
if (!shape || shape.mode !== "required")
|
|
@@ -4452,8 +4537,6 @@ export class Lowerer {
|
|
|
4452
4537
|
// Promote every implementation and its parameter bindings so
|
|
4453
4538
|
// downstream calls and returns see the same optional value.
|
|
4454
4539
|
const family = familyBySymbol.get(symbol);
|
|
4455
|
-
if (family)
|
|
4456
|
-
optionalMethodFamilies.add(family);
|
|
4457
4540
|
for (const target of family ?? [symbol]) {
|
|
4458
4541
|
const parameterShape = signatureBySymbol.get(target)?.params[i];
|
|
4459
4542
|
if (!parameterShape)
|
|
@@ -4501,6 +4584,19 @@ export class Lowerer {
|
|
|
4501
4584
|
}
|
|
4502
4585
|
return changed;
|
|
4503
4586
|
};
|
|
4587
|
+
// A `var` that code can read before its first store holds undefined
|
|
4588
|
+
// there, whatever its declared type.
|
|
4589
|
+
for (const symbol of earlyReadVarSymbols(this, sourceFiles)) {
|
|
4590
|
+
// Text codec bindings keep their own presence-checked storage.
|
|
4591
|
+
const declaration = this.checker.valueDeclarationOf(symbol);
|
|
4592
|
+
const mapped = declaration && ts.isVariableDeclaration(declaration)
|
|
4593
|
+
? mappedOrNull(declaration.name)
|
|
4594
|
+
: null;
|
|
4595
|
+
if (mapped?.kind === "record" && recordTextCodecClass(this.shapes.get(mapped.shapeId)))
|
|
4596
|
+
continue;
|
|
4597
|
+
optionalSymbols.add(symbol);
|
|
4598
|
+
this.earlyReadVars.add(symbol);
|
|
4599
|
+
}
|
|
4504
4600
|
let changed = true;
|
|
4505
4601
|
while (changed) {
|
|
4506
4602
|
changed = false;
|
|
@@ -4518,8 +4614,10 @@ export class Lowerer {
|
|
|
4518
4614
|
if (scanReturns(symbol, decl))
|
|
4519
4615
|
changed = true;
|
|
4520
4616
|
for (const fn of tsLambdas) {
|
|
4521
|
-
// An annotated return is the author's contract, as for parameters
|
|
4522
|
-
|
|
4617
|
+
// An annotated return is the author's contract, as for parameters,
|
|
4618
|
+
// except that a var read before its first store is undefined
|
|
4619
|
+
// whatever the annotation says.
|
|
4620
|
+
if (fn.type && !returnsEarlyVar(fn))
|
|
4523
4621
|
continue;
|
|
4524
4622
|
const mapped = this.mapTypeOf(this.typeOf(fn));
|
|
4525
4623
|
if (mapped?.kind !== "func")
|
|
@@ -4580,18 +4678,35 @@ export class Lowerer {
|
|
|
4580
4678
|
changed = true;
|
|
4581
4679
|
}
|
|
4582
4680
|
}
|
|
4583
|
-
// Every implementation of a virtual slot must retain the same ABI
|
|
4584
|
-
//
|
|
4585
|
-
|
|
4586
|
-
|
|
4681
|
+
// Every implementation of a virtual slot must retain the same ABI:
|
|
4682
|
+
// when one body can return undefined at runtime (an unchecked element
|
|
4683
|
+
// read, a forwarded omitted parameter), the abstract or base
|
|
4684
|
+
// declaration and every override return the widened type too.
|
|
4685
|
+
for (const family of methodFamilies.values()) {
|
|
4686
|
+
if (family.length < 2)
|
|
4587
4687
|
continue;
|
|
4588
|
-
|
|
4688
|
+
const optional = family.some((symbol) => optionalReturns.has(symbol));
|
|
4689
|
+
for (const symbol of optional ? family : []) {
|
|
4589
4690
|
if (!optionalReturns.has(symbol)) {
|
|
4590
4691
|
optionalReturns.add(symbol);
|
|
4591
4692
|
provenance?.note("return", functionDeclBySymbol.get(symbol), undefined, "(override family)");
|
|
4592
4693
|
changed = true;
|
|
4593
4694
|
}
|
|
4594
4695
|
}
|
|
4696
|
+
// A primitive-widened result (`names[i] + 1` is NaN for a missing
|
|
4697
|
+
// string) likewise becomes the slot's result for every member.
|
|
4698
|
+
if (!family.some((symbol) => arithmeticReturns.has(symbol)))
|
|
4699
|
+
continue;
|
|
4700
|
+
const joined = joinPrimitiveTypes(family.map((symbol) => arithmeticReturns.get(symbol) ?? signatureBySymbol.get(symbol)?.returnType));
|
|
4701
|
+
if (!joined)
|
|
4702
|
+
continue;
|
|
4703
|
+
for (const symbol of family) {
|
|
4704
|
+
const previous = arithmeticReturns.get(symbol);
|
|
4705
|
+
if (previous && typeEquals(previous, joined))
|
|
4706
|
+
continue;
|
|
4707
|
+
arithmeticReturns.set(symbol, joined);
|
|
4708
|
+
changed = true;
|
|
4709
|
+
}
|
|
4595
4710
|
}
|
|
4596
4711
|
}
|
|
4597
4712
|
// NaN-coded slots convert optional values on entry instead of holding
|
|
@@ -4959,6 +5074,8 @@ export class Lowerer {
|
|
|
4959
5074
|
/** Final retention, pruning, and module assembly shared by ordinary emit
|
|
4960
5075
|
* and the retained reachability worklist. */
|
|
4961
5076
|
finishModule(functions) {
|
|
5077
|
+
if (this.diags.length === 0)
|
|
5078
|
+
fuseArrayPipelines(this, functions);
|
|
4962
5079
|
finalizeClassMethodValues(this, functions);
|
|
4963
5080
|
trackClassFieldCreation(this, functions);
|
|
4964
5081
|
// Globals typed by a class that never REGISTERED (a JS class whose
|
|
@@ -5060,6 +5177,7 @@ export class Lowerer {
|
|
|
5060
5177
|
globals: this.globalsList,
|
|
5061
5178
|
entry: ENTRY_NAME,
|
|
5062
5179
|
...(this.usesWorkers ? { workers: true } : {}),
|
|
5180
|
+
...(this.usesLifetimeRegions ? { lifetimeRegions: true } : {}),
|
|
5063
5181
|
...(isNodeEsmFile(this.entry, this.program) ? {} : { commonJsEntry: true }),
|
|
5064
5182
|
...(this.ffiImports.length > 0 ? { ffiImports: [...this.ffiImports] } : {}),
|
|
5065
5183
|
};
|
|
@@ -5244,6 +5362,8 @@ export class Lowerer {
|
|
|
5244
5362
|
for (const info of this.classes.values()) {
|
|
5245
5363
|
if (info.builtinError)
|
|
5246
5364
|
continue; // runtime-provided; nothing lowers
|
|
5365
|
+
if (info.lifetimeRegion)
|
|
5366
|
+
continue; // synthesized with the class
|
|
5247
5367
|
// Generic-class INSTANTIATIONS (and mixin instantiations) are
|
|
5248
5368
|
// demand-driven, not units: their members lower unconditionally in
|
|
5249
5369
|
// the instance drain below — the generic-fn instance rule.
|
|
@@ -5343,11 +5463,17 @@ export class Lowerer {
|
|
|
5343
5463
|
};
|
|
5344
5464
|
const reachable = new Set();
|
|
5345
5465
|
this.constructedClasses = new Set();
|
|
5466
|
+
// Every constructor edge except super() may create an instance of
|
|
5467
|
+
// exactly that class (`new C`, class values, library roots, dynamic
|
|
5468
|
+
// construction, ...).
|
|
5469
|
+
const instantiated = new Set();
|
|
5346
5470
|
const queue = [];
|
|
5347
5471
|
const loweredUnits = new Map();
|
|
5348
5472
|
const initFunctions = [];
|
|
5349
5473
|
const instanceFunctions = [];
|
|
5350
5474
|
this.onEdge = (name) => {
|
|
5475
|
+
if (!this.superConstructorEdge && name.endsWith(".constructor"))
|
|
5476
|
+
instantiated.add(name.slice(1, -".constructor".length));
|
|
5351
5477
|
if (reachable.has(name))
|
|
5352
5478
|
return;
|
|
5353
5479
|
reachable.add(name);
|
|
@@ -5553,35 +5679,17 @@ export class Lowerer {
|
|
|
5553
5679
|
...this.liftedFns,
|
|
5554
5680
|
...this.implicitFns,
|
|
5555
5681
|
];
|
|
5556
|
-
|
|
5682
|
+
if (this.regexGroupResults)
|
|
5683
|
+
for (const fn of functions)
|
|
5684
|
+
foldRegexSpanReads(this, fn);
|
|
5685
|
+
// The worklist can leave a virtual site with a single implementation.
|
|
5557
5686
|
// Devirtualize after construction/override reachability has settled.
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
const info = this.classes.get(expression.className);
|
|
5565
|
-
const method = info && this.findMethodOn(info, expression.method);
|
|
5566
|
-
if (!method ||
|
|
5567
|
-
method.sig.abstract ||
|
|
5568
|
-
[...this.classes.values()].some((candidate) => this.isSubclassOf(candidate.def.name, expression.className) &&
|
|
5569
|
-
candidate.def.name !== expression.className &&
|
|
5570
|
-
candidate.methods.has(expression.method) &&
|
|
5571
|
-
reachable.has(`%${candidate.def.name}.${expression.method}`)))
|
|
5572
|
-
return expression;
|
|
5573
|
-
return {
|
|
5574
|
-
kind: "call",
|
|
5575
|
-
callee: `%${method.declarer.def.name}.${expression.method}`,
|
|
5576
|
-
args: [
|
|
5577
|
-
this.upcastTo(expression.args[0], method.declarer.def.name),
|
|
5578
|
-
...expression.args.slice(1),
|
|
5579
|
-
],
|
|
5580
|
-
type: expression.type,
|
|
5581
|
-
loc: expression.loc,
|
|
5582
|
-
};
|
|
5583
|
-
},
|
|
5584
|
-
});
|
|
5687
|
+
devirtualizeVirtualCalls(this, functions, {
|
|
5688
|
+
reachable,
|
|
5689
|
+
instantiated,
|
|
5690
|
+
library: extraRoots !== undefined,
|
|
5691
|
+
files: parts.map((fp) => fp.sf),
|
|
5692
|
+
});
|
|
5585
5693
|
this.reachableForArtifacts = reachable;
|
|
5586
5694
|
return { reachable, result: this.finishModule(functions) };
|
|
5587
5695
|
}
|
|
@@ -5591,6 +5699,17 @@ export class Lowerer {
|
|
|
5591
5699
|
if (this.onEdge)
|
|
5592
5700
|
this.onEdge(name);
|
|
5593
5701
|
}
|
|
5702
|
+
/** A subclass constructor's super() edge: the base constructor runs, but
|
|
5703
|
+
* no instance of exactly the base class is created. */
|
|
5704
|
+
noteSuperConstructorEdge(name) {
|
|
5705
|
+
this.superConstructorEdge = true;
|
|
5706
|
+
try {
|
|
5707
|
+
this.noteEdge(name);
|
|
5708
|
+
}
|
|
5709
|
+
finally {
|
|
5710
|
+
this.superConstructorEdge = false;
|
|
5711
|
+
}
|
|
5712
|
+
}
|
|
5594
5713
|
/** Discovery hook for virtual dispatch: a virtualCall on `info`'s static
|
|
5595
5714
|
* class reaches the nearest declaration at/above it plus every override
|
|
5596
5715
|
* on a STRICT descendant (receivers of sibling branches can't flow into
|
|
@@ -7391,10 +7510,10 @@ export class Lowerer {
|
|
|
7391
7510
|
}
|
|
7392
7511
|
/** The value of a `return` statement. In an async function `return p`
|
|
7393
7512
|
* where p is a promise flattens (JS: the returned promise's settlement
|
|
7394
|
-
* becomes the async function's result)
|
|
7395
|
-
*
|
|
7396
|
-
*
|
|
7397
|
-
*
|
|
7513
|
+
* becomes the async function's result) through an adopting awaitExpr,
|
|
7514
|
+
* which parks the fiber and re-throws rejections after the adoption's
|
|
7515
|
+
* then-job turn. Everything else flows into the function's return slot
|
|
7516
|
+
* through the usual coercion path. */
|
|
7398
7517
|
/** The value of `return <expr>` against the context's declared return —
|
|
7399
7518
|
* or NULL for a bare return: `return undefined`/`return null` in a
|
|
7400
7519
|
* void-returning function (`{ bar() { return undefined } }`, inferred
|
|
@@ -7425,11 +7544,40 @@ export class Lowerer {
|
|
|
7425
7544
|
if (expected.kind === "void" && e.kind === "unitLit")
|
|
7426
7545
|
return null;
|
|
7427
7546
|
if (this.ctx.isAsync && e.type.kind === "promise" && expected.kind !== "promise") {
|
|
7428
|
-
const awaited =
|
|
7547
|
+
const awaited = this.returnedPromiseAwait(e);
|
|
7429
7548
|
return this.coerceInto(node, awaited, expected);
|
|
7430
7549
|
}
|
|
7431
7550
|
return this.coerceInto(node, e, expected);
|
|
7432
7551
|
}
|
|
7552
|
+
/** Whether a promise returned here resolves the function's own promise
|
|
7553
|
+
* by adoption (async functions; async generators await their return
|
|
7554
|
+
* operand instead). */
|
|
7555
|
+
adoptsReturnedPromise() {
|
|
7556
|
+
return this.ctx.isAsync === true && !this.ctx.generator;
|
|
7557
|
+
}
|
|
7558
|
+
/** `return p` of a promise into a non-promise result `R` (a void result
|
|
7559
|
+
* drops the settled value; widening keeps the adopting await the return's
|
|
7560
|
+
* own value). */
|
|
7561
|
+
adoptingReturn(e, R, coerce) {
|
|
7562
|
+
const loc = e.loc;
|
|
7563
|
+
if (R.kind !== "void")
|
|
7564
|
+
return { kind: "return", value: coerce(this.returnedPromiseAwait(e)), loc };
|
|
7565
|
+
const widened = e.type.kind === "promise" && e.type.inner.kind !== "void"
|
|
7566
|
+
? { kind: "promiseVoidWiden", value: e, type: { kind: "promise", inner: VOID }, loc }
|
|
7567
|
+
: e;
|
|
7568
|
+
return { kind: "return", value: this.returnedPromiseAwait(widened), loc };
|
|
7569
|
+
}
|
|
7570
|
+
/** The await a returned promise `e` lowers to: adopting in async
|
|
7571
|
+
* functions (one then-job turn first, outside the function's handlers). */
|
|
7572
|
+
returnedPromiseAwait(e) {
|
|
7573
|
+
if (e.type.kind !== "promise")
|
|
7574
|
+
throw new InternalCompilerError("returned-promise await of a non-promise");
|
|
7575
|
+
if (!this.adoptsReturnedPromise()) {
|
|
7576
|
+
this.returnAwaitedPromise = true;
|
|
7577
|
+
return { kind: "awaitExpr", value: e, type: e.type.inner, loc: e.loc };
|
|
7578
|
+
}
|
|
7579
|
+
return { kind: "awaitExpr", value: e, type: e.type.inner, adopt: true, loc: e.loc };
|
|
7580
|
+
}
|
|
7433
7581
|
/** `return <expr>` lowered as a STATEMENT against the declared return.
|
|
7434
7582
|
* Void-returning contexts get the JS drop: a contextually void-typed
|
|
7435
7583
|
* function may return a value (`fv = function() { return 0; }` into a
|
|
@@ -7437,11 +7585,33 @@ export class Lowerer {
|
|
|
7437
7585
|
* caller never sees a value, so the return goes out bare. Async
|
|
7438
7586
|
* void-inner returns still resolve a returned promise first. */
|
|
7439
7587
|
lowerReturnStmt(node, loc) {
|
|
7588
|
+
if (!(this.ctx.isAsync === true && this.ctx.generator))
|
|
7589
|
+
return this.lowerReturnOf(node, loc);
|
|
7590
|
+
// An async generator's `return x` awaits x; for a promise that await
|
|
7591
|
+
// is the returned-promise await, and the return needs no other turn.
|
|
7592
|
+
const saved = this.returnAwaitedPromise;
|
|
7593
|
+
this.returnAwaitedPromise = false;
|
|
7594
|
+
const s = this.lowerReturnOf(node, loc);
|
|
7595
|
+
const awaited = this.returnAwaitedPromise;
|
|
7596
|
+
this.returnAwaitedPromise = saved;
|
|
7597
|
+
if (!awaited)
|
|
7598
|
+
return s;
|
|
7599
|
+
if (s.kind === "return")
|
|
7600
|
+
return { ...s, awaited: true };
|
|
7601
|
+
if (s.kind === "block" && s.body.at(-1)?.kind === "return") {
|
|
7602
|
+
const last = s.body.at(-1);
|
|
7603
|
+
return { ...s, body: [...s.body.slice(0, -1), { ...last, awaited: true }] };
|
|
7604
|
+
}
|
|
7605
|
+
return s;
|
|
7606
|
+
}
|
|
7607
|
+
lowerReturnOf(node, loc) {
|
|
7440
7608
|
const expected = this.ctx.returnType;
|
|
7441
7609
|
if (expected.kind === "void") {
|
|
7442
7610
|
let e = this.lowerExpr(node);
|
|
7443
7611
|
if (this.ctx.isAsync && e.type.kind === "promise") {
|
|
7444
|
-
|
|
7612
|
+
if (this.adoptsReturnedPromise())
|
|
7613
|
+
return this.adoptingReturn(e, VOID, (x) => x);
|
|
7614
|
+
e = this.returnedPromiseAwait(e);
|
|
7445
7615
|
}
|
|
7446
7616
|
if (e.kind === "unitLit")
|
|
7447
7617
|
return { kind: "return", value: null, loc };
|
|
@@ -8873,7 +9043,8 @@ export class Lowerer {
|
|
|
8873
9043
|
// dispatch. The general identifier-call paths have no lowering for a
|
|
8874
9044
|
// promise-returning ambient global, and `import` is a keyword callee no
|
|
8875
9045
|
// identifier path matches.
|
|
8876
|
-
return (
|
|
9046
|
+
return (lowerLifetimeRegionCall(this, expr) ??
|
|
9047
|
+
lowerFfiCall(this, expr) ??
|
|
8877
9048
|
lowerFetchCall(this, expr) ??
|
|
8878
9049
|
lowerStaticFetchCompanionCall(this, expr) ??
|
|
8879
9050
|
lowerStaticAbortControllerCall(this, expr) ??
|
|
@@ -9008,10 +9179,13 @@ export class Lowerer {
|
|
|
9008
9179
|
return inheritsBuiltinEmitterCtor(this, info);
|
|
9009
9180
|
}
|
|
9010
9181
|
lowerNew(expr) {
|
|
9011
|
-
const builtin =
|
|
9182
|
+
const builtin = lowerLifetimeRegionNew(this, expr) ??
|
|
9183
|
+
lowerAbortControllerNew(this, expr) ??
|
|
9184
|
+
lowerEventTargetNew(this, expr) ??
|
|
9012
9185
|
lowerFetchWebNew(this, expr) ??
|
|
9013
9186
|
lowerResponseNew(this, expr) ??
|
|
9014
|
-
lowerStaticReadableStreamNew(this, expr)
|
|
9187
|
+
lowerStaticReadableStreamNew(this, expr) ??
|
|
9188
|
+
lowerConsoleNew(this, expr);
|
|
9015
9189
|
return (builtin ?? this.withRuntimeOptionalClassValue(expr.expression, () => lowerNew(this, expr)));
|
|
9016
9190
|
}
|
|
9017
9191
|
lowerFieldRead(expr) {
|
|
@@ -9062,6 +9236,9 @@ export class Lowerer {
|
|
|
9062
9236
|
consoleCallMember(call) {
|
|
9063
9237
|
return consoleCallMember(this, call);
|
|
9064
9238
|
}
|
|
9239
|
+
consoleMethodMember(call) {
|
|
9240
|
+
return consoleMethodMember(this, call);
|
|
9241
|
+
}
|
|
9065
9242
|
/* ── standard library (process + node:fs) ─────────────────────────── */
|
|
9066
9243
|
builtinImportOf(ident) {
|
|
9067
9244
|
return builtinImportOf(this, ident);
|
|
@@ -9288,6 +9465,10 @@ export class Lowerer {
|
|
|
9288
9465
|
if (bi.module === "http" && bi.member === "STATUS_CODES") {
|
|
9289
9466
|
return { kind: "libCall", fn: "http.statusCodes", args: [], type: DYN, loc };
|
|
9290
9467
|
}
|
|
9468
|
+
// os.constants: the runtime's null-prototype constants object.
|
|
9469
|
+
if (bi.module === "os" && bi.member === "constants") {
|
|
9470
|
+
return { kind: "libCall", fn: "os.constants", args: [], type: DYN, loc };
|
|
9471
|
+
}
|
|
9291
9472
|
// tls.rootCertificates through the namespace: the same runtime-valued
|
|
9292
9473
|
// constant the named-import read lowers to.
|
|
9293
9474
|
{
|