@scriptc/compiler 0.2.7 → 0.2.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/scriptc-node-fallback.d.ts +2 -0
- package/dist/backend/llvm/alloc.d.ts +3 -0
- package/dist/backend/llvm/alloc.js +54 -13
- package/dist/backend/llvm/alloc.js.map +1 -1
- package/dist/backend/llvm/blocks.d.ts +9 -0
- package/dist/backend/llvm/blocks.js +9 -0
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/borrowed-receivers.d.ts +7 -0
- package/dist/backend/llvm/borrowed-receivers.js +39 -0
- package/dist/backend/llvm/borrowed-receivers.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.d.ts +4 -1
- package/dist/backend/llvm/call-lifetimes.js +14 -3
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/call-lifetimes.test.js +8 -3
- package/dist/backend/llvm/call-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/checked-narrows.d.ts +24 -0
- package/dist/backend/llvm/checked-narrows.js +108 -0
- package/dist/backend/llvm/checked-narrows.js.map +1 -0
- package/dist/backend/llvm/checked-narrows.test.d.ts +1 -0
- package/dist/backend/llvm/checked-narrows.test.js +208 -0
- package/dist/backend/llvm/checked-narrows.test.js.map +1 -0
- package/dist/backend/llvm/classes.d.ts +13 -1
- package/dist/backend/llvm/classes.js +26 -18
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.js +32 -3
- package/dist/backend/llvm/classes.test.js.map +1 -1
- package/dist/backend/llvm/debug-info.d.ts +6 -2
- package/dist/backend/llvm/debug-info.js +11 -1
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/dense-array-access.test.js +89 -0
- package/dist/backend/llvm/dense-array-access.test.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +31 -20
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +184 -11
- package/dist/backend/llvm/emitter.js +1189 -125
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +21 -1
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +4 -4
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -1
- package/dist/backend/llvm/expr-bytes.js +85 -8
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.js +29 -21
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-calls.d.ts +5 -0
- package/dist/backend/llvm/expr-calls.js +55 -10
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.d.ts +7 -1
- package/dist/backend/llvm/expr-containers.js +230 -27
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-control.js +25 -10
- package/dist/backend/llvm/expr-control.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +72 -21
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-island.js +3 -8
- package/dist/backend/llvm/expr-island.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +41 -12
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +50 -2
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -1
- package/dist/backend/llvm/expr-records.js +28 -14
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +41 -31
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.js +6 -3
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/layouts.d.ts +2 -1
- package/dist/backend/llvm/layouts.js +2 -2
- package/dist/backend/llvm/layouts.js.map +1 -1
- package/dist/backend/llvm/lib-abi.js +10 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +7 -11
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +8 -8
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +1 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.js +73 -13
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +7 -3
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.js +10 -6
- package/dist/backend/llvm/local-union-storage.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +3 -2
- package/dist/backend/llvm/local-union-storage.test.js.map +1 -1
- package/dist/backend/llvm/map-number-lookup.d.ts +18 -0
- package/dist/backend/llvm/map-number-lookup.js +62 -0
- package/dist/backend/llvm/map-number-lookup.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.d.ts +6 -0
- package/dist/backend/llvm/map-read-lifetimes.js +24 -3
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +38 -19
- package/dist/backend/llvm/map-read-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.d.ts +68 -0
- package/dist/backend/llvm/nullable-unions.js +132 -0
- package/dist/backend/llvm/nullable-unions.js.map +1 -0
- package/dist/backend/llvm/publish.d.ts +58 -0
- package/dist/backend/llvm/publish.js +286 -0
- package/dist/backend/llvm/publish.js.map +1 -0
- package/dist/backend/llvm/rebound-parameters.d.ts +12 -0
- package/dist/backend/llvm/rebound-parameters.js +72 -0
- package/dist/backend/llvm/rebound-parameters.js.map +1 -0
- package/dist/backend/llvm/rebound-parameters.test.d.ts +1 -0
- package/dist/backend/llvm/rebound-parameters.test.js +67 -0
- package/dist/backend/llvm/rebound-parameters.test.js.map +1 -0
- package/dist/backend/llvm/reference-effects.d.ts +18 -2
- package/dist/backend/llvm/reference-effects.js +106 -16
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/reference-effects.test.js +52 -1
- package/dist/backend/llvm/reference-effects.test.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +45 -17
- package/dist/backend/llvm/shapes.js +131 -53
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +33 -8
- package/dist/backend/llvm/shapes.test.js.map +1 -1
- package/dist/backend/llvm/stack-unions.test.js +5 -2
- package/dist/backend/llvm/stack-unions.test.js.map +1 -1
- package/dist/backend/llvm/string-construction.d.ts +10 -0
- package/dist/backend/llvm/string-construction.js +42 -0
- package/dist/backend/llvm/string-construction.js.map +1 -1
- package/dist/backend/llvm/string-key-hash.d.ts +9 -2
- package/dist/backend/llvm/string-key-hash.js +20 -3
- package/dist/backend/llvm/string-key-hash.js.map +1 -1
- package/dist/backend/llvm/string-key-hash.test.js +14 -3
- package/dist/backend/llvm/string-key-hash.test.js.map +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +24 -11
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-reads.d.ts +7 -0
- package/dist/backend/llvm/string-reads.js +76 -0
- package/dist/backend/llvm/string-reads.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.test.js +1 -1
- package/dist/backend/llvm/switch-dispatch.test.js.map +1 -1
- package/dist/backend/llvm/test-boxed-unions.d.ts +5 -0
- package/dist/backend/llvm/test-boxed-unions.js +13 -0
- package/dist/backend/llvm/test-boxed-unions.js.map +1 -0
- package/dist/backend/llvm/union-repr.d.ts +15 -0
- package/dist/backend/llvm/union-repr.js +89 -0
- package/dist/backend/llvm/union-repr.js.map +1 -0
- package/dist/backend/llvm/virtual-borrows.d.ts +31 -0
- package/dist/backend/llvm/virtual-borrows.js +82 -0
- package/dist/backend/llvm/virtual-borrows.js.map +1 -0
- package/dist/backend/llvm/walk-borrows.d.ts +43 -0
- package/dist/backend/llvm/walk-borrows.js +150 -0
- package/dist/backend/llvm/walk-borrows.js.map +1 -0
- package/dist/backend/llvm/walk-borrows.test.d.ts +1 -0
- package/dist/backend/llvm/walk-borrows.test.js +119 -0
- package/dist/backend/llvm/walk-borrows.test.js.map +1 -0
- package/dist/backend/llvm/walkers.d.ts +5 -1
- package/dist/backend/llvm/walkers.js +24 -21
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.d.ts +29 -1
- package/dist/backend/may-throw.js +346 -3
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +113 -1
- package/dist/backend/may-throw.test.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +7 -5
- package/dist/backend/native-codegen-core.js +14 -9
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +4 -0
- package/dist/backend/native-codegen.js +49 -2
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +41 -10
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-tools.d.ts +2 -0
- package/dist/backend/native-tools.js +3 -0
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/publication.d.ts +28 -0
- package/dist/backend/publication.js +155 -0
- package/dist/backend/publication.js.map +1 -0
- package/dist/backend/publication.test.d.ts +1 -0
- package/dist/backend/publication.test.js +72 -0
- package/dist/backend/publication.test.js.map +1 -0
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack.test.js +1 -1
- package/dist/cli/command.js +70 -7
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/usage.d.ts +4 -1
- package/dist/cli/usage.js +8 -1
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +12 -3
- package/dist/coverage/report.d.ts +25 -2
- package/dist/coverage/report.js +161 -33
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/verdict-cache.d.ts +63 -0
- package/dist/coverage/verdict-cache.js +193 -0
- package/dist/coverage/verdict-cache.js.map +1 -0
- package/dist/coverage/verdict-cache.test.d.ts +1 -0
- package/dist/coverage/verdict-cache.test.js +52 -0
- package/dist/coverage/verdict-cache.test.js.map +1 -0
- package/dist/coverage/verdict-semantic.d.ts +2 -0
- package/dist/coverage/verdict-semantic.js +24 -0
- package/dist/coverage/verdict-semantic.js.map +1 -0
- package/dist/coverage/verdict-startup.d.ts +15 -0
- package/dist/coverage/verdict-startup.js +66 -0
- package/dist/coverage/verdict-startup.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +29 -1
- package/dist/diagnostics/diagnostic.js +74 -4
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/envelope.d.ts +130 -0
- package/dist/diagnostics/envelope.js +257 -0
- package/dist/diagnostics/envelope.js.map +1 -0
- package/dist/diagnostics/envelope.test.d.ts +1 -0
- package/dist/diagnostics/envelope.test.js +91 -0
- package/dist/diagnostics/envelope.test.js.map +1 -0
- package/dist/diagnostics/render.d.ts +3 -0
- package/dist/diagnostics/render.js +13 -2
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/executable/prepare.d.ts +4 -0
- package/dist/executable/prepare.js +7 -1
- package/dist/executable/prepare.js.map +1 -1
- package/dist/frontend/analysis.js +1 -0
- package/dist/frontend/analysis.js.map +1 -1
- package/dist/frontend/lowering/array-values.d.ts +7 -0
- package/dist/frontend/lowering/array-values.js +120 -4
- package/dist/frontend/lowering/array-values.js.map +1 -1
- package/dist/frontend/lowering/builtins/numbers.js +29 -1
- package/dist/frontend/lowering/builtins/numbers.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.d.ts +4 -0
- package/dist/frontend/lowering/builtins/process.js +10 -0
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.js +4 -2
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/class-assertions.d.ts +8 -0
- package/dist/frontend/lowering/class-assertions.js +217 -1
- package/dist/frontend/lowering/class-assertions.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.js +8 -5
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/coercions/state.d.ts +6 -0
- package/dist/frontend/lowering/coercions/state.js +2 -0
- package/dist/frontend/lowering/coercions/state.js.map +1 -1
- package/dist/frontend/lowering/coercions/unions.d.ts +8 -0
- package/dist/frontend/lowering/coercions/unions.js +67 -2
- package/dist/frontend/lowering/coercions/unions.js.map +1 -1
- package/dist/frontend/lowering/collation-repertoire.d.ts +1 -0
- package/dist/frontend/lowering/collation-repertoire.js +19 -0
- package/dist/frontend/lowering/collation-repertoire.js.map +1 -0
- package/dist/frontend/lowering/construction-escapes.d.ts +38 -0
- package/dist/frontend/lowering/construction-escapes.js +146 -0
- package/dist/frontend/lowering/construction-escapes.js.map +1 -0
- package/dist/frontend/lowering/construction-escapes.test.d.ts +1 -0
- package/dist/frontend/lowering/construction-escapes.test.js +150 -0
- package/dist/frontend/lowering/construction-escapes.test.js.map +1 -0
- package/dist/frontend/lowering/containers/array-callbacks.js +81 -44
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +15 -2
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +231 -12
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/callback-arguments.js +43 -1
- package/dist/frontend/lowering/containers/callback-arguments.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +7 -63
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/cycle-initialization.d.ts +6 -1
- package/dist/frontend/lowering/cycle-initialization.js +59 -33
- package/dist/frontend/lowering/cycle-initialization.js.map +1 -1
- package/dist/frontend/lowering/divergences.d.ts +9 -0
- package/dist/frontend/lowering/divergences.js +630 -0
- package/dist/frontend/lowering/divergences.js.map +1 -0
- package/dist/frontend/lowering/expressions/object-literals.js +40 -2
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +5 -0
- package/dist/frontend/lowering/lower-calls.js +226 -157
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +4 -0
- package/dist/frontend/lowering/lower-classes.js +72 -22
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +13 -0
- package/dist/frontend/lowering/lower-exprs.js +431 -107
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +19 -13
- package/dist/frontend/lowering/lower-generators.js +67 -44
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +3 -2
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +1 -1
- package/dist/frontend/lowering/lower-island.js +24 -7
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +90 -1
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +36 -6
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +78 -2
- package/dist/frontend/lowering/lowerer.js +986 -73
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/runtime-optional-bounds.d.ts +19 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js +354 -0
- package/dist/frontend/lowering/runtime-optional-bounds.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-bounds.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-bounds.test.js +66 -0
- package/dist/frontend/lowering/runtime-optional-bounds.test.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-elements.d.ts +117 -0
- package/dist/frontend/lowering/runtime-optional-elements.js +738 -0
- package/dist/frontend/lowering/runtime-optional-elements.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-guards.d.ts +36 -0
- package/dist/frontend/lowering/runtime-optional-guards.js +375 -0
- package/dist/frontend/lowering/runtime-optional-guards.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-guards.test.d.ts +1 -0
- package/dist/frontend/lowering/runtime-optional-guards.test.js +92 -0
- package/dist/frontend/lowering/runtime-optional-guards.test.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-ownership.d.ts +63 -0
- package/dist/frontend/lowering/runtime-optional-ownership.js +382 -0
- package/dist/frontend/lowering/runtime-optional-ownership.js.map +1 -0
- package/dist/frontend/lowering/runtime-optional-provenance.d.ts +2 -1
- package/dist/frontend/lowering/runtime-optional-provenance.js +2 -1
- package/dist/frontend/lowering/runtime-optional-provenance.js.map +1 -1
- package/dist/frontend/lowering/string-index-bounds.d.ts +36 -0
- package/dist/frontend/lowering/string-index-bounds.js +537 -0
- package/dist/frontend/lowering/string-index-bounds.js.map +1 -0
- package/dist/frontend/lowering/string-index-bounds.test.d.ts +1 -0
- package/dist/frontend/lowering/string-index-bounds.test.js +223 -0
- package/dist/frontend/lowering/string-index-bounds.test.js.map +1 -0
- package/dist/frontend/lowering/union-narrow.d.ts +2 -0
- package/dist/frontend/lowering/union-narrow.js +10 -6
- package/dist/frontend/lowering/union-narrow.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +10 -0
- package/dist/frontend/program-analysis.js +7 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.d.ts +25 -0
- package/dist/frontend/program.js +613 -17
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/program.test.js +64 -1
- package/dist/frontend/program.test.js.map +1 -1
- package/dist/frontend/resolve.d.ts +6 -0
- package/dist/frontend/resolve.js +14 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/threads-import.d.ts +5 -0
- package/dist/frontend/threads-import.js +21 -0
- package/dist/frontend/threads-import.js.map +1 -0
- package/dist/frontend/type-mapper.d.ts +3 -0
- package/dist/frontend/type-mapper.js +72 -6
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/worker-target.d.ts +4 -0
- package/dist/frontend/worker-target.js +8 -1
- package/dist/frontend/worker-target.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +47 -9
- package/dist/index.js.map +1 -1
- package/dist/ir/build.d.ts +5 -0
- package/dist/ir/build.js +7 -0
- package/dist/ir/build.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +3 -0
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/int32-slots.d.ts +72 -0
- package/dist/ir/int32-slots.js +837 -0
- package/dist/ir/int32-slots.js.map +1 -0
- package/dist/ir/int32-slots.test.d.ts +1 -0
- package/dist/ir/int32-slots.test.js +222 -0
- package/dist/ir/int32-slots.test.js.map +1 -0
- package/dist/ir/integer-ranges.d.ts +19 -3
- package/dist/ir/integer-ranges.js +168 -23
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +74 -2
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +24 -6
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/validate.js +21 -2
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +39 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/native/cache.d.ts +3 -0
- package/dist/native/cache.js +49 -1
- package/dist/native/cache.js.map +1 -1
- package/dist/native/cache.test.js +21 -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.d.ts +5 -0
- package/dist/native/compiler.js +51 -4
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/prepare.d.ts +4 -0
- package/dist/native/prepare.js +2 -1
- package/dist/native/prepare.js.map +1 -1
- package/dist/startup-cache.d.ts +2 -0
- package/dist/startup-cache.js +2 -0
- package/dist/startup-cache.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +1 -1
|
@@ -5,11 +5,15 @@ import { isRefCounted, typeEquals, typeKey } from "../../ir/ir.js";
|
|
|
5
5
|
import { mangleResolveThunk } from "../mangle.js";
|
|
6
6
|
import { elemAccess, FN_ATTRS, mapKeyAccess, mapKeyKindNum, mapKeyParamType, mapValKindNum, traceArg, vAdapters, } from "./shapes.js";
|
|
7
7
|
import { F64_INF, f64Lit } from "./common.js";
|
|
8
|
+
import { MUTATING_COLLECTION_METHODS } from "../publication.js";
|
|
8
9
|
import { borrowsStringInputs, emitStringInputs } from "./string-lifetimes.js";
|
|
9
|
-
import { emitMapLookupKey, borrowsMapReadInputs, borrowsMapMutationReceiver, } from "./map-read-lifetimes.js";
|
|
10
|
+
import { emitMapLookupKey, borrowsMapReadInputs, borrowsMapMutationReceiver, inlineNumberKey, } from "./map-read-lifetimes.js";
|
|
11
|
+
import { emitNumberMapGetRef, emitNumberMapGetScalar, emitNumberMapHas, } from "./map-number-lookup.js";
|
|
10
12
|
import { emitBorrowedInput } from "./borrowed-inputs.js";
|
|
11
13
|
import { emitStringSliceRead } from "./string-slices.js";
|
|
14
|
+
import { STRING_CHAR_CODE_AT_DECL, STRING_UTF16_LEN_DECL } from "./string-reads.js";
|
|
12
15
|
import { emitDenseArrayNumber, emitDenseArrayPush } from "./dense-array-access.js";
|
|
16
|
+
import { emitUnionWiden } from "./expr-records.js";
|
|
13
17
|
export function resolveThunkFor(host, inner) {
|
|
14
18
|
const key = typeKey(inner);
|
|
15
19
|
let sym = host.resolveThunks.get(key);
|
|
@@ -22,9 +26,9 @@ export function resolveThunkFor(host, inner) {
|
|
|
22
26
|
}
|
|
23
27
|
return sym;
|
|
24
28
|
}
|
|
25
|
-
export function tagInSet(host, uName, tags) {
|
|
29
|
+
export function tagInSet(host, uName, unionId, tags) {
|
|
26
30
|
const B = host.B;
|
|
27
|
-
const tag = host.unionTag(uName);
|
|
31
|
+
const tag = host.unionTag(uName, unionId);
|
|
28
32
|
let acc = "";
|
|
29
33
|
for (const t of tags) {
|
|
30
34
|
const c = B.tmp();
|
|
@@ -92,6 +96,97 @@ export function emitArrayValues(host, arr, acc, values, prepend = false, sharedB
|
|
|
92
96
|
}
|
|
93
97
|
return result;
|
|
94
98
|
}
|
|
99
|
+
/** A splice whose removed-elements array is discarded (statement position)
|
|
100
|
+
* and whose insertion items, if any, are plain evaluated values: evaluate
|
|
101
|
+
* the receiver, start, count, and items in order, then splice the values in
|
|
102
|
+
* without a result or argument array. Returns false for every other shape,
|
|
103
|
+
* which keeps the ordinary intrinsic. */
|
|
104
|
+
export function emitDiscardedSplice(host, e) {
|
|
105
|
+
if (!discardsSplice(e))
|
|
106
|
+
return false;
|
|
107
|
+
emitDiscarded(host, e);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
/** The plain-value items of a splice that can drop its result, or null. */
|
|
111
|
+
function droppableSpliceItems(e) {
|
|
112
|
+
if (e.kind !== "arrIntrinsic" || e.receiver.type.kind !== "array")
|
|
113
|
+
return null;
|
|
114
|
+
if (e.method === "splice")
|
|
115
|
+
return [];
|
|
116
|
+
if (e.method !== "spliceInsert")
|
|
117
|
+
return null;
|
|
118
|
+
const list = e.args[2];
|
|
119
|
+
if (list?.kind !== "arrayLit" || (list.spreads?.length ?? 0) > 0)
|
|
120
|
+
return null;
|
|
121
|
+
return list.elems.length <= 64 ? list.elems : null;
|
|
122
|
+
}
|
|
123
|
+
/** A droppable splice, possibly behind statements or one arm of a
|
|
124
|
+
* conditional (the runtime-optional item lowering). */
|
|
125
|
+
function discardsSplice(e) {
|
|
126
|
+
if (e.kind === "seqExpr")
|
|
127
|
+
return discardsSplice(e.result);
|
|
128
|
+
if (e.kind === "ternary")
|
|
129
|
+
return discardsSplice(e.then) || discardsSplice(e.else_);
|
|
130
|
+
return droppableSpliceItems(e) !== null;
|
|
131
|
+
}
|
|
132
|
+
/** Emit an expression whose value is unused. Ternary arms keep their own
|
|
133
|
+
* frames, exactly like an evaluated conditional. */
|
|
134
|
+
function emitDiscarded(host, e) {
|
|
135
|
+
const B = host.B;
|
|
136
|
+
if (e.kind === "seqExpr") {
|
|
137
|
+
for (const s of e.stmts)
|
|
138
|
+
host.emitStmt(s);
|
|
139
|
+
emitDiscarded(host, e.result);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (e.kind === "ternary") {
|
|
143
|
+
const c = host.emitExpr(e.cond);
|
|
144
|
+
const lt = B.newLabel("drop.t"), lf = B.newLabel("drop.f"), lj = B.newLabel("drop.j");
|
|
145
|
+
B.condBr(c.name, lt, lf);
|
|
146
|
+
for (const [label, arm] of [
|
|
147
|
+
[lt, e.then],
|
|
148
|
+
[lf, e.else_],
|
|
149
|
+
]) {
|
|
150
|
+
B.startBlock(label);
|
|
151
|
+
host.frames.push([]);
|
|
152
|
+
emitDiscarded(host, arm);
|
|
153
|
+
host.releaseFrame(host.frames.pop());
|
|
154
|
+
B.br(lj);
|
|
155
|
+
}
|
|
156
|
+
B.startBlock(lj);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const items = droppableSpliceItems(e);
|
|
160
|
+
if (items === null || e.kind !== "arrIntrinsic" || e.receiver.type.kind !== "array") {
|
|
161
|
+
host.emitExpr(e);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const r = emitBorrowedInput(host, e.receiver);
|
|
165
|
+
const acc = elemAccess(e.receiver.type.elem);
|
|
166
|
+
const start = host.emitExpr(e.args[0]);
|
|
167
|
+
const count = e.args[1] ? host.emitExpr(e.args[1]).name : F64_INF;
|
|
168
|
+
const values = items.map((item) => host.emitExpr(item));
|
|
169
|
+
if (acc === "ref")
|
|
170
|
+
values.forEach((value) => host.moveTemp(value));
|
|
171
|
+
let buffer = "null";
|
|
172
|
+
if (values.length > 0) {
|
|
173
|
+
buffer = B.tmp();
|
|
174
|
+
B.entryAllocas.push(`${buffer} = alloca [${values.length} x i64]`);
|
|
175
|
+
values.forEach((value, i) => {
|
|
176
|
+
const slot = B.tmp(), pointer = B.tmp();
|
|
177
|
+
const pack = acc === "f64"
|
|
178
|
+
? `bitcast double ${value.name} to i64`
|
|
179
|
+
: acc === "bool"
|
|
180
|
+
? `zext i1 ${value.name} to i64`
|
|
181
|
+
: `ptrtoint ptr ${value.name} to i64`;
|
|
182
|
+
B.line(`${slot} = ${pack}`);
|
|
183
|
+
B.line(`${pointer} = getelementptr inbounds i64, ptr ${buffer}, ${host.sizeType} ${i}`);
|
|
184
|
+
B.line(`store i64 ${slot}, ptr ${pointer}`);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
host.declare(`declare void @scr_arr_splice_drop(ptr, double, double, ${host.sizeType}, ptr)`);
|
|
188
|
+
B.line(`call void @scr_arr_splice_drop(ptr ${r.name}, double ${start.name}, double ${count}, ${host.sizeType} ${values.length}, ptr ${buffer})`);
|
|
189
|
+
}
|
|
95
190
|
export function emitArrayCopyLoop(host, dst, src, acc) {
|
|
96
191
|
void acc;
|
|
97
192
|
host.declare(`declare double @scr_arr_push_spread(ptr, ptr)`);
|
|
@@ -123,10 +218,19 @@ export function emitStrIntrinsic(host, e) {
|
|
|
123
218
|
};
|
|
124
219
|
const method = e.method;
|
|
125
220
|
switch (method) {
|
|
126
|
-
case "length":
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
221
|
+
case "length": {
|
|
222
|
+
// sc_str_utf16_len (string-reads.ts) answers proven-ASCII strings inline.
|
|
223
|
+
host.declare(STRING_UTF16_LEN_DECL);
|
|
224
|
+
const t = B.tmp();
|
|
225
|
+
B.line(`${t} = call double @sc_str_utf16_len(ptr ${r.name})`);
|
|
226
|
+
return { name: t, type: e.type };
|
|
227
|
+
}
|
|
228
|
+
case "charCodeAt": {
|
|
229
|
+
host.declare(STRING_CHAR_CODE_AT_DECL);
|
|
230
|
+
const t = B.tmp();
|
|
231
|
+
B.line(`${t} = call double @sc_str_char_code_at(ptr ${r.name}, double ${args[0].name})`);
|
|
232
|
+
return { name: t, type: e.type };
|
|
233
|
+
}
|
|
130
234
|
case "charAt":
|
|
131
235
|
return call("scr_str_char_at", "ptr (ptr, double)", `ptr ${r.name}, double ${args[0].name}`, "ptr", true);
|
|
132
236
|
case "indexOf":
|
|
@@ -153,8 +257,12 @@ export function emitStrIntrinsic(host, e) {
|
|
|
153
257
|
return call("scr_str_slice", "ptr (ptr, double, double)", `ptr ${r.name}, double ${args[0]?.name ?? f64Lit(0)}, double ${args[1]?.name ?? F64_INF}`, "ptr", true);
|
|
154
258
|
case "substring":
|
|
155
259
|
return call("scr_str_substring", "ptr (ptr, double, double)", `ptr ${r.name}, double ${args[0].name}, double ${args[1]?.name ?? F64_INF}`, "ptr", true);
|
|
156
|
-
case "repeat":
|
|
157
|
-
|
|
260
|
+
case "repeat": {
|
|
261
|
+
// A negative or infinite count throws Node's catchable RangeError.
|
|
262
|
+
const result = call("scr_str_repeat", "ptr (ptr, double)", `ptr ${r.name}, double ${args[0].name}`, "ptr", true);
|
|
263
|
+
host.emitPendingCheck();
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
158
266
|
case "trim":
|
|
159
267
|
return call("scr_str_trim", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
160
268
|
case "trimStart":
|
|
@@ -275,12 +383,19 @@ export function emitArrIntrinsic(host, e) {
|
|
|
275
383
|
// the last push's return, or the unchanged length for Node's
|
|
276
384
|
// no-op zero-argument call.
|
|
277
385
|
const vs = e.args.map((a) => host.emitExpr(a));
|
|
386
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 1, f64Lit(0), f64Lit(vs.length));
|
|
278
387
|
return { name: emitArrayValues(host, r.name, acc, vs), type: e.type };
|
|
279
388
|
}
|
|
280
389
|
case "pushSpread": {
|
|
281
390
|
// `a.push(...src)`: append src's elements in order (borrowed src,
|
|
282
391
|
// count snapshotted). Result: the new length.
|
|
283
392
|
const src = emitBorrowedInput(host, e.args[0]);
|
|
393
|
+
if (host.publishedTypes?.containerGuarded(e.receiver.type) === true) {
|
|
394
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
395
|
+
const n = B.tmp();
|
|
396
|
+
B.line(`${n} = call double @scr_arr_len(ptr ${src.name})`);
|
|
397
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 1, f64Lit(0), n);
|
|
398
|
+
}
|
|
284
399
|
host.emitArrayCopyLoop(r.name, src.name, acc);
|
|
285
400
|
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
286
401
|
const t = B.tmp();
|
|
@@ -298,11 +413,18 @@ export function emitArrIntrinsic(host, e) {
|
|
|
298
413
|
// Evaluate every argument before the first mutation, then insert
|
|
299
414
|
// from right to left so the final front order is source order.
|
|
300
415
|
const vs = e.args.map((a) => host.emitExpr(a));
|
|
416
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 4, f64Lit(0), f64Lit(vs.length));
|
|
301
417
|
return { name: emitArrayValues(host, r.name, acc, vs, true), type: e.type };
|
|
302
418
|
}
|
|
303
419
|
case "unshiftSpread": {
|
|
304
420
|
// The runtime snapshots the borrowed source and handles self-spread.
|
|
305
421
|
const src = emitBorrowedInput(host, e.args[0]);
|
|
422
|
+
if (host.publishedTypes?.containerGuarded(e.receiver.type) === true) {
|
|
423
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
424
|
+
const n = B.tmp();
|
|
425
|
+
B.line(`${n} = call double @scr_arr_len(ptr ${src.name})`);
|
|
426
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 4, f64Lit(0), n);
|
|
427
|
+
}
|
|
306
428
|
host.declare(`declare double @scr_arr_unshift_spread(ptr, ptr)`);
|
|
307
429
|
const t = B.tmp();
|
|
308
430
|
B.line(`${t} = call double @scr_arr_unshift_spread(ptr ${r.name}, ptr ${src.name})`);
|
|
@@ -310,6 +432,7 @@ export function emitArrIntrinsic(host, e) {
|
|
|
310
432
|
}
|
|
311
433
|
case "pop":
|
|
312
434
|
case "shift": {
|
|
435
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, method === "pop" ? 2 : 6);
|
|
313
436
|
const dynamic = elem.kind === "dyn" && e.type.kind === "dyn";
|
|
314
437
|
if (!dynamic && e.type.kind !== "union")
|
|
315
438
|
throw new InternalCompilerError("llvm emitter bug: array removal result is not a union");
|
|
@@ -342,7 +465,7 @@ export function emitArrIntrinsic(host, e) {
|
|
|
342
465
|
B.line(`${value} = icmp ne i64 ${raw}, 0`);
|
|
343
466
|
else
|
|
344
467
|
B.line(`${value} = inttoptr i64 ${raw} to ptr`);
|
|
345
|
-
B.line(`store ptr ${dynamic || sameUnion ? value : host.unionNewOwned(tag, { name: value, type: elem })}, ptr ${resultSlot}`);
|
|
468
|
+
B.line(`store ptr ${dynamic || sameUnion || e.type.kind !== "union" ? value : host.unionNewOwned(e.type.unionId, tag, { name: value, type: elem })}, ptr ${resultSlot}`);
|
|
346
469
|
B.br(lj);
|
|
347
470
|
B.startBlock(la);
|
|
348
471
|
if (dynamic) {
|
|
@@ -412,6 +535,8 @@ export function emitArrIntrinsic(host, e) {
|
|
|
412
535
|
}
|
|
413
536
|
case "sortPrimitive":
|
|
414
537
|
case "toSortedPrimitive": {
|
|
538
|
+
if (e.method === "sortPrimitive")
|
|
539
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 7);
|
|
415
540
|
host.declare(`declare ptr @scr_arr_sort_primitive(ptr, i1 zeroext)`);
|
|
416
541
|
const result = B.tmp();
|
|
417
542
|
B.line(`${result} = call ptr @scr_arr_sort_primitive(ptr ${r.name}, i1 ${e.method === "toSortedPrimitive" ? 1 : 0})`);
|
|
@@ -431,6 +556,7 @@ export function emitArrIntrinsic(host, e) {
|
|
|
431
556
|
}
|
|
432
557
|
case "reverse": {
|
|
433
558
|
// Mutates in place and returns the same receiver as a fresh +1.
|
|
559
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 7);
|
|
434
560
|
host.declare(`declare ptr @scr_arr_reverse(ptr)`);
|
|
435
561
|
const t = B.tmp();
|
|
436
562
|
B.line(`${t} = call ptr @scr_arr_reverse(ptr ${r.name})`);
|
|
@@ -440,6 +566,7 @@ export function emitArrIntrinsic(host, e) {
|
|
|
440
566
|
case "fill":
|
|
441
567
|
case "fillUndefined": {
|
|
442
568
|
const args = e.args.map((arg) => host.emitExpr(arg));
|
|
569
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 7);
|
|
443
570
|
const helper = e.method === "copyWithin"
|
|
444
571
|
? "scr_arr_copy_within"
|
|
445
572
|
: e.method === "fillUndefined"
|
|
@@ -488,6 +615,7 @@ export function emitArrIntrinsic(host, e) {
|
|
|
488
615
|
// removes to the end (+Infinity, the slice convention).
|
|
489
616
|
const start = host.emitExpr(e.args[0]);
|
|
490
617
|
const cnt = e.args[1] ? host.emitExpr(e.args[1]).name : F64_INF;
|
|
618
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 7);
|
|
491
619
|
host.declare(`declare ptr @scr_arr_splice(ptr, double, double)`);
|
|
492
620
|
const t = B.tmp();
|
|
493
621
|
B.line(`${t} = call ptr @scr_arr_splice(ptr ${r.name}, double ${start.name}, double ${cnt})`);
|
|
@@ -497,6 +625,7 @@ export function emitArrIntrinsic(host, e) {
|
|
|
497
625
|
const start = host.emitExpr(e.args[0]);
|
|
498
626
|
const count = host.emitExpr(e.args[1]);
|
|
499
627
|
const items = emitBorrowedInput(host, e.args[2]);
|
|
628
|
+
host.emitPublishedArrayGuard(r.name, e.receiver.type, 7);
|
|
500
629
|
host.declare(`declare ptr @scr_arr_splice_insert(ptr, double, double, ptr)`);
|
|
501
630
|
const t = B.tmp();
|
|
502
631
|
B.line(`${t} = call ptr @scr_arr_splice_insert(ptr ${r.name}, double ${start.name}, double ${count.name}, ptr ${items.name})`);
|
|
@@ -519,6 +648,16 @@ export function emitArrIntrinsic(host, e) {
|
|
|
519
648
|
}
|
|
520
649
|
export function wrapNullable(host, raw, present, valueType, valueTag, resultType, absentTag) {
|
|
521
650
|
const B = host.B;
|
|
651
|
+
if (host.nullableUnions.has(resultType.unionId)) {
|
|
652
|
+
// A nullable union is its present payload, or the absent arm's encoding.
|
|
653
|
+
const absent = host.unitInstanceRef(resultType.unionId, absentTag);
|
|
654
|
+
if (raw === present && absent === "null")
|
|
655
|
+
return host.own({ name: present, type: resultType });
|
|
656
|
+
const isnull = B.tmp(), t = B.tmp();
|
|
657
|
+
B.line(`${isnull} = icmp eq ptr ${raw}, null`);
|
|
658
|
+
B.line(`${t} = select i1 ${isnull}, ptr ${absent}, ptr ${present}`);
|
|
659
|
+
return host.own({ name: t, type: resultType });
|
|
660
|
+
}
|
|
522
661
|
const slot = B.slot();
|
|
523
662
|
B.entryAllocas.push(`${slot} = alloca ptr`);
|
|
524
663
|
const isnull = B.tmp();
|
|
@@ -528,7 +667,7 @@ export function wrapNullable(host, raw, present, valueType, valueTag, resultType
|
|
|
528
667
|
const lj = B.newLabel("nw.j");
|
|
529
668
|
B.condBr(isnull, la, lp);
|
|
530
669
|
B.startBlock(lp);
|
|
531
|
-
B.line(`store ptr ${host.unionNewOwned(valueTag, { name: present, type: valueType })}, ptr ${slot}`);
|
|
670
|
+
B.line(`store ptr ${host.unionNewOwned(resultType.unionId, valueTag, { name: present, type: valueType })}, ptr ${slot}`);
|
|
532
671
|
B.br(lj);
|
|
533
672
|
B.startBlock(la);
|
|
534
673
|
B.line(`store ptr ${host.unitInstanceRef(resultType.unionId, absentTag)}, ptr ${slot}`);
|
|
@@ -612,6 +751,10 @@ export function emitMapLikeIntrinsic(host, e) {
|
|
|
612
751
|
const kAcc = mapKeyAccess(key);
|
|
613
752
|
const kTy = mapKeyParamType(kAcc);
|
|
614
753
|
const method = e.method;
|
|
754
|
+
// A published Map or Set rejects mutation (the guard precedes the
|
|
755
|
+
// operands, which each method evaluates itself).
|
|
756
|
+
if (MUTATING_COLLECTION_METHODS.has(method))
|
|
757
|
+
host.emitPublishedCollectionGuard(r.name, receiverType);
|
|
615
758
|
if (method === "clone" || method === "keySet") {
|
|
616
759
|
const keysOnly = method === "keySet" || receiverType.kind === "set";
|
|
617
760
|
const checked = key.kind === "dyn" &&
|
|
@@ -715,12 +858,48 @@ export function emitMapLikeIntrinsic(host, e) {
|
|
|
715
858
|
if (!def || undefTag < 0)
|
|
716
859
|
throw new InternalCompilerError("llvm emitter bug: map get union lacks its undefined arm");
|
|
717
860
|
const absent = host.unitInstanceRef(e.type.unionId, undefTag);
|
|
718
|
-
if (value.kind === "union"
|
|
861
|
+
if (value.kind === "union" &&
|
|
862
|
+
host.nullableUnions.has(value.unionId) &&
|
|
863
|
+
!typeEquals(value, e.type)) {
|
|
864
|
+
// A nullable `C | null` value widens into `C | null | undefined`:
|
|
865
|
+
// NULL is the stored null, so presence decides the undefined arm.
|
|
866
|
+
host.declare(`declare zeroext i1 @scr_map_has_${kAcc}(ptr, ${kTy})`);
|
|
719
867
|
host.declare(`declare ptr @scr_map_get_${kAcc}_ref(ptr, ${kTy})`);
|
|
868
|
+
const has = B.tmp();
|
|
869
|
+
B.line(`${has} = call zeroext i1 @scr_map_has_${kAcc}(ptr ${r.name}, ${k.args})`);
|
|
870
|
+
const slot = B.slot();
|
|
871
|
+
B.entryAllocas.push(`${slot} = alloca ptr`);
|
|
872
|
+
const lp = B.newLabel("mgn.p");
|
|
873
|
+
const la = B.newLabel("mgn.a");
|
|
874
|
+
const lj = B.newLabel("mgn.j");
|
|
875
|
+
B.condBr(has, lp, la);
|
|
876
|
+
B.startBlock(lp);
|
|
720
877
|
const raw = B.tmp();
|
|
878
|
+
B.line(`${raw} = call ptr @scr_map_get_${kAcc}_ref(ptr ${r.name}, ${k.args})`);
|
|
879
|
+
const widened = emitUnionWiden(host, raw, value.unionId, e.type.unionId, true);
|
|
880
|
+
B.line(`store ptr ${widened}, ptr ${slot}`);
|
|
881
|
+
B.br(lj);
|
|
882
|
+
B.startBlock(la);
|
|
883
|
+
B.line(`store ptr ${absent}, ptr ${slot}`);
|
|
884
|
+
B.br(lj);
|
|
885
|
+
B.startBlock(lj);
|
|
886
|
+
const t = B.tmp();
|
|
887
|
+
B.line(`${t} = load ptr, ptr ${slot}`);
|
|
888
|
+
return host.own({ name: t, type: e.type });
|
|
889
|
+
}
|
|
890
|
+
const numberKey = inlineNumberKey(k);
|
|
891
|
+
if (value.kind === "union") {
|
|
721
892
|
const isnull = B.tmp();
|
|
722
893
|
const t = B.tmp();
|
|
723
|
-
|
|
894
|
+
let raw;
|
|
895
|
+
if (numberKey !== null) {
|
|
896
|
+
raw = emitNumberMapGetRef(host, r.name, numberKey, value);
|
|
897
|
+
}
|
|
898
|
+
else {
|
|
899
|
+
host.declare(`declare ptr @scr_map_get_${kAcc}_ref(ptr, ${kTy})`);
|
|
900
|
+
raw = B.tmp();
|
|
901
|
+
B.line(`${raw} = call ptr @scr_map_get_${kAcc}_ref(ptr ${r.name}, ${k.args})`);
|
|
902
|
+
}
|
|
724
903
|
B.line(`${isnull} = icmp eq ptr ${raw}, null`);
|
|
725
904
|
B.line(`${t} = select i1 ${isnull}, ptr ${absent}, ptr ${raw}`);
|
|
726
905
|
return host.own({ name: t, type: e.type });
|
|
@@ -730,12 +909,36 @@ export function emitMapLikeIntrinsic(host, e) {
|
|
|
730
909
|
throw new InternalCompilerError("llvm emitter bug: map get union lacks its value arm");
|
|
731
910
|
if (value.kind === "f64" || value.kind === "bool") {
|
|
732
911
|
const outTy = value.kind === "f64" ? "double" : "i8";
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
912
|
+
let found;
|
|
913
|
+
let readHit;
|
|
914
|
+
if (numberKey !== null) {
|
|
915
|
+
const scalar = emitNumberMapGetScalar(host, r.name, numberKey);
|
|
916
|
+
found = scalar.found;
|
|
917
|
+
readHit = () => {
|
|
918
|
+
const hit = B.tmp();
|
|
919
|
+
B.line(value.kind === "f64"
|
|
920
|
+
? `${hit} = bitcast i64 ${scalar.bits} to double`
|
|
921
|
+
: `${hit} = icmp ne i64 ${scalar.bits}, 0`);
|
|
922
|
+
return hit;
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
const outSlot = B.slot();
|
|
927
|
+
B.entryAllocas.push(`${outSlot} = alloca ${outTy}`);
|
|
928
|
+
B.line(`store ${outTy} ${value.kind === "f64" ? f64Lit(0) : "0"}, ptr ${outSlot}`);
|
|
929
|
+
host.declare(`declare zeroext i1 @scr_map_get_${kAcc}_${value.kind === "f64" ? "f64" : "bool"}(ptr, ${kTy}, ptr)`);
|
|
930
|
+
found = B.tmp();
|
|
931
|
+
B.line(`${found} = call zeroext i1 @scr_map_get_${kAcc}_${value.kind === "f64" ? "f64" : "bool"}(ptr ${r.name}, ${k.args}, ptr ${outSlot})`);
|
|
932
|
+
readHit = () => {
|
|
933
|
+
const rawOut = B.tmp();
|
|
934
|
+
B.line(`${rawOut} = load ${outTy}, ptr ${outSlot}`);
|
|
935
|
+
if (value.kind !== "bool")
|
|
936
|
+
return rawOut;
|
|
937
|
+
const hit = B.tmp();
|
|
938
|
+
B.line(`${hit} = trunc i8 ${rawOut} to i1`);
|
|
939
|
+
return hit;
|
|
940
|
+
};
|
|
941
|
+
}
|
|
739
942
|
const slot = B.slot();
|
|
740
943
|
B.entryAllocas.push(`${slot} = alloca ptr`);
|
|
741
944
|
const lp = B.newLabel("mg.p");
|
|
@@ -743,14 +946,8 @@ export function emitMapLikeIntrinsic(host, e) {
|
|
|
743
946
|
const lj = B.newLabel("mg.j");
|
|
744
947
|
B.condBr(found, lp, la);
|
|
745
948
|
B.startBlock(lp);
|
|
746
|
-
const
|
|
747
|
-
B.line(
|
|
748
|
-
let hit = rawOut;
|
|
749
|
-
if (value.kind === "bool") {
|
|
750
|
-
hit = B.tmp();
|
|
751
|
-
B.line(`${hit} = trunc i8 ${rawOut} to i1`);
|
|
752
|
-
}
|
|
753
|
-
B.line(`store ptr ${host.unionNewOwned(valueTag, { name: hit, type: value })}, ptr ${slot}`);
|
|
949
|
+
const hit = readHit();
|
|
950
|
+
B.line(`store ptr ${host.unionNewOwned(e.type.unionId, valueTag, { name: hit, type: value })}, ptr ${slot}`);
|
|
754
951
|
B.br(lj);
|
|
755
952
|
B.startBlock(la);
|
|
756
953
|
B.line(`store ptr ${absent}, ptr ${slot}`);
|
|
@@ -760,6 +957,10 @@ export function emitMapLikeIntrinsic(host, e) {
|
|
|
760
957
|
B.line(`${t} = load ptr, ptr ${slot}`);
|
|
761
958
|
return host.own({ name: t, type: e.type });
|
|
762
959
|
}
|
|
960
|
+
if (numberKey !== null && isRefCounted(value)) {
|
|
961
|
+
const raw = emitNumberMapGetRef(host, r.name, numberKey, value);
|
|
962
|
+
return host.wrapNullable(raw, raw, value, valueTag, e.type, undefTag);
|
|
963
|
+
}
|
|
763
964
|
host.declare(`declare ptr @scr_map_get_${kAcc}_ref(ptr, ${kTy})`);
|
|
764
965
|
const raw = B.tmp();
|
|
765
966
|
B.line(`${raw} = call ptr @scr_map_get_${kAcc}_ref(ptr ${r.name}, ${k.args})`);
|
|
@@ -789,6 +990,8 @@ export function emitMapLikeIntrinsic(host, e) {
|
|
|
789
990
|
}
|
|
790
991
|
case "has": {
|
|
791
992
|
const k = borrowInputs ? host.emitReadReceiver(e.args[0]) : host.emitExpr(e.args[0]);
|
|
993
|
+
if (kAcc === "f64")
|
|
994
|
+
return { name: emitNumberMapHas(host, r.name, k.name), type: e.type };
|
|
792
995
|
host.declare(`declare zeroext i1 @scr_map_has_${kAcc}(ptr, ${kTy})`);
|
|
793
996
|
const t = B.tmp();
|
|
794
997
|
B.line(`${t} = call zeroext i1 @scr_map_has_${kAcc}(ptr ${r.name}, ${kTy} ${k.name})`);
|