@scriptc/compiler 0.0.34 → 0.0.36
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 +7 -6
- package/dist/backend/build-cache.d.ts +44 -0
- package/dist/backend/build-cache.js +241 -0
- package/dist/backend/build-cache.js.map +1 -0
- package/dist/backend/{emission/emit-async.d.ts → c/async.d.ts} +21 -30
- package/dist/backend/{emission/emit-async.js → c/async.js} +270 -286
- package/dist/backend/c/async.js.map +1 -0
- package/dist/backend/{emission/emitter.d.ts → c/c-emitter.d.ts} +6 -23
- package/dist/backend/{emission/emitter.js → c/c-emitter.js} +53 -107
- package/dist/backend/c/c-emitter.js.map +1 -0
- package/dist/backend/c/exprs.d.ts +8 -0
- package/dist/backend/c/exprs.js +7913 -0
- package/dist/backend/c/exprs.js.map +1 -0
- package/dist/backend/{emission/emit-island.d.ts → c/island.d.ts} +5 -5
- package/dist/backend/{emission/emit-island.js → c/island.js} +24 -22
- package/dist/backend/c/island.js.map +1 -0
- package/dist/backend/{emission → c}/may-throw.d.ts +1 -1
- package/dist/backend/{emission → c}/may-throw.js +1 -1
- package/dist/backend/c/may-throw.js.map +1 -0
- package/dist/backend/{emission/emit-shapes.d.ts → c/shapes.d.ts} +19 -19
- package/dist/backend/{emission/emit-shapes.js → c/shapes.js} +78 -87
- package/dist/backend/c/shapes.js.map +1 -0
- package/dist/backend/{emission/emit-stmts.d.ts → c/stmts.d.ts} +12 -12
- package/dist/backend/{emission/emit-stmts.js → c/stmts.js} +377 -343
- package/dist/backend/c/stmts.js.map +1 -0
- package/dist/backend/{emission/emit-types.d.ts → c/types.d.ts} +1 -1
- package/dist/backend/{emission/emit-types.js → c/types.js} +42 -286
- package/dist/backend/c/types.js.map +1 -0
- package/dist/backend/c/types.test.js +25 -0
- package/dist/backend/c/types.test.js.map +1 -0
- package/dist/backend/{emission/emit-walkers.d.ts → c/walkers.d.ts} +19 -41
- package/dist/backend/{emission/emit-walkers.js → c/walkers.js} +238 -298
- package/dist/backend/c/walkers.js.map +1 -0
- package/dist/backend/ffi-callbacks.d.ts +1 -1
- package/dist/backend/ffi-callbacks.js +4 -3
- package/dist/backend/ffi-callbacks.js.map +1 -1
- package/dist/backend/{library-identity.d.ts → library-identity-markers.d.ts} +0 -4
- package/dist/backend/{library-identity.js → library-identity-markers.js} +10 -9
- package/dist/backend/library-identity-markers.js.map +1 -0
- package/dist/backend/llvm/blocks.d.ts +4 -0
- package/dist/backend/llvm/blocks.js +29 -0
- package/dist/backend/llvm/blocks.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +2 -19
- package/dist/backend/llvm/classes.js +20 -52
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +4 -0
- package/dist/backend/llvm/common.js +27 -0
- package/dist/backend/llvm/common.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +3 -8
- package/dist/backend/llvm/dyn.js +152 -224
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +4 -1
- package/dist/backend/llvm/emitter.js +514 -9981
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-async.d.ts +4 -0
- package/dist/backend/llvm/expr-async.js +726 -0
- package/dist/backend/llvm/expr-async.js.map +1 -0
- package/dist/backend/llvm/expr-bytes.d.ts +13 -0
- package/dist/backend/llvm/expr-bytes.js +456 -0
- package/dist/backend/llvm/expr-bytes.js.map +1 -0
- package/dist/backend/llvm/expr-callbacks.d.ts +22 -0
- package/dist/backend/llvm/expr-callbacks.js +520 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -0
- package/dist/backend/llvm/expr-calls.d.ts +2 -0
- package/dist/backend/llvm/expr-calls.js +618 -0
- package/dist/backend/llvm/expr-calls.js.map +1 -0
- package/dist/backend/llvm/expr-containers.d.ts +25 -0
- package/dist/backend/llvm/expr-containers.js +623 -0
- package/dist/backend/llvm/expr-containers.js.map +1 -0
- package/dist/backend/llvm/expr-context.d.ts +255 -0
- package/dist/backend/llvm/expr-context.js +2 -0
- package/dist/backend/llvm/expr-context.js.map +1 -0
- package/dist/backend/llvm/expr-control.d.ts +2 -0
- package/dist/backend/llvm/expr-control.js +473 -0
- package/dist/backend/llvm/expr-control.js.map +1 -0
- package/dist/backend/llvm/expr-dispatch.d.ts +4 -0
- package/dist/backend/llvm/expr-dispatch.js +151 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -0
- package/dist/backend/llvm/expr-dynamic.d.ts +2 -0
- package/dist/backend/llvm/expr-dynamic.js +810 -0
- package/dist/backend/llvm/expr-dynamic.js.map +1 -0
- package/dist/backend/llvm/expr-island.d.ts +15 -0
- package/dist/backend/llvm/expr-island.js +690 -0
- package/dist/backend/llvm/expr-island.js.map +1 -0
- package/dist/backend/llvm/expr-primitives.d.ts +6 -0
- package/dist/backend/llvm/expr-primitives.js +622 -0
- package/dist/backend/llvm/expr-primitives.js.map +1 -0
- package/dist/backend/llvm/expr-records.d.ts +9 -0
- package/dist/backend/llvm/expr-records.js +299 -0
- package/dist/backend/llvm/expr-records.js.map +1 -0
- package/dist/backend/llvm/expr-stream-bridges.d.ts +13 -0
- package/dist/backend/llvm/expr-stream-bridges.js +396 -0
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -0
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +12 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +360 -0
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -0
- package/dist/backend/llvm/lib-dispatch.d.ts +5 -0
- package/dist/backend/llvm/lib-dispatch.js +267 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -0
- package/dist/backend/llvm/lib-filesystem.d.ts +6 -0
- package/dist/backend/llvm/lib-filesystem.js +594 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -0
- package/dist/backend/llvm/lib-network.d.ts +2 -0
- package/dist/backend/llvm/lib-network.js +429 -0
- package/dist/backend/llvm/lib-network.js.map +1 -0
- package/dist/backend/llvm/lib-process.d.ts +5 -0
- package/dist/backend/llvm/lib-process.js +585 -0
- package/dist/backend/llvm/lib-process.js.map +1 -0
- package/dist/backend/llvm/lib-shared.d.ts +6 -0
- package/dist/backend/llvm/lib-shared.js +687 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -0
- package/dist/backend/llvm/lib-stream.d.ts +2 -0
- package/dist/backend/llvm/lib-stream.js +470 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -0
- package/dist/backend/llvm/shapes.d.ts +12 -2
- package/dist/backend/llvm/shapes.js +66 -307
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/shapes.test.js +52 -0
- package/dist/backend/llvm/shapes.test.js.map +1 -0
- package/dist/backend/llvm/split.d.ts +43 -0
- package/dist/backend/llvm/split.js +227 -0
- package/dist/backend/llvm/split.js.map +1 -0
- package/dist/backend/llvm/split.test.d.ts +1 -0
- package/dist/backend/llvm/split.test.js +102 -0
- package/dist/backend/llvm/split.test.js.map +1 -0
- package/dist/backend/llvm/unsupported.d.ts +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -3
- package/dist/backend/llvm/walkers.js +164 -218
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +38 -0
- package/dist/backend/native-codegen.js +261 -0
- package/dist/backend/native-codegen.js.map +1 -0
- package/dist/backend/native-codegen.test.d.ts +1 -0
- package/dist/backend/native-codegen.test.js +188 -0
- package/dist/backend/native-codegen.test.js.map +1 -0
- package/dist/backend/native-link-info.d.ts +96 -0
- package/dist/backend/native-link-info.js +219 -0
- package/dist/backend/native-link-info.js.map +1 -0
- package/dist/backend/native-link-info.test.d.ts +1 -0
- package/dist/backend/native-link-info.test.js +134 -0
- package/dist/backend/native-link-info.test.js.map +1 -0
- package/dist/backend/{cc.d.ts → native-toolchain.d.ts} +139 -47
- package/dist/backend/{cc.js → native-toolchain.js} +1008 -910
- package/dist/backend/native-toolchain.js.map +1 -0
- package/dist/backend/native-toolchain.test.d.ts +1 -0
- package/dist/backend/{cc-cache.test.js → native-toolchain.test.js} +1297 -127
- package/dist/backend/native-toolchain.test.js.map +1 -0
- package/dist/backend/object-localize.js +1 -1
- package/dist/backend/object-localize.test.js +20 -0
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +10 -0
- package/dist/backend/runtime-abi.js +11 -0
- package/dist/backend/runtime-abi.js.map +1 -0
- package/dist/backend/runtime-pack.d.ts +137 -0
- package/dist/backend/runtime-pack.js +400 -0
- package/dist/backend/runtime-pack.js.map +1 -0
- package/dist/backend/runtime-pack.test.d.ts +1 -0
- package/dist/backend/runtime-pack.test.js +438 -0
- package/dist/backend/runtime-pack.test.js.map +1 -0
- package/dist/backend/targets.d.ts +30 -0
- package/dist/backend/targets.js +46 -0
- package/dist/backend/targets.js.map +1 -0
- package/dist/backend/targets.test.d.ts +1 -0
- package/dist/backend/targets.test.js +19 -0
- package/dist/backend/targets.test.js.map +1 -0
- package/dist/backend/vendor-archives.d.ts +41 -0
- package/dist/backend/vendor-archives.js +462 -0
- package/dist/backend/vendor-archives.js.map +1 -0
- package/dist/compat/fetch-profile.d.ts +0 -1
- package/dist/compat/fetch-profile.js +0 -1
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/report.js +3 -3
- package/dist/coverage/report.js.map +1 -1
- package/dist/coverage/surface-manifest.js +25 -32
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +11 -12
- package/dist/diagnostics/diagnostic.js +19 -17
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/render.d.ts +1 -1
- package/dist/diagnostics/render.js +1 -1
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/executable/executable-cache.d.ts +86 -0
- package/dist/executable/executable-cache.js +398 -0
- package/dist/executable/executable-cache.js.map +1 -0
- package/dist/executable/executable-cache.test.d.ts +1 -0
- package/dist/executable/executable-cache.test.js +300 -0
- package/dist/executable/executable-cache.test.js.map +1 -0
- package/dist/ffi/{profile.d.ts → ffi-manifest.d.ts} +7 -2
- package/dist/ffi/{profile.js → ffi-manifest.js} +2 -1
- package/dist/ffi/ffi-manifest.js.map +1 -0
- package/dist/frontend/builtin-modules.d.ts +21 -0
- package/dist/frontend/builtin-modules.js +82 -0
- package/dist/frontend/builtin-modules.js.map +1 -0
- package/dist/frontend/cjs-lexer.d.ts +7 -0
- package/dist/frontend/cjs-lexer.js +15 -17
- package/dist/frontend/cjs-lexer.js.map +1 -1
- package/dist/frontend/dts-paths.d.ts +26 -0
- package/dist/frontend/dts-paths.js +41 -0
- package/dist/frontend/dts-paths.js.map +1 -0
- package/dist/frontend/input-tracker.d.ts +0 -2
- package/dist/frontend/input-tracker.js +1 -4
- package/dist/frontend/input-tracker.js.map +1 -1
- package/dist/frontend/lib-contract.d.ts +1 -5
- package/dist/frontend/lib-contract.js +1 -1
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/lib-exports.d.ts +1 -1
- package/dist/frontend/lowering/call-position.d.ts +4 -0
- package/dist/frontend/lowering/call-position.js +7 -0
- package/dist/frontend/lowering/call-position.js.map +1 -0
- package/dist/frontend/lowering/callback-arg.d.ts +20 -0
- package/dist/frontend/lowering/callback-arg.js +44 -0
- package/dist/frontend/lowering/callback-arg.js.map +1 -0
- package/dist/frontend/lowering/lib-boundary.d.ts +1 -1
- package/dist/frontend/lowering/lib-boundary.js +34 -34
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.d.ts +3 -3
- package/dist/frontend/lowering/lower-assert.js +214 -241
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +74 -146
- package/dist/frontend/lowering/lower-builtins.js +1126 -1234
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +56 -188
- package/dist/frontend/lowering/lower-calls.js +1409 -1494
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +62 -125
- package/dist/frontend/lowering/lower-classes.js +832 -866
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-comptime.d.ts +5 -12
- package/dist/frontend/lowering/lower-comptime.js +32 -31
- package/dist/frontend/lowering/lower-comptime.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +35 -135
- package/dist/frontend/lowering/lower-containers.js +1394 -1715
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.d.ts +3 -7
- package/dist/frontend/lowering/lower-dgram.js +97 -111
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-enums.d.ts +4 -4
- package/dist/frontend/lowering/lower-enums.js +30 -30
- package/dist/frontend/lowering/lower-enums.js.map +1 -1
- package/dist/frontend/lowering/{lower-emitter.d.ts → lower-event-emitter.d.ts} +7 -18
- package/dist/frontend/lowering/{lower-emitter.js → lower-event-emitter.js} +172 -174
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -0
- package/dist/frontend/lowering/lower-expando.d.ts +5 -5
- package/dist/frontend/lowering/lower-expando.js +40 -40
- package/dist/frontend/lowering/lower-expando.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +56 -264
- package/dist/frontend/lowering/lower-exprs.js +1644 -1704
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.d.ts +6 -6
- package/dist/frontend/lowering/lower-generators.js +73 -72
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +5 -17
- package/dist/frontend/lowering/lower-inspect.js +236 -238
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +34 -45
- package/dist/frontend/lowering/lower-island.js +440 -511
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +7 -10
- package/dist/frontend/lowering/lower-mixins.js +86 -86
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +12 -18
- package/dist/frontend/lowering/lower-modules.js +284 -283
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +23 -49
- package/dist/frontend/lowering/lower-namespaces.js +123 -115
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +18 -25
- package/dist/frontend/lowering/lower-server.js +899 -899
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +30 -149
- package/dist/frontend/lowering/lower-stmts.js +1176 -1229
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +12 -12
- package/dist/frontend/lowering/lower-stream.js +300 -301
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.d.ts +5 -5
- package/dist/frontend/lowering/lower-test.js +82 -82
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +66 -20
- package/dist/frontend/lowering/lowerer.js +421 -198
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/pairs-snapshot.d.ts +11 -0
- package/dist/frontend/lowering/pairs-snapshot.js +85 -0
- package/dist/frontend/lowering/pairs-snapshot.js.map +1 -0
- package/dist/frontend/lowering/static-this.d.ts +6 -0
- package/dist/frontend/lowering/static-this.js +24 -0
- package/dist/frontend/lowering/static-this.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +14 -33
- package/dist/frontend/lowering/surfaces.js +64 -64
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm-static-rewrite.js +6 -28
- package/dist/frontend/npm-static-rewrite.js.map +1 -1
- package/dist/frontend/npm-static.d.ts +0 -10
- package/dist/frontend/npm-static.js +4 -7
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +0 -24
- package/dist/frontend/npm.js +11 -85
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/program.d.ts +3 -1
- package/dist/frontend/program.js +51 -17
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/provenance-registry.d.ts +0 -2
- package/dist/frontend/provenance-registry.js +0 -10
- package/dist/frontend/provenance-registry.js.map +1 -1
- package/dist/frontend/provenance.js +4 -7
- package/dist/frontend/provenance.js.map +1 -1
- package/dist/frontend/resolve.d.ts +7 -2
- package/dist/frontend/resolve.js +12 -17
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.d.ts +1 -0
- package/dist/frontend/resolve.test.js +29 -0
- package/dist/frontend/resolve.test.js.map +1 -0
- package/dist/frontend/ts7/adapter.d.ts +2 -2
- package/dist/frontend/ts7/adapter.js +1 -1
- package/dist/frontend/ts7/adapter.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +40 -2
- package/dist/frontend/ts7/checker.js +182 -54
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/enums.js +2 -1
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/{program.js → program-adapter.js} +7 -6
- package/dist/frontend/ts7/program-adapter.js.map +1 -0
- package/dist/frontend/ts7/world-check.d.ts +1 -3
- package/dist/frontend/ts7/world-check.js +3 -1
- package/dist/frontend/ts7/world-check.js.map +1 -1
- package/dist/frontend/tsc-codes.d.ts +8 -0
- package/dist/frontend/tsc-codes.js +109 -0
- package/dist/frontend/tsc-codes.js.map +1 -0
- package/dist/frontend/{types.d.ts → type-mapper.d.ts} +2 -25
- package/dist/frontend/{types.js → type-mapper.js} +31 -52
- package/dist/frontend/type-mapper.js.map +1 -0
- package/dist/frontend/workspace-registry.d.ts +26 -0
- package/dist/frontend/workspace-registry.js +71 -0
- package/dist/frontend/workspace-registry.js.map +1 -0
- package/dist/index.d.ts +115 -30
- package/dist/index.js +650 -146
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.d.ts +37 -0
- package/dist/ir/analysis.js +118 -0
- package/dist/ir/analysis.js.map +1 -0
- package/dist/ir/analysis.test.d.ts +1 -0
- package/dist/ir/analysis.test.js +21 -0
- package/dist/ir/analysis.test.js.map +1 -0
- package/dist/ir/build.d.ts +9 -0
- package/dist/ir/build.js +33 -0
- package/dist/ir/build.js.map +1 -0
- package/dist/ir/integer-loops.d.ts +1 -1
- package/dist/ir/{nodes.d.ts → ir.d.ts} +60 -26
- package/dist/ir/{nodes.js → ir.js} +173 -141
- package/dist/ir/ir.js.map +1 -0
- package/dist/ir/ir.test.d.ts +1 -0
- package/dist/ir/ir.test.js +17 -0
- package/dist/ir/ir.test.js.map +1 -0
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +2 -1
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.d.ts +1 -1
- package/dist/ir/validate.js +16 -5
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/cache-primitives.d.ts +24 -0
- package/dist/library/cache-primitives.js +83 -0
- package/dist/library/cache-primitives.js.map +1 -0
- package/dist/library/cache-reset.test.d.ts +1 -0
- package/dist/library/cache-reset.test.js +47 -0
- package/dist/library/cache-reset.test.js.map +1 -0
- package/dist/library/compiler-self-identity.d.ts +23 -0
- package/dist/library/compiler-self-identity.js +84 -0
- package/dist/library/compiler-self-identity.js.map +1 -0
- package/dist/library/fence-eval.d.ts +3 -1
- package/dist/library/fence-eval.js +5 -1
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.d.ts +1 -36
- package/dist/library/int-infer.js +17 -17
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/{early-cache.d.ts → library-cache.d.ts} +1 -1
- package/dist/library/{early-cache.js → library-cache.js} +37 -111
- package/dist/library/library-cache.js.map +1 -0
- package/dist/library/library-cache.test.d.ts +1 -0
- package/dist/library/{early-cache.test.js → library-cache.test.js} +2 -2
- package/dist/library/library-cache.test.js.map +1 -0
- package/dist/library/{profile.d.ts → library-profile.d.ts} +4 -7
- package/dist/library/{profile.js → library-profile.js} +18 -11
- package/dist/library/library-profile.js.map +1 -0
- package/dist/library/semantic-source.js +2 -1
- package/dist/library/semantic-source.js.map +1 -1
- package/dist/library/sidecar.d.ts +5 -2
- package/dist/library/sidecar.js +11 -5
- package/dist/library/sidecar.js.map +1 -1
- package/dist/startup-cache.d.ts +6 -0
- package/dist/startup-cache.js +6 -0
- package/dist/startup-cache.js.map +1 -0
- package/package.json +7 -2
- package/surface-manifest.json +1 -1
- package/dist/backend/cc-cache.test.js.map +0 -1
- package/dist/backend/cc.js.map +0 -1
- package/dist/backend/emission/emit-async.js.map +0 -1
- package/dist/backend/emission/emit-exprs.d.ts +0 -13
- package/dist/backend/emission/emit-exprs.js +0 -7407
- package/dist/backend/emission/emit-exprs.js.map +0 -1
- package/dist/backend/emission/emit-island.js.map +0 -1
- package/dist/backend/emission/emit-shapes.js.map +0 -1
- package/dist/backend/emission/emit-stmts.js.map +0 -1
- package/dist/backend/emission/emit-types.js.map +0 -1
- package/dist/backend/emission/emit-walkers.js.map +0 -1
- package/dist/backend/emission/emitter.js.map +0 -1
- package/dist/backend/emission/may-throw.js.map +0 -1
- package/dist/backend/library-identity.js.map +0 -1
- package/dist/ffi/profile.js.map +0 -1
- package/dist/frontend/lowering/lower-emitter.js.map +0 -1
- package/dist/frontend/shared.d.ts +0 -82
- package/dist/frontend/shared.js +0 -308
- package/dist/frontend/shared.js.map +0 -1
- package/dist/frontend/ts7/program.js.map +0 -1
- package/dist/frontend/types.js.map +0 -1
- package/dist/ir/nodes.js.map +0 -1
- package/dist/library/early-cache.js.map +0 -1
- package/dist/library/early-cache.test.js.map +0 -1
- package/dist/library/profile.js.map +0 -1
- /package/dist/backend/{cc-cache.test.d.ts → c/types.test.d.ts} +0 -0
- /package/dist/{library/early-cache.test.d.ts → backend/llvm/shapes.test.d.ts} +0 -0
- /package/dist/frontend/ts7/{program.d.ts → program-adapter.d.ts} +0 -0
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
/* Focused LLVM expression emission extracted from emitter.ts. */
|
|
2
|
+
import { InternalCompilerError } from "../../errors.js";
|
|
3
|
+
import { undefinedArmTag } from "../../ir/analysis.js";
|
|
4
|
+
import { isRefCounted, typeEquals, typeKey } from "../../ir/ir.js";
|
|
5
|
+
import { mangleResolveThunk } from "../mangle.js";
|
|
6
|
+
import { elemAccess, FN_ATTRS, mapKeyAccess, mapKeyKindNum, mapValKindNum, traceArg, vAdapters } from "./shapes.js";
|
|
7
|
+
import { F64_INF, f64Lit } from "./common.js";
|
|
8
|
+
export function resolveThunkFor(host, inner) {
|
|
9
|
+
const key = typeKey(inner);
|
|
10
|
+
let sym = host.resolveThunks.get(key);
|
|
11
|
+
if (!sym) {
|
|
12
|
+
sym = mangleResolveThunk(host.resolveThunks.size);
|
|
13
|
+
host.resolveThunks.set(key, sym);
|
|
14
|
+
const v = vAdapters(host, inner);
|
|
15
|
+
host.declare(`declare void @scr_resolve_ref_impl(ptr, ptr, ptr, ptr, ptr)`);
|
|
16
|
+
host.resolveThunkDefs.push(`define internal void @${sym}(ptr %self, ptr %v) ${FN_ATTRS} { ; resolve<${key}>`, `entry:`, ` call void @scr_resolve_ref_impl(ptr %self, ptr %v, ptr ${v.retain}, ptr ${v.release}, ptr ${traceArg(host, inner)})`, ` ret void`, `}`, ``);
|
|
17
|
+
}
|
|
18
|
+
return sym;
|
|
19
|
+
}
|
|
20
|
+
export function tagInSet(host, uName, tags) {
|
|
21
|
+
const B = host.B;
|
|
22
|
+
const tag = host.unionTag(uName);
|
|
23
|
+
let acc = "";
|
|
24
|
+
for (const t of tags) {
|
|
25
|
+
const c = B.tmp();
|
|
26
|
+
B.line(`${c} = icmp eq i32 ${tag}, ${t}`);
|
|
27
|
+
if (acc === "") {
|
|
28
|
+
acc = c;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const o = B.tmp();
|
|
32
|
+
B.line(`${o} = or i1 ${acc}, ${c}`);
|
|
33
|
+
acc = o;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
export function arrPush(host, arr, acc, value) {
|
|
39
|
+
const argTy = acc === "f64" ? "double" : acc === "bool" ? "i1" : "ptr";
|
|
40
|
+
host.declare(`declare double @scr_arr_push_${acc}(ptr, ${argTy === "i1" ? "i1 zeroext" : argTy})`);
|
|
41
|
+
const t = host.B.tmp();
|
|
42
|
+
host.B.line(`${t} = call double @scr_arr_push_${acc}(ptr ${arr}, ${argTy} ${value})`);
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
export function emitArrayCopyLoop(host, dst, src, acc) {
|
|
46
|
+
const B = host.B;
|
|
47
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
48
|
+
const accTy = acc === "f64" ? "double" : acc === "bool" ? "i1" : "ptr";
|
|
49
|
+
host.declare(`declare ${acc === "bool" ? "zeroext i1" : accTy} @scr_arr_get_${acc}(ptr, double)`);
|
|
50
|
+
const len = B.tmp();
|
|
51
|
+
B.line(`${len} = call double @scr_arr_len(ptr ${src})`);
|
|
52
|
+
B.countedLoop(len, (i) => {
|
|
53
|
+
const v = B.tmp();
|
|
54
|
+
B.line(`${v} = call ${accTy} @scr_arr_get_${acc}(ptr ${src}, double ${i})`);
|
|
55
|
+
host.arrPush(dst, acc, v);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export function emitStrIntrinsic(host, e) {
|
|
59
|
+
// Receiver and string arguments are owned temps in the current frame;
|
|
60
|
+
// every scr_str_* method BORROWS them. String/array-returning methods
|
|
61
|
+
// hand back a +1 reference, which own() registers like any other.
|
|
62
|
+
// Omitted optional args get the C-side defaults from docs/ir.md.
|
|
63
|
+
const B = host.B;
|
|
64
|
+
const r = host.emitExpr(e.receiver);
|
|
65
|
+
const args = e.args.map((a) => host.emitExpr(a));
|
|
66
|
+
const call = (sym, sig, argText, retTy, owned) => {
|
|
67
|
+
// sig reads "<ret> (<params>)" — respelled to LLVM's declare form.
|
|
68
|
+
const m = /^(.+?) \((.*)\)$/.exec(sig);
|
|
69
|
+
if (!m)
|
|
70
|
+
throw new InternalCompilerError(`llvm emitter bug: bad strIntrinsic sig ${sig}`);
|
|
71
|
+
host.declare(`declare ${m[1]} @${sym}(${m[2]})`);
|
|
72
|
+
const t = B.tmp();
|
|
73
|
+
B.line(`${t} = call ${retTy} @${sym}(${argText})`);
|
|
74
|
+
return owned ? host.own({ name: t, type: e.type }) : { name: t, type: e.type };
|
|
75
|
+
};
|
|
76
|
+
const method = e.method;
|
|
77
|
+
switch (method) {
|
|
78
|
+
case "length":
|
|
79
|
+
return call("scr_str_utf16_len", "double (ptr)", `ptr ${r.name}`, "double", false);
|
|
80
|
+
case "charCodeAt":
|
|
81
|
+
return call("scr_str_char_code_at", "double (ptr, double)", `ptr ${r.name}, double ${args[0].name}`, "double", false);
|
|
82
|
+
case "charAt":
|
|
83
|
+
return call("scr_str_char_at", "ptr (ptr, double)", `ptr ${r.name}, double ${args[0].name}`, "ptr", true);
|
|
84
|
+
case "indexOf":
|
|
85
|
+
return call("scr_str_index_of", "double (ptr, ptr, double)", `ptr ${r.name}, ptr ${args[0].name}, double ${args[1]?.name ?? f64Lit(0)}`, "double", false);
|
|
86
|
+
case "includes": {
|
|
87
|
+
if (args[1]) {
|
|
88
|
+
// The position form is indexOf's clamp exactly: found ⇔ != -1.
|
|
89
|
+
const idx = call("scr_str_index_of", "double (ptr, ptr, double)", `ptr ${r.name}, ptr ${args[0].name}, double ${args[1].name}`, "double", false);
|
|
90
|
+
const t = B.tmp();
|
|
91
|
+
B.line(`${t} = fcmp une double ${idx.name}, ${f64Lit(-1)}`);
|
|
92
|
+
return { name: t, type: e.type };
|
|
93
|
+
}
|
|
94
|
+
return call("scr_str_includes", "zeroext i1 (ptr, ptr)", `ptr ${r.name}, ptr ${args[0].name}`, "i1", false);
|
|
95
|
+
}
|
|
96
|
+
case "startsWith":
|
|
97
|
+
return call("scr_str_starts_with", "zeroext i1 (ptr, ptr)", `ptr ${r.name}, ptr ${args[0].name}`, "i1", false);
|
|
98
|
+
case "endsWith":
|
|
99
|
+
return call("scr_str_ends_with", "zeroext i1 (ptr, ptr)", `ptr ${r.name}, ptr ${args[0].name}`, "i1", false);
|
|
100
|
+
case "slice":
|
|
101
|
+
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);
|
|
102
|
+
case "substring":
|
|
103
|
+
return call("scr_str_substring", "ptr (ptr, double, double)", `ptr ${r.name}, double ${args[0].name}, double ${args[1]?.name ?? F64_INF}`, "ptr", true);
|
|
104
|
+
case "repeat":
|
|
105
|
+
return call("scr_str_repeat", "ptr (ptr, double)", `ptr ${r.name}, double ${args[0].name}`, "ptr", true);
|
|
106
|
+
case "trim":
|
|
107
|
+
return call("scr_str_trim", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
108
|
+
case "trimStart":
|
|
109
|
+
return call("scr_str_trim_start", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
110
|
+
case "trimEnd":
|
|
111
|
+
return call("scr_str_trim_end", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
112
|
+
case "split":
|
|
113
|
+
return call("scr_str_split_limit", "ptr (ptr, ptr, double)", `ptr ${r.name}, ptr ${args[0].name}, double ${args[1].name}`, "ptr", true);
|
|
114
|
+
case "padStart":
|
|
115
|
+
return call("scr_str_pad_start", "ptr (ptr, double, ptr)", `ptr ${r.name}, double ${args[0].name}, ptr ${args[1].name}`, "ptr", true);
|
|
116
|
+
case "padEnd":
|
|
117
|
+
return call("scr_str_pad_end", "ptr (ptr, double, ptr)", `ptr ${r.name}, double ${args[0].name}, ptr ${args[1].name}`, "ptr", true);
|
|
118
|
+
case "toLowerCase":
|
|
119
|
+
return call("scr_str_to_lower", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
120
|
+
case "toUpperCase":
|
|
121
|
+
return call("scr_str_to_upper", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
122
|
+
// The well-formedness pair: no-ops over well-formed storage
|
|
123
|
+
// (constant true / retained identity; scr_string.c).
|
|
124
|
+
case "isWellFormed":
|
|
125
|
+
return call("scr_str_is_well_formed", "zeroext i1 (ptr)", `ptr ${r.name}`, "i1", false);
|
|
126
|
+
case "toWellFormed":
|
|
127
|
+
return call("scr_str_to_well_formed", "ptr (ptr)", `ptr ${r.name}`, "ptr", true);
|
|
128
|
+
case "cpAt":
|
|
129
|
+
// The code point AT an index as a one-code-point string (+1) —
|
|
130
|
+
// the string-for-of desugar's read.
|
|
131
|
+
return call("scr_str_cp_at", "ptr (ptr, double)", `ptr ${r.name}, double ${args[0].name}`, "ptr", true);
|
|
132
|
+
default: {
|
|
133
|
+
const _exhaustive = method;
|
|
134
|
+
void _exhaustive;
|
|
135
|
+
throw new InternalCompilerError("unreachable");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export function emitArrIntrinsic(host, e) {
|
|
140
|
+
const B = host.B;
|
|
141
|
+
const r = host.emitExpr(e.receiver);
|
|
142
|
+
if (e.receiver.type.kind !== "array")
|
|
143
|
+
throw new InternalCompilerError("llvm emitter bug: arrIntrinsic on non-array");
|
|
144
|
+
const elem = e.receiver.type.elem;
|
|
145
|
+
const acc = elemAccess(elem);
|
|
146
|
+
const accTy = acc === "f64" ? "double" : acc === "bool" ? "i1" : "ptr";
|
|
147
|
+
const accArg = acc === "bool" ? "i1 zeroext" : accTy;
|
|
148
|
+
const method = e.method;
|
|
149
|
+
switch (method) {
|
|
150
|
+
case "length": {
|
|
151
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
152
|
+
const t = B.tmp();
|
|
153
|
+
B.line(`${t} = call double @scr_arr_len(ptr ${r.name})`);
|
|
154
|
+
return { name: t, type: e.type };
|
|
155
|
+
}
|
|
156
|
+
case "push": {
|
|
157
|
+
// Variadic like JS: every argument evaluates first (left to
|
|
158
|
+
// right), then each appends in order. Ownership of refcounted
|
|
159
|
+
// arguments moves into the array; the result is the new length —
|
|
160
|
+
// the last push's return, or the unchanged length for Node's
|
|
161
|
+
// no-op zero-argument call.
|
|
162
|
+
const vs = e.args.map((a) => host.emitExpr(a));
|
|
163
|
+
if (acc === "ref")
|
|
164
|
+
vs.forEach((v) => host.moveTemp(v));
|
|
165
|
+
let last = "";
|
|
166
|
+
for (const v of vs)
|
|
167
|
+
last = host.arrPush(r.name, acc, v.name);
|
|
168
|
+
if (last !== "")
|
|
169
|
+
return { name: last, type: e.type };
|
|
170
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
171
|
+
const t = B.tmp();
|
|
172
|
+
B.line(`${t} = call double @scr_arr_len(ptr ${r.name})`);
|
|
173
|
+
return { name: t, type: e.type };
|
|
174
|
+
}
|
|
175
|
+
case "pushSpread": {
|
|
176
|
+
// `a.push(...src)`: append src's elements in order (borrowed src,
|
|
177
|
+
// count snapshotted). Result: the new length.
|
|
178
|
+
const src = host.emitExpr(e.args[0]);
|
|
179
|
+
host.emitArrayCopyLoop(r.name, src.name, acc);
|
|
180
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
181
|
+
const t = B.tmp();
|
|
182
|
+
B.line(`${t} = call double @scr_arr_len(ptr ${r.name})`);
|
|
183
|
+
return { name: t, type: e.type };
|
|
184
|
+
}
|
|
185
|
+
case "unshift": {
|
|
186
|
+
// Evaluate every argument before the first mutation, then insert
|
|
187
|
+
// from right to left so the final front order is source order.
|
|
188
|
+
const vs = e.args.map((a) => host.emitExpr(a));
|
|
189
|
+
if (acc === "ref")
|
|
190
|
+
vs.forEach((v) => host.moveTemp(v));
|
|
191
|
+
host.declare(`declare double @scr_arr_unshift_${acc}(ptr, ${accArg})`);
|
|
192
|
+
let last = "";
|
|
193
|
+
for (let i = vs.length - 1; i >= 0; i--) {
|
|
194
|
+
last = B.tmp();
|
|
195
|
+
B.line(`${last} = call double @scr_arr_unshift_${acc}(ptr ${r.name}, ${accTy} ${vs[i].name})`);
|
|
196
|
+
}
|
|
197
|
+
if (last !== "")
|
|
198
|
+
return { name: last, type: e.type };
|
|
199
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
200
|
+
const t = B.tmp();
|
|
201
|
+
B.line(`${t} = call double @scr_arr_len(ptr ${r.name})`);
|
|
202
|
+
return { name: t, type: e.type };
|
|
203
|
+
}
|
|
204
|
+
case "unshiftSpread": {
|
|
205
|
+
// The runtime snapshots the borrowed source and handles self-spread.
|
|
206
|
+
const src = host.emitExpr(e.args[0]);
|
|
207
|
+
host.declare(`declare double @scr_arr_unshift_spread(ptr, ptr)`);
|
|
208
|
+
const t = B.tmp();
|
|
209
|
+
B.line(`${t} = call double @scr_arr_unshift_spread(ptr ${r.name}, ptr ${src.name})`);
|
|
210
|
+
return { name: t, type: e.type };
|
|
211
|
+
}
|
|
212
|
+
case "pop": {
|
|
213
|
+
// Ownership of a refcounted element moves OUT of the array to
|
|
214
|
+
// this temp (+1 to us, the runtime does not release it).
|
|
215
|
+
host.declare(`declare ${acc === "bool" ? "zeroext i1" : accTy} @scr_arr_pop_${acc}(ptr)`);
|
|
216
|
+
const t = B.tmp();
|
|
217
|
+
B.line(`${t} = call ${accTy} @scr_arr_pop_${acc}(ptr ${r.name})`);
|
|
218
|
+
return host.own({ name: t, type: e.type });
|
|
219
|
+
}
|
|
220
|
+
case "indexOf": {
|
|
221
|
+
// The needle is BORROWED (released with this statement's frame);
|
|
222
|
+
// the ref variant dispatches on the array's element kind (strings
|
|
223
|
+
// by content, everything else by pointer). Strict equality.
|
|
224
|
+
const v = host.emitExpr(e.args[0]);
|
|
225
|
+
host.declare(`declare double @scr_arr_index_of_${acc}(ptr, ${accArg})`);
|
|
226
|
+
const t = B.tmp();
|
|
227
|
+
B.line(`${t} = call double @scr_arr_index_of_${acc}(ptr ${r.name}, ${accTy} ${v.name})`);
|
|
228
|
+
return { name: t, type: e.type };
|
|
229
|
+
}
|
|
230
|
+
case "includes": {
|
|
231
|
+
// Borrowed needle, SameValueZero (NaN matches NaN).
|
|
232
|
+
const v = host.emitExpr(e.args[0]);
|
|
233
|
+
host.declare(`declare zeroext i1 @scr_arr_includes_${acc}(ptr, ${accArg})`);
|
|
234
|
+
const t = B.tmp();
|
|
235
|
+
B.line(`${t} = call zeroext i1 @scr_arr_includes_${acc}(ptr ${r.name}, ${accTy} ${v.name})`);
|
|
236
|
+
return { name: t, type: e.type };
|
|
237
|
+
}
|
|
238
|
+
case "join": {
|
|
239
|
+
// Separator borrowed; the result is an owned (+1) string. Union
|
|
240
|
+
// elements ride the per-union join walker (nullish arms print
|
|
241
|
+
// empty, everything else through the union ToString) — the C
|
|
242
|
+
// emitter's sc_uj_*, ported in walkers.ts.
|
|
243
|
+
const sep = host.emitExpr(e.args[0]);
|
|
244
|
+
if (elem.kind === "union") {
|
|
245
|
+
const helper = host.walkers.unionJoinHelper(elem.unionId);
|
|
246
|
+
const t = B.tmp();
|
|
247
|
+
B.line(`${t} = call ptr @${helper}(ptr ${r.name}, ptr ${sep.name})`);
|
|
248
|
+
return host.own({ name: t, type: e.type });
|
|
249
|
+
}
|
|
250
|
+
host.declare(`declare ptr @scr_arr_join(ptr, ptr)`);
|
|
251
|
+
const t = B.tmp();
|
|
252
|
+
B.line(`${t} = call ptr @scr_arr_join(ptr ${r.name}, ptr ${sep.name})`);
|
|
253
|
+
return host.own({ name: t, type: e.type });
|
|
254
|
+
}
|
|
255
|
+
case "slice": {
|
|
256
|
+
// Receiver borrowed; the result a fresh +1 shallow copy (ref
|
|
257
|
+
// elements retained). Omitted indices get the JS defaults.
|
|
258
|
+
const start = e.args[0] ? host.emitExpr(e.args[0]).name : f64Lit(0);
|
|
259
|
+
const end = e.args[1] ? host.emitExpr(e.args[1]).name : F64_INF;
|
|
260
|
+
host.declare(`declare ptr @scr_arr_slice(ptr, double, double)`);
|
|
261
|
+
const t = B.tmp();
|
|
262
|
+
B.line(`${t} = call ptr @scr_arr_slice(ptr ${r.name}, double ${start}, double ${end})`);
|
|
263
|
+
return host.own({ name: t, type: e.type });
|
|
264
|
+
}
|
|
265
|
+
case "toReversed": {
|
|
266
|
+
host.declare(`declare ptr @scr_arr_to_reversed(ptr)`);
|
|
267
|
+
const t = B.tmp();
|
|
268
|
+
B.line(`${t} = call ptr @scr_arr_to_reversed(ptr ${r.name})`);
|
|
269
|
+
return host.own({ name: t, type: e.type });
|
|
270
|
+
}
|
|
271
|
+
case "reverse": {
|
|
272
|
+
// Mutates in place and returns the same receiver as a fresh +1.
|
|
273
|
+
host.declare(`declare ptr @scr_arr_reverse(ptr)`);
|
|
274
|
+
const t = B.tmp();
|
|
275
|
+
B.line(`${t} = call ptr @scr_arr_reverse(ptr ${r.name})`);
|
|
276
|
+
return host.own({ name: t, type: e.type });
|
|
277
|
+
}
|
|
278
|
+
case "toSpliced": {
|
|
279
|
+
const start = host.emitExpr(e.args[0]);
|
|
280
|
+
const count = host.emitExpr(e.args[1]);
|
|
281
|
+
const items = host.emitExpr(e.args[2]);
|
|
282
|
+
host.declare(`declare ptr @scr_arr_to_spliced(ptr, double, double, ptr)`);
|
|
283
|
+
const t = B.tmp();
|
|
284
|
+
B.line(`${t} = call ptr @scr_arr_to_spliced(ptr ${r.name}, double ${start.name}, ` +
|
|
285
|
+
`double ${count.name}, ptr ${items.name})`);
|
|
286
|
+
return host.own({ name: t, type: e.type });
|
|
287
|
+
}
|
|
288
|
+
case "with": {
|
|
289
|
+
const index = host.emitExpr(e.args[0]);
|
|
290
|
+
const value = host.emitExpr(e.args[1]);
|
|
291
|
+
host.declare(`declare ptr @scr_arr_with_${acc}(ptr, double, ${accArg})`);
|
|
292
|
+
const t = B.tmp();
|
|
293
|
+
B.line(`${t} = call ptr @scr_arr_with_${acc}(ptr ${r.name}, double ${index.name}, ` +
|
|
294
|
+
`${accTy} ${value.name})`);
|
|
295
|
+
const out = host.own({ name: t, type: e.type });
|
|
296
|
+
host.emitPendingCheck();
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
case "splice": {
|
|
300
|
+
// The removal splice: removed elements come back as a fresh +1
|
|
301
|
+
// array, ownership MOVED out of the receiver. An omitted count
|
|
302
|
+
// removes to the end (+Infinity, the slice convention).
|
|
303
|
+
const start = host.emitExpr(e.args[0]);
|
|
304
|
+
const cnt = e.args[1] ? host.emitExpr(e.args[1]).name : F64_INF;
|
|
305
|
+
host.declare(`declare ptr @scr_arr_splice(ptr, double, double)`);
|
|
306
|
+
const t = B.tmp();
|
|
307
|
+
B.line(`${t} = call ptr @scr_arr_splice(ptr ${r.name}, double ${start.name}, double ${cnt})`);
|
|
308
|
+
return host.own({ name: t, type: e.type });
|
|
309
|
+
}
|
|
310
|
+
case "shift": {
|
|
311
|
+
// JS shift: undefined on an empty array, else the first element
|
|
312
|
+
// out (ref ownership moves into the union box) with the tail
|
|
313
|
+
// sliding down. Union construction is type-directed here.
|
|
314
|
+
if (e.type.kind !== "union")
|
|
315
|
+
throw new InternalCompilerError("llvm emitter bug: shift result is not a union");
|
|
316
|
+
const def = host.unionsById.get(e.type.unionId);
|
|
317
|
+
const tag = def ? def.arms.findIndex((a) => typeEquals(a, elem)) : -1;
|
|
318
|
+
const undefTag = undefinedArmTag(e.type, host.unionsById);
|
|
319
|
+
if (tag < 0 || undefTag < 0)
|
|
320
|
+
throw new InternalCompilerError("llvm emitter bug: shift union lacks its arms");
|
|
321
|
+
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
322
|
+
const slot = B.slot();
|
|
323
|
+
B.entryAllocas.push(`${slot} = alloca ptr`);
|
|
324
|
+
const len = B.tmp();
|
|
325
|
+
const has = B.tmp();
|
|
326
|
+
B.line(`${len} = call double @scr_arr_len(ptr ${r.name})`);
|
|
327
|
+
B.line(`${has} = fcmp one double ${len}, ${f64Lit(0)}`);
|
|
328
|
+
const lp = B.newLabel("shf.p");
|
|
329
|
+
const la = B.newLabel("shf.a");
|
|
330
|
+
const lj = B.newLabel("shf.j");
|
|
331
|
+
B.condBr(has, lp, la);
|
|
332
|
+
B.startBlock(lp);
|
|
333
|
+
host.declare(`declare ${acc === "bool" ? "zeroext i1" : accTy} @scr_arr_shift_${acc}(ptr)`);
|
|
334
|
+
const v = B.tmp();
|
|
335
|
+
B.line(`${v} = call ${accTy} @scr_arr_shift_${acc}(ptr ${r.name})`);
|
|
336
|
+
B.line(`store ptr ${host.unionNewOwned(tag, { name: v, type: elem })}, ptr ${slot}`);
|
|
337
|
+
B.br(lj);
|
|
338
|
+
B.startBlock(la);
|
|
339
|
+
B.line(`store ptr ${host.unitInstanceRef(e.type.unionId, undefTag)}, ptr ${slot}`);
|
|
340
|
+
B.br(lj);
|
|
341
|
+
B.startBlock(lj);
|
|
342
|
+
const t = B.tmp();
|
|
343
|
+
B.line(`${t} = load ptr, ptr ${slot}`);
|
|
344
|
+
return host.own({ name: t, type: e.type });
|
|
345
|
+
}
|
|
346
|
+
default: {
|
|
347
|
+
const _exhaustive = method;
|
|
348
|
+
void _exhaustive;
|
|
349
|
+
throw new InternalCompilerError("unreachable");
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
export function wrapNullable(host, raw, present, valueType, valueTag, resultType, absentTag) {
|
|
354
|
+
const B = host.B;
|
|
355
|
+
const slot = B.slot();
|
|
356
|
+
B.entryAllocas.push(`${slot} = alloca ptr`);
|
|
357
|
+
const isnull = B.tmp();
|
|
358
|
+
B.line(`${isnull} = icmp eq ptr ${raw}, null`);
|
|
359
|
+
const lp = B.newLabel("nw.p");
|
|
360
|
+
const la = B.newLabel("nw.a");
|
|
361
|
+
const lj = B.newLabel("nw.j");
|
|
362
|
+
B.condBr(isnull, la, lp);
|
|
363
|
+
B.startBlock(lp);
|
|
364
|
+
B.line(`store ptr ${host.unionNewOwned(valueTag, { name: present, type: valueType })}, ptr ${slot}`);
|
|
365
|
+
B.br(lj);
|
|
366
|
+
B.startBlock(la);
|
|
367
|
+
B.line(`store ptr ${host.unitInstanceRef(resultType.unionId, absentTag)}, ptr ${slot}`);
|
|
368
|
+
B.br(lj);
|
|
369
|
+
B.startBlock(lj);
|
|
370
|
+
const t = B.tmp();
|
|
371
|
+
B.line(`${t} = load ptr, ptr ${slot}`);
|
|
372
|
+
return host.own({ name: t, type: resultType });
|
|
373
|
+
}
|
|
374
|
+
export function emitMapNew(host, e) {
|
|
375
|
+
// Empty map: the runtime stores the value kind's RC entry points as
|
|
376
|
+
// function pointers (scalar values pass nulls); the trace argument
|
|
377
|
+
// doubles as the cycle-capability flag — exactly the C mapNew.
|
|
378
|
+
if (e.type.kind !== "map")
|
|
379
|
+
throw new InternalCompilerError("llvm emitter bug: mapNew of non-map type");
|
|
380
|
+
const B = host.B;
|
|
381
|
+
const value = e.type.value;
|
|
382
|
+
const rc = isRefCounted(value) ? vAdapters(host, value) : { retain: "null", release: "null" };
|
|
383
|
+
host.declare(`declare ptr @scr_map_new(i32, i32, ptr, ptr, ptr)`);
|
|
384
|
+
const m = B.tmp();
|
|
385
|
+
B.line(`${m} = call ptr @scr_map_new(i32 ${mapKeyKindNum(e.type.key)}, i32 ${mapValKindNum(value)}, ptr ${rc.retain}, ptr ${rc.release}, ptr ${isRefCounted(value) ? traceArg(host, value) : "null"})`);
|
|
386
|
+
const out = host.own({ name: m, type: e.type });
|
|
387
|
+
// Seeded construction: set() each pair in source order — a repeated
|
|
388
|
+
// key overwrites (the runtime releases the old value).
|
|
389
|
+
const kAcc = mapKeyAccess(e.type.key);
|
|
390
|
+
const vAcc = elemAccess(value);
|
|
391
|
+
for (const pair of e.seed ?? []) {
|
|
392
|
+
const k = host.emitExpr(pair.key);
|
|
393
|
+
const v = host.emitExpr(pair.value);
|
|
394
|
+
if (vAcc === "ref")
|
|
395
|
+
host.moveTemp(v); // the value MOVES in
|
|
396
|
+
host.mapSet(m, kAcc, vAcc, k.name, v.name);
|
|
397
|
+
}
|
|
398
|
+
return out;
|
|
399
|
+
}
|
|
400
|
+
export function mapSet(host, m, kAcc, vAcc, key, value) {
|
|
401
|
+
const kTy = kAcc === "f64" ? "double" : "ptr";
|
|
402
|
+
const vTy = vAcc === "f64" ? "double" : vAcc === "bool" ? "i1" : "ptr";
|
|
403
|
+
host.declare(`declare void @scr_map_set_${kAcc}_${vAcc}(ptr, ${kTy}, ${vTy === "i1" ? "i1 zeroext" : vTy})`);
|
|
404
|
+
host.B.line(`call void @scr_map_set_${kAcc}_${vAcc}(ptr ${m}, ${kTy} ${key}, ${vTy} ${value})`);
|
|
405
|
+
}
|
|
406
|
+
export function emitMapLikeIntrinsic(host, e) {
|
|
407
|
+
const B = host.B;
|
|
408
|
+
const r = host.emitExpr(e.receiver);
|
|
409
|
+
const receiverType = e.receiver.type;
|
|
410
|
+
if (e.kind === "mapIntrinsic" && receiverType.kind !== "map") {
|
|
411
|
+
throw new InternalCompilerError("llvm emitter bug: mapIntrinsic on non-map");
|
|
412
|
+
}
|
|
413
|
+
if (e.kind === "setIntrinsic" && receiverType.kind !== "set") {
|
|
414
|
+
throw new InternalCompilerError("llvm emitter bug: setIntrinsic on non-set");
|
|
415
|
+
}
|
|
416
|
+
if (receiverType.kind !== "map" && receiverType.kind !== "set") {
|
|
417
|
+
throw new InternalCompilerError("unreachable");
|
|
418
|
+
}
|
|
419
|
+
const key = receiverType.kind === "map" ? receiverType.key : receiverType.elem;
|
|
420
|
+
const kAcc = mapKeyAccess(key);
|
|
421
|
+
const kTy = kAcc === "f64" ? "double" : "ptr";
|
|
422
|
+
const method = e.method;
|
|
423
|
+
switch (method) {
|
|
424
|
+
case "get": {
|
|
425
|
+
if (receiverType.kind !== "map")
|
|
426
|
+
throw new InternalCompilerError("unreachable");
|
|
427
|
+
const value = receiverType.value;
|
|
428
|
+
// The union construction is type-directed HERE, like envGet — the
|
|
429
|
+
// runtime knows no tags. Ref values come back +1 (ownership MOVES
|
|
430
|
+
// into the fresh union box on a hit); scalars ride an out-param
|
|
431
|
+
// behind a found flag; a miss is the interned undefined-arm
|
|
432
|
+
// instance. When V is itself a union, the stored box IS the
|
|
433
|
+
// result (`undefined` sorts last in canonical arm order).
|
|
434
|
+
const k = host.emitExpr(e.args[0]);
|
|
435
|
+
if (e.type.kind !== "union")
|
|
436
|
+
throw new InternalCompilerError("llvm emitter bug: map get result is not a union");
|
|
437
|
+
const def = host.unionsById.get(e.type.unionId);
|
|
438
|
+
const undefTag = undefinedArmTag(e.type, host.unionsById);
|
|
439
|
+
if (!def || undefTag < 0)
|
|
440
|
+
throw new InternalCompilerError("llvm emitter bug: map get union lacks its undefined arm");
|
|
441
|
+
const absent = host.unitInstanceRef(e.type.unionId, undefTag);
|
|
442
|
+
if (value.kind === "union") {
|
|
443
|
+
host.declare(`declare ptr @scr_map_get_${kAcc}_ref(ptr, ${kTy})`);
|
|
444
|
+
const raw = B.tmp();
|
|
445
|
+
const isnull = B.tmp();
|
|
446
|
+
const t = B.tmp();
|
|
447
|
+
B.line(`${raw} = call ptr @scr_map_get_${kAcc}_ref(ptr ${r.name}, ${kTy} ${k.name})`);
|
|
448
|
+
B.line(`${isnull} = icmp eq ptr ${raw}, null`);
|
|
449
|
+
B.line(`${t} = select i1 ${isnull}, ptr ${absent}, ptr ${raw}`);
|
|
450
|
+
return host.own({ name: t, type: e.type });
|
|
451
|
+
}
|
|
452
|
+
const valueTag = def.arms.findIndex((a) => typeEquals(a, value));
|
|
453
|
+
if (valueTag < 0)
|
|
454
|
+
throw new InternalCompilerError("llvm emitter bug: map get union lacks its value arm");
|
|
455
|
+
if (value.kind === "f64" || value.kind === "bool") {
|
|
456
|
+
const outTy = value.kind === "f64" ? "double" : "i8";
|
|
457
|
+
const outSlot = B.slot();
|
|
458
|
+
B.entryAllocas.push(`${outSlot} = alloca ${outTy}`);
|
|
459
|
+
B.line(`store ${outTy} ${value.kind === "f64" ? f64Lit(0) : "0"}, ptr ${outSlot}`);
|
|
460
|
+
host.declare(`declare zeroext i1 @scr_map_get_${kAcc}_${value.kind === "f64" ? "f64" : "bool"}(ptr, ${kTy}, ptr)`);
|
|
461
|
+
const found = B.tmp();
|
|
462
|
+
B.line(`${found} = call zeroext i1 @scr_map_get_${kAcc}_${value.kind === "f64" ? "f64" : "bool"}(ptr ${r.name}, ${kTy} ${k.name}, ptr ${outSlot})`);
|
|
463
|
+
const slot = B.slot();
|
|
464
|
+
B.entryAllocas.push(`${slot} = alloca ptr`);
|
|
465
|
+
const lp = B.newLabel("mg.p");
|
|
466
|
+
const la = B.newLabel("mg.a");
|
|
467
|
+
const lj = B.newLabel("mg.j");
|
|
468
|
+
B.condBr(found, lp, la);
|
|
469
|
+
B.startBlock(lp);
|
|
470
|
+
const rawOut = B.tmp();
|
|
471
|
+
B.line(`${rawOut} = load ${outTy}, ptr ${outSlot}`);
|
|
472
|
+
let hit = rawOut;
|
|
473
|
+
if (value.kind === "bool") {
|
|
474
|
+
hit = B.tmp();
|
|
475
|
+
B.line(`${hit} = trunc i8 ${rawOut} to i1`);
|
|
476
|
+
}
|
|
477
|
+
B.line(`store ptr ${host.unionNewOwned(valueTag, { name: hit, type: value })}, ptr ${slot}`);
|
|
478
|
+
B.br(lj);
|
|
479
|
+
B.startBlock(la);
|
|
480
|
+
B.line(`store ptr ${absent}, ptr ${slot}`);
|
|
481
|
+
B.br(lj);
|
|
482
|
+
B.startBlock(lj);
|
|
483
|
+
const t = B.tmp();
|
|
484
|
+
B.line(`${t} = load ptr, ptr ${slot}`);
|
|
485
|
+
return host.own({ name: t, type: e.type });
|
|
486
|
+
}
|
|
487
|
+
host.declare(`declare ptr @scr_map_get_${kAcc}_ref(ptr, ${kTy})`);
|
|
488
|
+
const raw = B.tmp();
|
|
489
|
+
B.line(`${raw} = call ptr @scr_map_get_${kAcc}_ref(ptr ${r.name}, ${kTy} ${k.name})`);
|
|
490
|
+
return host.wrapNullable(raw, raw, value, valueTag, e.type, undefTag);
|
|
491
|
+
}
|
|
492
|
+
case "set": {
|
|
493
|
+
if (receiverType.kind !== "map")
|
|
494
|
+
throw new InternalCompilerError("unreachable");
|
|
495
|
+
// Key borrowed (the runtime retains stored string keys); the
|
|
496
|
+
// value MOVES in (replacement releases the old value inside).
|
|
497
|
+
const k = host.emitExpr(e.args[0]);
|
|
498
|
+
const v = host.emitExpr(e.args[1]);
|
|
499
|
+
const vAcc = elemAccess(receiverType.value);
|
|
500
|
+
if (vAcc === "ref")
|
|
501
|
+
host.moveTemp(v);
|
|
502
|
+
host.mapSet(r.name, kAcc, vAcc, k.name, v.name);
|
|
503
|
+
return { name: "", type: e.type };
|
|
504
|
+
}
|
|
505
|
+
case "add": {
|
|
506
|
+
if (receiverType.kind !== "set")
|
|
507
|
+
throw new InternalCompilerError("unreachable");
|
|
508
|
+
// Element borrowed (the runtime retains stored strings); the unit
|
|
509
|
+
// value is 0. Re-adding overwrites in place, preserving insertion.
|
|
510
|
+
const k = host.emitExpr(e.args[0]);
|
|
511
|
+
host.mapSet(r.name, kAcc, "f64", k.name, f64Lit(0));
|
|
512
|
+
return { name: "", type: e.type };
|
|
513
|
+
}
|
|
514
|
+
case "has": {
|
|
515
|
+
const k = host.emitExpr(e.args[0]);
|
|
516
|
+
host.declare(`declare zeroext i1 @scr_map_has_${kAcc}(ptr, ${kTy})`);
|
|
517
|
+
const t = B.tmp();
|
|
518
|
+
B.line(`${t} = call zeroext i1 @scr_map_has_${kAcc}(ptr ${r.name}, ${kTy} ${k.name})`);
|
|
519
|
+
return { name: t, type: e.type };
|
|
520
|
+
}
|
|
521
|
+
case "delete": {
|
|
522
|
+
const k = host.emitExpr(e.args[0]);
|
|
523
|
+
host.declare(`declare zeroext i1 @scr_map_delete_${kAcc}(ptr, ${kTy})`);
|
|
524
|
+
const t = B.tmp();
|
|
525
|
+
B.line(`${t} = call zeroext i1 @scr_map_delete_${kAcc}(ptr ${r.name}, ${kTy} ${k.name})`);
|
|
526
|
+
return { name: t, type: e.type };
|
|
527
|
+
}
|
|
528
|
+
case "size": {
|
|
529
|
+
host.declare(`declare double @scr_map_size(ptr)`);
|
|
530
|
+
const t = B.tmp();
|
|
531
|
+
B.line(`${t} = call double @scr_map_size(ptr ${r.name})`);
|
|
532
|
+
return { name: t, type: e.type };
|
|
533
|
+
}
|
|
534
|
+
case "clear":
|
|
535
|
+
host.declare(`declare void @scr_map_clear(ptr)`);
|
|
536
|
+
B.line(`call void @scr_map_clear(ptr ${r.name})`);
|
|
537
|
+
return { name: "", type: e.type };
|
|
538
|
+
case "iterCount": {
|
|
539
|
+
host.declare(`declare double @scr_map_iter_count(ptr)`);
|
|
540
|
+
const t = B.tmp();
|
|
541
|
+
B.line(`${t} = call double @scr_map_iter_count(ptr ${r.name})`);
|
|
542
|
+
return { name: t, type: e.type };
|
|
543
|
+
}
|
|
544
|
+
case "iterLive": {
|
|
545
|
+
const i = host.emitExpr(e.args[0]);
|
|
546
|
+
host.declare(`declare zeroext i1 @scr_map_iter_live(ptr, double)`);
|
|
547
|
+
const t = B.tmp();
|
|
548
|
+
B.line(`${t} = call zeroext i1 @scr_map_iter_live(ptr ${r.name}, double ${i.name})`);
|
|
549
|
+
return { name: t, type: e.type };
|
|
550
|
+
}
|
|
551
|
+
case "iterKey": {
|
|
552
|
+
// String/ref keys come back +1 (own registers the owned temp).
|
|
553
|
+
const i = host.emitExpr(e.args[0]);
|
|
554
|
+
const retTy = kAcc === "f64" ? "double" : "ptr";
|
|
555
|
+
host.declare(`declare ${retTy} @scr_map_iter_key_${kAcc}(ptr, double)`);
|
|
556
|
+
const t = B.tmp();
|
|
557
|
+
B.line(`${t} = call ${retTy} @scr_map_iter_key_${kAcc}(ptr ${r.name}, double ${i.name})`);
|
|
558
|
+
return host.own({ name: t, type: e.type });
|
|
559
|
+
}
|
|
560
|
+
case "iterValue": {
|
|
561
|
+
if (receiverType.kind !== "map")
|
|
562
|
+
throw new InternalCompilerError("unreachable");
|
|
563
|
+
const vAcc = elemAccess(receiverType.value);
|
|
564
|
+
const i = host.emitExpr(e.args[0]);
|
|
565
|
+
const retTy = vAcc === "f64" ? "double" : vAcc === "bool" ? "i1" : "ptr";
|
|
566
|
+
host.declare(`declare ${vAcc === "bool" ? "zeroext i1" : retTy} @scr_map_iter_val_${vAcc}(ptr, double)`);
|
|
567
|
+
const t = B.tmp();
|
|
568
|
+
B.line(`${t} = call ${retTy} @scr_map_iter_val_${vAcc}(ptr ${r.name}, double ${i.name})`);
|
|
569
|
+
return host.own({ name: t, type: e.type });
|
|
570
|
+
}
|
|
571
|
+
case "iterEnter":
|
|
572
|
+
host.declare(`declare void @scr_map_iter_enter(ptr)`);
|
|
573
|
+
B.line(`call void @scr_map_iter_enter(ptr ${r.name})`);
|
|
574
|
+
return { name: "", type: e.type };
|
|
575
|
+
case "iterExit":
|
|
576
|
+
host.declare(`declare void @scr_map_iter_exit(ptr)`);
|
|
577
|
+
B.line(`call void @scr_map_iter_exit(ptr ${r.name})`);
|
|
578
|
+
return { name: "", type: e.type };
|
|
579
|
+
case "toArray": {
|
|
580
|
+
if (receiverType.kind !== "set")
|
|
581
|
+
throw new InternalCompilerError("unreachable");
|
|
582
|
+
// Fresh +1 elem[] of the live entries in insertion order.
|
|
583
|
+
host.declare(`declare ptr @scr_set_to_arr_${kAcc}(ptr)`);
|
|
584
|
+
const t = B.tmp();
|
|
585
|
+
B.line(`${t} = call ptr @scr_set_to_arr_${kAcc}(ptr ${r.name})`);
|
|
586
|
+
return host.own({ name: t, type: e.type });
|
|
587
|
+
}
|
|
588
|
+
default: {
|
|
589
|
+
const _exhaustive = method;
|
|
590
|
+
void _exhaustive;
|
|
591
|
+
throw new InternalCompilerError("unreachable");
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
export function emitSetNew(host, e) {
|
|
596
|
+
// Empty set: the map runtime with the element as the KEY and the
|
|
597
|
+
// value slot pinned to the scalar kind. Handle-kind elements (symbol
|
|
598
|
+
// identity hashing) carry their RC adapters at construction.
|
|
599
|
+
if (e.type.kind !== "set")
|
|
600
|
+
throw new InternalCompilerError("llvm emitter bug: setNew of non-set type");
|
|
601
|
+
const B = host.B;
|
|
602
|
+
const kAcc = mapKeyAccess(e.type.elem);
|
|
603
|
+
const s = B.tmp();
|
|
604
|
+
if (kAcc === "ref") {
|
|
605
|
+
const rc = vAdapters(host, e.type.elem);
|
|
606
|
+
host.declare(`declare ptr @scr_set_new_ref(ptr, ptr)`);
|
|
607
|
+
B.line(`${s} = call ptr @scr_set_new_ref(ptr ${rc.retain}, ptr ${rc.release})`);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
host.declare(`declare ptr @scr_map_new(i32, i32, ptr, ptr, ptr)`);
|
|
611
|
+
B.line(`${s} = call ptr @scr_map_new(i32 ${mapKeyKindNum(e.type.elem)}, i32 0, ptr null, ptr null, ptr null)`);
|
|
612
|
+
}
|
|
613
|
+
const out = host.own({ name: s, type: e.type });
|
|
614
|
+
if (e.seed) {
|
|
615
|
+
// Seeded construction (`new Set(values)`): one borrowed T[] whose
|
|
616
|
+
// elements add() in order (duplicates keep first insertion position).
|
|
617
|
+
const arr = host.emitExpr(e.seed);
|
|
618
|
+
host.declare(`declare void @scr_set_add_all(ptr, ptr)`);
|
|
619
|
+
B.line(`call void @scr_set_add_all(ptr ${s}, ptr ${arr.name})`);
|
|
620
|
+
}
|
|
621
|
+
return out;
|
|
622
|
+
}
|
|
623
|
+
//# sourceMappingURL=expr-containers.js.map
|