@scriptc/compiler 0.4.0 → 0.4.1
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 +35 -5
- package/dist/backend/executable-features.js +7 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.js +3 -0
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +2 -0
- package/dist/backend/link-plan-core.js +2 -0
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +1 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/array-search.js +3 -1
- package/dist/backend/llvm/array-search.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +27 -1
- package/dist/backend/llvm/classes.js +115 -22
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +21 -9
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +21 -3
- package/dist/backend/llvm/common.js +50 -3
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.d.ts +3 -1
- package/dist/backend/llvm/dense-array-access.js +61 -38
- package/dist/backend/llvm/dense-array-access.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +4 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dense-array-loops.js +3 -3
- package/dist/backend/llvm/dense-array-loops.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +9 -0
- package/dist/backend/llvm/dyn.js +62 -6
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +5 -2
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +54 -32
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-statements.d.ts +3 -2
- package/dist/backend/llvm/emit-statements.js +90 -13
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +20 -9
- package/dist/backend/llvm/emitter.js +42 -31
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +17 -4
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +6 -9
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +46 -4
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +3 -3
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +55 -0
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +11 -15
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/integer-clones.js +3 -3
- package/dist/backend/llvm/integer-clones.js.map +1 -1
- package/dist/backend/llvm/js-ic.d.ts +18 -0
- package/dist/backend/llvm/js-ic.js +712 -0
- package/dist/backend/llvm/js-ic.js.map +1 -0
- package/dist/backend/llvm/jsval.js +139 -11
- package/dist/backend/llvm/jsval.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +4 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +22 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +40 -31
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +20 -4
- package/dist/backend/llvm/map-number-lookup.js +43 -7
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/narrow-guards.js +64 -0
- package/dist/backend/llvm/narrow-guards.js.map +1 -1
- package/dist/backend/llvm/publish.d.ts +3 -0
- package/dist/backend/llvm/publish.js +36 -17
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/regions.js +2 -2
- package/dist/backend/llvm/regions.js.map +1 -1
- package/dist/backend/llvm/regions.test.js +7 -1
- package/dist/backend/llvm/regions.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +8 -2
- package/dist/backend/llvm/shapes.js +9 -7
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +20 -1
- package/dist/backend/llvm/speculative-integers.js +94 -6
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.test.js +55 -1
- package/dist/backend/llvm/speculative-integers.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +1 -1
- package/dist/backend/llvm/string-reads.js +4 -4
- package/dist/backend/llvm/string-reads.js.map +1 -1
- package/dist/backend/llvm/thread-slots.test.js +5 -4
- package/dist/backend/llvm/thread-slots.test.js.map +1 -1
- package/dist/backend/mangle.d.ts +5 -0
- package/dist/backend/mangle.js +7 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +20 -0
- package/dist/backend/native/executable.js +20 -3
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/library.js +2 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +6 -0
- package/dist/backend/native-codegen.js +19 -0
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +27 -0
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +18 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-profile.d.ts +32 -0
- package/dist/backend/native-profile.js +39 -0
- package/dist/backend/native-profile.js.map +1 -0
- package/dist/backend/native-profile.test.d.ts +1 -0
- package/dist/backend/native-profile.test.js +58 -0
- package/dist/backend/native-profile.test.js.map +1 -0
- package/dist/backend/native-tools.d.ts +14 -0
- package/dist/backend/native-tools.js +13 -0
- package/dist/backend/native-tools.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 +4 -0
- package/dist/backend/runtime-pack-core.js +4 -0
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +4 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +4 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.js +7 -0
- package/dist/backend/target-diagnostics.js.map +1 -1
- package/dist/backend/warm-cache.js +3 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/cli/command.js +63 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/host.d.ts +3 -0
- package/dist/cli/output-options.d.ts +2 -0
- package/dist/cli/output-options.js +9 -0
- package/dist/cli/output-options.js.map +1 -1
- package/dist/cli/usage.d.ts +11 -1
- package/dist/cli/usage.js +23 -0
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +9 -0
- package/dist/contracts/check.js +1 -2
- package/dist/contracts/check.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +10 -0
- package/dist/executable/executable-cache.js +6 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +5 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/arguments-usage.d.ts +8 -0
- package/dist/frontend/arguments-usage.js +98 -0
- package/dist/frontend/arguments-usage.js.map +1 -1
- package/dist/frontend/arguments-usage.test.d.ts +1 -0
- package/dist/frontend/arguments-usage.test.js +32 -0
- package/dist/frontend/arguments-usage.test.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.d.ts +24 -0
- package/dist/frontend/builtin-package-aliases.js +133 -0
- package/dist/frontend/builtin-package-aliases.js.map +1 -0
- package/dist/frontend/builtin-package-aliases.test.d.ts +1 -0
- package/dist/frontend/builtin-package-aliases.test.js +48 -0
- package/dist/frontend/builtin-package-aliases.test.js.map +1 -0
- package/dist/frontend/dts-paths.d.ts +4 -0
- package/dist/frontend/dts-paths.js +9 -1
- package/dist/frontend/dts-paths.js.map +1 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.d.ts +8 -0
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js +50 -1
- package/dist/frontend/lowering/builtins/builtin-class-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +3 -2
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.d.ts +3 -0
- package/dist/frontend/lowering/builtins/crypto.js +4 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/ecdh.d.ts +10 -0
- package/dist/frontend/lowering/builtins/ecdh.js +208 -0
- package/dist/frontend/lowering/builtins/ecdh.js.map +1 -0
- package/dist/frontend/lowering/builtins/json.js +52 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +9 -0
- package/dist/frontend/lowering/builtins/process.js +44 -0
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promisify-callback.d.ts +3 -0
- package/dist/frontend/lowering/builtins/promisify-callback.js +21 -3
- package/dist/frontend/lowering/builtins/promisify-callback.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +26 -0
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/timers.js +5 -1
- package/dist/frontend/lowering/builtins/timers.js.map +1 -1
- package/dist/frontend/lowering/builtins/typed-array-members.d.ts +7 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js +160 -0
- package/dist/frontend/lowering/builtins/typed-array-members.js.map +1 -0
- package/dist/frontend/lowering/call-signatures.d.ts +4 -0
- package/dist/frontend/lowering/call-signatures.js +126 -9
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js +34 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +9 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +10 -0
- package/dist/frontend/lowering/class-protocols.js +53 -3
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +6 -1
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-to-primitive.d.ts +2 -2
- package/dist/frontend/lowering/class-to-primitive.js +6 -3
- package/dist/frontend/lowering/class-to-primitive.js.map +1 -1
- package/dist/frontend/lowering/coercions/fresh-spread.d.ts +13 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js +95 -0
- package/dist/frontend/lowering/coercions/fresh-spread.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.js +99 -70
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +22 -19
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +7 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +5 -0
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +9 -0
- package/dist/frontend/lowering/containers/bytes.js +493 -17
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +72 -3
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +49 -13
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +26 -10
- package/dist/frontend/lowering/cycle-initialization.js +152 -35
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/expressions/array-literals.js +33 -13
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +79 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +13 -6
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +14 -2
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +91 -10
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.js +17 -2
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +48 -1
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.d.ts +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +12 -3
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +5 -0
- package/dist/frontend/lowering/expressions/property-access.js +252 -9
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +49 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +13 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +1 -1
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +8 -0
- package/dist/frontend/lowering/generator-delegation.js +191 -1
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +4 -0
- package/dist/frontend/lowering/generic-functions.js +213 -56
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.d.ts +24 -0
- package/dist/frontend/lowering/handle-properties.js +281 -0
- package/dist/frontend/lowering/handle-properties.js.map +1 -0
- package/dist/frontend/lowering/iterable-spelling.d.ts +7 -0
- package/dist/frontend/lowering/iterable-spelling.js +38 -0
- package/dist/frontend/lowering/iterable-spelling.js.map +1 -0
- package/dist/frontend/lowering/lower-array-sort.d.ts +33 -15
- package/dist/frontend/lowering/lower-array-sort.js +117 -21
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -1
- package/dist/frontend/lowering/lower-array-sort.test.js +93 -14
- package/dist/frontend/lowering/lower-array-sort.test.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.js +1 -0
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +166 -7
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -0
- package/dist/frontend/lowering/lower-classes.js +59 -7
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +62 -13
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +32 -1
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +4 -0
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +10 -4
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +569 -11
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +11 -3
- package/dist/frontend/lowering/lower-modules.js +212 -67
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +20 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +26 -1
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +28 -9
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +7 -10
- package/dist/frontend/lowering/lower-stmts.js +418 -51
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +17 -1
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +29 -5
- package/dist/frontend/lowering/lowerer.js +172 -25
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/rebindable-functions.d.ts +8 -0
- package/dist/frontend/lowering/rebindable-functions.js +54 -0
- package/dist/frontend/lowering/rebindable-functions.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +26 -0
- package/dist/frontend/lowering/static-typeof.js +133 -0
- package/dist/frontend/lowering/static-typeof.js.map +1 -0
- package/dist/frontend/lowering/string-index-bounds.js +3 -2
- package/dist/frontend/lowering/string-index-bounds.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +30 -4
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/thenables.d.ts +16 -0
- package/dist/frontend/lowering/thenables.js +124 -0
- package/dist/frontend/lowering/thenables.js.map +1 -0
- package/dist/frontend/npm-static-builtin-aliases.d.ts +8 -0
- package/dist/frontend/npm-static-builtin-aliases.js +65 -0
- package/dist/frontend/npm-static-builtin-aliases.js.map +1 -0
- package/dist/frontend/npm-static-bundled-chunks.d.ts +8 -1
- package/dist/frontend/npm-static-bundled-chunks.js +173 -2
- package/dist/frontend/npm-static-bundled-chunks.js.map +1 -1
- package/dist/frontend/npm-static-bundled-chunks.test.js +112 -0
- package/dist/frontend/npm-static-bundled-chunks.test.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.js +224 -4
- package/dist/frontend/npm-static-bundled-esm.js.map +1 -1
- package/dist/frontend/npm-static-bundled-esm.test.js +129 -0
- package/dist/frontend/npm-static-bundled-esm.test.js.map +1 -1
- package/dist/frontend/npm-static-enum-iife.d.ts +6 -0
- package/dist/frontend/npm-static-enum-iife.js +280 -0
- package/dist/frontend/npm-static-enum-iife.js.map +1 -0
- package/dist/frontend/npm-static-enum-iife.test.d.ts +1 -0
- package/dist/frontend/npm-static-enum-iife.test.js +116 -0
- package/dist/frontend/npm-static-enum-iife.test.js.map +1 -0
- package/dist/frontend/npm-static.d.ts +8 -0
- package/dist/frontend/npm-static.js +46 -1
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.js +13 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/package-shims.d.ts +47 -0
- package/dist/frontend/package-shims.js +300 -0
- package/dist/frontend/package-shims.js.map +1 -0
- package/dist/frontend/pipeline.js +67 -1
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program.d.ts +8 -0
- package/dist/frontend/program.js +72 -9
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.js +13 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/services.d.ts +6 -0
- package/dist/frontend/services.js +19 -0
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +6 -5
- package/dist/frontend/ts7/program-host.js +7 -0
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.d.ts +3 -0
- package/dist/frontend/ts7/semantic-model.js +26 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/session.d.ts +19 -4
- package/dist/frontend/ts7/session.js.map +1 -1
- package/dist/frontend/type-mapper.js +201 -15
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +58 -6
- package/dist/index.js.map +1 -1
- package/dist/ir/array-length-stability.d.ts +3 -2
- package/dist/ir/array-length-stability.js +15 -2
- package/dist/ir/array-length-stability.js.map +1 -1
- package/dist/ir/array-length-stability.test.js +22 -1
- package/dist/ir/array-length-stability.test.js.map +1 -1
- package/dist/ir/builtin-effects.js +13 -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 +46 -4
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/integer-loop-facts.d.ts +5 -0
- package/dist/ir/integer-loop-facts.js +79 -14
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-ranges.d.ts +10 -1
- package/dist/ir/integer-ranges.js +122 -25
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +191 -1
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.js +8 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-ic.d.ts +52 -0
- package/dist/ir/js-ic.js +199 -0
- package/dist/ir/js-ic.js.map +1 -0
- package/dist/ir/js-ic.test.d.ts +1 -0
- package/dist/ir/js-ic.test.js +148 -0
- package/dist/ir/js-ic.test.js.map +1 -0
- package/dist/ir/jsval.js +38 -4
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +39 -4
- package/dist/ir/runtime-features.js +229 -99
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/traverse.js +110 -68
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +21 -8
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +15 -2
- 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/cli.js +17 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +33 -4
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache.js +3 -0
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.js +3 -0
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +21 -20
- package/shims/fs-extra/core/api.ts +1192 -0
- package/shims/fs-extra/index.ts +9 -0
- package/shims/undici/core/agent.ts +163 -0
- package/shims/undici/core/api.ts +93 -0
- package/shims/undici/core/client.ts +1304 -0
- package/shims/undici/core/connector.ts +157 -0
- package/shims/undici/core/diagnostics-types.ts +68 -0
- package/shims/undici/core/diagnostics.ts +16 -0
- package/shims/undici/core/dispatcher.ts +574 -0
- package/shims/undici/core/errors-v5.ts +22 -0
- package/shims/undici/core/errors-v7.ts +25 -0
- package/shims/undici/core/errors.ts +255 -0
- package/shims/undici/core/fetch.ts +635 -0
- package/shims/undici/core/pool.ts +280 -0
- package/shims/undici/core/readable.ts +268 -0
- package/shims/undici/core/request.ts +313 -0
- package/shims/undici/core/timers.ts +80 -0
- package/shims/undici/core/types.ts +167 -0
- package/shims/undici/core/util.ts +67 -0
- package/shims/undici/v5.ts +119 -0
- package/shims/undici/v7.ts +119 -0
- package/surface-manifest.json +2 -4
|
@@ -8,6 +8,7 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
8
8
|
* seeds), npm/JSON import collection, per-file %init functions, %main, and
|
|
9
9
|
* the module artifacts (globals, embedded npm tables) the IR module carries. */
|
|
10
10
|
import * as ts from "../ts7/adapter.js";
|
|
11
|
+
import { collectRebindableFunctions, isRebindableFunction } from "./rebindable-functions.js";
|
|
11
12
|
import { bindingSource } from "../binding-source.js";
|
|
12
13
|
import { dirname as dirnamePath, resolve as resolvePath } from "node:path";
|
|
13
14
|
import { packageNameOfPath, probeNodeImportRefusal } from "../npm.js";
|
|
@@ -37,11 +38,12 @@ import { streamClassAliasDecl } from "./lower-stream.js";
|
|
|
37
38
|
import { isAssertClassNew } from "./assert-instances.js";
|
|
38
39
|
import { stdlibGlobalAliasDecl, stdlibGlobalAliasNameOf, stdlibGlobalNameOf } from "./surfaces.js";
|
|
39
40
|
import { isNativeBuiltinValueInitializer } from "./lower-builtin-values.js";
|
|
41
|
+
import { isPromisePrototypeRead } from "./expressions/property-access.js";
|
|
40
42
|
import { collectNamespaceStmt, nsMemberIdentOf, nsPathPrefix, trapDeclRootOf, } from "./lower-namespaces.js";
|
|
41
43
|
import { collectExpandoMembers } from "./lower-expando.js";
|
|
42
44
|
import { recordTextCodecClass } from "../../ir/ir.js";
|
|
43
45
|
import { isUnitOnlyTsType, unitOnlyUnion } from "../type-mapper.js";
|
|
44
|
-
import { collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType, } from "./lower-classes.js";
|
|
46
|
+
import { builtinRequireBaseOf, collectInheritedJsFieldWrites, collectVirtualJsMethods, decoratorNodesOf, genericIfaceBindingKeepsClass, guaranteedDecorationThrow, storedClassValueType, } from "./lower-classes.js";
|
|
45
47
|
import { isMixinFnBinding, mixinResultBindingClassOf } from "./lower-mixins.js";
|
|
46
48
|
import { cjsModuleRef, cjsModuleRegistryPrelude } from "./lower-node-module.js";
|
|
47
49
|
import { forkTargetPaths } from "../fork-target.js";
|
|
@@ -50,18 +52,45 @@ import { isNativeProxyInitializer } from "./expressions/native-proxy.js";
|
|
|
50
52
|
import { handleEventReaderPrelude } from "./lower-event-target.js";
|
|
51
53
|
import { cjsAccessorSnapshotStores, jsHoldsDynObject } from "./lower-exprs.js";
|
|
52
54
|
import { keptIdentityAssertion } from "./assertion-identity.js";
|
|
55
|
+
/** An appended module's edges: its import and export declarations, then
|
|
56
|
+
* the require() edges preflight resolved — a CommonJS file's only edges
|
|
57
|
+
* (the compiled CommonJS package a workspace module loaded on demand
|
|
58
|
+
* imports, and the sibling packages and files IT requires). */
|
|
59
|
+
function appendedEdgesOf(program, graph) {
|
|
60
|
+
const cache = new Map();
|
|
61
|
+
return (sf) => {
|
|
62
|
+
let out = cache.get(sf);
|
|
63
|
+
if (out !== undefined)
|
|
64
|
+
return out;
|
|
65
|
+
out = orderedImportsOf(program, sf).flatMap(({ stmt, dep }) => dep !== null && dep !== sf
|
|
66
|
+
? [{ dep, stmt: stmt }]
|
|
67
|
+
: []);
|
|
68
|
+
for (const e of graph?.edges?.get(sf) ?? [])
|
|
69
|
+
if (e.stmt === undefined && e.dep !== sf)
|
|
70
|
+
out.push(e);
|
|
71
|
+
cache.set(sf, out);
|
|
72
|
+
return out;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Lazy inline requires run after their module's top level: their modules
|
|
76
|
+
* join the order afterwards, as in preflight's walk. */
|
|
77
|
+
function visitLazyEdges(sf, edgesOf, state, visit) {
|
|
78
|
+
for (const e of edgesOf(sf))
|
|
79
|
+
if (e.lazy === true && state.get(e.dep) === undefined)
|
|
80
|
+
visit(e.dep);
|
|
81
|
+
}
|
|
53
82
|
/** Program modules selected by statically resolved child_process.fork()
|
|
54
83
|
* calls join the compiled graph without becoming startup dependencies of
|
|
55
84
|
* the parent entry. Their guarded init functions are selected by %main only
|
|
56
85
|
* in a re-executed fork child. `targets` is append-only so ids stay stable
|
|
57
86
|
* across the dynamic-import/fork discovery fixpoint. */
|
|
58
|
-
export function appendForkModules(program, order, targets, onCycle) {
|
|
59
|
-
appendEntryModules(program, order, targets, forkTargetPaths(program, order), onCycle);
|
|
87
|
+
export function appendForkModules(program, order, targets, onCycle, graph) {
|
|
88
|
+
appendEntryModules(program, order, targets, forkTargetPaths(program, order), onCycle, graph);
|
|
60
89
|
}
|
|
61
|
-
export function appendWorkerModules(program, order, targets, onCycle) {
|
|
62
|
-
appendEntryModules(program, order, targets, workerTargetPaths(program, order), onCycle);
|
|
90
|
+
export function appendWorkerModules(program, order, targets, onCycle, graph) {
|
|
91
|
+
appendEntryModules(program, order, targets, workerTargetPaths(program, order), onCycle, graph);
|
|
63
92
|
}
|
|
64
|
-
function appendEntryModules(program, order, targets, paths, onCycle) {
|
|
93
|
+
function appendEntryModules(program, order, targets, paths, onCycle, graph) {
|
|
65
94
|
if (order.length === 0)
|
|
66
95
|
return;
|
|
67
96
|
const byPath = new Map(program.getImplementationSourceFiles().map((sf) => [resolvePath(sf.fileName), sf]));
|
|
@@ -70,10 +99,8 @@ function appendEntryModules(program, order, targets, paths, onCycle) {
|
|
|
70
99
|
state.set(sf, "done");
|
|
71
100
|
const added = [];
|
|
72
101
|
const stack = [];
|
|
73
|
-
const staticEdgesOf = (
|
|
74
|
-
|
|
75
|
-
: []);
|
|
76
|
-
const cycleAdmissionReason = makeCycleAdmission(program, staticEdgesOf);
|
|
102
|
+
const staticEdgesOf = appendedEdgesOf(program, graph);
|
|
103
|
+
const cycleAdmissionReason = makeCycleAdmission(program, (sf) => staticEdgesOf(sf).filter((e) => e.call === undefined));
|
|
77
104
|
const visit = (sf) => {
|
|
78
105
|
const prior = state.get(sf);
|
|
79
106
|
if (prior === "done")
|
|
@@ -81,10 +108,16 @@ function appendEntryModules(program, order, targets, paths, onCycle) {
|
|
|
81
108
|
state.set(sf, "visiting");
|
|
82
109
|
stack.push(sf.fileName);
|
|
83
110
|
for (const edge of staticEdgesOf(sf)) {
|
|
111
|
+
if (edge.lazy === true)
|
|
112
|
+
continue; // visited after this module completes
|
|
84
113
|
const edgeState = state.get(edge.dep);
|
|
85
114
|
if (edgeState === "done")
|
|
86
115
|
continue;
|
|
87
116
|
if (edgeState === "visiting") {
|
|
117
|
+
if (edge.call !== undefined) {
|
|
118
|
+
graph?.inlineCycleCalls?.add(edge.call);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
88
121
|
const reason = cycleAdmissionReason(sf, edge);
|
|
89
122
|
if (reason !== null) {
|
|
90
123
|
const cycleStart = stack.indexOf(edge.dep.fileName);
|
|
@@ -97,6 +130,7 @@ function appendEntryModules(program, order, targets, paths, onCycle) {
|
|
|
97
130
|
stack.pop();
|
|
98
131
|
state.set(sf, "done");
|
|
99
132
|
added.push(sf);
|
|
133
|
+
visitLazyEdges(sf, staticEdgesOf, state, visit);
|
|
100
134
|
};
|
|
101
135
|
const knownTargets = new Set(targets);
|
|
102
136
|
for (const path of paths) {
|
|
@@ -121,8 +155,13 @@ export function splitFiles(lowerer) {
|
|
|
121
155
|
const files = lowerer.moduleOrder.length > 0 ? lowerer.moduleOrder : [lowerer.entry];
|
|
122
156
|
return files.map((sf) => {
|
|
123
157
|
const fp = { sf, fnDecls: [], classDecls: [], topStmts: [] };
|
|
158
|
+
const rebindable = collectRebindableFunctions(lowerer, sf);
|
|
124
159
|
for (const stmt of sf.statements.nodes) {
|
|
125
|
-
|
|
160
|
+
// A reassigned JavaScript declaration lives in a module global that
|
|
161
|
+
// the init body assigns first (rebindable-functions.ts).
|
|
162
|
+
if (ts.isFunctionDeclaration(stmt) && rebindable.has(stmt))
|
|
163
|
+
fp.topStmts.push(stmt);
|
|
164
|
+
else if (ts.isFunctionDeclaration(stmt))
|
|
126
165
|
fp.fnDecls.push(stmt);
|
|
127
166
|
else if (ts.isClassDeclaration(stmt))
|
|
128
167
|
fp.classDecls.push(stmt);
|
|
@@ -181,7 +220,7 @@ function dynamicProgramImportsOf(program, sf) {
|
|
|
181
220
|
});
|
|
182
221
|
return out;
|
|
183
222
|
}
|
|
184
|
-
export function appendDynamicImportModules(program, order, onCycle) {
|
|
223
|
+
export function appendDynamicImportModules(program, order, onCycle, graph) {
|
|
185
224
|
if (order.length === 0)
|
|
186
225
|
return; // no preflight order — sites keep their fences
|
|
187
226
|
const state = new Map();
|
|
@@ -189,20 +228,24 @@ export function appendDynamicImportModules(program, order, onCycle) {
|
|
|
189
228
|
state.set(sf, "done");
|
|
190
229
|
const added = [];
|
|
191
230
|
const stack = [];
|
|
192
|
-
const staticEdgesOf = (
|
|
193
|
-
|
|
194
|
-
: []);
|
|
195
|
-
const cycleAdmissionReason = makeCycleAdmission(program, staticEdgesOf);
|
|
231
|
+
const staticEdgesOf = appendedEdgesOf(program, graph);
|
|
232
|
+
const cycleAdmissionReason = makeCycleAdmission(program, (sf) => staticEdgesOf(sf).filter((e) => e.call === undefined));
|
|
196
233
|
const visit = (sf) => {
|
|
197
234
|
if (state.get(sf) !== undefined)
|
|
198
235
|
return;
|
|
199
236
|
state.set(sf, "visiting");
|
|
200
237
|
stack.push(sf.fileName);
|
|
201
238
|
for (const e of staticEdgesOf(sf)) {
|
|
239
|
+
if (e.lazy === true)
|
|
240
|
+
continue; // visited after this module completes
|
|
202
241
|
const s = state.get(e.dep);
|
|
203
242
|
if (s === "done")
|
|
204
243
|
continue;
|
|
205
244
|
if (s === "visiting") {
|
|
245
|
+
if (e.call !== undefined) {
|
|
246
|
+
graph?.inlineCycleCalls?.add(e.call);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
206
249
|
// A back edge: Node answers it from the cache. Same admission
|
|
207
250
|
// question as preflight's static walk, same fence when refused.
|
|
208
251
|
const reason = cycleAdmissionReason(sf, e);
|
|
@@ -217,6 +260,7 @@ export function appendDynamicImportModules(program, order, onCycle) {
|
|
|
217
260
|
stack.pop();
|
|
218
261
|
state.set(sf, "done");
|
|
219
262
|
added.push(sf);
|
|
263
|
+
visitLazyEdges(sf, staticEdgesOf, state, visit);
|
|
220
264
|
};
|
|
221
265
|
const scanned = new Set();
|
|
222
266
|
for (;;) {
|
|
@@ -242,7 +286,7 @@ export function collectProgram(lowerer, parts) {
|
|
|
242
286
|
for (const fp of parts)
|
|
243
287
|
for (const decl of fp.classDecls) {
|
|
244
288
|
const heritage = decl.heritageClauses?.nodes.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types?.nodes[0]?.expression;
|
|
245
|
-
if (heritage && ts.isCallExpression(heritage))
|
|
289
|
+
if (heritage && ts.isCallExpression(heritage) && !builtinRequireBaseOf(lowerer, heritage))
|
|
246
290
|
computed.add(decl);
|
|
247
291
|
}
|
|
248
292
|
// Descendants need the computed ancestor's completed layout before
|
|
@@ -1056,6 +1100,30 @@ function jsDynHoldableInitializer(lowerer, init) {
|
|
|
1056
1100
|
}
|
|
1057
1101
|
return false;
|
|
1058
1102
|
}
|
|
1103
|
+
/** A JavaScript default-export object literal holding a class the program
|
|
1104
|
+
* could not lower (`export default { parse, TomlDate }` where TomlDate
|
|
1105
|
+
* extends an unsupported base): the literal narrows that member away, its
|
|
1106
|
+
* diagnostics deferred to the reads that reach it, so the binding's type
|
|
1107
|
+
* drops it too. Otherwise the module's own initialization would fail the
|
|
1108
|
+
* width check against members no build can supply. */
|
|
1109
|
+
function withoutRejectedClassMembers(lowerer, expression, type) {
|
|
1110
|
+
let literal = expression;
|
|
1111
|
+
while (ts.isParenthesizedExpression(literal))
|
|
1112
|
+
literal = literal.expression;
|
|
1113
|
+
if (!ts.isObjectLiteralExpression(literal) || type.kind !== "record")
|
|
1114
|
+
return type;
|
|
1115
|
+
const shape = lowerer.shapes.get(type.shapeId);
|
|
1116
|
+
if (!shape || shape.tuple)
|
|
1117
|
+
return type;
|
|
1118
|
+
const rejected = (t) => t.kind === "classval" &&
|
|
1119
|
+
!lowerer.classes.has(t.className) &&
|
|
1120
|
+
lowerer.deferredClassByName.has(t.className);
|
|
1121
|
+
if (!shape.fields.some((f) => rejected(f.type)))
|
|
1122
|
+
return type;
|
|
1123
|
+
const kept = shape.fields.filter((f) => !rejected(f.type));
|
|
1124
|
+
const shapeId = lowerer.shapes.intern(kept.map((f) => ({ name: f.name, type: f.type })), false, shape.indexValue);
|
|
1125
|
+
return { kind: "record", shapeId };
|
|
1126
|
+
}
|
|
1059
1127
|
export function collectGlobals(lowerer, sf, topStmts) {
|
|
1060
1128
|
// Segment-tagged so mangled names can't collide across files (user
|
|
1061
1129
|
// identifiers cannot contain '.'): entry globals "e.<name>", others
|
|
@@ -1067,6 +1135,21 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1067
1135
|
// collected earlier in this pass must resolve them (lower-expando.ts).
|
|
1068
1136
|
collectExpandoMembers(lowerer, sf);
|
|
1069
1137
|
for (const stmt of topStmts) {
|
|
1138
|
+
if (ts.isFunctionDeclaration(stmt) && stmt.name && isRebindableFunction(lowerer, stmt)) {
|
|
1139
|
+
const symbol = lowerer.checker.getSymbolAtLocation(stmt.name);
|
|
1140
|
+
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1141
|
+
const g = {
|
|
1142
|
+
id: `%g.${tag}${stmt.name.text}`,
|
|
1143
|
+
name: stmt.name.text,
|
|
1144
|
+
type: DYN,
|
|
1145
|
+
mutable: true,
|
|
1146
|
+
};
|
|
1147
|
+
lowerer.globalsBySymbol.set(symbol, g);
|
|
1148
|
+
lowerer.globalsByDeclNode.set(stmt, g);
|
|
1149
|
+
lowerer.globalsList.push(g);
|
|
1150
|
+
}
|
|
1151
|
+
continue;
|
|
1152
|
+
}
|
|
1070
1153
|
// `export default <expr>`: the module's `default` binding is a const
|
|
1071
1154
|
// module global (registered under the checker's default-export
|
|
1072
1155
|
// symbol — the symbol a default IMPORT's alias chain terminates at,
|
|
@@ -1155,6 +1238,8 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1155
1238
|
}
|
|
1156
1239
|
if (type.kind === "void")
|
|
1157
1240
|
lowerer.badType(stmt.expression, tsType);
|
|
1241
|
+
if (isJsSourceFile(sf))
|
|
1242
|
+
type = withoutRejectedClassMembers(lowerer, stmt.expression, type);
|
|
1158
1243
|
const g = { id: `%g.${tag}default`, name: "default", type, mutable: false };
|
|
1159
1244
|
lowerer.globalsBySymbol.set(symbol, g);
|
|
1160
1245
|
lowerer.globalsList.push(g);
|
|
@@ -1194,9 +1279,19 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1194
1279
|
// common/tls's `exports.check = function (certs) {...}` —
|
|
1195
1280
|
// keep func-ness with dyn pieces; everything else is dyn).
|
|
1196
1281
|
const strict = lowerer.checker.getTypeOfSymbol(symbol);
|
|
1197
|
-
|
|
1282
|
+
let t = lowerer.mapTypeOf(strict) ?? dynFallbackType(lowerer, nameNode, strict);
|
|
1198
1283
|
if (!t || t.kind === "void")
|
|
1199
1284
|
lowerer.badType(typeNode, strict);
|
|
1285
|
+
// An export typed as the empty object literal (tsc's enum output
|
|
1286
|
+
// `exports.E || (exports.E = {})` after its `exports.E = void 0`
|
|
1287
|
+
// preamble): TS's `{}` admits any later non-nullish value and the
|
|
1288
|
+
// export is undefined until then, so it rides checked-dynamic
|
|
1289
|
+
// storage like the same-shaped var binding (varBindingType).
|
|
1290
|
+
if (t.kind === "record" && isJsSourceFile(sf)) {
|
|
1291
|
+
const shape = lowerer.shapes.get(t.shapeId);
|
|
1292
|
+
if (shape && shape.fields.length === 0 && !shape.indexValue && !shape.tuple)
|
|
1293
|
+
t = DYN;
|
|
1294
|
+
}
|
|
1200
1295
|
// An immutable export source shares its live storage and native
|
|
1201
1296
|
// callable ABI. Mutable sources need a separate snapshot slot:
|
|
1202
1297
|
// later writes to the binding do not change the exported value.
|
|
@@ -1442,44 +1537,9 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1442
1537
|
if (isRequireStatement(stmt) &&
|
|
1443
1538
|
!(ts.isVariableStatement(stmt) &&
|
|
1444
1539
|
stmt.declarationList.declarations.nodes.some((decl) => isNativeFfiRequire(lowerer, decl.initializer) || isJsonRequireDecl(lowerer, decl)))) {
|
|
1445
|
-
if (ts.isVariableStatement(stmt)
|
|
1446
|
-
for (const decl of stmt.declarationList.declarations.nodes)
|
|
1447
|
-
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
// `const { codes: { ERR_X } } = require("./errors")`: the outer
|
|
1451
|
-
// keys stay alias plumbing, but a nested pattern destructures the
|
|
1452
|
-
// export's value at the require, so its bindings own storage like
|
|
1453
|
-
// any destructured declaration (lowerVarDeclarator assigns them).
|
|
1454
|
-
if (ts.isVariableStatement(stmt)) {
|
|
1455
|
-
const isLetList = (stmt.declarationList.flags & ts.NodeFlags.Let) !== 0 ||
|
|
1456
|
-
(stmt.declarationList.flags & ts.NodeFlags.BlockScoped) === 0;
|
|
1457
|
-
for (const decl of stmt.declarationList.declarations.nodes) {
|
|
1458
|
-
for (const element of requireNestedPatternsOf(decl)) {
|
|
1459
|
-
for (const nameNode of boundIdentifiersOf(element.name)) {
|
|
1460
|
-
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1461
|
-
if (!symbol || lowerer.globalsBySymbol.has(symbol))
|
|
1462
|
-
continue;
|
|
1463
|
-
const mapped = lowerer.mapTypeOf(lowerer.typeOf(nameNode));
|
|
1464
|
-
const type = mapped && mapped.kind !== "void" ? mapped : DYN;
|
|
1465
|
-
const g = {
|
|
1466
|
-
id: `%g.${tag}${nameNode.text}`,
|
|
1467
|
-
name: nameNode.text,
|
|
1468
|
-
type,
|
|
1469
|
-
mutable: isLetList,
|
|
1470
|
-
source: bindingSource(nameNode),
|
|
1471
|
-
...((type.kind === "func" || type.kind === "dyn") && !isVarDeclared(decl)
|
|
1472
|
-
? { tdz: true }
|
|
1473
|
-
: {}),
|
|
1474
|
-
};
|
|
1475
|
-
lowerer.globalsBySymbol.set(symbol, g);
|
|
1476
|
-
lowerer.globalsList.push(g);
|
|
1477
|
-
if (isVarDeclared(decl))
|
|
1478
|
-
noteVarGlobalEntryInit(lowerer, sf, g);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1540
|
+
if (ts.isVariableStatement(stmt))
|
|
1541
|
+
for (const decl of stmt.declarationList.declarations.nodes)
|
|
1542
|
+
registerRequireDeclBindings(lowerer, sf, stmt.declarationList, decl, tag);
|
|
1483
1543
|
continue;
|
|
1484
1544
|
}
|
|
1485
1545
|
// `declare const __VERSION__: string` — AMBIENT: no storage exists
|
|
@@ -1512,6 +1572,16 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1512
1572
|
// and put its fences on the build.
|
|
1513
1573
|
if (provenanceElidedConstDecl(lowerer, decl))
|
|
1514
1574
|
continue;
|
|
1575
|
+
// A require declarator beside other declarators (`var EventEmitter =
|
|
1576
|
+
// require("events"), R = class extends EventEmitter {}`): the
|
|
1577
|
+
// statement lowering treats it as the alias plumbing of a whole
|
|
1578
|
+
// require statement (lowerVarDeclarator), so it owns no storage
|
|
1579
|
+
// either. A global here would never be assigned, and a read through
|
|
1580
|
+
// it would see null.
|
|
1581
|
+
if (requireAliasDecl(lowerer, decl)) {
|
|
1582
|
+
registerRequireDeclBindings(lowerer, sf, list, decl, tag);
|
|
1583
|
+
continue;
|
|
1584
|
+
}
|
|
1515
1585
|
// A stored built-in numeric value iterator has no first-class
|
|
1516
1586
|
// global representation. Its same-%init for-of uses are backed by
|
|
1517
1587
|
// hidden source/cursor/done locals registered when the declaration
|
|
@@ -1789,18 +1859,23 @@ export function collectGlobals(lowerer, sf, topStmts) {
|
|
|
1789
1859
|
// Builtin declarations do not always describe the concrete native
|
|
1790
1860
|
// callable ABI. Preserve checked-native values in shared storage;
|
|
1791
1861
|
// adapting the loader to (string) would replace its validation.
|
|
1862
|
+
// An inferred Promise.prototype binding holds an ordinary object
|
|
1863
|
+
// (isPromisePrototypeRead), in TypeScript as well.
|
|
1792
1864
|
const initializer = decl.initializer ? stripTypeCasts(decl.initializer) : undefined;
|
|
1793
|
-
if (
|
|
1794
|
-
|
|
1795
|
-
initializer
|
|
1796
|
-
(
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1865
|
+
if ((nameNode === decl.name &&
|
|
1866
|
+
!decl.type &&
|
|
1867
|
+
isPromisePrototypeRead(lowerer, decl.initializer)) ||
|
|
1868
|
+
(isJsSourceFile(sf) &&
|
|
1869
|
+
nameNode === decl.name &&
|
|
1870
|
+
initializer &&
|
|
1871
|
+
(isNativeBuiltinValueInitializer(lowerer, initializer) ||
|
|
1872
|
+
(!decl.type &&
|
|
1873
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1874
|
+
lowerer.mapTypeOf(lowerer.typeOf(nameNode))?.kind === "date") ||
|
|
1875
|
+
(!decl.type &&
|
|
1876
|
+
!hasJsTypeAnnotation(decl) &&
|
|
1877
|
+
checkedGlobalReference(lowerer, initializer)) ||
|
|
1878
|
+
stdlibGlobalNameOf(lowerer, initializer) === "globalThis"))) {
|
|
1804
1879
|
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
1805
1880
|
if (symbol && !lowerer.globalsBySymbol.has(symbol)) {
|
|
1806
1881
|
const g = {
|
|
@@ -2372,6 +2447,52 @@ function noteVarGlobalEntryInit(lowerer, sf, g) {
|
|
|
2372
2447
|
inits.push(g);
|
|
2373
2448
|
lowerer.varGlobalEntryInits.set(sf, inits);
|
|
2374
2449
|
}
|
|
2450
|
+
/** A JavaScript require declaration the statement lowering treats as alias
|
|
2451
|
+
* plumbing (lowerVarDeclarator): no storage, the reads resolve through to
|
|
2452
|
+
* the module. JSON documents and native FFI requires keep their storage. */
|
|
2453
|
+
function requireAliasDecl(lowerer, decl) {
|
|
2454
|
+
return (decl.initializer !== undefined &&
|
|
2455
|
+
requireSpecOf(decl.initializer) !== null &&
|
|
2456
|
+
!isNativeFfiRequire(lowerer, decl.initializer) &&
|
|
2457
|
+
!isJsonRequireDecl(lowerer, decl) &&
|
|
2458
|
+
isJsSourceFile(decl.getSourceFile()));
|
|
2459
|
+
}
|
|
2460
|
+
/** The registrations a top-level require declaration does make. `const
|
|
2461
|
+
* process = require('node:process')` aliases the global process
|
|
2462
|
+
* (stdlibGlobalAliasDecl's require form) so reads through the binding
|
|
2463
|
+
* lower via the process surface. In `const { codes: { ERR_X } } =
|
|
2464
|
+
* require("./errors")` the outer keys stay alias plumbing, but a nested
|
|
2465
|
+
* pattern destructures the export's value at the require, so its bindings
|
|
2466
|
+
* own storage like any destructured declaration (lowerVarDeclarator
|
|
2467
|
+
* assigns them). */
|
|
2468
|
+
function registerRequireDeclBindings(lowerer, sf, list, decl, tag) {
|
|
2469
|
+
if ((list.flags & ts.NodeFlags.Const) !== 0)
|
|
2470
|
+
stdlibGlobalAliasDecl(lowerer, decl.name, decl.initializer);
|
|
2471
|
+
const isLetList = (list.flags & ts.NodeFlags.Let) !== 0 || (list.flags & ts.NodeFlags.BlockScoped) === 0;
|
|
2472
|
+
for (const element of requireNestedPatternsOf(decl)) {
|
|
2473
|
+
for (const nameNode of boundIdentifiersOf(element.name)) {
|
|
2474
|
+
const symbol = lowerer.checker.getSymbolAtLocation(nameNode);
|
|
2475
|
+
if (!symbol || lowerer.globalsBySymbol.has(symbol))
|
|
2476
|
+
continue;
|
|
2477
|
+
const mapped = lowerer.mapTypeOf(lowerer.typeOf(nameNode));
|
|
2478
|
+
const type = mapped && mapped.kind !== "void" ? mapped : DYN;
|
|
2479
|
+
const g = {
|
|
2480
|
+
id: `%g.${tag}${nameNode.text}`,
|
|
2481
|
+
name: nameNode.text,
|
|
2482
|
+
type,
|
|
2483
|
+
mutable: isLetList,
|
|
2484
|
+
source: bindingSource(nameNode),
|
|
2485
|
+
...((type.kind === "func" || type.kind === "dyn") && !isVarDeclared(decl)
|
|
2486
|
+
? { tdz: true }
|
|
2487
|
+
: {}),
|
|
2488
|
+
};
|
|
2489
|
+
lowerer.globalsBySymbol.set(symbol, g);
|
|
2490
|
+
lowerer.globalsList.push(g);
|
|
2491
|
+
if (isVarDeclared(decl))
|
|
2492
|
+
noteVarGlobalEntryInit(lowerer, sf, g);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2375
2496
|
/** The nested half of module-scope `var` hoisting: a `var` inside a
|
|
2376
2497
|
* top-level BLOCK (an if arm, a loop body, a try) is module-scoped in
|
|
2377
2498
|
* JS — other functions in the file read the same binding — so it must
|
|
@@ -2409,6 +2530,12 @@ function collectNestedVarGlobals(lowerer, sf, stmt, tag) {
|
|
|
2409
2530
|
});
|
|
2410
2531
|
for (const list of lists) {
|
|
2411
2532
|
for (const decl of list.declarations.nodes) {
|
|
2533
|
+
// A nested builtin require (`if (c) { var fs = require("fs"); }`)
|
|
2534
|
+
// lowers to nothing: its bindings are alias plumbing wherever the
|
|
2535
|
+
// statement sits (lowerVarDeclarator), so they own no storage.
|
|
2536
|
+
if (requireAliasDecl(lowerer, decl) &&
|
|
2537
|
+
canonicalBuiltinModule(requireSpecOf(decl.initializer)) !== null)
|
|
2538
|
+
continue;
|
|
2412
2539
|
for (const nameNode of boundIdentifiersOf(decl.name)) {
|
|
2413
2540
|
const diagsBefore = lowerer.diags.length;
|
|
2414
2541
|
try {
|
|
@@ -2565,6 +2692,24 @@ export function lowerFileInit(lowerer, sf, stmts, name) {
|
|
|
2565
2692
|
loc: loc0,
|
|
2566
2693
|
});
|
|
2567
2694
|
}
|
|
2695
|
+
// Reassigned function declarations are initialized when the module
|
|
2696
|
+
// starts, as declarations are hoisted: before its dependencies run, so
|
|
2697
|
+
// a module of an import cycle can call one while it initializes. Their
|
|
2698
|
+
// statements then lower to nothing (rebindable-functions.ts).
|
|
2699
|
+
for (const stmt of stmts) {
|
|
2700
|
+
if (!ts.isFunctionDeclaration(stmt) || !stmt.name || !isRebindableFunction(lowerer, stmt))
|
|
2701
|
+
continue;
|
|
2702
|
+
const g = lowerer.globalsByDeclNode.get(stmt);
|
|
2703
|
+
if (!g)
|
|
2704
|
+
continue;
|
|
2705
|
+
header.push({
|
|
2706
|
+
kind: "assign",
|
|
2707
|
+
localId: g.id,
|
|
2708
|
+
value: lowerer.coerceToExpected(lowerer.lowerLambda(stmt), DYN),
|
|
2709
|
+
loc: locOf(stmt),
|
|
2710
|
+
});
|
|
2711
|
+
ctx.hoistedFnDecls.add(stmt);
|
|
2712
|
+
}
|
|
2568
2713
|
for (const { stmt, dep } of orderedImportsOf(lowerer.program, sf)) {
|
|
2569
2714
|
const npm = lowerer.npmInitActions.get(sf)?.get(stmt);
|
|
2570
2715
|
if (npm !== undefined && npm.length > 0) {
|