@scriptc/compiler 0.4.6 → 0.4.8
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/node-fallback/child_process.d.ts +71 -22
- package/ambient/node-fallback/crypto.d.ts +15 -7
- package/ambient/node-fallback/events.d.ts +29 -6
- package/ambient/node-fallback/fs-promises.d.ts +1 -1
- package/ambient/node-fallback/fs.d.ts +57 -12
- package/ambient/node-fallback/http.d.ts +26 -18
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +25 -0
- package/ambient/node-fallback/os.d.ts +11 -1
- package/ambient/node-fallback/path-posix.d.ts +6 -0
- package/ambient/node-fallback/path-win32.d.ts +5 -0
- package/ambient/node-fallback/path.d.ts +2 -0
- package/ambient/node-fallback/querystring.d.ts +3 -3
- package/ambient/node-fallback/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +95 -20
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +22 -1
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/immutability.d.ts +12 -1
- package/dist/backend/immutability.js +50 -4
- package/dist/backend/immutability.js.map +1 -1
- package/dist/backend/immutability.test.js +95 -1
- package/dist/backend/immutability.test.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +18 -5
- package/dist/backend/library-pack.js.map +1 -1
- package/dist/backend/library-pack.test.d.ts +1 -0
- package/dist/backend/library-pack.test.js +28 -0
- package/dist/backend/library-pack.test.js.map +1 -0
- package/dist/backend/linker.d.ts +20 -2
- package/dist/backend/linker.js +221 -35
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +15 -6
- package/dist/backend/lld.js +24 -16
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +13 -5
- package/dist/backend/lld.test.js.map +1 -1
- package/dist/backend/llvm/alloc.d.ts +15 -2
- package/dist/backend/llvm/alloc.js +172 -36
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/alloc.test.js +69 -1
- package/dist/backend/llvm/alloc.test.js.map +1 -1
- package/dist/backend/llvm/arenas.d.ts +17 -4
- package/dist/backend/llvm/arenas.js +105 -10
- package/dist/backend/llvm/arenas.js.map +1 -1
- package/dist/backend/llvm/arenas.test.js +229 -0
- package/dist/backend/llvm/arenas.test.js.map +1 -1
- package/dist/backend/llvm/bytes-alias.js +10 -1
- package/dist/backend/llvm/bytes-alias.js.map +1 -1
- package/dist/backend/llvm/bytes-headers.js +6 -0
- package/dist/backend/llvm/bytes-headers.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +25 -0
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.js +10 -0
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +16 -9
- package/dist/backend/llvm/classes.js +142 -37
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +42 -0
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/constant-callbacks.test.js +50 -1
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -1
- package/dist/backend/llvm/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +34 -9
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +64 -3
- package/dist/backend/llvm/dyn.js +251 -15
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +68 -5
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +226 -77
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emit-module.test.d.ts +1 -0
- package/dist/backend/llvm/emit-module.test.js +52 -0
- package/dist/backend/llvm/emit-module.test.js.map +1 -0
- package/dist/backend/llvm/emit-statements.js +138 -34
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +142 -10
- package/dist/backend/llvm/emitter.js +523 -73
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +31 -3
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +19 -1
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +16 -1
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +4 -1
- package/dist/backend/llvm/expr-calls.js +38 -6
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +237 -23
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +123 -12
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-records.d.ts +1 -1
- package/dist/backend/llvm/expr-records.js +124 -56
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.d.ts +8 -0
- package/dist/backend/llvm/expr-stream-bridges.js +59 -2
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +16 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +206 -20
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +2 -0
- package/dist/backend/llvm/integer-values.js +6 -0
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/js-groups.d.ts +21 -0
- package/dist/backend/llvm/js-groups.js +277 -0
- package/dist/backend/llvm/js-groups.js.map +1 -0
- package/dist/backend/llvm/js-ic.d.ts +57 -1
- package/dist/backend/llvm/js-ic.js +389 -22
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +152 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +116 -11
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +33 -6
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +180 -27
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +139 -2
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +67 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +32 -0
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/loop-entry-versions.d.ts +2 -2
- package/dist/backend/llvm/loop-entry-versions.js +43 -21
- package/dist/backend/llvm/loop-entry-versions.js.map +1 -1
- package/dist/backend/llvm/loop-state.d.ts +7 -1
- package/dist/backend/llvm/loop-state.js +26 -3
- package/dist/backend/llvm/loop-state.js.map +1 -1
- package/dist/backend/llvm/map-entry-fusion.d.ts +8 -0
- package/dist/backend/llvm/map-entry-fusion.js +3 -3
- package/dist/backend/llvm/map-entry-fusion.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +3 -1
- package/dist/backend/llvm/map-number-lookup.js +7 -3
- package/dist/backend/llvm/map-number-lookup.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.test.js +58 -17
- package/dist/backend/llvm/map-number-lookup.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.js +7 -6
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.test.js +4 -1
- package/dist/backend/llvm/nullable-unions.test.js.map +1 -1
- package/dist/backend/llvm/receiver-brackets.test.d.ts +1 -0
- package/dist/backend/llvm/receiver-brackets.test.js +68 -0
- package/dist/backend/llvm/receiver-brackets.test.js.map +1 -0
- package/dist/backend/llvm/receivers.js +3 -0
- package/dist/backend/llvm/receivers.js.map +1 -1
- package/dist/backend/llvm/record-entry-fusion.d.ts +32 -0
- package/dist/backend/llvm/record-entry-fusion.js +217 -0
- package/dist/backend/llvm/record-entry-fusion.js.map +1 -0
- package/dist/backend/llvm/record-results.d.ts +5 -2
- package/dist/backend/llvm/record-results.js +13 -12
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/record-views.d.ts +22 -2
- package/dist/backend/llvm/record-views.js +147 -12
- package/dist/backend/llvm/record-views.js.map +1 -1
- package/dist/backend/llvm/record-views.test.js +76 -0
- package/dist/backend/llvm/record-views.test.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +1 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +4 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/region-ir.js +1 -0
- package/dist/backend/llvm/region-ir.js.map +1 -1
- package/dist/backend/llvm/region-sites.d.ts +18 -0
- package/dist/backend/llvm/region-sites.js +79 -1
- package/dist/backend/llvm/region-sites.js.map +1 -1
- package/dist/backend/llvm/runtime-registries.test.js +53 -6
- package/dist/backend/llvm/runtime-registries.test.js.map +1 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js +3 -1
- package/dist/backend/llvm/serialized-ir-emission.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +36 -3
- package/dist/backend/llvm/shapes.js +201 -16
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +4 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +10 -1
- package/dist/backend/llvm/speculative-integers.js +59 -8
- package/dist/backend/llvm/speculative-integers.js.map +1 -1
- package/dist/backend/llvm/stack-objects.d.ts +1 -2
- package/dist/backend/llvm/stack-objects.js +8 -5
- package/dist/backend/llvm/stack-objects.js.map +1 -1
- package/dist/backend/llvm/unwind-abi.d.ts +3 -3
- package/dist/backend/llvm/unwind-abi.js +8 -3
- package/dist/backend/llvm/unwind-abi.js.map +1 -1
- package/dist/backend/llvm/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +47 -3
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +12 -2
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +13 -0
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/contracts.d.ts +94 -0
- package/dist/backend/native/executable.js +134 -10
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/helper-identity-record.d.ts +11 -0
- package/dist/backend/native/helper-identity-record.js +76 -0
- package/dist/backend/native/helper-identity-record.js.map +1 -0
- package/dist/backend/native/helper-identity-record.test.d.ts +1 -0
- package/dist/backend/native/helper-identity-record.test.js +101 -0
- package/dist/backend/native/helper-identity-record.test.js.map +1 -0
- package/dist/backend/native/library.js +10 -2
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +8 -1
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native/vendor.d.ts +1 -1
- package/dist/backend/native/vendor.js +1 -1
- package/dist/backend/native/vendor.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +13 -10
- package/dist/backend/native-codegen-core.js +26 -13
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.js +30 -8
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +110 -14
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +72 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-link-info.js +1 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-profile.d.ts +4 -1
- package/dist/backend/native-profile.js +12 -1
- package/dist/backend/native-profile.js.map +1 -1
- package/dist/backend/native-profile.test.js +10 -0
- package/dist/backend/native-profile.test.js.map +1 -1
- package/dist/backend/publication.d.ts +4 -1
- package/dist/backend/publication.js +4 -2
- package/dist/backend/publication.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 +46 -7
- package/dist/backend/runtime-pack-core.js +37 -2
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-native.d.ts +18 -1
- package/dist/backend/runtime-pack-native.js +138 -29
- package/dist/backend/runtime-pack-native.js.map +1 -1
- package/dist/backend/runtime-pack-native.test.js +166 -4
- package/dist/backend/runtime-pack-native.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +3 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -0
- package/dist/backend/runtime-pack.js +25 -3
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +213 -12
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/tree-classes.d.ts +42 -0
- package/dist/backend/tree-classes.js +723 -0
- package/dist/backend/tree-classes.js.map +1 -0
- package/dist/backend/tree-classes.test.d.ts +1 -0
- package/dist/backend/tree-classes.test.js +338 -0
- package/dist/backend/tree-classes.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +8 -1
- package/dist/backend/vendor-archives.js +313 -8
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +60 -3
- package/dist/backend/vendor-inputs.js +109 -3
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +62 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +2 -0
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +7 -1
- package/dist/compat/fetch-profile.js +25 -12
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- package/dist/contracts/check.d.ts +3 -0
- package/dist/contracts/check.js +18 -5
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/report.js +47 -0
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/codes.d.ts +14 -0
- package/dist/diagnostics/codes.js +14 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +68 -0
- package/dist/diagnostics/diagnostic.js +186 -6
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/dynamic-tier.js +3 -1
- package/dist/diagnostics/dynamic-tier.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +18 -0
- package/dist/diagnostics/envelope.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +48 -0
- package/dist/executable/executable-cache.js +38 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +127 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.d.ts +13 -3
- package/dist/executable/prepare.js +438 -234
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +200 -18
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/builtin-modules.d.ts +4 -0
- package/dist/frontend/builtin-modules.js +10 -0
- package/dist/frontend/builtin-modules.js.map +1 -1
- package/dist/frontend/early-errors.d.ts +24 -0
- package/dist/frontend/early-errors.js +836 -0
- package/dist/frontend/early-errors.js.map +1 -0
- package/dist/frontend/early-errors.test.d.ts +1 -0
- package/dist/frontend/early-errors.test.js +207 -0
- package/dist/frontend/early-errors.test.js.map +1 -0
- package/dist/frontend/inferred-js-diagnostics.test.js +88 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- package/dist/frontend/input-tracker.d.ts +47 -0
- package/dist/frontend/input-tracker.js +173 -36
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/input-tracker.test.js +86 -2
- package/dist/frontend/input-tracker.test.js.map +1 -1
- package/dist/frontend/js-inference.d.ts +2 -0
- package/dist/frontend/js-inference.js +18 -0
- package/dist/frontend/js-inference.js.map +1 -0
- package/dist/frontend/jsx-opinion-sites.test.d.ts +1 -0
- package/dist/frontend/jsx-opinion-sites.test.js +86 -0
- package/dist/frontend/jsx-opinion-sites.test.js.map +1 -0
- package/dist/frontend/lib-exports.d.ts +23 -4
- package/dist/frontend/lib-exports.js +98 -26
- package/dist/frontend/lib-exports.js.map +1 -1
- package/dist/frontend/lowering/binding-analysis.d.ts +2 -1
- package/dist/frontend/lowering/binding-analysis.js +86 -4
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/buffers.d.ts +8 -0
- package/dist/frontend/lowering/buffers.js +43 -0
- package/dist/frontend/lowering/buffers.js.map +1 -0
- package/dist/frontend/lowering/builtin-calls.js +13 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtin-namespaces.d.ts +3 -2
- package/dist/frontend/lowering/builtin-namespaces.js +41 -3
- package/dist/frontend/lowering/builtin-namespaces.js.map +1 -1
- package/dist/frontend/lowering/builtin-statics.d.ts +24 -0
- package/dist/frontend/lowering/builtin-statics.js +407 -0
- package/dist/frontend/lowering/builtin-statics.js.map +1 -0
- package/dist/frontend/lowering/builtins/arguments.d.ts +4 -0
- package/dist/frontend/lowering/builtins/arguments.js +12 -0
- package/dist/frontend/lowering/builtins/arguments.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +6 -1
- package/dist/frontend/lowering/builtins/atomics.js +87 -1
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-methods.d.ts +7 -0
- package/dist/frontend/lowering/builtins/child-process-methods.js +52 -12
- package/dist/frontend/lowering/builtins/child-process-methods.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process-sync.d.ts +13 -0
- package/dist/frontend/lowering/builtins/child-process-sync.js +1 -13
- package/dist/frontend/lowering/builtins/child-process-sync.js.map +1 -1
- package/dist/frontend/lowering/builtins/child-process.d.ts +10 -4
- package/dist/frontend/lowering/builtins/child-process.js +565 -28
- package/dist/frontend/lowering/builtins/child-process.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +2 -2
- package/dist/frontend/lowering/builtins/compression.js +41 -21
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/constants.js +7 -2
- package/dist/frontend/lowering/builtins/constants.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.d.ts +1 -1
- package/dist/frontend/lowering/builtins/dates.js +23 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/environment.d.ts +55 -0
- package/dist/frontend/lowering/builtins/environment.js +213 -2
- package/dist/frontend/lowering/builtins/environment.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +75 -18
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +25 -7
- package/dist/frontend/lowering/builtins/filesystem.js +185 -16
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/json.js +4 -0
- package/dist/frontend/lowering/builtins/json.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +42 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-resolution.d.ts +8 -0
- package/dist/frontend/lowering/builtins/module-resolution.js +31 -5
- package/dist/frontend/lowering/builtins/module-resolution.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.d.ts +4 -1
- package/dist/frontend/lowering/builtins/numbers.js +10 -2
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/operating-system.d.ts +9 -5
- package/dist/frontend/lowering/builtins/operating-system.js +101 -20
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +18 -2
- package/dist/frontend/lowering/builtins/process.js +386 -25
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.js +169 -8
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/builtins/properties.js +6 -2
- package/dist/frontend/lowering/builtins/properties.js.map +1 -1
- package/dist/frontend/lowering/builtins/querystring.d.ts +8 -0
- package/dist/frontend/lowering/builtins/querystring.js +202 -18
- package/dist/frontend/lowering/builtins/querystring.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +200 -38
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/reflection.js +60 -1
- package/dist/frontend/lowering/builtins/reflection.js.map +1 -1
- package/dist/frontend/lowering/builtins/text-codecs.js +208 -59
- package/dist/frontend/lowering/builtins/text-codecs.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +55 -13
- package/dist/frontend/lowering/builtins/url.js.map +1 -1
- package/dist/frontend/lowering/builtins/v8.d.ts +5 -5
- package/dist/frontend/lowering/builtins/v8.js +7 -5
- package/dist/frontend/lowering/builtins/v8.js.map +1 -1
- package/dist/frontend/lowering/builtins/web-streams-dyn.d.ts +17 -2
- package/dist/frontend/lowering/builtins/web-streams-dyn.js +97 -9
- package/dist/frontend/lowering/builtins/web-streams-dyn.js.map +1 -1
- package/dist/frontend/lowering/builtins/webassembly.js +2 -0
- package/dist/frontend/lowering/builtins/webassembly.js.map +1 -1
- package/dist/frontend/lowering/call-arguments.d.ts +10 -0
- package/dist/frontend/lowering/call-arguments.js +37 -2
- package/dist/frontend/lowering/call-arguments.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.d.ts +10 -0
- package/dist/frontend/lowering/call-signatures.js +180 -0
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.d.ts +3 -0
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.js +5 -0
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/class-construction.d.ts +14 -2
- package/dist/frontend/lowering/class-construction.js +99 -5
- package/dist/frontend/lowering/class-construction.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +14 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1376 -1009
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js +158 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.test.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.js +59 -10
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/class-prototypes.js +20 -15
- package/dist/frontend/lowering/class-prototypes.js.map +1 -1
- package/dist/frontend/lowering/class-runtime-statics.d.ts +8 -0
- package/dist/frontend/lowering/class-runtime-statics.js +35 -1
- package/dist/frontend/lowering/class-runtime-statics.js.map +1 -1
- package/dist/frontend/lowering/class-unions.js +21 -4
- package/dist/frontend/lowering/class-unions.js.map +1 -1
- package/dist/frontend/lowering/class-views.d.ts +13 -0
- package/dist/frontend/lowering/class-views.js +51 -0
- package/dist/frontend/lowering/class-views.js.map +1 -0
- package/dist/frontend/lowering/coercions/function-adapters.d.ts +15 -1
- package/dist/frontend/lowering/coercions/function-adapters.js +63 -10
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +15 -0
- package/dist/frontend/lowering/coercions/state.js +24 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +75 -3
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +39 -2
- package/dist/frontend/lowering/coercions/structural.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +2 -1
- package/dist/frontend/lowering/coercions/unions.js +54 -10
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/constructor-returns.d.ts +23 -2
- package/dist/frontend/lowering/constructor-returns.js +284 -58
- package/dist/frontend/lowering/constructor-returns.js.map +1 -1
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +8 -1
- package/dist/frontend/lowering/containers/array-callbacks.js +288 -90
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +37 -8
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.js +139 -3
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -1
- package/dist/frontend/lowering/containers/array-iteration.d.ts +14 -4
- package/dist/frontend/lowering/containers/array-iteration.js +24 -7
- package/dist/frontend/lowering/containers/array-iteration.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +30 -11
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +6 -0
- package/dist/frontend/lowering/containers/bytes.js +450 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +16 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +74 -12
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-grouping.js +421 -2
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +52 -17
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/filter-predicates.d.ts +10 -0
- package/dist/frontend/lowering/containers/filter-predicates.js +69 -3
- package/dist/frontend/lowering/containers/filter-predicates.js.map +1 -1
- package/dist/frontend/lowering/containers/indexed-objects.js +46 -2
- package/dist/frontend/lowering/containers/indexed-objects.js.map +1 -1
- package/dist/frontend/lowering/containers/iterator-helpers.d.ts +23 -0
- package/dist/frontend/lowering/containers/iterator-helpers.js +176 -10
- package/dist/frontend/lowering/containers/iterator-helpers.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +5 -2
- package/dist/frontend/lowering/containers/string-and-regexp.js +45 -11
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/crypto-tables.d.ts +3 -3
- package/dist/frontend/lowering/crypto-tables.js +5 -5
- package/dist/frontend/lowering/dispatch-sites.js +3 -0
- package/dist/frontend/lowering/dispatch-sites.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +40 -0
- package/dist/frontend/lowering/divergences.js +239 -20
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/effect-free.d.ts +12 -0
- package/dist/frontend/lowering/effect-free.js +44 -0
- package/dist/frontend/lowering/effect-free.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.d.ts +24 -0
- package/dist/frontend/lowering/expressions/array-literals.js +88 -10
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +216 -14
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +272 -11
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.d.ts +15 -0
- package/dist/frontend/lowering/expressions/hosted-narrowing.js +54 -1
- package/dist/frontend/lowering/expressions/hosted-narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +173 -4
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.d.ts +11 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js +22 -1
- package/dist/frontend/lowering/expressions/keyed-field-targets.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +195 -18
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.d.ts +5 -1
- package/dist/frontend/lowering/expressions/object-literals.js +951 -240
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +71 -21
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +39 -0
- package/dist/frontend/lowering/expressions/property-access.js +1141 -87
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +262 -4
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +25 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/union-fields.d.ts +20 -1
- package/dist/frontend/lowering/expressions/union-fields.js +103 -13
- package/dist/frontend/lowering/expressions/union-fields.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +156 -22
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.d.ts +6 -0
- package/dist/frontend/lowering/frozen-records.js +10 -4
- package/dist/frontend/lowering/frozen-records.js.map +1 -1
- package/dist/frontend/lowering/frozen-records.test.d.ts +1 -0
- package/dist/frontend/lowering/frozen-records.test.js +44 -0
- package/dist/frontend/lowering/frozen-records.test.js.map +1 -0
- package/dist/frontend/lowering/function-names.d.ts +9 -0
- package/dist/frontend/lowering/function-names.js +95 -0
- package/dist/frontend/lowering/function-names.js.map +1 -0
- package/dist/frontend/lowering/function-returns.js +42 -13
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/general-streams.js +5 -0
- package/dist/frontend/lowering/general-streams.js.map +1 -1
- package/dist/frontend/lowering/generator-delegation.d.ts +15 -7
- package/dist/frontend/lowering/generator-delegation.js +301 -118
- package/dist/frontend/lowering/generator-delegation.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +75 -0
- package/dist/frontend/lowering/generic-functions.js +790 -18
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/global-function-values.d.ts +25 -0
- package/dist/frontend/lowering/global-function-values.js +193 -0
- package/dist/frontend/lowering/global-function-values.js.map +1 -0
- package/dist/frontend/lowering/global-values.d.ts +15 -4
- package/dist/frontend/lowering/global-values.js +67 -9
- package/dist/frontend/lowering/global-values.js.map +1 -1
- package/dist/frontend/lowering/handle-properties.js +34 -1
- package/dist/frontend/lowering/handle-properties.js.map +1 -1
- package/dist/frontend/lowering/host-global-values.d.ts +31 -0
- package/dist/frontend/lowering/host-global-values.js +121 -0
- package/dist/frontend/lowering/host-global-values.js.map +1 -0
- package/dist/frontend/lowering/host-globals.d.ts +74 -0
- package/dist/frontend/lowering/host-globals.js +344 -0
- package/dist/frontend/lowering/host-globals.js.map +1 -0
- package/dist/frontend/lowering/http2-constants.js +1 -1
- package/dist/frontend/lowering/iterator-adapters.js +46 -17
- package/dist/frontend/lowering/iterator-adapters.js.map +1 -1
- package/dist/frontend/lowering/iterator-prototype.d.ts +30 -0
- package/dist/frontend/lowering/iterator-prototype.js +160 -0
- package/dist/frontend/lowering/iterator-prototype.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.d.ts +54 -0
- package/dist/frontend/lowering/key-order-witness.js +571 -9
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +1 -0
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +25 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +140 -16
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-async-iteration.d.ts +11 -0
- package/dist/frontend/lowering/lower-async-iteration.js +15 -0
- package/dist/frontend/lowering/lower-async-iteration.js.map +1 -1
- package/dist/frontend/lowering/lower-builtin-values.d.ts +36 -6
- package/dist/frontend/lowering/lower-builtin-values.js +342 -58
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +47 -1
- package/dist/frontend/lowering/lower-calls.js +1354 -273
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.d.ts +1 -0
- package/dist/frontend/lowering/lower-calls.test.js +121 -0
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -0
- package/dist/frontend/lowering/lower-classes.d.ts +36 -5
- package/dist/frontend/lowering/lower-classes.js +630 -89
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +15 -2
- package/dist/frontend/lowering/lower-event-emitter.js +610 -98
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +15 -1
- package/dist/frontend/lowering/lower-exprs.js +96 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +27 -6
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +57 -10
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-global-value.d.ts +6 -0
- package/dist/frontend/lowering/lower-global-value.js +14 -5
- package/dist/frontend/lowering/lower-global-value.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +713 -92
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +135 -27
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +18 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-node-island.d.ts +35 -4
- package/dist/frontend/lowering/lower-node-island.js +472 -67
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +463 -96
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-shared-modules.js +13 -1
- package/dist/frontend/lowering/lower-shared-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.d.ts +3 -2
- package/dist/frontend/lowering/lower-stdlib.js +77 -18
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +24 -4
- package/dist/frontend/lowering/lower-stmts.js +831 -136
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +126 -8
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +243 -48
- package/dist/frontend/lowering/lower-timers.js.map +1 -1
- package/dist/frontend/lowering/lower-url.js +6 -3
- package/dist/frontend/lowering/lower-url.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +363 -21
- package/dist/frontend/lowering/lowerer.js +1224 -129
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +19 -1
- package/dist/frontend/lowering/lowerer.test.js.map +1 -1
- package/dist/frontend/lowering/lowering-facts.d.ts +110 -0
- package/dist/frontend/lowering/lowering-facts.js +323 -0
- package/dist/frontend/lowering/lowering-facts.js.map +1 -0
- package/dist/frontend/lowering/lowering-facts.test.d.ts +1 -0
- package/dist/frontend/lowering/lowering-facts.test.js +100 -0
- package/dist/frontend/lowering/lowering-facts.test.js.map +1 -0
- package/dist/frontend/lowering/module-namespace-elements.js +15 -0
- package/dist/frontend/lowering/module-namespace-elements.js.map +1 -1
- package/dist/frontend/lowering/nan-coded-reads.d.ts +27 -4
- package/dist/frontend/lowering/nan-coded-reads.js +112 -9
- package/dist/frontend/lowering/nan-coded-reads.js.map +1 -1
- package/dist/frontend/lowering/new-target.js +2 -2
- package/dist/frontend/lowering/nullish-empty-pattern.d.ts +17 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js +118 -0
- package/dist/frontend/lowering/nullish-empty-pattern.js.map +1 -0
- package/dist/frontend/lowering/optional-arguments.d.ts +4 -0
- package/dist/frontend/lowering/optional-arguments.js +26 -2
- package/dist/frontend/lowering/optional-arguments.js.map +1 -1
- package/dist/frontend/lowering/partial-assertions.d.ts +36 -0
- package/dist/frontend/lowering/partial-assertions.js +189 -0
- package/dist/frontend/lowering/partial-assertions.js.map +1 -0
- package/dist/frontend/lowering/primitive-throws.d.ts +100 -0
- package/dist/frontend/lowering/primitive-throws.js +241 -0
- package/dist/frontend/lowering/primitive-throws.js.map +1 -0
- package/dist/frontend/lowering/primitive-wrappers.d.ts +34 -0
- package/dist/frontend/lowering/primitive-wrappers.js +221 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -0
- package/dist/frontend/lowering/private-statics.d.ts +46 -0
- package/dist/frontend/lowering/private-statics.js +322 -0
- package/dist/frontend/lowering/private-statics.js.map +1 -0
- package/dist/frontend/lowering/record-inherited.d.ts +17 -1
- package/dist/frontend/lowering/record-inherited.js +16 -2
- package/dist/frontend/lowering/record-inherited.js.map +1 -1
- package/dist/frontend/lowering/record-links.d.ts +73 -0
- package/dist/frontend/lowering/record-links.js +797 -0
- package/dist/frontend/lowering/record-links.js.map +1 -0
- package/dist/frontend/lowering/record-sources.d.ts +12 -1
- package/dist/frontend/lowering/record-sources.js +60 -0
- package/dist/frontend/lowering/record-sources.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +27 -7
- package/dist/frontend/lowering/runtime-optional-provenance.js +25 -11
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-report.d.ts +40 -0
- package/dist/frontend/lowering/runtime-optional-report.js +300 -0
- package/dist/frontend/lowering/runtime-optional-report.js.map +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.d.ts +1 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js +86 -0
- package/dist/frontend/lowering/scoped-type-memo.test.js.map +1 -0
- package/dist/frontend/lowering/static-typeof.d.ts +3 -1
- package/dist/frontend/lowering/static-typeof.js +6 -1
- package/dist/frontend/lowering/static-typeof.js.map +1 -1
- package/dist/frontend/lowering/strict-equality.d.ts +4 -0
- package/dist/frontend/lowering/strict-equality.js +14 -0
- package/dist/frontend/lowering/strict-equality.js.map +1 -1
- package/dist/frontend/lowering/strict-mode.d.ts +1 -5
- package/dist/frontend/lowering/strict-mode.js +4 -30
- package/dist/frontend/lowering/strict-mode.js.map +1 -1
- package/dist/frontend/lowering/structural-instances.d.ts +7 -0
- package/dist/frontend/lowering/structural-instances.js +23 -0
- package/dist/frontend/lowering/structural-instances.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +42 -1
- package/dist/frontend/lowering/surfaces.js +212 -71
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/lowering/union-retag.d.ts +13 -1
- package/dist/frontend/lowering/union-retag.js +55 -1
- package/dist/frontend/lowering/union-retag.js.map +1 -1
- package/dist/frontend/lowering/union-retag.test.js +51 -0
- package/dist/frontend/lowering/union-retag.test.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.d.ts +136 -17
- package/dist/frontend/lowering/unit-journal.js +324 -53
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +126 -3
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/unit-reuse.d.ts +92 -0
- package/dist/frontend/lowering/unit-reuse.js +1008 -0
- package/dist/frontend/lowering/unit-reuse.js.map +1 -0
- package/dist/frontend/lowering/width-lift.d.ts +12 -0
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-file-import.test.d.ts +1 -0
- package/dist/frontend/npm-file-import.test.js +76 -0
- package/dist/frontend/npm-file-import.test.js.map +1 -0
- package/dist/frontend/npm-static.js +95 -11
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm-static.test.js +95 -2
- package/dist/frontend/npm-static.test.js.map +1 -1
- package/dist/frontend/npm.d.ts +9 -0
- package/dist/frontend/npm.js +82 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/pipeline-native.js +2 -1
- package/dist/frontend/pipeline-native.js.map +1 -1
- package/dist/frontend/pipeline.d.ts +9 -4
- package/dist/frontend/pipeline.js +162 -38
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/pipeline.test.js +68 -11
- package/dist/frontend/pipeline.test.js.map +1 -1
- package/dist/frontend/program-node.d.ts +3 -0
- package/dist/frontend/program-node.js +13 -6
- package/dist/frontend/program-node.js.map +1 -1
- package/dist/frontend/program.d.ts +71 -2
- package/dist/frontend/program.js +836 -411
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +37 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/provenance-core.js +4 -0
- package/dist/frontend/provenance-core.js.map +1 -1
- package/dist/frontend/services-node.d.ts +7 -0
- package/dist/frontend/services-node.js +32 -1
- package/dist/frontend/services-node.js.map +1 -1
- package/dist/frontend/services-node.test.js +51 -0
- package/dist/frontend/services-node.test.js.map +1 -1
- package/dist/frontend/services.d.ts +14 -0
- package/dist/frontend/services.js +52 -2
- package/dist/frontend/services.js.map +1 -1
- package/dist/frontend/services.test.js +61 -1
- package/dist/frontend/services.test.js.map +1 -1
- package/dist/frontend/shape-inference/analyze.d.ts +5 -0
- package/dist/frontend/shape-inference/analyze.js +104 -4
- package/dist/frontend/shape-inference/analyze.js.map +1 -1
- package/dist/frontend/shape-inference/domain.js +0 -1
- package/dist/frontend/shape-inference/domain.js.map +1 -1
- package/dist/frontend/shape-inference/index.js +5 -1
- package/dist/frontend/shape-inference/index.js.map +1 -1
- package/dist/frontend/shape-inference/memo.d.ts +2 -1
- package/dist/frontend/shape-inference/memo.js +6 -2
- package/dist/frontend/shape-inference/memo.js.map +1 -1
- package/dist/frontend/shape-inference/overlay.d.ts +1 -1
- package/dist/frontend/shape-inference/overlay.js +184 -4
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- package/dist/frontend/shape-inference/static-objects.js +11 -6
- package/dist/frontend/shape-inference/static-objects.js.map +1 -1
- package/dist/frontend/source-phase-imports.test.d.ts +1 -0
- package/dist/frontend/source-phase-imports.test.js +37 -0
- package/dist/frontend/source-phase-imports.test.js.map +1 -0
- package/dist/frontend/tier-analysis.d.ts +9 -0
- package/dist/frontend/tier-analysis.js +1 -0
- package/dist/frontend/tier-analysis.js.map +1 -1
- package/dist/frontend/ts7/ast-node.d.ts +6 -1
- package/dist/frontend/ts7/ast-node.js +12 -0
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-wire-protocols.test.js +11 -3
- package/dist/frontend/ts7/ast-wire-protocols.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.js +3 -5
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.d.ts +13 -0
- package/dist/frontend/ts7/checker-backend.js +84 -2
- package/dist/frontend/ts7/checker-backend.js.map +1 -1
- package/dist/frontend/ts7/checker-backend.test.js +126 -2
- package/dist/frontend/ts7/checker-backend.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +22 -1
- package/dist/frontend/ts7/program-host.js +49 -4
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +83 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.d.ts +16 -1
- package/dist/frontend/ts7/rpc-process.js +170 -92
- package/dist/frontend/ts7/rpc-process.js.map +1 -1
- package/dist/frontend/ts7/rpc-process.test.js +49 -21
- package/dist/frontend/ts7/rpc-process.test.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +956 -101
- package/dist/frontend/tsc-codes.js.map +1 -1
- package/dist/frontend/tsc-codes.test.js +221 -12
- package/dist/frontend/tsc-codes.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +98 -11
- package/dist/frontend/type-mapper.js +770 -182
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +224 -15
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +60 -0
- package/dist/index.test.js.map +1 -0
- package/dist/ir/api.d.ts +1 -1
- package/dist/ir/api.js +1 -1
- package/dist/ir/api.js.map +1 -1
- package/dist/ir/build.d.ts +3 -2
- package/dist/ir/build.js +4 -2
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-effects.js +96 -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 +453 -26
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/callback-specialization.d.ts +3 -2
- package/dist/ir/callback-specialization.js +35 -25
- package/dist/ir/callback-specialization.js.map +1 -1
- package/dist/ir/capture-values.d.ts +8 -4
- package/dist/ir/capture-values.js +9 -6
- package/dist/ir/capture-values.js.map +1 -1
- package/dist/ir/char-unit-locals.d.ts +6 -2
- package/dist/ir/char-unit-locals.js +11 -2
- package/dist/ir/char-unit-locals.js.map +1 -1
- package/dist/ir/class-key-index.d.ts +18 -0
- package/dist/ir/class-key-index.js +29 -0
- package/dist/ir/class-key-index.js.map +1 -0
- package/dist/ir/class-key-index.test.d.ts +1 -0
- package/dist/ir/class-key-index.test.js +25 -0
- package/dist/ir/class-key-index.test.js.map +1 -0
- package/dist/ir/codec.d.ts +82 -0
- package/dist/ir/codec.generated.d.ts +13 -0
- package/dist/ir/codec.generated.js +5350 -0
- package/dist/ir/codec.generated.js.map +1 -0
- package/dist/ir/codec.js +325 -0
- package/dist/ir/codec.js.map +1 -0
- package/dist/ir/codec.test.d.ts +1 -0
- package/dist/ir/codec.test.js +225 -0
- package/dist/ir/codec.test.js.map +1 -0
- package/dist/ir/constant-globals.d.ts +5 -2
- package/dist/ir/constant-globals.js +25 -27
- package/dist/ir/constant-globals.js.map +1 -1
- package/dist/ir/expression-inlining.d.ts +4 -2
- package/dist/ir/expression-inlining.js +8 -2
- package/dist/ir/expression-inlining.js.map +1 -1
- package/dist/ir/field-values.d.ts +5 -2
- package/dist/ir/field-values.js +32 -21
- package/dist/ir/field-values.js.map +1 -1
- package/dist/ir/fields.generated.d.ts +29 -10
- package/dist/ir/fields.generated.js +1039 -11
- package/dist/ir/fields.generated.js.map +1 -1
- package/dist/ir/fields.test.js +46 -2
- package/dist/ir/fields.test.js.map +1 -1
- package/dist/ir/final-fields.js +1 -1
- package/dist/ir/final-fields.js.map +1 -1
- package/dist/ir/function-references.d.ts +6 -4
- package/dist/ir/function-references.js +11 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +14 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/init-only-globals.d.ts +4 -2
- package/dist/ir/init-only-globals.js +17 -18
- package/dist/ir/init-only-globals.js.map +1 -1
- package/dist/ir/inline-array-sources.js +4 -1
- package/dist/ir/inline-array-sources.js.map +1 -1
- package/dist/ir/inline-array-views.d.ts +13 -0
- package/dist/ir/inline-array-views.js +945 -0
- package/dist/ir/inline-array-views.js.map +1 -0
- package/dist/ir/inline-arrays.d.ts +7 -0
- package/dist/ir/inline-arrays.js +190 -55
- package/dist/ir/inline-arrays.js.map +1 -1
- package/dist/ir/inline-arrays.test.js +140 -2
- package/dist/ir/inline-arrays.test.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/integer-ranges.js +16 -6
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/ir.d.ts +130 -44
- package/dist/ir/ir.js +7 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/js-groups.d.ts +51 -0
- package/dist/ir/js-groups.js +394 -0
- package/dist/ir/js-groups.js.map +1 -0
- package/dist/ir/js-groups.test.d.ts +1 -0
- package/dist/ir/js-groups.test.js +555 -0
- package/dist/ir/js-groups.test.js.map +1 -0
- package/dist/ir/js-ic.d.ts +10 -9
- package/dist/ir/js-ic.js +58 -25
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +37 -3
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/jsval.js +374 -63
- package/dist/ir/jsval.js.map +1 -1
- package/dist/ir/jsval.test.js +96 -2
- package/dist/ir/jsval.test.js.map +1 -1
- package/dist/ir/loop-entry-ranges.js +112 -9
- package/dist/ir/loop-entry-ranges.js.map +1 -1
- package/dist/ir/loop-entry-ranges.test.js +40 -0
- package/dist/ir/loop-entry-ranges.test.js.map +1 -1
- package/dist/ir/node-index.d.ts +23 -6
- package/dist/ir/node-index.js +126 -49
- package/dist/ir/node-index.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +4 -2
- package/dist/ir/numeric-call-specialization.js +40 -26
- package/dist/ir/numeric-call-specialization.js.map +1 -1
- package/dist/ir/paired-while-loops.d.ts +4 -2
- package/dist/ir/paired-while-loops.js +8 -2
- package/dist/ir/paired-while-loops.js.map +1 -1
- package/dist/ir/parameter-versions.d.ts +13 -3
- package/dist/ir/parameter-versions.js +63 -40
- package/dist/ir/parameter-versions.js.map +1 -1
- package/dist/ir/property-bags.d.ts +4 -2
- package/dist/ir/property-bags.js +22 -17
- package/dist/ir/property-bags.js.map +1 -1
- package/dist/ir/receiver-readers.js +58 -2
- package/dist/ir/receiver-readers.js.map +1 -1
- package/dist/ir/row-pairs.d.ts +4 -2
- package/dist/ir/row-pairs.js +12 -11
- package/dist/ir/row-pairs.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +139 -5
- package/dist/ir/runtime-features.js +397 -19
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +135 -1
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/runtime-jam-loops.d.ts +35 -0
- package/dist/ir/runtime-jam-loops.js +604 -0
- package/dist/ir/runtime-jam-loops.js.map +1 -0
- package/dist/ir/runtime-jam-loops.test.d.ts +1 -0
- package/dist/ir/runtime-jam-loops.test.js +565 -0
- package/dist/ir/runtime-jam-loops.test.js.map +1 -0
- package/dist/ir/saturating-loop-jams.d.ts +11 -2
- package/dist/ir/saturating-loop-jams.js +56 -16
- package/dist/ir/saturating-loop-jams.js.map +1 -1
- package/dist/ir/saturating-loop-jams.test.js +39 -1
- package/dist/ir/saturating-loop-jams.test.js.map +1 -1
- package/dist/ir/scalar-records.d.ts +5 -2
- package/dist/ir/scalar-records.js +12 -2
- package/dist/ir/scalar-records.js.map +1 -1
- package/dist/ir/self-captures.d.ts +4 -2
- package/dist/ir/self-captures.js +40 -28
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/self-captures.test.js +15 -0
- package/dist/ir/self-captures.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +8 -2
- package/dist/ir/serialize.js +92 -24
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/serialize.test.js +26 -0
- package/dist/ir/serialize.test.js.map +1 -1
- package/dist/ir/tiers.js +1 -0
- package/dist/ir/tiers.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/typed-argument-clones.d.ts +30 -0
- package/dist/ir/typed-argument-clones.js +789 -0
- package/dist/ir/typed-argument-clones.js.map +1 -0
- package/dist/ir/union-arm-loops.d.ts +3 -0
- package/dist/ir/union-arm-loops.js +373 -0
- package/dist/ir/union-arm-loops.js.map +1 -0
- package/dist/ir/union-arm-loops.test.d.ts +1 -0
- package/dist/ir/union-arm-loops.test.js +230 -0
- package/dist/ir/union-arm-loops.test.js.map +1 -0
- package/dist/ir/validate.js +170 -22
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +46 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/compiler-self-identity.d.ts +8 -2
- package/dist/library/compiler-self-identity.js +92 -18
- package/dist/library/compiler-self-identity.js.map +1 -1
- package/dist/library/compiler-self-identity.test.js +150 -3
- package/dist/library/compiler-self-identity.test.js.map +1 -1
- package/dist/library/int-infer.d.ts +5 -0
- package/dist/library/int-infer.js +15 -3
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/ir-policy.js +4 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.d.ts +4 -0
- package/dist/library/library-cache.js +2 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +26 -0
- package/dist/library/library-cache.test.js.map +1 -1
- package/dist/library/prepare.js +99 -31
- package/dist/library/prepare.js.map +1 -1
- package/dist/native/cache.d.ts +7 -0
- package/dist/native/cache.js +49 -0
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +13 -1
- package/dist/native/cache.test.js.map +1 -1
- package/dist/native/cli.js +2 -0
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +26 -5
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/executable-cache-open.test.js +31 -5
- package/dist/native/executable-cache-open.test.js.map +1 -1
- package/dist/native/executable-cache.d.ts +6 -1
- package/dist/native/executable-cache.js +7 -1
- package/dist/native/executable-cache.js.map +1 -1
- package/dist/native/prepare.d.ts +3 -0
- package/dist/native/prepare.js +74 -28
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +25 -3
- package/dist/native/prepare.test.js.map +1 -1
- package/dist/native/sanitizer.js +63 -4
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +93 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/native/toolchain.js +9 -2
- package/dist/native/toolchain.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +37 -1
- package/dist/node-islands/boundary.js +65 -7
- package/dist/node-islands/boundary.js.map +1 -1
- package/dist/node-islands/boundary.test.d.ts +1 -0
- package/dist/node-islands/boundary.test.js +76 -0
- package/dist/node-islands/boundary.test.js.map +1 -0
- package/dist/node-islands/detect.d.ts +27 -1
- package/dist/node-islands/detect.js +475 -40
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +175 -4
- package/dist/node-islands/detect.test.js.map +1 -1
- package/dist/node-islands/effect-gate.js +30 -20
- package/dist/node-islands/effect-gate.js.map +1 -1
- package/dist/node-islands/effect-gate.test.js +4 -1
- package/dist/node-islands/effect-gate.test.js.map +1 -1
- package/dist/node-islands/graph-islands.d.ts +40 -0
- package/dist/node-islands/graph-islands.js +128 -0
- package/dist/node-islands/graph-islands.js.map +1 -0
- package/dist/node-islands/growth.d.ts +57 -0
- package/dist/node-islands/growth.js +205 -0
- package/dist/node-islands/growth.js.map +1 -0
- package/dist/node-islands/libnode.d.ts +1 -1
- package/dist/node-islands/libnode.js +1 -1
- package/dist/node-islands/libnode.js.map +1 -1
- package/dist/node-islands/modules.d.ts +28 -0
- package/dist/node-islands/modules.js +156 -0
- package/dist/node-islands/modules.js.map +1 -1
- package/dist/node-islands/modules.test.js +105 -1
- package/dist/node-islands/modules.test.js.map +1 -1
- package/dist/node-islands/policy.js +2 -3
- package/dist/node-islands/policy.js.map +1 -1
- package/dist/node-islands/probe-recorder.d.ts +1 -0
- package/dist/node-islands/probe-recorder.js +596 -0
- package/dist/node-islands/probe-recorder.js.map +1 -0
- package/dist/node-islands/probe-recorder.test.d.ts +1 -0
- package/dist/node-islands/probe-recorder.test.js +80 -0
- package/dist/node-islands/probe-recorder.test.js.map +1 -0
- package/dist/node-islands/report.d.ts +12 -0
- package/dist/node-islands/report.js +28 -0
- package/dist/node-islands/report.js.map +1 -1
- package/dist/node-islands/report.test.js +4 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +9 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +16 -1
- package/dist/node-islands/scan.js +110 -9
- package/dist/node-islands/scan.js.map +1 -1
- package/dist/node-islands/snapshot.d.ts +38 -1
- package/dist/node-islands/snapshot.js +165 -161
- package/dist/node-islands/snapshot.js.map +1 -1
- package/dist/node-islands/snapshot.test.js +63 -2
- package/dist/node-islands/snapshot.test.js.map +1 -1
- package/dist/node-islands/summary.js +8 -0
- package/dist/node-islands/summary.js.map +1 -1
- package/dist/node-islands/type-strip.d.ts +11 -0
- package/dist/node-islands/type-strip.js +157 -0
- package/dist/node-islands/type-strip.js.map +1 -0
- package/dist/node-islands/type-strip.test.d.ts +1 -0
- package/dist/node-islands/type-strip.test.js +31 -0
- package/dist/node-islands/type-strip.test.js.map +1 -0
- package/dist/project-config.d.ts +4 -0
- package/dist/project-config.js +19 -0
- package/dist/project-config.js.map +1 -1
- package/dist/project-config.test.js +10 -0
- package/dist/project-config.test.js.map +1 -1
- package/dist/wasm/translate.js +11 -5
- package/dist/wasm/translate.js.map +1 -1
- package/dist/wasm/translate.test.js +35 -0
- package/dist/wasm/translate.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +221 -122
|
@@ -0,0 +1,1008 @@
|
|
|
1
|
+
/* Reuse of lowered units across builds (SCRIPTC_INCR_LOWERING=1).
|
|
2
|
+
*
|
|
3
|
+
* A build with a unit store records every reachable-emit unit
|
|
4
|
+
* (unit-journal.ts) and writes the records to the store, one entry per
|
|
5
|
+
* source file, beside a program entry that describes the build's program.
|
|
6
|
+
* The next build applies a unit's stored record in place of lowering the
|
|
7
|
+
* unit when nothing the unit's lowering read can have changed:
|
|
8
|
+
*
|
|
9
|
+
* - the program digest is unchanged: the IR version, the files outside the
|
|
10
|
+
* program's own modules (declaration files, the library), the module
|
|
11
|
+
* order and the statements with global effect;
|
|
12
|
+
* - the unit's source file has the same text, and so does every other file
|
|
13
|
+
* whose source positions its record holds;
|
|
14
|
+
* - the unit's text spells no name in the build's changed names.
|
|
15
|
+
*
|
|
16
|
+
* The changed names come from the two builds' declaration tables. A
|
|
17
|
+
* declaration is a top-level statement or a member of a top-level class or
|
|
18
|
+
* interface. Its surface is its text without the bodies of functions that
|
|
19
|
+
* declare their return type: what other declarations' types can depend on.
|
|
20
|
+
* Its facts are what the steps before the worklist settled for it: a
|
|
21
|
+
* function's signature, a class's layout and method signatures, a
|
|
22
|
+
* variable's globals. The changed names are:
|
|
23
|
+
*
|
|
24
|
+
* - the names of top-level declarations that were added or removed, or
|
|
25
|
+
* whose surface or facts changed, and the interfaces whose members did,
|
|
26
|
+
* closed over the surfaces that spell one of them (a declaration whose
|
|
27
|
+
* surface spells one joins);
|
|
28
|
+
* - the names of such class and interface members, and of declarations
|
|
29
|
+
* whose text alone changed;
|
|
30
|
+
* - the names a changed, added or removed declaration writes to outside
|
|
31
|
+
* itself, since analyses read a binding's or property's writes anywhere;
|
|
32
|
+
* - the names that refer to a module's namespace object, by a namespace
|
|
33
|
+
* import or an `import()` or `require()` call, when the module's exports
|
|
34
|
+
* changed;
|
|
35
|
+
* - the names that hold one of these under another name (Alias): a renamed
|
|
36
|
+
* or default import, a renamed or default export, a renamed `require()`
|
|
37
|
+
* destructuring, and the aliases of those.
|
|
38
|
+
*
|
|
39
|
+
* TypeScript resolves every dependency of a type through a name some text
|
|
40
|
+
* spells, so a unit whose text spells none of these sees the same types,
|
|
41
|
+
* the same declarations and the same facts. A unit's spelled names include
|
|
42
|
+
* its strings, which can name members.
|
|
43
|
+
*
|
|
44
|
+
* The first build into a cache records nothing: it writes only the
|
|
45
|
+
* declaration tables, and the build after it records its units.
|
|
46
|
+
*
|
|
47
|
+
* Applying a record goes through applyRecord, which still lowers the unit
|
|
48
|
+
* when the record disagrees with what this build holds by the unit's turn.
|
|
49
|
+
* SCRIPTC_INCR_VERIFY=1 lowers every unit whose record would apply and
|
|
50
|
+
* throws an InternalCompilerError naming the unit when the new record
|
|
51
|
+
* differs from the stored one. */
|
|
52
|
+
import { createHash } from "node:crypto";
|
|
53
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
54
|
+
import { join } from "node:path";
|
|
55
|
+
import { InternalCompilerError } from "../../errors.js";
|
|
56
|
+
import { IrReader, IrWriter, decodeFunctionBinary } from "../../ir/codec.js";
|
|
57
|
+
import { IR_CODEC_LAYOUT } from "../../ir/codec.generated.js";
|
|
58
|
+
import { IR_VERSION } from "../../ir/serialize.js";
|
|
59
|
+
import * as ts from "../ts7/adapter.js";
|
|
60
|
+
import { invalidateTrackedPath } from "../input-tracker.js";
|
|
61
|
+
import { isJsSourceFileName } from "../tsc-codes.js";
|
|
62
|
+
import { decodeRecordFunction, encodeUnitFunction, } from "./unit-journal.js";
|
|
63
|
+
/** A unit store in `directory`: the program entry for `key` under
|
|
64
|
+
* `program/`, file entries by content digest under `files/`. Failing reads
|
|
65
|
+
* are misses and failing writes leave the store as it was. */
|
|
66
|
+
export function directoryUnitStore(directory, key) {
|
|
67
|
+
const read = (path) => {
|
|
68
|
+
try {
|
|
69
|
+
return readFileSync(path);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const write = (path, bytes) => {
|
|
76
|
+
try {
|
|
77
|
+
mkdirSync(join(path, ".."), { recursive: true, mode: 0o700 });
|
|
78
|
+
const stage = `${path}.${process.pid}.tmp`;
|
|
79
|
+
writeFileSync(stage, bytes);
|
|
80
|
+
renameSync(stage, path);
|
|
81
|
+
invalidateTrackedPath(path);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// A failed write only costs the next build its reuse.
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const programPath = join(directory, "program", key);
|
|
88
|
+
return {
|
|
89
|
+
readProgram: () => read(programPath),
|
|
90
|
+
writeProgram: (bytes) => write(programPath, bytes),
|
|
91
|
+
readFile: (name) => (/^[0-9a-f]{64}$/.test(name) ? read(join(directory, "files", name)) : null),
|
|
92
|
+
writeFile: (bytes) => {
|
|
93
|
+
const name = createHash("sha256").update(bytes).digest("hex");
|
|
94
|
+
const path = join(directory, "files", name);
|
|
95
|
+
if (read(path) === null)
|
|
96
|
+
write(path, bytes);
|
|
97
|
+
return name;
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** Whether builds reuse lowered units (SCRIPTC_INCR_LOWERING=1). */
|
|
102
|
+
export function unitReuseEnabled() {
|
|
103
|
+
return process.env["SCRIPTC_INCR_LOWERING"] === "1";
|
|
104
|
+
}
|
|
105
|
+
/** Whether every unit whose record would apply lowers again and is checked
|
|
106
|
+
* against it (SCRIPTC_INCR_VERIFY=1). */
|
|
107
|
+
export function unitReuseVerify() {
|
|
108
|
+
return process.env["SCRIPTC_INCR_VERIFY"] === "1";
|
|
109
|
+
}
|
|
110
|
+
/** The first line of a program entry and of a file entry. */
|
|
111
|
+
const PROGRAM_MAGIC = "scriptc-units-program-2";
|
|
112
|
+
const FILE_MAGIC = "scriptc-units-file-3";
|
|
113
|
+
/** A recorded unit as an entry holds it. `named` are the files the fields
|
|
114
|
+
* named `file` in its binary function hold (RecordedUnit.files). */
|
|
115
|
+
function storedUnit(record, named, own) {
|
|
116
|
+
const files = positionFiles(record, named, own);
|
|
117
|
+
const fn = record.fn;
|
|
118
|
+
if (fn === null || typeof fn === "string")
|
|
119
|
+
return { record, files, bytes: null };
|
|
120
|
+
const bytes = Buffer.from(fn.buffer, fn.byteOffset, fn.byteLength);
|
|
121
|
+
return { record: { ...record, fn: null }, files, bytes };
|
|
122
|
+
}
|
|
123
|
+
/** The record of a stored unit, with its function. */
|
|
124
|
+
function storedRecord(unit) {
|
|
125
|
+
const bytes = unit.bytes;
|
|
126
|
+
const record = unit.record;
|
|
127
|
+
return {
|
|
128
|
+
record,
|
|
129
|
+
fn: () => bytes !== null
|
|
130
|
+
? decodeFunctionBinary(bytes)
|
|
131
|
+
: record.fn === null
|
|
132
|
+
? null
|
|
133
|
+
: decodeRecordFunction(record.fn),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** The files whose source positions `record` holds, other than `own`:
|
|
137
|
+
* those of its JSON function and entries, and `named` for a binary
|
|
138
|
+
* function. */
|
|
139
|
+
function positionFiles(record, named, own) {
|
|
140
|
+
const files = new Set();
|
|
141
|
+
if (named !== null)
|
|
142
|
+
for (const file of named)
|
|
143
|
+
if (file !== own)
|
|
144
|
+
files.add(file);
|
|
145
|
+
const scan = (text) => {
|
|
146
|
+
const pattern = /"file":("(?:[^"\\]|\\.)*")/g;
|
|
147
|
+
for (let match = pattern.exec(text); match !== null; match = pattern.exec(text)) {
|
|
148
|
+
const file = JSON.parse(match[1]);
|
|
149
|
+
if (file !== own)
|
|
150
|
+
files.add(file);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
if (typeof record.fn === "string")
|
|
154
|
+
scan(record.fn);
|
|
155
|
+
for (const entries of Object.values(record.tables))
|
|
156
|
+
for (const entry of entries)
|
|
157
|
+
scan(entry);
|
|
158
|
+
return [...files].sort();
|
|
159
|
+
}
|
|
160
|
+
/** A SHA-256 digest of `text`, in hex. */
|
|
161
|
+
function digestOf(text) {
|
|
162
|
+
return createHash("sha256").update(text).digest("hex");
|
|
163
|
+
}
|
|
164
|
+
/** The body of a function-like node whose body other declarations' types
|
|
165
|
+
* cannot see: it declares its return type, or it is a constructor or set
|
|
166
|
+
* accessor. Undefined for other nodes. */
|
|
167
|
+
function opaqueBody(node) {
|
|
168
|
+
if (!ts.isFunctionLikeDeclaration(node) || node.body === undefined)
|
|
169
|
+
return undefined;
|
|
170
|
+
return node.type !== undefined || ts.isConstructorDeclaration(node) || ts.isSetAccessor(node)
|
|
171
|
+
? node.body
|
|
172
|
+
: undefined;
|
|
173
|
+
}
|
|
174
|
+
/** The name node of a declaration or member, if it has one. */
|
|
175
|
+
function nameNodeOf(node) {
|
|
176
|
+
if (ts.isFunctionDeclaration(node) ||
|
|
177
|
+
ts.isClassDeclaration(node) ||
|
|
178
|
+
ts.isClassExpression(node) ||
|
|
179
|
+
ts.isInterfaceDeclaration(node) ||
|
|
180
|
+
ts.isTypeAliasDeclaration(node) ||
|
|
181
|
+
ts.isEnumDeclaration(node) ||
|
|
182
|
+
ts.isModuleDeclaration(node) ||
|
|
183
|
+
ts.isMethodDeclaration(node) ||
|
|
184
|
+
ts.isPropertyDeclaration(node) ||
|
|
185
|
+
ts.isGetAccessor(node) ||
|
|
186
|
+
ts.isSetAccessor(node) ||
|
|
187
|
+
ts.isPropertySignature(node) ||
|
|
188
|
+
ts.isMethodSignatureDeclaration(node))
|
|
189
|
+
return node.name ?? undefined;
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
/** The kinds the name walks materialize. */
|
|
193
|
+
const NAME_KINDS = new Set([
|
|
194
|
+
ts.SyntaxKind.Identifier,
|
|
195
|
+
ts.SyntaxKind.PrivateIdentifier,
|
|
196
|
+
]);
|
|
197
|
+
/** The kinds of string literals. */
|
|
198
|
+
const STRING_KINDS = new Set([
|
|
199
|
+
ts.SyntaxKind.StringLiteral,
|
|
200
|
+
ts.SyntaxKind.NoSubstitutionTemplateLiteral,
|
|
201
|
+
]);
|
|
202
|
+
/** The kinds that assign to their operand. */
|
|
203
|
+
const WRITE_KINDS = new Set([
|
|
204
|
+
ts.SyntaxKind.BinaryExpression,
|
|
205
|
+
ts.SyntaxKind.PrefixUnaryExpression,
|
|
206
|
+
ts.SyntaxKind.PostfixUnaryExpression,
|
|
207
|
+
ts.SyntaxKind.DeleteExpression,
|
|
208
|
+
]);
|
|
209
|
+
/** The operators of assignments. */
|
|
210
|
+
const ASSIGNMENTS = new Set([
|
|
211
|
+
ts.SyntaxKind.EqualsToken,
|
|
212
|
+
ts.SyntaxKind.PlusEqualsToken,
|
|
213
|
+
ts.SyntaxKind.MinusEqualsToken,
|
|
214
|
+
ts.SyntaxKind.AsteriskEqualsToken,
|
|
215
|
+
ts.SyntaxKind.AsteriskAsteriskEqualsToken,
|
|
216
|
+
ts.SyntaxKind.SlashEqualsToken,
|
|
217
|
+
ts.SyntaxKind.PercentEqualsToken,
|
|
218
|
+
ts.SyntaxKind.LessThanLessThanEqualsToken,
|
|
219
|
+
ts.SyntaxKind.GreaterThanGreaterThanEqualsToken,
|
|
220
|
+
ts.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken,
|
|
221
|
+
ts.SyntaxKind.AmpersandEqualsToken,
|
|
222
|
+
ts.SyntaxKind.BarEqualsToken,
|
|
223
|
+
ts.SyntaxKind.CaretEqualsToken,
|
|
224
|
+
ts.SyntaxKind.BarBarEqualsToken,
|
|
225
|
+
ts.SyntaxKind.AmpersandAmpersandEqualsToken,
|
|
226
|
+
ts.SyntaxKind.QuestionQuestionEqualsToken,
|
|
227
|
+
]);
|
|
228
|
+
/** The identifier names `node`'s text spells, all of them or only those
|
|
229
|
+
* outside the bodies opaqueBody names. */
|
|
230
|
+
function spelledNames(node, surfaceOnly, out) {
|
|
231
|
+
if (!surfaceOnly) {
|
|
232
|
+
ts.walkPreorder(node, (child) => {
|
|
233
|
+
out.add(child.text);
|
|
234
|
+
}, NAME_KINDS);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
ts.walkPreorder(node, (child) => {
|
|
238
|
+
if (ts.isIdentifier(child) || ts.isPrivateIdentifier(child)) {
|
|
239
|
+
out.add(child.text);
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const parent = child.parent;
|
|
243
|
+
if (parent !== undefined && opaqueBody(parent) === child)
|
|
244
|
+
return "skip";
|
|
245
|
+
return undefined;
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/** The names `node`'s text writes to outside it: the bindings, properties
|
|
249
|
+
* and elements that its assignments, `++`, `--` and `delete` target, but
|
|
250
|
+
* not bindings declared inside `node`. A property write names the property;
|
|
251
|
+
* an element write names what the element's object spells. */
|
|
252
|
+
function assignedNames(node, hooks) {
|
|
253
|
+
const out = new Set();
|
|
254
|
+
const spellsOutside = (expression) => {
|
|
255
|
+
ts.walkPreorder(expression, (child) => {
|
|
256
|
+
if (ts.isIdentifier(child)) {
|
|
257
|
+
if (!hooks.isLocal(child, node))
|
|
258
|
+
out.add(child.text);
|
|
259
|
+
}
|
|
260
|
+
else if (ts.isPrivateIdentifier(child))
|
|
261
|
+
out.add(child.text);
|
|
262
|
+
}, NAME_KINDS);
|
|
263
|
+
};
|
|
264
|
+
const written = (target) => {
|
|
265
|
+
if (ts.isParenthesizedExpression(target))
|
|
266
|
+
written(target.expression);
|
|
267
|
+
else if (ts.isIdentifier(target)) {
|
|
268
|
+
if (!hooks.isLocal(target, node))
|
|
269
|
+
out.add(target.text);
|
|
270
|
+
}
|
|
271
|
+
else if (ts.isPropertyAccessExpression(target))
|
|
272
|
+
out.add(target.name.text);
|
|
273
|
+
else if (ts.isElementAccessExpression(target))
|
|
274
|
+
spellsOutside(target.expression);
|
|
275
|
+
else if (ts.isObjectLiteralExpression(target)) {
|
|
276
|
+
for (const property of target.properties.nodes) {
|
|
277
|
+
if (ts.isShorthandPropertyAssignment(property))
|
|
278
|
+
written(property.name);
|
|
279
|
+
else if (ts.isPropertyAssignment(property))
|
|
280
|
+
written(property.initializer);
|
|
281
|
+
else if (ts.isSpreadAssignment(property))
|
|
282
|
+
written(property.expression);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else if (ts.isArrayLiteralExpression(target)) {
|
|
286
|
+
for (const element of target.elements.nodes)
|
|
287
|
+
written(ts.isSpreadElement(element) ? element.expression : element);
|
|
288
|
+
}
|
|
289
|
+
else if (ts.isBinaryExpression(target))
|
|
290
|
+
written(target.left);
|
|
291
|
+
else
|
|
292
|
+
spellsOutside(target);
|
|
293
|
+
};
|
|
294
|
+
ts.walkPreorder(node, (child) => {
|
|
295
|
+
if (ts.isBinaryExpression(child)) {
|
|
296
|
+
if (ASSIGNMENTS.has(child.operatorToken.kind))
|
|
297
|
+
written(child.left);
|
|
298
|
+
}
|
|
299
|
+
else if (ts.isPrefixUnaryExpression(child) || ts.isPostfixUnaryExpression(child)) {
|
|
300
|
+
if (child.operator === ts.SyntaxKind.PlusPlusToken ||
|
|
301
|
+
child.operator === ts.SyntaxKind.MinusMinusToken)
|
|
302
|
+
written(child.operand);
|
|
303
|
+
}
|
|
304
|
+
else if (ts.isDeleteExpression(child))
|
|
305
|
+
written(child.expression);
|
|
306
|
+
}, WRITE_KINDS);
|
|
307
|
+
return [...out].sort();
|
|
308
|
+
}
|
|
309
|
+
/** `node`'s text with the bodies opaqueBody names replaced by `{}`. */
|
|
310
|
+
function surfaceText(sf, node, js) {
|
|
311
|
+
const text = sf.text;
|
|
312
|
+
const start = node.getStart(sf);
|
|
313
|
+
if (js)
|
|
314
|
+
return text.slice(start, node.end);
|
|
315
|
+
const cuts = [];
|
|
316
|
+
ts.walkPreorder(node, (child) => {
|
|
317
|
+
const body = child === node ? undefined : opaqueBody(child);
|
|
318
|
+
if (body === undefined)
|
|
319
|
+
return undefined;
|
|
320
|
+
cuts.push([body.getStart(sf), body.end]);
|
|
321
|
+
return "skip";
|
|
322
|
+
});
|
|
323
|
+
let out = "";
|
|
324
|
+
let at = start;
|
|
325
|
+
for (const [from, to] of cuts) {
|
|
326
|
+
if (from < at)
|
|
327
|
+
continue;
|
|
328
|
+
out += text.slice(at, from) + "{}";
|
|
329
|
+
at = to;
|
|
330
|
+
}
|
|
331
|
+
return out + text.slice(at, node.end);
|
|
332
|
+
}
|
|
333
|
+
/** The names a statement declares. A statement without a name (an
|
|
334
|
+
* expression statement, a loop) declares the names it assigns, such as the
|
|
335
|
+
* base of an expando `f.prop = value`; in JavaScript, where such statements
|
|
336
|
+
* also define exports, every name and string it spells. */
|
|
337
|
+
function statementNames(statement, js, hooks) {
|
|
338
|
+
const names = declaredNames(statement, js, hooks);
|
|
339
|
+
// A default export also declares the module's `default`, the name a
|
|
340
|
+
// default import holds (Alias), also when it has no name of its own.
|
|
341
|
+
return isDefaultExport(statement) && !names.includes("default") ? [...names, "default"] : names;
|
|
342
|
+
}
|
|
343
|
+
/** Whether `statement` is its module's default export: `export default`
|
|
344
|
+
* or `export =`. */
|
|
345
|
+
function isDefaultExport(statement) {
|
|
346
|
+
if (ts.isExportAssignment(statement))
|
|
347
|
+
return true;
|
|
348
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;
|
|
349
|
+
return modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword) === true;
|
|
350
|
+
}
|
|
351
|
+
/** The names `statement` declares (statementNames), apart from `default`. */
|
|
352
|
+
function declaredNames(statement, js, hooks) {
|
|
353
|
+
if (ts.isVariableStatement(statement)) {
|
|
354
|
+
const names = [];
|
|
355
|
+
for (const declaration of statement.declarationList.declarations.nodes) {
|
|
356
|
+
const name = declaration.name;
|
|
357
|
+
if (ts.isIdentifier(name))
|
|
358
|
+
names.push(name.text);
|
|
359
|
+
else
|
|
360
|
+
ts.walkPreorder(name, (child) => {
|
|
361
|
+
names.push(child.text);
|
|
362
|
+
}, NAME_KINDS);
|
|
363
|
+
}
|
|
364
|
+
return names;
|
|
365
|
+
}
|
|
366
|
+
if (ts.isExportDeclaration(statement) || ts.isExportAssignment(statement)) {
|
|
367
|
+
const names = new Set();
|
|
368
|
+
spelledNames(statement, false, names);
|
|
369
|
+
return [...names].sort();
|
|
370
|
+
}
|
|
371
|
+
const name = nameNodeOf(statement);
|
|
372
|
+
if (name !== undefined && (ts.isIdentifier(name) || ts.isStringLiteral(name)))
|
|
373
|
+
return [name.text];
|
|
374
|
+
if (!js)
|
|
375
|
+
return assignedNames(statement, hooks);
|
|
376
|
+
const names = new Set();
|
|
377
|
+
spelledNames(statement, false, names);
|
|
378
|
+
ts.walkPreorder(statement, (child) => {
|
|
379
|
+
if (ts.isStringLiteral(child))
|
|
380
|
+
names.add(child.text);
|
|
381
|
+
return undefined;
|
|
382
|
+
});
|
|
383
|
+
return [...names].sort();
|
|
384
|
+
}
|
|
385
|
+
/** Whether a statement of a module changes names outside the module:
|
|
386
|
+
* `declare global`, a module augmentation, or `export * from`. */
|
|
387
|
+
function hasGlobalEffect(statement) {
|
|
388
|
+
if (ts.isModuleDeclaration(statement)) {
|
|
389
|
+
const name = statement.name;
|
|
390
|
+
return !ts.isIdentifier(name) || name.text === "global";
|
|
391
|
+
}
|
|
392
|
+
return ts.isExportDeclaration(statement) && statement.exportClause === undefined;
|
|
393
|
+
}
|
|
394
|
+
/** The names a class or interface member declares: its name, or the
|
|
395
|
+
* identifiers a computed name spells. */
|
|
396
|
+
function memberNames(member) {
|
|
397
|
+
const name = nameNodeOf(member);
|
|
398
|
+
if (name === undefined)
|
|
399
|
+
return ts.isConstructorDeclaration(member) ? ["constructor"] : [];
|
|
400
|
+
if (ts.isIdentifier(name) || ts.isPrivateIdentifier(name) || ts.isStringLiteral(name))
|
|
401
|
+
return [name.text];
|
|
402
|
+
const names = new Set();
|
|
403
|
+
spelledNames(name, false, names);
|
|
404
|
+
if (names.size === 0)
|
|
405
|
+
names.add(name.getText());
|
|
406
|
+
return [...names].sort();
|
|
407
|
+
}
|
|
408
|
+
/** The sites in `node` that refer to a module's namespace object: a
|
|
409
|
+
* namespace import or re-export, `import x = require()`, and `import()` and
|
|
410
|
+
* `require()` calls with a string, which `names` stand for. */
|
|
411
|
+
function namespaceSites(sf, statement, names, hooks, out) {
|
|
412
|
+
const add = (specifier, holders) => {
|
|
413
|
+
const exports = hooks.exportsOf(specifier);
|
|
414
|
+
if (exports === null)
|
|
415
|
+
return;
|
|
416
|
+
out.push({
|
|
417
|
+
key: `${specifier.getText(sf)}\n${holders.join(",")}`,
|
|
418
|
+
names: holders,
|
|
419
|
+
exports: digestOf(exports),
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
if (ts.isImportDeclaration(statement)) {
|
|
423
|
+
const bindings = statement.importClause?.namedBindings;
|
|
424
|
+
if (bindings !== undefined && ts.isNamespaceImport(bindings))
|
|
425
|
+
add(statement.moduleSpecifier, [bindings.name.text]);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (ts.isImportEqualsDeclaration(statement)) {
|
|
429
|
+
const reference = statement.moduleReference;
|
|
430
|
+
if (ts.isExternalModuleReference(reference))
|
|
431
|
+
add(reference.expression, [statement.name.text]);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
if (ts.isExportDeclaration(statement)) {
|
|
435
|
+
const clause = statement.exportClause;
|
|
436
|
+
if (clause !== undefined &&
|
|
437
|
+
ts.isNamespaceExport(clause) &&
|
|
438
|
+
statement.moduleSpecifier !== undefined)
|
|
439
|
+
add(statement.moduleSpecifier, [clause.name.getText(sf)]);
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
const text = sf.text.slice(statement.pos, statement.end);
|
|
443
|
+
if (!text.includes("import(") && !text.includes("require("))
|
|
444
|
+
return;
|
|
445
|
+
ts.walkPreorder(statement, (child) => {
|
|
446
|
+
if (!ts.isCallExpression(child))
|
|
447
|
+
return undefined;
|
|
448
|
+
const callee = child.expression;
|
|
449
|
+
const first = child.arguments.nodes[0];
|
|
450
|
+
if (first === undefined || !ts.isStringLiteralLike(first))
|
|
451
|
+
return undefined;
|
|
452
|
+
if (callee.kind === ts.SyntaxKind.ImportKeyword ||
|
|
453
|
+
(ts.isIdentifier(callee) && callee.text === "require"))
|
|
454
|
+
add(first, names);
|
|
455
|
+
return undefined;
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
/** The aliases `statement` makes (Alias). `names` are the names it
|
|
459
|
+
* declares. */
|
|
460
|
+
function aliasesOf(statement, names, out) {
|
|
461
|
+
const add = (from, to) => {
|
|
462
|
+
if (from !== to)
|
|
463
|
+
out.push([from, to]);
|
|
464
|
+
};
|
|
465
|
+
const specifiers = (elements) => {
|
|
466
|
+
for (const element of elements)
|
|
467
|
+
add((element.propertyName ?? element.name).text, element.name.text);
|
|
468
|
+
};
|
|
469
|
+
if (ts.isImportDeclaration(statement)) {
|
|
470
|
+
const clause = statement.importClause;
|
|
471
|
+
if (clause?.name !== undefined)
|
|
472
|
+
add("default", clause.name.text);
|
|
473
|
+
const bindings = clause?.namedBindings;
|
|
474
|
+
if (bindings !== undefined && ts.isNamedImports(bindings))
|
|
475
|
+
specifiers(bindings.elements.nodes);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (ts.isImportEqualsDeclaration(statement)) {
|
|
479
|
+
const reference = statement.moduleReference;
|
|
480
|
+
if (ts.isIdentifier(reference))
|
|
481
|
+
add(reference.text, statement.name.text);
|
|
482
|
+
else if (ts.isQualifiedName(reference))
|
|
483
|
+
add(reference.right.text, statement.name.text);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (ts.isExportDeclaration(statement)) {
|
|
487
|
+
const clause = statement.exportClause;
|
|
488
|
+
if (clause !== undefined && ts.isNamedExports(clause))
|
|
489
|
+
specifiers(clause.elements.nodes);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (isDefaultExport(statement)) {
|
|
493
|
+
for (const name of names)
|
|
494
|
+
add(name, "default");
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
// `const { from: to } = require("...")`.
|
|
498
|
+
if (ts.isVariableStatement(statement))
|
|
499
|
+
for (const declaration of statement.declarationList.declarations.nodes) {
|
|
500
|
+
const initializer = declaration.initializer;
|
|
501
|
+
if (!ts.isObjectBindingPattern(declaration.name) ||
|
|
502
|
+
initializer === undefined ||
|
|
503
|
+
!ts.isCallExpression(initializer) ||
|
|
504
|
+
!ts.isIdentifier(initializer.expression) ||
|
|
505
|
+
initializer.expression.text !== "require")
|
|
506
|
+
continue;
|
|
507
|
+
for (const element of declaration.name.elements.nodes)
|
|
508
|
+
if (element.propertyName !== undefined &&
|
|
509
|
+
ts.isIdentifier(element.propertyName) &&
|
|
510
|
+
ts.isIdentifier(element.name))
|
|
511
|
+
add(element.propertyName.text, element.name.text);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
/** A module's declaration table, its declarations' nodes, and the text of
|
|
515
|
+
* its statements with global effect. A file that is not a module has global
|
|
516
|
+
* effect as a whole. */
|
|
517
|
+
function fileTable(sf, hooks, previous) {
|
|
518
|
+
// A declaration with the text it had in the previous build writes what it
|
|
519
|
+
// wrote then.
|
|
520
|
+
const before = new Map((previous?.declarations ?? []).map((d) => [d.key, d]));
|
|
521
|
+
const assigns = (key, text, node) => {
|
|
522
|
+
const then = before.get(key);
|
|
523
|
+
return then !== undefined && then.text === text ? then.assigns : assignedNames(node, hooks);
|
|
524
|
+
};
|
|
525
|
+
const js = isJsSourceFileName(sf.fileName);
|
|
526
|
+
const declarations = [];
|
|
527
|
+
const namespaces = [];
|
|
528
|
+
const nodes = [];
|
|
529
|
+
const aliases = [];
|
|
530
|
+
const keys = new Set();
|
|
531
|
+
let global = "";
|
|
532
|
+
const unique = (key) => {
|
|
533
|
+
let out = key;
|
|
534
|
+
for (let ordinal = 1; keys.has(out); ordinal++)
|
|
535
|
+
out = `${key}#${ordinal}`;
|
|
536
|
+
keys.add(out);
|
|
537
|
+
return out;
|
|
538
|
+
};
|
|
539
|
+
const module = ts.isExternalModule(sf) || js;
|
|
540
|
+
for (const statement of sf.statements.nodes) {
|
|
541
|
+
if (ts.isImportDeclaration(statement) || ts.isImportEqualsDeclaration(statement)) {
|
|
542
|
+
namespaceSites(sf, statement, [], hooks, namespaces);
|
|
543
|
+
aliasesOf(statement, [], aliases);
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
if (!module || hasGlobalEffect(statement)) {
|
|
547
|
+
global += sf.text.slice(statement.getStart(sf), statement.end) + "\n";
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
const names = statementNames(statement, js, hooks);
|
|
551
|
+
namespaceSites(sf, statement, names, hooks, namespaces);
|
|
552
|
+
aliasesOf(statement, names, aliases);
|
|
553
|
+
const kind = String(statement.kind);
|
|
554
|
+
if (ts.isClassDeclaration(statement) || ts.isInterfaceDeclaration(statement)) {
|
|
555
|
+
// Each member is a declaration of its own; the rest of the class or
|
|
556
|
+
// interface (its name, type parameters, heritage and modifiers) is the
|
|
557
|
+
// header, named by the class, and holds the class's facts.
|
|
558
|
+
const owner = names[0] ?? "";
|
|
559
|
+
const seeds = ts.isInterfaceDeclaration(statement) ? owner : null;
|
|
560
|
+
for (const member of statement.members.nodes) {
|
|
561
|
+
const declared = memberNames(member);
|
|
562
|
+
const key = unique(`${kind}:${owner}.${declared.join(",")}`);
|
|
563
|
+
const text = digestOf(sf.text.slice(member.getStart(sf), member.end));
|
|
564
|
+
declarations.push({
|
|
565
|
+
key,
|
|
566
|
+
names: declared,
|
|
567
|
+
member: true,
|
|
568
|
+
owner: seeds,
|
|
569
|
+
text,
|
|
570
|
+
surface: digestOf(surfaceText(sf, member, js)),
|
|
571
|
+
facts: "",
|
|
572
|
+
assigns: assigns(key, text, member),
|
|
573
|
+
});
|
|
574
|
+
nodes.push({
|
|
575
|
+
names: declared,
|
|
576
|
+
member: true,
|
|
577
|
+
owner: seeds,
|
|
578
|
+
node: member,
|
|
579
|
+
header: false,
|
|
580
|
+
js,
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
const members = statement.members;
|
|
584
|
+
const header = sf.text.slice(statement.getStart(sf), members.pos) +
|
|
585
|
+
sf.text.slice(members.end, statement.end);
|
|
586
|
+
const digest = digestOf(header);
|
|
587
|
+
declarations.push({
|
|
588
|
+
key: unique(`${kind}:${owner}`),
|
|
589
|
+
names,
|
|
590
|
+
member: false,
|
|
591
|
+
owner: null,
|
|
592
|
+
text: digest,
|
|
593
|
+
surface: digest,
|
|
594
|
+
facts: digestOf(hooks.facts(statement)),
|
|
595
|
+
assigns: [],
|
|
596
|
+
});
|
|
597
|
+
nodes.push({ names, member: false, owner: null, node: statement, header: true, js });
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
const digest = digestOf(sf.text.slice(statement.getStart(sf), statement.end));
|
|
601
|
+
const key = unique(`${kind}:${names.join(",")}`);
|
|
602
|
+
declarations.push({
|
|
603
|
+
key,
|
|
604
|
+
names,
|
|
605
|
+
member: false,
|
|
606
|
+
owner: null,
|
|
607
|
+
text: digest,
|
|
608
|
+
surface: js ? digest : digestOf(surfaceText(sf, statement, js)),
|
|
609
|
+
facts: digestOf(hooks.facts(statement)),
|
|
610
|
+
assigns: assigns(key, digest, statement),
|
|
611
|
+
});
|
|
612
|
+
nodes.push({ names, member: false, owner: null, node: statement, header: false, js });
|
|
613
|
+
}
|
|
614
|
+
return {
|
|
615
|
+
table: {
|
|
616
|
+
path: sf.fileName,
|
|
617
|
+
text: digestOf(sf.text),
|
|
618
|
+
entry: "",
|
|
619
|
+
declarations,
|
|
620
|
+
namespaces,
|
|
621
|
+
},
|
|
622
|
+
nodes,
|
|
623
|
+
aliases,
|
|
624
|
+
global,
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
/** The names a declaration's surface spells: a JavaScript declaration's
|
|
628
|
+
* whole text, a header without its members. */
|
|
629
|
+
function surfaceNames(declaration) {
|
|
630
|
+
const names = new Set();
|
|
631
|
+
if (!declaration.header) {
|
|
632
|
+
spelledNames(declaration.node, !declaration.js, names);
|
|
633
|
+
return names;
|
|
634
|
+
}
|
|
635
|
+
const members = new Set(declaration.node.members.nodes);
|
|
636
|
+
ts.walkPreorder(declaration.node, (child) => {
|
|
637
|
+
if (members.has(child))
|
|
638
|
+
return "skip";
|
|
639
|
+
if (ts.isIdentifier(child) || ts.isPrivateIdentifier(child))
|
|
640
|
+
names.add(child.text);
|
|
641
|
+
return undefined;
|
|
642
|
+
});
|
|
643
|
+
return names;
|
|
644
|
+
}
|
|
645
|
+
/** What a build knows about the units it lowers, and what it writes. */
|
|
646
|
+
export class UnitReuse {
|
|
647
|
+
store;
|
|
648
|
+
program;
|
|
649
|
+
tables;
|
|
650
|
+
/** Whether this build records its units. A build that finds no program
|
|
651
|
+
* entry, the first one into a cache, records none: it lowers as a build
|
|
652
|
+
* without reuse does and writes only the declaration tables, so that
|
|
653
|
+
* recording costs the next build instead. */
|
|
654
|
+
records;
|
|
655
|
+
/** The previous build's tables by path, when its program digest matches. */
|
|
656
|
+
previous;
|
|
657
|
+
/** The names whose declarations changed since the previous build. */
|
|
658
|
+
changed;
|
|
659
|
+
/** The decoded file entries by path. */
|
|
660
|
+
decoded = new Map();
|
|
661
|
+
/** The records this build made or applied, by file path, in unit order. */
|
|
662
|
+
written = new Map();
|
|
663
|
+
/** Files whose units this build lowered. */
|
|
664
|
+
rewritten = new Set();
|
|
665
|
+
/** Counts, and the time opening (tables and changed names) and finishing
|
|
666
|
+
* (writing entries) took, in milliseconds. */
|
|
667
|
+
stats = {
|
|
668
|
+
candidates: 0,
|
|
669
|
+
hits: 0,
|
|
670
|
+
misses: 0,
|
|
671
|
+
changedNames: 0,
|
|
672
|
+
openMs: 0,
|
|
673
|
+
readMs: 0,
|
|
674
|
+
finishMs: 0,
|
|
675
|
+
/** Functions this build stored in the binary encoding, and as JSON, and
|
|
676
|
+
* the time making their units' entries took. */
|
|
677
|
+
binary: 0,
|
|
678
|
+
json: 0,
|
|
679
|
+
storeMs: 0,
|
|
680
|
+
};
|
|
681
|
+
constructor(store, program, tables, previous, nodes, aliases) {
|
|
682
|
+
this.store = store;
|
|
683
|
+
this.program = program;
|
|
684
|
+
this.tables = tables;
|
|
685
|
+
this.previous = previous !== null && previous.program === program ? previous.tables : null;
|
|
686
|
+
this.records = previous !== null;
|
|
687
|
+
this.changed =
|
|
688
|
+
this.previous === null ? new Set() : changedNames(this.previous, tables, nodes, aliases);
|
|
689
|
+
this.stats.changedNames = this.changed.size;
|
|
690
|
+
}
|
|
691
|
+
/** Opens reuse for a build of `files`, the program's own modules in
|
|
692
|
+
* module order, within `program`. */
|
|
693
|
+
static open(store, program, files, hooks) {
|
|
694
|
+
const started = performance.now();
|
|
695
|
+
const own = new Set(files);
|
|
696
|
+
const tables = new Map();
|
|
697
|
+
const nodes = [];
|
|
698
|
+
const aliases = [];
|
|
699
|
+
const previous = readProgram(store);
|
|
700
|
+
const digest = createHash("sha256").update(`${PROGRAM_MAGIC}\n${IR_VERSION}\n${IR_CODEC_LAYOUT}\n`);
|
|
701
|
+
for (const sf of files) {
|
|
702
|
+
const file = fileTable(sf, hooks, previous?.tables.get(sf.fileName));
|
|
703
|
+
tables.set(sf.fileName, file.table);
|
|
704
|
+
for (const node of file.nodes)
|
|
705
|
+
nodes.push(node);
|
|
706
|
+
for (const alias of file.aliases)
|
|
707
|
+
aliases.push(alias);
|
|
708
|
+
digest.update(`${sf.fileName}\n${digestOf(file.global)}\n`);
|
|
709
|
+
}
|
|
710
|
+
const others = program
|
|
711
|
+
.getSourceFiles()
|
|
712
|
+
.filter((sf) => !own.has(sf))
|
|
713
|
+
.map((sf) => `${sf.fileName}\n${digestOf(sf.text)}\n`)
|
|
714
|
+
.sort();
|
|
715
|
+
for (const other of others)
|
|
716
|
+
digest.update(other);
|
|
717
|
+
const reuse = new UnitReuse(store, digest.digest("hex"), tables, previous, nodes, aliases);
|
|
718
|
+
reuse.stats.openMs = performance.now() - started;
|
|
719
|
+
return reuse;
|
|
720
|
+
}
|
|
721
|
+
/** The stored record of unit `name`, whose text is `source` in `file`
|
|
722
|
+
* inside the declarations `owners`, when the unit can apply it. */
|
|
723
|
+
candidate(name, file, source, owners) {
|
|
724
|
+
if (this.previous === null || source === null)
|
|
725
|
+
return null;
|
|
726
|
+
const before = this.previous.get(file);
|
|
727
|
+
const now = this.tables.get(file);
|
|
728
|
+
if (before === undefined ||
|
|
729
|
+
now === undefined ||
|
|
730
|
+
before.text !== now.text ||
|
|
731
|
+
before.entry === "")
|
|
732
|
+
return null;
|
|
733
|
+
let units = this.decoded.get(file);
|
|
734
|
+
if (units === undefined) {
|
|
735
|
+
const started = performance.now();
|
|
736
|
+
units = readFileEntry(this.store, before.entry);
|
|
737
|
+
this.decoded.set(file, units);
|
|
738
|
+
this.stats.readMs += performance.now() - started;
|
|
739
|
+
}
|
|
740
|
+
const stored = units?.get(name);
|
|
741
|
+
if (stored === undefined)
|
|
742
|
+
return null;
|
|
743
|
+
this.stats.candidates++;
|
|
744
|
+
for (const other of stored.files) {
|
|
745
|
+
const then = this.previous.get(other);
|
|
746
|
+
if (then === undefined || then.text !== this.tables.get(other)?.text)
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
if (this.changed.size > 0) {
|
|
750
|
+
const names = new Set();
|
|
751
|
+
spelledNames(source, false, names);
|
|
752
|
+
// A string can name a member too (`value["name"]`, `keyof` types).
|
|
753
|
+
ts.walkPreorder(source, (child) => {
|
|
754
|
+
names.add(child.text);
|
|
755
|
+
}, STRING_KINDS);
|
|
756
|
+
for (const owner of owners) {
|
|
757
|
+
const ownerName = nameNodeOf(owner);
|
|
758
|
+
if (ownerName !== undefined && ts.isIdentifier(ownerName))
|
|
759
|
+
names.add(ownerName.text);
|
|
760
|
+
}
|
|
761
|
+
for (const spelled of names)
|
|
762
|
+
if (this.changed.has(spelled))
|
|
763
|
+
return null;
|
|
764
|
+
}
|
|
765
|
+
return storedRecord(stored);
|
|
766
|
+
}
|
|
767
|
+
/** Notes the record a unit of `file` lowered to, with the files its
|
|
768
|
+
* binary function names (RecordedUnit.files), or the stored record it
|
|
769
|
+
* applied (`applied`). A unit without a record is noted with null. */
|
|
770
|
+
note(name, file, record, applied, files) {
|
|
771
|
+
let units = this.written.get(file);
|
|
772
|
+
if (units === undefined) {
|
|
773
|
+
units = new Map();
|
|
774
|
+
this.written.set(file, units);
|
|
775
|
+
}
|
|
776
|
+
if (record !== null) {
|
|
777
|
+
let unit = applied ? this.decoded.get(file)?.get(name) : undefined;
|
|
778
|
+
if (unit === undefined) {
|
|
779
|
+
const started = performance.now();
|
|
780
|
+
unit = storedUnit(record, files, file);
|
|
781
|
+
this.stats.storeMs += performance.now() - started;
|
|
782
|
+
if (unit.bytes !== null)
|
|
783
|
+
this.stats.binary++;
|
|
784
|
+
else if (unit.record.fn !== null)
|
|
785
|
+
this.stats.json++;
|
|
786
|
+
}
|
|
787
|
+
units.set(name, unit);
|
|
788
|
+
}
|
|
789
|
+
if (applied)
|
|
790
|
+
this.stats.hits++;
|
|
791
|
+
else {
|
|
792
|
+
this.stats.misses++;
|
|
793
|
+
this.rewritten.add(file);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
/** Writes the file entries of files whose units changed and the program
|
|
797
|
+
* entry. A file none of whose units this build lowered or applied keeps
|
|
798
|
+
* no entry. */
|
|
799
|
+
finish() {
|
|
800
|
+
const started = performance.now();
|
|
801
|
+
for (const [path, table] of this.tables) {
|
|
802
|
+
const units = this.written.get(path);
|
|
803
|
+
if (units === undefined || units.size === 0)
|
|
804
|
+
continue;
|
|
805
|
+
const before = this.previous?.get(path);
|
|
806
|
+
const unchanged = before !== undefined &&
|
|
807
|
+
before.text === table.text &&
|
|
808
|
+
before.entry !== "" &&
|
|
809
|
+
!this.rewritten.has(path) &&
|
|
810
|
+
this.decoded.get(path)?.size === units.size;
|
|
811
|
+
table.entry = unchanged ? before.entry : this.store.writeFile(encodeFileEntry(units));
|
|
812
|
+
}
|
|
813
|
+
this.store.writeProgram(encodeProgramEntry(this.program, this.tables));
|
|
814
|
+
this.stats.finishMs = performance.now() - started;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
/** The changed names of a build (see the comment at the top) from the
|
|
818
|
+
* previous build's tables and this build's. */
|
|
819
|
+
function changedNames(before, now, nodes, aliases) {
|
|
820
|
+
const surfaces = new Set();
|
|
821
|
+
const direct = new Set();
|
|
822
|
+
// Text reaches a member through a value whose type names its owner, so a
|
|
823
|
+
// member with another type stops the units that spell it, and an
|
|
824
|
+
// interface's member gives the interface another type. A class's own type
|
|
825
|
+
// changes with its header's facts.
|
|
826
|
+
const typeChanged = (declaration) => {
|
|
827
|
+
for (const name of declaration.names)
|
|
828
|
+
(declaration.member ? direct : surfaces).add(name);
|
|
829
|
+
if (declaration.owner !== null)
|
|
830
|
+
surfaces.add(declaration.owner);
|
|
831
|
+
};
|
|
832
|
+
const compare = (from, to) => {
|
|
833
|
+
const old = new Map((from?.declarations ?? []).map((d) => [d.key, d]));
|
|
834
|
+
const seen = new Set();
|
|
835
|
+
for (const declaration of to?.declarations ?? []) {
|
|
836
|
+
seen.add(declaration.key);
|
|
837
|
+
const previous = old.get(declaration.key);
|
|
838
|
+
if (previous === undefined ||
|
|
839
|
+
previous.surface !== declaration.surface ||
|
|
840
|
+
previous.facts !== declaration.facts)
|
|
841
|
+
typeChanged(declaration);
|
|
842
|
+
else if (previous.text !== declaration.text)
|
|
843
|
+
for (const name of declaration.names)
|
|
844
|
+
direct.add(name);
|
|
845
|
+
else
|
|
846
|
+
continue;
|
|
847
|
+
for (const name of declaration.assigns)
|
|
848
|
+
direct.add(name);
|
|
849
|
+
for (const name of previous?.assigns ?? [])
|
|
850
|
+
direct.add(name);
|
|
851
|
+
}
|
|
852
|
+
for (const declaration of from?.declarations ?? [])
|
|
853
|
+
if (!seen.has(declaration.key)) {
|
|
854
|
+
typeChanged(declaration);
|
|
855
|
+
for (const name of declaration.assigns)
|
|
856
|
+
direct.add(name);
|
|
857
|
+
}
|
|
858
|
+
const sites = new Map((from?.namespaces ?? []).map((site) => [site.key, site.exports]));
|
|
859
|
+
for (const site of to?.namespaces ?? [])
|
|
860
|
+
if (sites.get(site.key) !== site.exports)
|
|
861
|
+
for (const name of site.names)
|
|
862
|
+
surfaces.add(name);
|
|
863
|
+
};
|
|
864
|
+
for (const [path, table] of now)
|
|
865
|
+
compare(before.get(path), table);
|
|
866
|
+
for (const [path, table] of before)
|
|
867
|
+
if (!now.has(path))
|
|
868
|
+
compare(table, undefined);
|
|
869
|
+
// A name that holds a changed name under another name changes the same
|
|
870
|
+
// way (Alias).
|
|
871
|
+
const follow = () => {
|
|
872
|
+
let grew = false;
|
|
873
|
+
for (const [from, to] of aliases) {
|
|
874
|
+
if (surfaces.has(from) && !surfaces.has(to)) {
|
|
875
|
+
surfaces.add(to);
|
|
876
|
+
grew = true;
|
|
877
|
+
}
|
|
878
|
+
if (direct.has(from) && !direct.has(to)) {
|
|
879
|
+
direct.add(to);
|
|
880
|
+
grew = true;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
return grew;
|
|
884
|
+
};
|
|
885
|
+
let pending = null;
|
|
886
|
+
for (let grew = true; grew;) {
|
|
887
|
+
grew = follow();
|
|
888
|
+
if (surfaces.size === 0)
|
|
889
|
+
continue;
|
|
890
|
+
// A declaration whose surface spells a changed name can have another
|
|
891
|
+
// type now (typeChanged); repeat until no surface or alias adds a name.
|
|
892
|
+
pending ??= nodes.map((declaration) => ({
|
|
893
|
+
declaration,
|
|
894
|
+
spells: surfaceNames(declaration),
|
|
895
|
+
}));
|
|
896
|
+
for (let index = 0; index < pending.length; index++) {
|
|
897
|
+
const entry = pending[index];
|
|
898
|
+
let hit = false;
|
|
899
|
+
for (const name of entry.spells)
|
|
900
|
+
if (surfaces.has(name)) {
|
|
901
|
+
hit = true;
|
|
902
|
+
break;
|
|
903
|
+
}
|
|
904
|
+
if (!hit)
|
|
905
|
+
continue;
|
|
906
|
+
typeChanged(entry.declaration);
|
|
907
|
+
// Each declaration joins once.
|
|
908
|
+
pending[index] = pending[pending.length - 1];
|
|
909
|
+
pending.pop();
|
|
910
|
+
index--;
|
|
911
|
+
grew = true;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
for (const name of direct)
|
|
915
|
+
surfaces.add(name);
|
|
916
|
+
return surfaces;
|
|
917
|
+
}
|
|
918
|
+
function encodeProgramEntry(program, tables) {
|
|
919
|
+
const lines = [PROGRAM_MAGIC, program];
|
|
920
|
+
for (const table of tables.values())
|
|
921
|
+
lines.push(JSON.stringify(table));
|
|
922
|
+
return Buffer.from(lines.join("\n"), "utf8");
|
|
923
|
+
}
|
|
924
|
+
function readProgram(store) {
|
|
925
|
+
const bytes = store.readProgram();
|
|
926
|
+
if (bytes === null)
|
|
927
|
+
return null;
|
|
928
|
+
try {
|
|
929
|
+
const lines = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength)
|
|
930
|
+
.toString("utf8")
|
|
931
|
+
.split("\n");
|
|
932
|
+
if (lines[0] !== PROGRAM_MAGIC || lines.length < 2)
|
|
933
|
+
return null;
|
|
934
|
+
const tables = new Map();
|
|
935
|
+
for (const line of lines.slice(2)) {
|
|
936
|
+
const table = JSON.parse(line);
|
|
937
|
+
tables.set(table.path, table);
|
|
938
|
+
}
|
|
939
|
+
return { program: lines[1], tables };
|
|
940
|
+
}
|
|
941
|
+
catch {
|
|
942
|
+
// An unreadable entry is a miss.
|
|
943
|
+
return null;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
/** A file entry: per stored unit, the unit without its function's bytes as
|
|
947
|
+
* JSON, then the bytes when it has them. */
|
|
948
|
+
function encodeFileEntry(units) {
|
|
949
|
+
const w = new IrWriter();
|
|
950
|
+
w.str(FILE_MAGIC);
|
|
951
|
+
w.length(units.size);
|
|
952
|
+
for (const unit of units.values()) {
|
|
953
|
+
w.str(JSON.stringify({ record: unit.record, files: unit.files }));
|
|
954
|
+
if (unit.bytes === null)
|
|
955
|
+
w.byte(0);
|
|
956
|
+
else {
|
|
957
|
+
w.byte(1);
|
|
958
|
+
w.blob(unit.bytes);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return w.finish();
|
|
962
|
+
}
|
|
963
|
+
function readFileEntry(store, name) {
|
|
964
|
+
const bytes = store.readFile(name);
|
|
965
|
+
if (bytes === null)
|
|
966
|
+
return null;
|
|
967
|
+
try {
|
|
968
|
+
const r = new IrReader(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength));
|
|
969
|
+
if (r.str() !== FILE_MAGIC)
|
|
970
|
+
return null;
|
|
971
|
+
const units = new Map();
|
|
972
|
+
for (let count = r.length(); count > 0; count--) {
|
|
973
|
+
const unit = JSON.parse(r.str());
|
|
974
|
+
const fn = r.byte() === 0 ? null : r.blob();
|
|
975
|
+
units.set(unit.record.name, { record: unit.record, files: unit.files, bytes: fn });
|
|
976
|
+
}
|
|
977
|
+
return r.done() ? units : null;
|
|
978
|
+
}
|
|
979
|
+
catch {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
/** Throws when a unit lowered to another record than its stored one
|
|
984
|
+
* (SCRIPTC_INCR_VERIFY=1), naming the unit and the first part that
|
|
985
|
+
* differs. `pending` is the stored record's entries the tables did not hold
|
|
986
|
+
* at the unit's turn. */
|
|
987
|
+
export function verifyStoredUnit(name, storedRecord, pending, lowered, reasons) {
|
|
988
|
+
const stored = storedRecord.record;
|
|
989
|
+
const fail = (what) => {
|
|
990
|
+
throw new InternalCompilerError(`SCRIPTC_INCR_VERIFY: unit ${name} lowered to another ${what} than its stored record`);
|
|
991
|
+
};
|
|
992
|
+
if (lowered === null)
|
|
993
|
+
return fail(`result (no record: ${reasons.join(", ")})`);
|
|
994
|
+
if (lowered.poisoned !== stored.poisoned)
|
|
995
|
+
fail("poison");
|
|
996
|
+
// As JSON text, which keeps key order, whichever encoding each record has.
|
|
997
|
+
const text = (fn) => fn === null ? null : (encodeUnitFunction(fn) ?? "");
|
|
998
|
+
const loweredFn = lowered.fn === null ? null : decodeRecordFunction(lowered.fn);
|
|
999
|
+
if (text(loweredFn) !== text(storedRecord.fn()))
|
|
1000
|
+
fail("function");
|
|
1001
|
+
if (JSON.stringify(lowered.events) !== JSON.stringify(stored.events))
|
|
1002
|
+
fail("event list");
|
|
1003
|
+
// A stored entry the tables hold already is one an earlier unit of this
|
|
1004
|
+
// build added: applying the record leaves it as it is.
|
|
1005
|
+
if (JSON.stringify(lowered.tables) !== JSON.stringify(pending))
|
|
1006
|
+
fail("table entries");
|
|
1007
|
+
}
|
|
1008
|
+
//# sourceMappingURL=unit-reuse.js.map
|