@scriptc/compiler 0.4.7 → 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 +23 -5
- package/ambient/node-fallback/fs.d.ts +3 -2
- package/ambient/node-fallback/http.d.ts +23 -17
- package/ambient/node-fallback/https.d.ts +5 -2
- package/ambient/node-fallback/net.d.ts +6 -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/zlib.d.ts +31 -2
- package/ambient/scriptc-node-fallback.d.ts +37 -7
- package/ambient/scriptc.d.ts +7 -2
- package/dist/backend/executable-features.js +11 -3
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/library-pack.d.ts +6 -0
- package/dist/backend/library-pack.js +17 -6
- 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 +9 -2
- package/dist/backend/linker.js +190 -32
- package/dist/backend/linker.js.map +1 -1
- package/dist/backend/lld.d.ts +8 -4
- package/dist/backend/lld.js +19 -13
- package/dist/backend/lld.js.map +1 -1
- package/dist/backend/lld.test.js +3 -1
- 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/cpu-dispatch.d.ts +15 -5
- package/dist/backend/llvm/cpu-dispatch.js +31 -7
- package/dist/backend/llvm/cpu-dispatch.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +12 -3
- package/dist/backend/llvm/dyn.js +31 -7
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +67 -4
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +90 -39
- 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 +99 -15
- package/dist/backend/llvm/emit-statements.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +113 -8
- package/dist/backend/llvm/emitter.js +438 -67
- 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.js +18 -2
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +31 -10
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +31 -3
- 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.js +17 -0
- package/dist/backend/llvm/expr-stream-bridges.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 +19 -1
- package/dist/backend/llvm/js-ic.js +96 -23
- package/dist/backend/llvm/js-ic.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +132 -1
- package/dist/backend/llvm/lib-dispatch.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 +44 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +69 -2
- package/dist/backend/llvm/lib-shared.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-state.js +7 -2
- 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.test.js +6 -6
- 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/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.js +12 -6
- package/dist/backend/llvm/record-views.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 +3 -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 +33 -3
- package/dist/backend/llvm/shapes.js +183 -13
- package/dist/backend/llvm/shapes.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/walkers.d.ts +12 -0
- package/dist/backend/llvm/walkers.js +46 -2
- 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 +48 -8
- package/dist/backend/native/executable.js +55 -13
- 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 +9 -1
- package/dist/backend/native/library.js.map +1 -1
- package/dist/backend/native/runtime-inputs.js +4 -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 +27 -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 +37 -8
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/runtime-pack-core.d.ts +17 -2
- package/dist/backend/runtime-pack-core.js +18 -3
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +211 -2
- 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 +5 -1
- package/dist/backend/vendor-archives.js +51 -7
- package/dist/backend/vendor-archives.js.map +1 -1
- package/dist/backend/vendor-inputs.d.ts +25 -4
- package/dist/backend/vendor-inputs.js +68 -4
- package/dist/backend/vendor-inputs.js.map +1 -1
- package/dist/backend/vendor-inputs.test.js +35 -1
- package/dist/backend/vendor-inputs.test.js.map +1 -1
- package/dist/backend/warm-cache.js +1 -1
- package/dist/backend/warm-cache.js.map +1 -1
- package/dist/compat/fetch-profile.js +2 -2
- 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/diagnostics/codes.d.ts +8 -0
- package/dist/diagnostics/codes.js +8 -0
- package/dist/diagnostics/codes.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +27 -9
- package/dist/diagnostics/diagnostic.js +60 -19
- package/dist/diagnostics/diagnostic.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 +21 -2
- package/dist/executable/executable-cache.js +21 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +123 -1
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/executable/prepare.js +199 -248
- 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 +12 -2
- package/dist/frontend/early-errors.js +535 -4
- package/dist/frontend/early-errors.js.map +1 -1
- package/dist/frontend/early-errors.test.js +165 -0
- package/dist/frontend/early-errors.test.js.map +1 -1
- package/dist/frontend/inferred-js-diagnostics.test.js +65 -0
- package/dist/frontend/inferred-js-diagnostics.test.js.map +1 -1
- 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.js +21 -3
- 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 +4 -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 +24 -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.js +2 -2
- 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 +560 -27
- 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/filesystem-calls.d.ts +1 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +28 -2
- package/dist/frontend/lowering/builtins/filesystem-calls.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 +3 -1
- package/dist/frontend/lowering/builtins/module-calls.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 +6 -3
- package/dist/frontend/lowering/builtins/operating-system.js +96 -16
- package/dist/frontend/lowering/builtins/operating-system.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +2 -2
- package/dist/frontend/lowering/builtins/process.js +103 -8
- 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/readline.d.ts +6 -4
- package/dist/frontend/lowering/builtins/readline.js +180 -36
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/url.js +35 -12
- package/dist/frontend/lowering/builtins/url.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 +103 -0
- package/dist/frontend/lowering/call-signatures.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 +9 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +1283 -1030
- 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-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 +20 -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/coercions/function-adapters.js +9 -0
- package/dist/frontend/lowering/coercions/function-adapters.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +8 -0
- package/dist/frontend/lowering/coercions/state.js +17 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural-plans.js +20 -5
- package/dist/frontend/lowering/coercions/structural-plans.js.map +1 -1
- package/dist/frontend/lowering/coercions/structural.js +10 -1
- 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.js +156 -62
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +21 -3
- 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 +14 -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 +446 -86
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.d.ts +5 -0
- package/dist/frontend/lowering/containers/callback-arguments.js +21 -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/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 +10 -0
- package/dist/frontend/lowering/expressions/array-literals.js +62 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +115 -5
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +151 -7
- 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 +31 -2
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/narrowing.d.ts +3 -0
- package/dist/frontend/lowering/expressions/narrowing.js +175 -22
- package/dist/frontend/lowering/expressions/narrowing.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +173 -11
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/optional-chains.js +5 -1
- package/dist/frontend/lowering/expressions/optional-chains.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.d.ts +8 -0
- package/dist/frontend/lowering/expressions/property-access.js +379 -109
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/relational.js +237 -7
- package/dist/frontend/lowering/expressions/relational.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +8 -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 +74 -55
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +37 -10
- 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 +27 -1
- package/dist/frontend/lowering/generic-functions.js +432 -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 +6 -4
- package/dist/frontend/lowering/global-values.js +24 -10
- package/dist/frontend/lowering/global-values.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.js +43 -22
- 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 +11 -3
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +30 -15
- 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.js +11 -1
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +25 -0
- package/dist/frontend/lowering/lower-calls.js +929 -227
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.test.js +59 -16
- package/dist/frontend/lowering/lower-calls.test.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +20 -0
- package/dist/frontend/lowering/lower-classes.js +468 -44
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.d.ts +6 -2
- package/dist/frontend/lowering/lower-event-emitter.js +253 -83
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
- package/dist/frontend/lowering/lower-exprs.js +71 -20
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.js +25 -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 +638 -64
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +48 -2
- 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.js +16 -6
- package/dist/frontend/lowering/lower-node-island.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +303 -87
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stdlib.js +45 -0
- package/dist/frontend/lowering/lower-stdlib.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +14 -11
- package/dist/frontend/lowering/lower-stmts.js +270 -52
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-timers.js +110 -27
- 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 +227 -21
- package/dist/frontend/lowering/lowerer.js +651 -92
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/lowerer.test.js +18 -0
- 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/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/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 +0 -3
- package/dist/frontend/lowering/partial-assertions.js +9 -15
- package/dist/frontend/lowering/partial-assertions.js.map +1 -1
- 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.js +1 -0
- package/dist/frontend/lowering/primitive-wrappers.js.map +1 -1
- 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/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-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 +15 -1
- package/dist/frontend/lowering/surfaces.js +78 -10
- 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 +8 -0
- package/dist/frontend/lowering/unit-journal.js +14 -0
- package/dist/frontend/lowering/unit-journal.js.map +1 -1
- package/dist/frontend/lowering/unit-journal.test.js +36 -1
- package/dist/frontend/lowering/unit-journal.test.js.map +1 -1
- package/dist/frontend/lowering/zlib-constants.js +3 -2
- package/dist/frontend/lowering/zlib-constants.js.map +1 -1
- package/dist/frontend/npm-static.js +78 -9
- 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/pipeline.d.ts +5 -4
- package/dist/frontend/pipeline.js +94 -31
- 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.d.ts +62 -2
- package/dist/frontend/program.js +695 -422
- 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/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/shape-inference/overlay.js +68 -2
- package/dist/frontend/shape-inference/overlay.js.map +1 -1
- 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/tsc-codes.d.ts +57 -3
- package/dist/frontend/tsc-codes.js +935 -150
- 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 +91 -9
- package/dist/frontend/type-mapper.js +622 -181
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +80 -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/builtin-effects.js +43 -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 +242 -16
- 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.generated.d.ts +1 -1
- package/dist/ir/codec.generated.js +724 -648
- package/dist/ir/codec.generated.js.map +1 -1
- 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 +11 -2
- package/dist/ir/fields.generated.js +8 -0
- package/dist/ir/fields.generated.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 +5 -4
- package/dist/ir/function-references.js +7 -4
- package/dist/ir/function-references.js.map +1 -1
- package/dist/ir/function-references.test.js +7 -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-views.js +1 -0
- package/dist/ir/inline-array-views.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/ir.d.ts +59 -4
- 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.js +30 -5
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +27 -1
- package/dist/ir/js-ic.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 -4
- package/dist/ir/parameter-versions.js +63 -42
- 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/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 +87 -12
- package/dist/ir/runtime-features.js +263 -160
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +109 -139
- 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 +4 -2
- package/dist/ir/saturating-loop-jams.js +11 -10
- package/dist/ir/saturating-loop-jams.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 +32 -27
- package/dist/ir/self-captures.js.map +1 -1
- package/dist/ir/serialize.d.ts +6 -1
- package/dist/ir/serialize.js +87 -23
- 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 +88 -18
- package/dist/ir/validate.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 +1 -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 +47 -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 +1 -1
- package/dist/native/cli.js.map +1 -1
- package/dist/native/compiler.js +18 -3
- 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 +43 -26
- 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 +10 -1
- package/dist/native/sanitizer.js.map +1 -1
- package/dist/native/sanitizer.test.js +7 -2
- package/dist/native/sanitizer.test.js.map +1 -1
- package/dist/node-islands/boundary.d.ts +12 -0
- package/dist/node-islands/boundary.js +38 -6
- 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 +9 -0
- package/dist/node-islands/detect.js +110 -0
- package/dist/node-islands/detect.js.map +1 -1
- package/dist/node-islands/detect.test.js +24 -0
- package/dist/node-islands/detect.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/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 +2 -0
- package/dist/node-islands/report.test.js.map +1 -1
- package/dist/node-islands/rules.js +5 -0
- package/dist/node-islands/rules.js.map +1 -1
- package/dist/node-islands/scan.d.ts +11 -2
- package/dist/node-islands/scan.js +61 -9
- package/dist/node-islands/scan.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 +184 -117
|
@@ -0,0 +1,797 @@
|
|
|
1
|
+
/* Links from narrowed record copies to their sources.
|
|
2
|
+
*
|
|
3
|
+
* TypeScript lets an object with more properties be assigned to a narrower
|
|
4
|
+
* record type; Node keeps the one object. A conversion into a narrower
|
|
5
|
+
* record type builds a copy with the declared fields, so when the source
|
|
6
|
+
* type has properties the target lacks, the copy links to its source
|
|
7
|
+
* (record.link, a native table entry released with the copy). Each such
|
|
8
|
+
* (source type, target type) pair has a number and a compose helper that
|
|
9
|
+
* answers a record of the source type from the copy and its source: the
|
|
10
|
+
* copy's values for the fields both declare, the source's for the others.
|
|
11
|
+
* A reflective surface over the target type (keys, for...in, `in`, the
|
|
12
|
+
* own-key tests, string conversion, Object.values and Object.entries,
|
|
13
|
+
* JSON, inspect and checked views) answers for a linked copy as it does
|
|
14
|
+
* for the composed record, and for any other value as before. Only
|
|
15
|
+
* conversions into a type such a surface can observe link their copies
|
|
16
|
+
* (finalizeRecordLinks); programs without them are unchanged. */
|
|
17
|
+
import { varRef } from "../../ir/build.js";
|
|
18
|
+
import { BOOL, DYN, F64, KEY_ORDER_FIELD, STRING, arrayOf, shapeKeyOrders, typeEquals, typeKey, } from "../../ir/ir.js";
|
|
19
|
+
import { everyStmtList, transformStmtList } from "../../ir/traverse.js";
|
|
20
|
+
import { keyedHelperName } from "./stable-names.js";
|
|
21
|
+
import { recordHasOwnHelper, recordKeysArrayCall } from "./lower-calls.js";
|
|
22
|
+
import { callOwn, callOwnOrBuiltin } from "./record-inherited.js";
|
|
23
|
+
import { recordMayKeepSource } from "./record-sources.js";
|
|
24
|
+
import { inspectHelperCall } from "./lower-inspect.js";
|
|
25
|
+
import { InternalCompilerError } from "../../errors.js";
|
|
26
|
+
import { unsupportedDiag } from "../../diagnostics/diagnostic.js";
|
|
27
|
+
/** The link pair of a conversion from record type `from` into the record
|
|
28
|
+
* type `to`, or null when the conversion keeps no link: the target is a
|
|
29
|
+
* plain closed record and the source has a field it does not declare. */
|
|
30
|
+
export function recordLinkPair(lowerer, from, to, loc) {
|
|
31
|
+
const key = `${from}:${to}`;
|
|
32
|
+
const known = lowerer.recordLinks.get(key);
|
|
33
|
+
if (known)
|
|
34
|
+
return known;
|
|
35
|
+
const source = lowerer.shapes.get(from);
|
|
36
|
+
const target = lowerer.shapes.get(to);
|
|
37
|
+
if (!source ||
|
|
38
|
+
!target ||
|
|
39
|
+
source.tuple ||
|
|
40
|
+
target.tuple ||
|
|
41
|
+
source.indexValue !== undefined ||
|
|
42
|
+
target.indexValue !== undefined ||
|
|
43
|
+
target.fields.length === 0 ||
|
|
44
|
+
target.fields.some((field) => field.name.startsWith("%")) ||
|
|
45
|
+
source.fields.some((field) => field.name.startsWith("%")))
|
|
46
|
+
return null;
|
|
47
|
+
const declared = new Set(target.fields.map((field) => field.name));
|
|
48
|
+
if (!source.fields.some((field) => !declared.has(field.name)))
|
|
49
|
+
return null;
|
|
50
|
+
// The surfaces route through the link helpers only for record types
|
|
51
|
+
// that can carry a source.
|
|
52
|
+
if (!recordMayKeepSource(lowerer, { kind: "record", shapeId: to }))
|
|
53
|
+
return null;
|
|
54
|
+
const compose = keyedHelperName(lowerer, "%rec.compose", `compose:${key}`);
|
|
55
|
+
const link = { pair: lowerer.recordLinks.size + 1, from, to, compose };
|
|
56
|
+
lowerer.recordLinks.set(key, link);
|
|
57
|
+
lowerer.recordLinkLocs.set(compose, loc);
|
|
58
|
+
return link;
|
|
59
|
+
}
|
|
60
|
+
/** Notes that the conversion helper `projection` builds copies of the
|
|
61
|
+
* link's pair. finalizeRecordLinks makes it link each copy to its source
|
|
62
|
+
* when a reflective surface can observe the copy's type. */
|
|
63
|
+
export function registerLinkSite(lowerer, link, projection) {
|
|
64
|
+
lowerer.recordLinkSites.push({ link, projection });
|
|
65
|
+
}
|
|
66
|
+
/** The links whose copies have record type `to`, in pair order. */
|
|
67
|
+
export function recordLinksInto(lowerer, to) {
|
|
68
|
+
return [...lowerer.recordLinks.values()].filter((link) => link.to === to);
|
|
69
|
+
}
|
|
70
|
+
/** `record.link(copy, source, pair)`. */
|
|
71
|
+
export function recordLinkCall(copy, source, link, loc) {
|
|
72
|
+
return {
|
|
73
|
+
kind: "libCall",
|
|
74
|
+
fn: "record.link",
|
|
75
|
+
args: [copy, source, { kind: "numLit", value: link.pair, type: F64, loc }],
|
|
76
|
+
type: { kind: "void" },
|
|
77
|
+
loc,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** `record.linkIs(copy, pair)`. */
|
|
81
|
+
export function recordLinkTest(copy, link, loc) {
|
|
82
|
+
return {
|
|
83
|
+
kind: "libCall",
|
|
84
|
+
fn: "record.linkIs",
|
|
85
|
+
args: [copy, { kind: "numLit", value: link.pair, type: F64, loc }],
|
|
86
|
+
type: BOOL,
|
|
87
|
+
loc,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** The record of the pair's source type composed from a copy that links
|
|
91
|
+
* through it (record.linkIs held). */
|
|
92
|
+
export function composedRecord(copy, link, loc) {
|
|
93
|
+
const fromT = { kind: "record", shapeId: link.from };
|
|
94
|
+
return {
|
|
95
|
+
kind: "call",
|
|
96
|
+
callee: link.compose,
|
|
97
|
+
args: [
|
|
98
|
+
copy,
|
|
99
|
+
{
|
|
100
|
+
kind: "libCall",
|
|
101
|
+
fn: "record.linkSource",
|
|
102
|
+
args: [copy, { kind: "numLit", value: link.pair, type: F64, loc }],
|
|
103
|
+
type: fromT,
|
|
104
|
+
loc,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
type: fromT,
|
|
108
|
+
loc,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** Registers `fn` (whose first parameter is a record of `shapeId`). */
|
|
112
|
+
export function registerLinkedHelper(lowerer, fn, shapeId, kind) {
|
|
113
|
+
lowerer.linkedHelpers.push({ fn, shapeId, kind });
|
|
114
|
+
}
|
|
115
|
+
/** Makes `fn` (whose first parameter is a record of `shapeId`) first
|
|
116
|
+
* answer `answer(composed)` for each copy linked into the type, where
|
|
117
|
+
* `composed` is the copy's composed record. Answers whether any link
|
|
118
|
+
* targets the type. */
|
|
119
|
+
export function answerLinkedCopies(lowerer, fn, shapeId, answer) {
|
|
120
|
+
const recordT = { kind: "record", shapeId };
|
|
121
|
+
const r = varRef(fn.params[0].localId, recordT, fn.loc);
|
|
122
|
+
const prefix = linkedCopyBranches(lowerer, fn, r, shapeId, answer);
|
|
123
|
+
if (prefix.length === 0)
|
|
124
|
+
return false;
|
|
125
|
+
fn.body = [...prefix, ...fn.body];
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
/** For each link into `shapeId`, the statement of `fn` that answers
|
|
129
|
+
* `answer(composed)` when `record` is a copy linked through it, with the
|
|
130
|
+
* composed record in a hidden local. Empty when no link targets the type. */
|
|
131
|
+
export function linkedCopyBranches(lowerer, fn, record, shapeId, answer) {
|
|
132
|
+
const loc = fn.loc;
|
|
133
|
+
const branches = [];
|
|
134
|
+
for (const link of recordLinksInto(lowerer, shapeId)) {
|
|
135
|
+
const fromT = { kind: "record", shapeId: link.from };
|
|
136
|
+
// A chain of links can reach a pair again inside another branch.
|
|
137
|
+
let local = `linked.${link.pair}`;
|
|
138
|
+
if (fn.locals.some((l) => l.id === local))
|
|
139
|
+
local = `${local}.${fn.locals.length}`;
|
|
140
|
+
fn.locals.push({ id: local, name: "linked", type: fromT, mutable: false });
|
|
141
|
+
const composed = varRef(local, fromT, loc);
|
|
142
|
+
branches.push({
|
|
143
|
+
kind: "if",
|
|
144
|
+
cond: recordLinkTest(record, link, loc),
|
|
145
|
+
then: [
|
|
146
|
+
{ kind: "varDecl", localId: local, init: composedRecord(record, link, loc), loc },
|
|
147
|
+
...answer(composed),
|
|
148
|
+
],
|
|
149
|
+
else_: null,
|
|
150
|
+
loc,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return branches;
|
|
154
|
+
}
|
|
155
|
+
/** Completes the record links after lowering. Links whose copies no
|
|
156
|
+
* reflective surface can observe are dropped (keepObservedLinks); the
|
|
157
|
+
* conversions of the others link each copy, and each kept pair gets its
|
|
158
|
+
* compose helper. A helper over a record type that kept links target
|
|
159
|
+
* first answers for each linked copy as for its composed record, and a
|
|
160
|
+
* helper over a record type whose values a checked conversion can build
|
|
161
|
+
* with a kept source (scanModule) answers for such a record from its live
|
|
162
|
+
* checked view. Every other helper keeps the body it was built with,
|
|
163
|
+
* and string conversions through helpers left with no other answer return
|
|
164
|
+
* to their plain form. Helpers this registers are completed too, and
|
|
165
|
+
* method calls a link source shadows are refused. */
|
|
166
|
+
export function finalizeRecordLinks(lowerer, functions) {
|
|
167
|
+
if (lowerer.linkedHelpers.length === 0 && lowerer.recordLinks.size === 0)
|
|
168
|
+
return;
|
|
169
|
+
const lifted = lowerer.liftedFns.length;
|
|
170
|
+
const scan = scanModule(lowerer, [...functions, ...lowerer.liftedFns]);
|
|
171
|
+
const sourced = scan.sourced;
|
|
172
|
+
keepObservedLinks(lowerer, scan.exposed);
|
|
173
|
+
for (const site of lowerer.recordLinkSites)
|
|
174
|
+
if (lowerer.recordLinks.has(`${site.link.from}:${site.link.to}`))
|
|
175
|
+
linkCopies(site.projection, site.link);
|
|
176
|
+
for (const link of lowerer.recordLinks.values())
|
|
177
|
+
addComposer(lowerer, link, sourced);
|
|
178
|
+
refuseShadowedMethodCalls(lowerer);
|
|
179
|
+
const answering = new Set();
|
|
180
|
+
for (let i = 0; i < lowerer.linkedHelpers.length; i++) {
|
|
181
|
+
const helper = lowerer.linkedHelpers[i];
|
|
182
|
+
if (helper.kind === "custom")
|
|
183
|
+
continue;
|
|
184
|
+
const recordT = { kind: "record", shapeId: helper.shapeId };
|
|
185
|
+
// util.inspect's helper tests a kept source itself.
|
|
186
|
+
if (sourced.has(helper.shapeId) && helper.kind !== "inspect") {
|
|
187
|
+
const loc = helper.fn.loc;
|
|
188
|
+
const r = varRef(helper.fn.params[0].localId, recordT, loc);
|
|
189
|
+
helper.fn.body = [sourcedAnswer(helper, r, loc), ...helper.fn.body];
|
|
190
|
+
answering.add(helper.fn.name);
|
|
191
|
+
}
|
|
192
|
+
if (answerLinkedCopies(lowerer, helper.fn, helper.shapeId, (composed) => linkedAnswer(lowerer, helper, composed, sourced, helper.fn.loc)))
|
|
193
|
+
answering.add(helper.fn.name);
|
|
194
|
+
}
|
|
195
|
+
for (const finalize of lowerer.linkedHelperFinalizers)
|
|
196
|
+
finalize();
|
|
197
|
+
// The module's functions already hold the helpers lifted before.
|
|
198
|
+
functions.push(...lowerer.liftedFns.slice(lifted));
|
|
199
|
+
restoreStringConversions(lowerer, functions, answering);
|
|
200
|
+
}
|
|
201
|
+
/** A call of an Object.prototype method by name on a record type runs
|
|
202
|
+
* the built-in, but a linked copy whose source has an own property of
|
|
203
|
+
* that name would run the source's: such calls are refused. */
|
|
204
|
+
function refuseShadowedMethodCalls(lowerer) {
|
|
205
|
+
for (const call of lowerer.recordMethodCalls) {
|
|
206
|
+
for (const link of recordLinksInto(lowerer, call.shapeId)) {
|
|
207
|
+
const source = lowerer.shapes.get(link.from);
|
|
208
|
+
if (!source?.fields.some((field) => field.name === call.method))
|
|
209
|
+
continue;
|
|
210
|
+
lowerer.pushDiag(unsupportedDiag("SC1090", call.loc, `'${call.method}()' on a record converted from an object with its own '${call.method}' property`, `call the source object's '${call.method}' through its own type`));
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Puts each call of a %rec.string or %rec.primitive helper that answers
|
|
216
|
+
* nothing but "[object Object]" (not in `answering`) back to the
|
|
217
|
+
* conversion it replaced (StringFallback), and drops those helpers. */
|
|
218
|
+
function restoreStringConversions(lowerer, functions, answering) {
|
|
219
|
+
const restored = new Map([...lowerer.recordStringFallbacks].filter(([helper]) => !answering.has(helper)));
|
|
220
|
+
if (restored.size === 0)
|
|
221
|
+
return;
|
|
222
|
+
for (const fn of functions) {
|
|
223
|
+
const calls = !everyStmtList(fn.body, {
|
|
224
|
+
stmt: () => true,
|
|
225
|
+
expr: (e) => e.kind !== "call" || !restored.has(e.callee),
|
|
226
|
+
});
|
|
227
|
+
if (!calls)
|
|
228
|
+
continue;
|
|
229
|
+
fn.body = transformStmtList(fn.body, {
|
|
230
|
+
stmt: (s) => s,
|
|
231
|
+
expr: (e) => {
|
|
232
|
+
const fallback = e.kind === "call" ? restored.get(e.callee) : undefined;
|
|
233
|
+
return fallback !== undefined && e.kind === "call"
|
|
234
|
+
? stringFallback(fallback, e.args[0], e.loc)
|
|
235
|
+
: e;
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
for (const list of [functions, lowerer.liftedFns])
|
|
240
|
+
for (let i = list.length - 1; i >= 0; i--)
|
|
241
|
+
if (restored.has(list[i].name))
|
|
242
|
+
list.splice(i, 1);
|
|
243
|
+
}
|
|
244
|
+
/** Makes the conversion helper `projection` (one `return <copy>`) link
|
|
245
|
+
* the copy it builds to its source record, the helper's parameter. */
|
|
246
|
+
function linkCopies(projection, link) {
|
|
247
|
+
const ret = projection.body[0];
|
|
248
|
+
if (projection.body.length !== 1 || ret?.kind !== "return" || ret.value === null)
|
|
249
|
+
throw new InternalCompilerError("lowerer bug: a record projection is not one return");
|
|
250
|
+
const loc = ret.loc;
|
|
251
|
+
const copyT = projection.returnType;
|
|
252
|
+
const param = projection.params[0];
|
|
253
|
+
const built = varRef("built.0", copyT, loc);
|
|
254
|
+
projection.locals.push({ id: "built.0", name: "built", type: copyT, mutable: false });
|
|
255
|
+
projection.body = [
|
|
256
|
+
{ kind: "varDecl", localId: "built.0", init: ret.value, loc },
|
|
257
|
+
{
|
|
258
|
+
kind: "exprStmt",
|
|
259
|
+
expr: recordLinkCall(built, varRef(param.localId, param.type, loc), link, loc),
|
|
260
|
+
loc,
|
|
261
|
+
},
|
|
262
|
+
{ kind: "return", value: built, loc },
|
|
263
|
+
];
|
|
264
|
+
}
|
|
265
|
+
/** Keeps the links whose copies a reflective surface can observe: the
|
|
266
|
+
* record types of the registered helpers (keys, own-key tests, string
|
|
267
|
+
* conversion, inspect, values and entries) and of Object.prototype method
|
|
268
|
+
* calls by name, and every record type that values of the `exposed` types
|
|
269
|
+
* can hold (JSON.stringify, checked views and the serializing library
|
|
270
|
+
* calls convert those through per-type helpers; the fields of a class
|
|
271
|
+
* instance's view are not followed). A kept link observes its
|
|
272
|
+
* source type too, through the composed record. The other links are
|
|
273
|
+
* dropped, so their conversions build plain copies. */
|
|
274
|
+
function keepObservedLinks(lowerer, exposed) {
|
|
275
|
+
if (lowerer.recordLinks.size === 0)
|
|
276
|
+
return;
|
|
277
|
+
// A call of an Object.prototype method by name observes the type too
|
|
278
|
+
// (refuseShadowedMethodCalls).
|
|
279
|
+
const observed = new Set([
|
|
280
|
+
...lowerer.linkedHelpers.map((helper) => helper.shapeId),
|
|
281
|
+
...lowerer.recordMethodCalls.map((call) => call.shapeId),
|
|
282
|
+
]);
|
|
283
|
+
const reached = new Set();
|
|
284
|
+
const visit = (t) => {
|
|
285
|
+
const key = typeKey(t);
|
|
286
|
+
if (reached.has(key))
|
|
287
|
+
return;
|
|
288
|
+
reached.add(key);
|
|
289
|
+
switch (t.kind) {
|
|
290
|
+
case "record": {
|
|
291
|
+
observed.add(t.shapeId);
|
|
292
|
+
const shape = lowerer.shapes.get(t.shapeId);
|
|
293
|
+
for (const field of shape?.fields ?? [])
|
|
294
|
+
visit(field.type);
|
|
295
|
+
if (shape?.indexValue !== undefined)
|
|
296
|
+
visit(shape.indexValue);
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
case "array":
|
|
300
|
+
case "set":
|
|
301
|
+
visit(t.elem);
|
|
302
|
+
break;
|
|
303
|
+
case "map":
|
|
304
|
+
visit(t.key);
|
|
305
|
+
visit(t.value);
|
|
306
|
+
break;
|
|
307
|
+
case "union":
|
|
308
|
+
for (const arm of lowerer.unions.get(t.unionId)?.arms ?? [])
|
|
309
|
+
visit(arm);
|
|
310
|
+
break;
|
|
311
|
+
case "promise":
|
|
312
|
+
visit(t.inner);
|
|
313
|
+
break;
|
|
314
|
+
case "func":
|
|
315
|
+
// A boxed function's results are boxed for its callers.
|
|
316
|
+
visit(t.ret);
|
|
317
|
+
break;
|
|
318
|
+
default:
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
for (const t of exposed)
|
|
323
|
+
visit(t);
|
|
324
|
+
for (let changed = true; changed;) {
|
|
325
|
+
changed = false;
|
|
326
|
+
for (const link of lowerer.recordLinks.values())
|
|
327
|
+
if (observed.has(link.to) && !observed.has(link.from)) {
|
|
328
|
+
observed.add(link.from);
|
|
329
|
+
changed = true;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
for (const [key, link] of lowerer.recordLinks)
|
|
333
|
+
if (!observed.has(link.to))
|
|
334
|
+
lowerer.recordLinks.delete(key);
|
|
335
|
+
}
|
|
336
|
+
/** Builds a link's compose helper once every link is known: a record of
|
|
337
|
+
* the source type with the copy's values for the fields both types declare
|
|
338
|
+
* and the source's for the others, created in the source type's first key
|
|
339
|
+
* order. The source can itself carry other properties: a kept checked
|
|
340
|
+
* source when its type is in `sourced` (record.sourceShare), and a
|
|
341
|
+
* link of its own when the source type is the target of other links (a
|
|
342
|
+
* copy converted again). The composed record keeps both. */
|
|
343
|
+
function addComposer(lowerer, link, sourced) {
|
|
344
|
+
const loc = lowerer.recordLinkLocs.get(link.compose);
|
|
345
|
+
const fromT = { kind: "record", shapeId: link.from };
|
|
346
|
+
const toT = { kind: "record", shapeId: link.to };
|
|
347
|
+
const sourceShape = lowerer.shapes.get(link.from);
|
|
348
|
+
const targetShape = lowerer.shapes.get(link.to);
|
|
349
|
+
const copy = varRef("copy.0", toT, loc);
|
|
350
|
+
const source = varRef("source.0", fromT, loc);
|
|
351
|
+
const composed = varRef("composed.0", fromT, loc);
|
|
352
|
+
const fields = shapeKeyOrders(sourceShape)[0].map((name) => {
|
|
353
|
+
const field = sourceShape.fields.find((f) => f.name === name);
|
|
354
|
+
const own = targetShape.fields.find((f) => f.name === name);
|
|
355
|
+
const [obj, shapeId] = own !== undefined && typeEquals(own.type, field.type) ? [copy, link.to] : [source, link.from];
|
|
356
|
+
const read = { kind: "recordGet", obj, shapeId, field: name, type: field.type, loc };
|
|
357
|
+
return { name, value: lowerer.presenceKeepingCopy(obj, shapeId, name, read, loc) };
|
|
358
|
+
});
|
|
359
|
+
// A source type written in several key orders records each value's order
|
|
360
|
+
// in a hidden field: the composed record enumerates in the source's.
|
|
361
|
+
if (sourceShape.fields.some((f) => f.name === KEY_ORDER_FIELD))
|
|
362
|
+
fields.push({
|
|
363
|
+
name: KEY_ORDER_FIELD,
|
|
364
|
+
value: {
|
|
365
|
+
kind: "recordGet",
|
|
366
|
+
obj: source,
|
|
367
|
+
shapeId: link.from,
|
|
368
|
+
field: KEY_ORDER_FIELD,
|
|
369
|
+
type: F64,
|
|
370
|
+
loc,
|
|
371
|
+
},
|
|
372
|
+
});
|
|
373
|
+
const body = [
|
|
374
|
+
{
|
|
375
|
+
kind: "varDecl",
|
|
376
|
+
localId: "composed.0",
|
|
377
|
+
init: { kind: "recordLit", fields, type: fromT, loc },
|
|
378
|
+
loc,
|
|
379
|
+
},
|
|
380
|
+
];
|
|
381
|
+
if (sourced.has(link.from))
|
|
382
|
+
body.push({
|
|
383
|
+
kind: "exprStmt",
|
|
384
|
+
expr: {
|
|
385
|
+
kind: "libCall",
|
|
386
|
+
fn: "record.sourceShare",
|
|
387
|
+
args: [composed, source],
|
|
388
|
+
type: { kind: "void" },
|
|
389
|
+
loc,
|
|
390
|
+
},
|
|
391
|
+
loc,
|
|
392
|
+
});
|
|
393
|
+
for (const next of recordLinksInto(lowerer, link.from)) {
|
|
394
|
+
const sourceOf = {
|
|
395
|
+
kind: "libCall",
|
|
396
|
+
fn: "record.linkSource",
|
|
397
|
+
args: [source, { kind: "numLit", value: next.pair, type: F64, loc }],
|
|
398
|
+
type: { kind: "record", shapeId: next.from },
|
|
399
|
+
loc,
|
|
400
|
+
};
|
|
401
|
+
body.push({
|
|
402
|
+
kind: "if",
|
|
403
|
+
cond: recordLinkTest(source, next, loc),
|
|
404
|
+
then: [{ kind: "exprStmt", expr: recordLinkCall(composed, sourceOf, next, loc), loc }],
|
|
405
|
+
else_: null,
|
|
406
|
+
loc,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
body.push({ kind: "return", value: composed, loc });
|
|
410
|
+
lowerer.liftedFns.push({
|
|
411
|
+
name: link.compose,
|
|
412
|
+
params: [
|
|
413
|
+
{ localId: "copy.0", name: "copy", type: toT },
|
|
414
|
+
{ localId: "source.0", name: "source", type: fromT },
|
|
415
|
+
],
|
|
416
|
+
returnType: fromT,
|
|
417
|
+
locals: [
|
|
418
|
+
{ id: "copy.0", name: "copy", type: toT, mutable: false },
|
|
419
|
+
{ id: "source.0", name: "source", type: fromT, mutable: false },
|
|
420
|
+
{ id: "composed.0", name: "composed", type: fromT, mutable: false },
|
|
421
|
+
],
|
|
422
|
+
body,
|
|
423
|
+
loc,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/** The library calls that serialize, inspect or box their arguments. */
|
|
427
|
+
const EXPOSING_LIB_CALLS = /^(json|insp|dyn|js)\.|^(child|process)\.send$/;
|
|
428
|
+
/** One walk over the module: the record types whose values can keep a
|
|
429
|
+
* checked source (keptSourceTypes), and the types of the values it boxes
|
|
430
|
+
* as checked values, serializes or inspects. */
|
|
431
|
+
function scanModule(lowerer, functions) {
|
|
432
|
+
const sourced = new Set();
|
|
433
|
+
const seen = new Set();
|
|
434
|
+
const exposed = new Map();
|
|
435
|
+
const expose = (t) => {
|
|
436
|
+
if (!exposed.has(typeKey(t)))
|
|
437
|
+
exposed.set(typeKey(t), t);
|
|
438
|
+
};
|
|
439
|
+
const links = lowerer.recordLinks.size > 0;
|
|
440
|
+
for (const fn of functions) {
|
|
441
|
+
everyStmtList(fn.body, {
|
|
442
|
+
stmt: () => true,
|
|
443
|
+
expr: (e) => {
|
|
444
|
+
if (e.kind === "dynCheck")
|
|
445
|
+
keptSourceTypes(lowerer, e.type, sourced, seen);
|
|
446
|
+
// A literal that starts with a spread of a record that kept a
|
|
447
|
+
// source keeps one too, as does a width spread or clone the
|
|
448
|
+
// key-order pass keeps (record.sourceNote).
|
|
449
|
+
if (e.kind === "libCall" &&
|
|
450
|
+
(e.fn === "record.sourceSpread" || e.fn === "record.sourceNote")) {
|
|
451
|
+
const built = e.args[0]?.type;
|
|
452
|
+
if (built?.kind === "record" && recordMayKeepSource(lowerer, built))
|
|
453
|
+
sourced.add(built.shapeId);
|
|
454
|
+
}
|
|
455
|
+
if (!links)
|
|
456
|
+
return true;
|
|
457
|
+
if (e.kind === "dynFrom")
|
|
458
|
+
expose(e.value.type);
|
|
459
|
+
if (e.kind === "jsonStringify")
|
|
460
|
+
expose(e.value.type);
|
|
461
|
+
if (e.kind === "libCall" && EXPOSING_LIB_CALLS.test(e.fn))
|
|
462
|
+
for (const arg of e.args)
|
|
463
|
+
expose(arg.type);
|
|
464
|
+
return true;
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
return { sourced, exposed: [...exposed.values()] };
|
|
469
|
+
}
|
|
470
|
+
/** Adds to `out` the record types a checked conversion into `t` can build
|
|
471
|
+
* with a kept source (recordMayKeepSource): `t` and the record types its
|
|
472
|
+
* values hold. `seen` holds the type keys already walked. */
|
|
473
|
+
function keptSourceTypes(lowerer, t, out, seen) {
|
|
474
|
+
const key = typeKey(t);
|
|
475
|
+
if (seen.has(key))
|
|
476
|
+
return;
|
|
477
|
+
seen.add(key);
|
|
478
|
+
switch (t.kind) {
|
|
479
|
+
case "record": {
|
|
480
|
+
if (recordMayKeepSource(lowerer, t))
|
|
481
|
+
out.add(t.shapeId);
|
|
482
|
+
const shape = lowerer.shapes.get(t.shapeId);
|
|
483
|
+
for (const field of shape?.fields ?? [])
|
|
484
|
+
keptSourceTypes(lowerer, field.type, out, seen);
|
|
485
|
+
if (shape?.indexValue !== undefined)
|
|
486
|
+
keptSourceTypes(lowerer, shape.indexValue, out, seen);
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
case "array":
|
|
490
|
+
case "set":
|
|
491
|
+
keptSourceTypes(lowerer, t.elem, out, seen);
|
|
492
|
+
break;
|
|
493
|
+
case "map":
|
|
494
|
+
keptSourceTypes(lowerer, t.key, out, seen);
|
|
495
|
+
keptSourceTypes(lowerer, t.value, out, seen);
|
|
496
|
+
break;
|
|
497
|
+
case "union":
|
|
498
|
+
for (const arm of lowerer.unions.get(t.unionId)?.arms ?? [])
|
|
499
|
+
keptSourceTypes(lowerer, arm, out, seen);
|
|
500
|
+
break;
|
|
501
|
+
case "promise":
|
|
502
|
+
keptSourceTypes(lowerer, t.inner, out, seen);
|
|
503
|
+
break;
|
|
504
|
+
default:
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
/** The helper's answer for the record `composed` of a link's source type.
|
|
509
|
+
* `sourced` holds the record types that can keep a checked source. */
|
|
510
|
+
function linkedAnswer(lowerer, helper, composed, sourced, loc) {
|
|
511
|
+
const source = composed.type.shapeId;
|
|
512
|
+
const shape = lowerer.shapes.get(source);
|
|
513
|
+
// A source type whose values can carry other properties (a copy linked
|
|
514
|
+
// again, or a kept checked source) converts through its own helper when
|
|
515
|
+
// it declares no method of its own for the conversion, so the method
|
|
516
|
+
// those properties hold runs.
|
|
517
|
+
const carries = sourced.has(source) || [...lowerer.recordLinks.values()].some((l) => l.to === source);
|
|
518
|
+
const k = varRef("k.0", STRING, loc);
|
|
519
|
+
switch (helper.kind) {
|
|
520
|
+
case "keys":
|
|
521
|
+
// The source type's helper, which answers for a composed record that
|
|
522
|
+
// keeps a checked source or links further.
|
|
523
|
+
return [
|
|
524
|
+
{
|
|
525
|
+
kind: "return",
|
|
526
|
+
value: recordKeysArrayCall(lowerer, composed, composed.type, shape, loc),
|
|
527
|
+
loc,
|
|
528
|
+
},
|
|
529
|
+
];
|
|
530
|
+
case "hasOwn":
|
|
531
|
+
return [
|
|
532
|
+
{
|
|
533
|
+
kind: "return",
|
|
534
|
+
value: {
|
|
535
|
+
kind: "call",
|
|
536
|
+
callee: recordHasOwnHelper(lowerer, source, loc),
|
|
537
|
+
args: [composed, k],
|
|
538
|
+
type: BOOL,
|
|
539
|
+
loc,
|
|
540
|
+
},
|
|
541
|
+
loc,
|
|
542
|
+
},
|
|
543
|
+
];
|
|
544
|
+
case "string":
|
|
545
|
+
if (carries && !shape.fields.some((f) => f.name === "toString"))
|
|
546
|
+
return [{ kind: "return", value: sourceConversion(lowerer, "string", composed, loc), loc }];
|
|
547
|
+
return [{ kind: "return", value: recordToString(lowerer, helper, composed, loc), loc }];
|
|
548
|
+
case "custom":
|
|
549
|
+
throw new InternalCompilerError("lowerer bug: custom helpers answer linked copies themselves");
|
|
550
|
+
case "inspect":
|
|
551
|
+
return [
|
|
552
|
+
{
|
|
553
|
+
kind: "return",
|
|
554
|
+
value: inspectHelperCall(lowerer, composed, varRef("r.0", F64, loc), varRef("d.0", F64, loc), loc),
|
|
555
|
+
loc,
|
|
556
|
+
},
|
|
557
|
+
];
|
|
558
|
+
case "primitive": {
|
|
559
|
+
const valueOf = shape.fields.find((f) => f.name === "valueOf");
|
|
560
|
+
if (valueOf === undefined || valueOf.type.kind !== "func")
|
|
561
|
+
return [
|
|
562
|
+
{
|
|
563
|
+
kind: "return",
|
|
564
|
+
value: carries
|
|
565
|
+
? sourceConversion(lowerer, "primitive", composed, loc)
|
|
566
|
+
: recordToString(lowerer, helper, composed, loc),
|
|
567
|
+
loc,
|
|
568
|
+
},
|
|
569
|
+
];
|
|
570
|
+
// ToPrimitive with the default hint calls an own valueOf first.
|
|
571
|
+
const own = {
|
|
572
|
+
kind: "recordGet",
|
|
573
|
+
obj: composed,
|
|
574
|
+
shapeId: source,
|
|
575
|
+
field: "valueOf",
|
|
576
|
+
type: valueOf.type,
|
|
577
|
+
loc,
|
|
578
|
+
};
|
|
579
|
+
const value = callOwn(lowerer, declarerOf(helper.fn), own, [], valueOf.type.ret, "valueOf", loc);
|
|
580
|
+
// A primitive answer converts as ToString does; an object makes
|
|
581
|
+
// ToPrimitive fall back to toString once valueOf has run.
|
|
582
|
+
if (value.type.kind === "string")
|
|
583
|
+
return [{ kind: "return", value, loc }];
|
|
584
|
+
if (value.type.kind === "f64" || value.type.kind === "bool")
|
|
585
|
+
return [
|
|
586
|
+
{ kind: "return", value: { kind: "toString", operand: value, type: STRING, loc }, loc },
|
|
587
|
+
];
|
|
588
|
+
const fallback = {
|
|
589
|
+
kind: "return",
|
|
590
|
+
value: recordToString(lowerer, helper, composed, loc),
|
|
591
|
+
loc,
|
|
592
|
+
};
|
|
593
|
+
if (OBJECT_KINDS.has(value.type.kind))
|
|
594
|
+
return [{ kind: "exprStmt", expr: value, loc }, fallback];
|
|
595
|
+
// Any other answer is tested once valueOf returns: null answers
|
|
596
|
+
// "object" and is falsy, and every object is truthy.
|
|
597
|
+
const boxed = lowerer.coerceToExpected(value, DYN);
|
|
598
|
+
if (boxed.type.kind !== "dyn")
|
|
599
|
+
return [{ kind: "exprStmt", expr: value, loc }, fallback];
|
|
600
|
+
const resultId = declarerOf(helper.fn)("%valueOfResult", DYN);
|
|
601
|
+
const result = varRef(resultId, DYN, loc);
|
|
602
|
+
const typeOf = {
|
|
603
|
+
kind: "libCall",
|
|
604
|
+
fn: "dyn.typeof",
|
|
605
|
+
args: [result],
|
|
606
|
+
type: STRING,
|
|
607
|
+
loc,
|
|
608
|
+
};
|
|
609
|
+
const typeIs = (name) => ({
|
|
610
|
+
kind: "strEq",
|
|
611
|
+
negated: false,
|
|
612
|
+
left: typeOf,
|
|
613
|
+
right: { kind: "strLit", value: name, type: STRING, loc },
|
|
614
|
+
type: BOOL,
|
|
615
|
+
loc,
|
|
616
|
+
});
|
|
617
|
+
return [
|
|
618
|
+
{ kind: "varDecl", localId: resultId, init: boxed, loc },
|
|
619
|
+
{
|
|
620
|
+
kind: "if",
|
|
621
|
+
cond: {
|
|
622
|
+
kind: "logical",
|
|
623
|
+
op: "||",
|
|
624
|
+
left: typeIs("function"),
|
|
625
|
+
right: {
|
|
626
|
+
kind: "logical",
|
|
627
|
+
op: "&&",
|
|
628
|
+
left: typeIs("object"),
|
|
629
|
+
right: { kind: "dynTest", test: "truthy", value: result, type: BOOL, loc },
|
|
630
|
+
type: BOOL,
|
|
631
|
+
loc,
|
|
632
|
+
},
|
|
633
|
+
type: BOOL,
|
|
634
|
+
loc,
|
|
635
|
+
},
|
|
636
|
+
then: [fallback],
|
|
637
|
+
else_: null,
|
|
638
|
+
loc,
|
|
639
|
+
},
|
|
640
|
+
{ kind: "return", value: { kind: "toString", operand: result, type: STRING, loc }, loc },
|
|
641
|
+
];
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
/** The IR type kinds whose values are always objects. */
|
|
646
|
+
const OBJECT_KINDS = new Set([
|
|
647
|
+
"record",
|
|
648
|
+
"object",
|
|
649
|
+
"array",
|
|
650
|
+
"map",
|
|
651
|
+
"set",
|
|
652
|
+
"func",
|
|
653
|
+
"promise",
|
|
654
|
+
]);
|
|
655
|
+
/** `%rec.<hint>.<n>(r)` over the source type of `composed`: ToString (or
|
|
656
|
+
* ToPrimitive with the default hint) as the record's other properties
|
|
657
|
+
* answer, for a copy linked again or a kept checked source, else as
|
|
658
|
+
* recordToString does. finalizeRecordLinks adds the answers, and the
|
|
659
|
+
* helper keeps its own conversion when none applies. */
|
|
660
|
+
function sourceConversion(lowerer, hint, composed, loc) {
|
|
661
|
+
const recordT = composed.type;
|
|
662
|
+
const key = `rec.${hint}.source:${recordT.shapeId}`;
|
|
663
|
+
let name = lowerer.valueHelpers.get(key);
|
|
664
|
+
if (!name) {
|
|
665
|
+
name = keyedHelperName(lowerer, `%rec.${hint}`, key);
|
|
666
|
+
lowerer.valueHelpers.set(key, name);
|
|
667
|
+
const fn = {
|
|
668
|
+
name,
|
|
669
|
+
params: [{ localId: "r.0", name: "r", type: recordT }],
|
|
670
|
+
returnType: STRING,
|
|
671
|
+
locals: [{ id: "r.0", name: "r", type: recordT, mutable: false }],
|
|
672
|
+
body: [],
|
|
673
|
+
loc,
|
|
674
|
+
};
|
|
675
|
+
const helper = { fn, shapeId: recordT.shapeId, kind: hint };
|
|
676
|
+
const r = varRef("r.0", recordT, loc);
|
|
677
|
+
fn.body = [{ kind: "return", value: recordToString(lowerer, helper, r, loc), loc }];
|
|
678
|
+
lowerer.liftedFns.push(fn);
|
|
679
|
+
registerLinkedHelper(lowerer, fn, recordT.shapeId, hint);
|
|
680
|
+
}
|
|
681
|
+
return { kind: "call", callee: name, args: [composed], type: STRING, loc };
|
|
682
|
+
}
|
|
683
|
+
/** ToString of the record `composed`: its own toString when it holds a
|
|
684
|
+
* callable one, else Object.prototype's "[object Object]". */
|
|
685
|
+
function recordToString(lowerer, helper, composed, loc) {
|
|
686
|
+
const source = composed.type.shapeId;
|
|
687
|
+
return callOwnOrBuiltin(lowerer, declarerOf(helper.fn), composed, source, "toString", [], STRING, "toString", loc);
|
|
688
|
+
}
|
|
689
|
+
/** A hidden-local declarer for statements added to `fn`. */
|
|
690
|
+
function declarerOf(fn) {
|
|
691
|
+
return (name, type) => {
|
|
692
|
+
const id = `${name}.${fn.locals.length}`;
|
|
693
|
+
fn.locals.push({ id, name, type, mutable: false });
|
|
694
|
+
return id;
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
/** `if (record.sourceHas(r)) return <the live checked view's answer>`. */
|
|
698
|
+
function sourcedAnswer(helper, r, loc) {
|
|
699
|
+
const view = { kind: "dynFrom", value: r, liveRef: true, type: DYN, loc };
|
|
700
|
+
const k = varRef("k.0", STRING, loc);
|
|
701
|
+
let answer;
|
|
702
|
+
switch (helper.kind) {
|
|
703
|
+
case "keys":
|
|
704
|
+
answer = {
|
|
705
|
+
kind: "libCall",
|
|
706
|
+
fn: "dyn.objKeyStrings",
|
|
707
|
+
args: [view],
|
|
708
|
+
type: arrayOf(STRING),
|
|
709
|
+
loc,
|
|
710
|
+
};
|
|
711
|
+
break;
|
|
712
|
+
case "hasOwn":
|
|
713
|
+
answer = {
|
|
714
|
+
kind: "libCall",
|
|
715
|
+
fn: "dyn.hasOwn",
|
|
716
|
+
args: [view, k],
|
|
717
|
+
type: BOOL,
|
|
718
|
+
loc,
|
|
719
|
+
};
|
|
720
|
+
break;
|
|
721
|
+
case "string":
|
|
722
|
+
answer = { kind: "toString", operand: view, type: STRING, loc };
|
|
723
|
+
break;
|
|
724
|
+
case "inspect":
|
|
725
|
+
case "custom":
|
|
726
|
+
throw new InternalCompilerError(`lowerer bug: ${helper.kind} helpers test kept sources themselves`);
|
|
727
|
+
case "primitive":
|
|
728
|
+
answer = {
|
|
729
|
+
kind: "toString",
|
|
730
|
+
operand: {
|
|
731
|
+
kind: "libCall",
|
|
732
|
+
fn: "dyn.add",
|
|
733
|
+
args: [
|
|
734
|
+
{
|
|
735
|
+
kind: "dynFrom",
|
|
736
|
+
value: { kind: "strLit", value: "", type: STRING, loc },
|
|
737
|
+
type: DYN,
|
|
738
|
+
loc,
|
|
739
|
+
},
|
|
740
|
+
view,
|
|
741
|
+
],
|
|
742
|
+
type: DYN,
|
|
743
|
+
loc,
|
|
744
|
+
},
|
|
745
|
+
type: STRING,
|
|
746
|
+
loc,
|
|
747
|
+
};
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
return {
|
|
751
|
+
kind: "if",
|
|
752
|
+
cond: { kind: "libCall", fn: "record.sourceHas", args: [r], type: BOOL, loc },
|
|
753
|
+
then: [{ kind: "return", value: answer, loc }],
|
|
754
|
+
else_: null,
|
|
755
|
+
loc,
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
/** `%rec.string.<n>(r)` (ToString) or `%rec.primitive.<n>(r)` (ToPrimitive
|
|
759
|
+
* with the default hint, then ToString) of a record type whose values
|
|
760
|
+
* answer Object.prototype.toString: "[object Object]", or for a linked
|
|
761
|
+
* copy or a record with a kept source, what its source answers. When no
|
|
762
|
+
* value of the type can answer otherwise, finalizeRecordLinks puts
|
|
763
|
+
* `fallback`, the conversion without the helper, in the calls' place. */
|
|
764
|
+
export function recordStringCall(lowerer, record, hint, loc, fallback) {
|
|
765
|
+
const recordT = record.type;
|
|
766
|
+
const key = `rec.${hint}:${recordT.shapeId}:${fallback}`;
|
|
767
|
+
let helper = lowerer.valueHelpers.get(key);
|
|
768
|
+
if (!helper) {
|
|
769
|
+
helper = keyedHelperName(lowerer, `%rec.${hint}`, key);
|
|
770
|
+
lowerer.valueHelpers.set(key, helper);
|
|
771
|
+
const fn = {
|
|
772
|
+
name: helper,
|
|
773
|
+
params: [{ localId: "r.0", name: "r", type: recordT }],
|
|
774
|
+
returnType: STRING,
|
|
775
|
+
locals: [{ id: "r.0", name: "r", type: recordT, mutable: false }],
|
|
776
|
+
body: [
|
|
777
|
+
{
|
|
778
|
+
kind: "return",
|
|
779
|
+
value: { kind: "strLit", value: "[object Object]", type: STRING, loc },
|
|
780
|
+
loc,
|
|
781
|
+
},
|
|
782
|
+
],
|
|
783
|
+
loc,
|
|
784
|
+
};
|
|
785
|
+
lowerer.liftedFns.push(fn);
|
|
786
|
+
registerLinkedHelper(lowerer, fn, recordT.shapeId, hint);
|
|
787
|
+
lowerer.recordStringFallbacks.set(helper, fallback);
|
|
788
|
+
}
|
|
789
|
+
return { kind: "call", callee: helper, args: [record], type: STRING, loc };
|
|
790
|
+
}
|
|
791
|
+
/** The conversion `fallback` of `record` at `loc`. */
|
|
792
|
+
function stringFallback(fallback, record, loc) {
|
|
793
|
+
return fallback === "constant"
|
|
794
|
+
? { kind: "strLit", value: "[object Object]", type: STRING, loc }
|
|
795
|
+
: { kind: "toString", operand: record, type: STRING, loc };
|
|
796
|
+
}
|
|
797
|
+
//# sourceMappingURL=record-links.js.map
|