@scriptc/compiler 0.0.35 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +14 -11
- package/ambient/scriptc-overrides.d.ts +0 -7
- package/ambient/scriptc.d.ts +1 -1
- 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 +7937 -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 +4 -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} +395 -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} +242 -304
- package/dist/backend/c/walkers.js.map +1 -0
- package/dist/backend/external-c.d.ts +33 -0
- package/dist/backend/external-c.js +51 -0
- package/dist/backend/external-c.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/link-plan.d.ts +37 -0
- package/dist/backend/link-plan.js +26 -0
- package/dist/backend/link-plan.js.map +1 -0
- package/dist/backend/linker.d.ts +22 -0
- package/dist/backend/linker.js +236 -0
- package/dist/backend/linker.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 +159 -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 +548 -9988
- 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 +637 -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 +153 -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 +642 -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 +420 -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/unsupported.d.ts +1 -1
- package/dist/backend/llvm/walkers.d.ts +2 -3
- package/dist/backend/llvm/walkers.js +195 -222
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +45 -0
- package/dist/backend/native-codegen.js +275 -0
- package/dist/backend/native-codegen.js.map +1 -0
- package/dist/backend/native-codegen.test.js +226 -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 +243 -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} +54 -34
- package/dist/backend/{cc.js → native-toolchain.js} +231 -810
- 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} +219 -7
- package/dist/backend/native-toolchain.test.js.map +1 -0
- package/dist/backend/object-localize.js +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-targets.test.d.ts +1 -0
- package/dist/backend/runtime-pack-targets.test.js +54 -0
- package/dist/backend/runtime-pack-targets.test.js.map +1 -0
- package/dist/backend/runtime-pack.d.ts +112 -0
- package/dist/backend/runtime-pack.js +305 -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 +473 -0
- package/dist/backend/runtime-pack.test.js.map +1 -0
- package/dist/backend/targets.d.ts +76 -0
- package/dist/backend/targets.js +262 -0
- package/dist/backend/targets.js.map +1 -0
- package/dist/backend/targets.test.d.ts +1 -0
- package/dist/backend/targets.test.js +41 -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 +35 -33
- 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/{early-cache.d.ts → executable-cache.d.ts} +2 -2
- package/dist/executable/{early-cache.js → executable-cache.js} +36 -98
- package/dist/executable/executable-cache.js.map +1 -0
- package/dist/executable/executable-cache.test.d.ts +1 -0
- package/dist/executable/{early-cache.test.js → executable-cache.test.js} +3 -3
- package/dist/executable/executable-cache.test.js.map +1 -0
- package/dist/ffi/{profile.js → ffi-manifest.js} +1 -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/array-values.d.ts +8 -0
- package/dist/frontend/lowering/array-values.js +60 -0
- package/dist/frontend/lowering/array-values.js.map +1 -0
- 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-array-sort.d.ts +22 -0
- package/dist/frontend/lowering/lower-array-sort.js +619 -0
- package/dist/frontend/lowering/lower-array-sort.js.map +1 -0
- 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 +1285 -1233
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +59 -192
- package/dist/frontend/lowering/lower-calls.js +1644 -1506
- 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 +1984 -2227
- 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 +60 -264
- package/dist/frontend/lowering/lower-exprs.js +2361 -1765
- 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 +273 -261
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +39 -49
- package/dist/frontend/lowering/lower-island.js +447 -513
- 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 +85 -85
- 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 +909 -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 +1463 -1285
- 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 +134 -22
- package/dist/frontend/lowering/lowerer.js +1277 -126
- 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 +24 -35
- package/dist/frontend/lowering/surfaces.js +78 -66
- 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 +9 -4
- 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.js +2 -36
- 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} +12 -11
- 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 +113 -31
- package/dist/index.js +536 -128
- 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} +119 -37
- package/dist/ir/{nodes.js → ir.js} +170 -166
- 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 +2 -2
- package/dist/ir/serialize.js +3 -2
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.d.ts +1 -1
- package/dist/ir/validate.js +93 -41
- 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/{implementation-identity.js → compiler-self-identity.js} +1 -1
- 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 +8 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.d.ts +1 -36
- package/dist/library/int-infer.js +29 -18
- package/dist/library/int-infer.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/{early-cache.d.ts → library-cache.d.ts} +1 -1
- package/dist/library/{early-cache.js → library-cache.js} +34 -89
- 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} +7 -7
- 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 +11 -3
- package/dist/startup-cache.js +17 -2
- package/dist/startup-cache.js.map +1 -1
- package/package.json +19 -2
- package/surface-manifest.json +5 -5
- 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/executable/early-cache.js.map +0 -1
- package/dist/executable/early-cache.test.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/implementation-identity.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/{executable/early-cache.test.d.ts → backend/llvm/shapes.test.d.ts} +0 -0
- /package/dist/{library/early-cache.test.d.ts → backend/native-codegen.test.d.ts} +0 -0
- /package/dist/ffi/{profile.d.ts → ffi-manifest.d.ts} +0 -0
- /package/dist/frontend/ts7/{program.d.ts → program-adapter.d.ts} +0 -0
- /package/dist/library/{implementation-identity.d.ts → compiler-self-identity.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IrType, IrUnionDef } from "../../ir/
|
|
1
|
+
import type { IrType, IrUnionDef } from "../../ir/ir.js";
|
|
2
2
|
import { type ShapeHost } from "./shapes.js";
|
|
3
3
|
/** What the walkers need from the emitter beyond the shape tables: union
|
|
4
4
|
* defs, the undefined-arm probe, interned ScrStr literals (unit-arm
|
|
@@ -6,7 +6,6 @@ import { type ShapeHost } from "./shapes.js";
|
|
|
6
6
|
* scr_error-style label texts). */
|
|
7
7
|
export interface WalkerHost extends ShapeHost {
|
|
8
8
|
readonly unionsById: Map<string, IrUnionDef>;
|
|
9
|
-
undefinedArmTag(t: IrType): number;
|
|
10
9
|
/** `@`-ref of an interned immortal ScrStr literal. */
|
|
11
10
|
internLiteral(text: string): string;
|
|
12
11
|
/** `@`-ref of an interned NUL-terminated byte-array constant. */
|
|
@@ -50,7 +49,7 @@ export declare class LlWalkers {
|
|
|
50
49
|
private emitArrayWriter;
|
|
51
50
|
private emitUnionWriter;
|
|
52
51
|
/** `JSON.stringify(v, null, space)` as a REWRITE of the compact text —
|
|
53
|
-
* Node's gap algorithm exactly (see
|
|
52
|
+
* Node's gap algorithm exactly (see walkers.ts's sc_ji). The indent
|
|
54
53
|
* rides as a NUL-terminated constant + byte length. */
|
|
55
54
|
jsonIndentHelper(): string;
|
|
56
55
|
/** The per-union ToString helper: unit arms return the interned
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InternalCompilerError } from "../../errors.js";
|
|
2
|
+
import { isRefCounted, typeKey } from "../../ir/ir.js";
|
|
2
3
|
import { mangleRecordStruct } from "../mangle.js";
|
|
3
4
|
import { BlockBuilder } from "./blocks.js";
|
|
4
5
|
import { llFieldType, releaseSym, traceAdapter } from "./shapes.js";
|
|
5
6
|
import { LlvmUnsupportedError } from "./unsupported.js";
|
|
7
|
+
import { undefinedArmTag } from "../../ir/analysis.js";
|
|
6
8
|
/** Exact double literal (the emitter's f64Lit — duplicated to avoid a
|
|
7
9
|
* cyclic import; both spell every bit pattern identically). */
|
|
8
10
|
function f64Lit(n) {
|
|
@@ -180,11 +182,11 @@ export class LlWalkers {
|
|
|
180
182
|
emitRecordWriter(B, shapeId) {
|
|
181
183
|
const shape = this.host.recordsById.get(shapeId);
|
|
182
184
|
if (!shape)
|
|
183
|
-
throw new
|
|
185
|
+
throw new InternalCompilerError(`llvm emitter bug: jsonStringify of unknown shape ${shapeId}`);
|
|
184
186
|
const fieldIndex = new Map(shape.fields.map((f, i) => [f.name, i + 1]));
|
|
185
187
|
// CYCLE-CAPABLE shapes bracket the walk with the circular-detection
|
|
186
188
|
// stack; edge labels stamp before members whose walk can re-enter —
|
|
187
|
-
//
|
|
189
|
+
// walkers.ts's contract, ported.
|
|
188
190
|
const cyclic = traceAdapter(this.host, { kind: "record", shapeId }) !== null;
|
|
189
191
|
const edgeable = (ft) => cyclic && traceAdapter(this.host, ft) !== null;
|
|
190
192
|
if (cyclic)
|
|
@@ -213,11 +215,11 @@ export class LlWalkers {
|
|
|
213
215
|
const order = shape.declaredOrder ?? shape.fields.map((f) => f.name);
|
|
214
216
|
const inOrder = new Set(order);
|
|
215
217
|
if (shape.fields.some((f) => !inOrder.has(f.name) && !f.name.startsWith("%"))) {
|
|
216
|
-
throw new
|
|
218
|
+
throw new InternalCompilerError(`llvm emitter bug: declaredOrder of shape ${shapeId} omits a non-internal field`);
|
|
217
219
|
}
|
|
218
220
|
const byName = new Map(shape.fields.map((f) => [f.name, f]));
|
|
219
221
|
const emitFields = order.map((n) => byName.get(n)).filter((f) => f !== undefined);
|
|
220
|
-
const droppable = emitFields.some((f) =>
|
|
222
|
+
const droppable = emitFields.some((f) => undefinedArmTag(f.type, this.host.unionsById) >= 0) || !!shape.indexValue;
|
|
221
223
|
this.putc(B, "%b", "123"); // '{'
|
|
222
224
|
if (!droppable) {
|
|
223
225
|
emitFields.forEach((f, i) => {
|
|
@@ -245,7 +247,7 @@ export class LlWalkers {
|
|
|
245
247
|
B.line(`store i1 false, ptr ${first}`);
|
|
246
248
|
};
|
|
247
249
|
for (const f of emitFields) {
|
|
248
|
-
const utag =
|
|
250
|
+
const utag = undefinedArmTag(f.type, this.host.unionsById);
|
|
249
251
|
const v = this.loadField(B, "%v", shapeId, fieldIndex.get(f.name), f.type);
|
|
250
252
|
let skip = null;
|
|
251
253
|
if (utag >= 0) {
|
|
@@ -293,110 +295,90 @@ export class LlWalkers {
|
|
|
293
295
|
const len = B.tmp();
|
|
294
296
|
B.line(`${ks} = call ptr @scr_map_keys_js_order(ptr ${ovf})`);
|
|
295
297
|
B.line(`${len} = call double @scr_arr_len(ptr ${ks})`);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
B.entryAllocas.push(`${outSlot} = alloca ${outTy}`);
|
|
319
|
-
B.line(`store ${outTy} ${iv.kind === "f64" ? f64Lit(0) : "0"}, ptr ${outSlot}`);
|
|
320
|
-
host.declare(`declare zeroext i1 @scr_map_get_str_${iv.kind === "f64" ? "f64" : "bool"}(ptr, ptr, ptr)`);
|
|
321
|
-
const found = B.tmp();
|
|
322
|
-
B.line(`${found} = call zeroext i1 @scr_map_get_str_${iv.kind === "f64" ? "f64" : "bool"}(ptr ${ovf}, ptr ${k}, ptr ${outSlot})`);
|
|
323
|
-
const raw = B.tmp();
|
|
324
|
-
B.line(`${raw} = load ${outTy}, ptr ${outSlot}`);
|
|
325
|
-
if (iv.kind === "bool") {
|
|
326
|
-
val = B.tmp();
|
|
327
|
-
B.line(`${val} = trunc i8 ${raw} to i1`);
|
|
298
|
+
B.countedLoop(len, (i, next) => {
|
|
299
|
+
const k = B.tmp();
|
|
300
|
+
B.line(`${k} = call ptr @scr_arr_get_ref(ptr ${ks}, double ${i}) ; key (+1)`);
|
|
301
|
+
// The entry value, type-directed off the overflow VALUE type.
|
|
302
|
+
let val;
|
|
303
|
+
if (iv.kind === "f64" || iv.kind === "bool") {
|
|
304
|
+
const outTy = iv.kind === "f64" ? "double" : "i8";
|
|
305
|
+
const outSlot = B.slot();
|
|
306
|
+
B.entryAllocas.push(`${outSlot} = alloca ${outTy}`);
|
|
307
|
+
B.line(`store ${outTy} ${iv.kind === "f64" ? f64Lit(0) : "0"}, ptr ${outSlot}`);
|
|
308
|
+
host.declare(`declare zeroext i1 @scr_map_get_str_${iv.kind === "f64" ? "f64" : "bool"}(ptr, ptr, ptr)`);
|
|
309
|
+
const found = B.tmp();
|
|
310
|
+
B.line(`${found} = call zeroext i1 @scr_map_get_str_${iv.kind === "f64" ? "f64" : "bool"}(ptr ${ovf}, ptr ${k}, ptr ${outSlot})`);
|
|
311
|
+
const raw = B.tmp();
|
|
312
|
+
B.line(`${raw} = load ${outTy}, ptr ${outSlot}`);
|
|
313
|
+
if (iv.kind === "bool") {
|
|
314
|
+
val = B.tmp();
|
|
315
|
+
B.line(`${val} = trunc i8 ${raw} to i1`);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
val = raw;
|
|
319
|
+
}
|
|
328
320
|
}
|
|
329
321
|
else {
|
|
330
|
-
|
|
322
|
+
host.declare(`declare ptr @scr_map_get_str_ref(ptr, ptr)`);
|
|
323
|
+
val = B.tmp();
|
|
324
|
+
B.line(`${val} = call ptr @scr_map_get_str_ref(ptr ${ovf}, ptr ${k}) ; value (+1)`);
|
|
331
325
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
326
|
+
// Undefined-valued entries drop, exactly the optional-field rule: a
|
|
327
|
+
// dyn value whose dyn kind follows its size_t RC word (enum
|
|
328
|
+
// member 6 — scr_runtime.h's ScrDynKind), or a union holding its
|
|
329
|
+
// undefined arm.
|
|
330
|
+
let skipUndef = null;
|
|
331
|
+
if (iv.kind === "dyn") {
|
|
332
|
+
const kp = B.tmp();
|
|
333
|
+
const kd = B.tmp();
|
|
334
|
+
const isu = B.tmp();
|
|
335
|
+
B.line(`${kp} = getelementptr inbounds i8, ptr ${val}, i64 ${this.abiOffset(8, 4)} ; ->kind`);
|
|
336
|
+
B.line(`${kd} = load i32, ptr ${kp}`);
|
|
337
|
+
B.line(`${isu} = icmp eq i32 ${kd}, 6 ; SCR_DYN_UNDEF (NULL is 0 — null members DO serialize)`);
|
|
338
|
+
skipUndef = isu;
|
|
339
|
+
}
|
|
340
|
+
else if (undefinedArmTag(iv, this.host.unionsById) >= 0) {
|
|
341
|
+
const tag = this.unionTag(B, val);
|
|
342
|
+
const isu = B.tmp();
|
|
343
|
+
B.line(`${isu} = icmp eq i32 ${tag}, ${undefinedArmTag(iv, this.host.unionsById)}`);
|
|
344
|
+
skipUndef = isu;
|
|
345
|
+
}
|
|
346
|
+
if (skipUndef !== null) {
|
|
347
|
+
const ld = B.newLabel("ovf.d");
|
|
348
|
+
const write = B.newLabel("ovf.w");
|
|
349
|
+
B.condBr(skipUndef, ld, write);
|
|
350
|
+
B.startBlock(ld);
|
|
351
|
+
if (isRefCounted(iv))
|
|
352
|
+
B.line(`call void ${releaseSym(host, iv)}(ptr ${val})`);
|
|
353
|
+
B.line(`call void @scr_str_release(ptr ${k})`);
|
|
354
|
+
B.br(next);
|
|
355
|
+
B.startBlock(write);
|
|
356
|
+
}
|
|
357
|
+
// The comma dance over the shared `first` flag.
|
|
358
|
+
{
|
|
359
|
+
const isf = B.tmp();
|
|
360
|
+
const lcm = B.newLabel("ovf.cm");
|
|
361
|
+
const lj = B.newLabel("ovf.cj");
|
|
362
|
+
B.line(`${isf} = load i1, ptr ${first}`);
|
|
363
|
+
B.condBr(isf, lj, lcm);
|
|
364
|
+
B.startBlock(lcm);
|
|
365
|
+
this.putc(B, "%b", "44"); // ','
|
|
366
|
+
B.br(lj);
|
|
367
|
+
B.startBlock(lj);
|
|
368
|
+
B.line(`store i1 false, ptr ${first}`);
|
|
369
|
+
}
|
|
370
|
+
host.declare(`declare void @scr_jb_put_json_str(ptr, ptr)`);
|
|
371
|
+
B.line(`call void @scr_jb_put_json_str(ptr %b, ptr ${k})`);
|
|
372
|
+
this.putc(B, "%b", "58"); // ':'
|
|
373
|
+
if (edgeKeys) {
|
|
374
|
+
this.host.declare(`declare void @scr_jb_edge_key(ptr, ptr)`);
|
|
375
|
+
B.line(`call void @scr_jb_edge_key(ptr %b, ptr ${k})`);
|
|
376
|
+
}
|
|
377
|
+
B.line(`call void @${this.jsonWriteHelper(iv)}(ptr %b, ${this.valTy(iv)} ${val})`);
|
|
378
|
+
B.line(`call void @scr_str_release(ptr ${k})`);
|
|
363
379
|
if (isRefCounted(iv))
|
|
364
380
|
B.line(`call void ${releaseSym(host, iv)}(ptr ${val})`);
|
|
365
|
-
|
|
366
|
-
B.br(ln);
|
|
367
|
-
B.startBlock(write);
|
|
368
|
-
}
|
|
369
|
-
// The comma dance over the shared `first` flag.
|
|
370
|
-
{
|
|
371
|
-
const isf = B.tmp();
|
|
372
|
-
const lcm = B.newLabel("ovf.cm");
|
|
373
|
-
const lj = B.newLabel("ovf.cj");
|
|
374
|
-
B.line(`${isf} = load i1, ptr ${first}`);
|
|
375
|
-
B.condBr(isf, lj, lcm);
|
|
376
|
-
B.startBlock(lcm);
|
|
377
|
-
this.putc(B, "%b", "44"); // ','
|
|
378
|
-
B.br(lj);
|
|
379
|
-
B.startBlock(lj);
|
|
380
|
-
B.line(`store i1 false, ptr ${first}`);
|
|
381
|
-
}
|
|
382
|
-
host.declare(`declare void @scr_jb_put_json_str(ptr, ptr)`);
|
|
383
|
-
B.line(`call void @scr_jb_put_json_str(ptr %b, ptr ${k})`);
|
|
384
|
-
this.putc(B, "%b", "58"); // ':'
|
|
385
|
-
if (edgeKeys) {
|
|
386
|
-
this.host.declare(`declare void @scr_jb_edge_key(ptr, ptr)`);
|
|
387
|
-
B.line(`call void @scr_jb_edge_key(ptr %b, ptr ${k})`);
|
|
388
|
-
}
|
|
389
|
-
B.line(`call void @${this.jsonWriteHelper(iv)}(ptr %b, ${this.valTy(iv)} ${val})`);
|
|
390
|
-
B.line(`call void @scr_str_release(ptr ${k})`);
|
|
391
|
-
if (isRefCounted(iv))
|
|
392
|
-
B.line(`call void ${releaseSym(host, iv)}(ptr ${val})`);
|
|
393
|
-
B.br(ln);
|
|
394
|
-
B.startBlock(ln);
|
|
395
|
-
const i2 = B.tmp();
|
|
396
|
-
B.line(`${i2} = fadd double ${i}, ${f64Lit(1)}`);
|
|
397
|
-
B.line(`store double ${i2}, ptr ${iSlot}`);
|
|
398
|
-
B.br(lc);
|
|
399
|
-
B.startBlock(le);
|
|
381
|
+
});
|
|
400
382
|
host.declare(`declare void @scr_arr_release(ptr)`);
|
|
401
383
|
B.line(`call void @scr_arr_release(ptr ${ks})`);
|
|
402
384
|
}
|
|
@@ -411,55 +393,54 @@ export class LlWalkers {
|
|
|
411
393
|
this.putc(B, "%b", "91"); // '['
|
|
412
394
|
const len = B.tmp();
|
|
413
395
|
B.line(`${len} = call double @scr_arr_len(ptr %v)`);
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
B.startBlock(le);
|
|
396
|
+
B.countedLoop(len, (i) => {
|
|
397
|
+
const nz = B.tmp();
|
|
398
|
+
const lcm = B.newLabel("jwa.cm");
|
|
399
|
+
const lj = B.newLabel("jwa.cj");
|
|
400
|
+
B.line(`${nz} = fcmp ogt double ${i}, ${f64Lit(0)}`);
|
|
401
|
+
B.condBr(nz, lcm, lj);
|
|
402
|
+
B.startBlock(lcm);
|
|
403
|
+
this.putc(B, "%b", "44"); // ','
|
|
404
|
+
B.br(lj);
|
|
405
|
+
B.startBlock(lj);
|
|
406
|
+
host.declare(`declare double @scr_arr_state(ptr, double)`);
|
|
407
|
+
const state = B.tmp();
|
|
408
|
+
const present = B.tmp();
|
|
409
|
+
const valueBlock = B.newLabel("jwa.value");
|
|
410
|
+
const missingBlock = B.newLabel("jwa.missing");
|
|
411
|
+
const doneBlock = B.newLabel("jwa.done");
|
|
412
|
+
B.line(`${state} = call double @scr_arr_state(ptr %v, double ${i})`);
|
|
413
|
+
B.line(`${present} = fcmp oeq double ${state}, ${f64Lit(1)}`);
|
|
414
|
+
B.condBr(present, valueBlock, missingBlock);
|
|
415
|
+
B.startBlock(missingBlock);
|
|
416
|
+
host.declare(`declare void @scr_jb_puts(ptr, ptr)`);
|
|
417
|
+
B.line(`call void @scr_jb_puts(ptr %b, ptr ${host.cstr("null")})`);
|
|
418
|
+
B.br(doneBlock);
|
|
419
|
+
B.startBlock(valueBlock);
|
|
420
|
+
if (cyclic) {
|
|
421
|
+
const idx = B.tmp();
|
|
422
|
+
B.line(`${idx} = fptoui double ${i} to ${this.S}`);
|
|
423
|
+
this.jbEdgeIdx(B, idx);
|
|
424
|
+
}
|
|
425
|
+
if (elem.kind === "f64" || elem.kind === "bool") {
|
|
426
|
+
const acc = elem.kind;
|
|
427
|
+
const accTy = elem.kind === "f64" ? "double" : "i1";
|
|
428
|
+
host.declare(`declare ${elem.kind === "bool" ? "zeroext i1" : accTy} @scr_arr_get_${acc}(ptr, double)`);
|
|
429
|
+
const v = B.tmp();
|
|
430
|
+
B.line(`${v} = call ${accTy} @scr_arr_get_${acc}(ptr %v, double ${i})`);
|
|
431
|
+
B.line(`call void @${w}(ptr %b, ${accTy} ${v})`);
|
|
432
|
+
}
|
|
433
|
+
else {
|
|
434
|
+
// _get_ref returns +1; release after writing.
|
|
435
|
+
host.declare(`declare ptr @scr_arr_get_ref(ptr, double)`);
|
|
436
|
+
const v = B.tmp();
|
|
437
|
+
B.line(`${v} = call ptr @scr_arr_get_ref(ptr %v, double ${i})`);
|
|
438
|
+
B.line(`call void @${w}(ptr %b, ptr ${v})`);
|
|
439
|
+
B.line(`call void ${releaseSym(host, elem)}(ptr ${v})`);
|
|
440
|
+
}
|
|
441
|
+
B.br(doneBlock);
|
|
442
|
+
B.startBlock(doneBlock);
|
|
443
|
+
});
|
|
463
444
|
this.putc(B, "%b", "93"); // ']'
|
|
464
445
|
if (cyclic)
|
|
465
446
|
this.jbLeave(B);
|
|
@@ -467,7 +448,7 @@ export class LlWalkers {
|
|
|
467
448
|
emitUnionWriter(B, unionId) {
|
|
468
449
|
const def = this.host.unionsById.get(unionId);
|
|
469
450
|
if (!def)
|
|
470
|
-
throw new
|
|
451
|
+
throw new InternalCompilerError(`llvm emitter bug: jsonStringify of unknown union ${unionId}`);
|
|
471
452
|
const tag = this.unionTag(B, "%v");
|
|
472
453
|
const bad = B.newLabel("jwu.bad");
|
|
473
454
|
const done = B.newLabel("jwu.d");
|
|
@@ -482,10 +463,10 @@ export class LlWalkers {
|
|
|
482
463
|
return;
|
|
483
464
|
}
|
|
484
465
|
if (arm.kind === "undefinedT") {
|
|
485
|
-
//
|
|
486
|
-
//
|
|
487
|
-
|
|
488
|
-
B.br(
|
|
466
|
+
// Array and tuple slots stringify undefined as null. Ordinary
|
|
467
|
+
// record fields drop the key before invoking this writer.
|
|
468
|
+
this.puts(B, "%b", "null");
|
|
469
|
+
B.br(done);
|
|
489
470
|
return;
|
|
490
471
|
}
|
|
491
472
|
const w = this.jsonWriteHelper(arm);
|
|
@@ -516,7 +497,7 @@ export class LlWalkers {
|
|
|
516
497
|
}
|
|
517
498
|
/* ── the pretty-print re-indenter (jsonIndentHelper, ported) ──────────── */
|
|
518
499
|
/** `JSON.stringify(v, null, space)` as a REWRITE of the compact text —
|
|
519
|
-
* Node's gap algorithm exactly (see
|
|
500
|
+
* Node's gap algorithm exactly (see walkers.ts's sc_ji). The indent
|
|
520
501
|
* rides as a NUL-terminated constant + byte length. */
|
|
521
502
|
jsonIndentHelper() {
|
|
522
503
|
if (this.indentFn)
|
|
@@ -698,7 +679,7 @@ export class LlWalkers {
|
|
|
698
679
|
return existing;
|
|
699
680
|
const def = this.host.unionsById.get(unionId);
|
|
700
681
|
if (!def)
|
|
701
|
-
throw new
|
|
682
|
+
throw new InternalCompilerError(`llvm emitter bug: ToString of unknown union ${unionId}`);
|
|
702
683
|
const name = `sc_us_${this.unionToStrFns.size}`;
|
|
703
684
|
this.unionToStrFns.set(unionId, name);
|
|
704
685
|
const host = this.host;
|
|
@@ -767,7 +748,7 @@ export class LlWalkers {
|
|
|
767
748
|
return existing;
|
|
768
749
|
const def = this.host.unionsById.get(unionId);
|
|
769
750
|
if (!def)
|
|
770
|
-
throw new
|
|
751
|
+
throw new InternalCompilerError(`llvm emitter bug: join of unknown union ${unionId}`);
|
|
771
752
|
const name = `sc_uj_${this.unionJoinFns.size}`;
|
|
772
753
|
this.unionJoinFns.set(unionId, name);
|
|
773
754
|
const toStr = this.unionToStrHelper(unionId);
|
|
@@ -776,77 +757,69 @@ export class LlWalkers {
|
|
|
776
757
|
host.declare(`declare void @scr_jb_init(ptr)`);
|
|
777
758
|
host.declare(`declare ptr @scr_jb_finish(ptr)`);
|
|
778
759
|
host.declare(`declare double @scr_arr_len(ptr)`);
|
|
760
|
+
host.declare(`declare double @scr_arr_state(ptr, double)`);
|
|
779
761
|
host.declare(`declare ptr @scr_arr_get_ref(ptr, double)`);
|
|
780
762
|
host.declare(`declare void @scr_union_release(ptr)`);
|
|
781
763
|
host.declare(`declare void @scr_str_release(ptr)`);
|
|
782
764
|
const B = new BlockBuilder();
|
|
783
765
|
const buf = "%jb";
|
|
784
|
-
|
|
785
|
-
B.entryAllocas.push(`${buf} = alloca %ScrJsonBuf`, `${iSlot} = alloca double`);
|
|
766
|
+
B.entryAllocas.push(`${buf} = alloca %ScrJsonBuf`);
|
|
786
767
|
B.line(`call void @scr_jb_init(ptr ${buf})`);
|
|
787
|
-
B.line(`store double ${f64Lit(0)}, ptr ${iSlot}`);
|
|
788
768
|
const len = B.tmp();
|
|
789
769
|
B.line(`${len} = call double @scr_arr_len(ptr %a)`);
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
770
|
+
B.countedLoop(len, (i, next) => {
|
|
771
|
+
// `if (i) put sep bytes` — separators between elements only.
|
|
772
|
+
const nz = B.tmp();
|
|
773
|
+
const lsep = B.newLabel("uj.s");
|
|
774
|
+
const lel = B.newLabel("uj.v");
|
|
775
|
+
B.line(`${nz} = fcmp ogt double ${i}, ${f64Lit(0)}`);
|
|
776
|
+
B.condBr(nz, lsep, lel);
|
|
777
|
+
B.startBlock(lsep);
|
|
778
|
+
this.putScrStr(B, buf, "%sep");
|
|
779
|
+
B.br(lel);
|
|
780
|
+
B.startBlock(lel);
|
|
781
|
+
// Holes and payload-free present undefined both stringify empty. The
|
|
782
|
+
// separator was already written for this logical index, and only a
|
|
783
|
+
// VALUE slot may reach the typed getter below.
|
|
784
|
+
const state = B.tmp();
|
|
785
|
+
const isValue = B.tmp();
|
|
786
|
+
const lvalue = B.newLabel("uj.p");
|
|
787
|
+
B.line(`${state} = call double @scr_arr_state(ptr %a, double ${i})`);
|
|
788
|
+
B.line(`${isValue} = fcmp oeq double ${state}, ${f64Lit(1)}`);
|
|
789
|
+
B.condBr(isValue, lvalue, next);
|
|
790
|
+
B.startBlock(lvalue);
|
|
791
|
+
const u = B.tmp();
|
|
792
|
+
B.line(`${u} = call ptr @scr_arr_get_ref(ptr %a, double ${i}) ; element (+1)`);
|
|
793
|
+
if (unitTags.length > 0) {
|
|
794
|
+
// Nullish arms print empty, exactly JS's join.
|
|
795
|
+
const tag = this.unionTag(B, u);
|
|
796
|
+
let acc = "";
|
|
797
|
+
for (const t of unitTags) {
|
|
798
|
+
const cnd = B.tmp();
|
|
799
|
+
B.line(`${cnd} = icmp eq i32 ${tag}, ${t}`);
|
|
800
|
+
if (acc === "") {
|
|
801
|
+
acc = cnd;
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
const o = B.tmp();
|
|
805
|
+
B.line(`${o} = or i1 ${acc}, ${cnd}`);
|
|
806
|
+
acc = o;
|
|
807
|
+
}
|
|
828
808
|
}
|
|
809
|
+
const lskip = B.newLabel("uj.k");
|
|
810
|
+
const lwrite = B.newLabel("uj.w");
|
|
811
|
+
B.condBr(acc, lskip, lwrite);
|
|
812
|
+
B.startBlock(lskip);
|
|
813
|
+
B.line(`call void @scr_union_release(ptr ${u})`);
|
|
814
|
+
B.br(next);
|
|
815
|
+
B.startBlock(lwrite);
|
|
829
816
|
}
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
B.
|
|
817
|
+
const s = B.tmp();
|
|
818
|
+
B.line(`${s} = call ptr @${toStr}(ptr ${u})`);
|
|
819
|
+
this.putScrStr(B, buf, s);
|
|
820
|
+
B.line(`call void @scr_str_release(ptr ${s})`);
|
|
834
821
|
B.line(`call void @scr_union_release(ptr ${u})`);
|
|
835
|
-
|
|
836
|
-
B.startBlock(lwrite);
|
|
837
|
-
}
|
|
838
|
-
const s = B.tmp();
|
|
839
|
-
B.line(`${s} = call ptr @${toStr}(ptr ${u})`);
|
|
840
|
-
this.putScrStr(B, buf, s);
|
|
841
|
-
B.line(`call void @scr_str_release(ptr ${s})`);
|
|
842
|
-
B.line(`call void @scr_union_release(ptr ${u})`);
|
|
843
|
-
B.br(ln);
|
|
844
|
-
B.startBlock(ln);
|
|
845
|
-
const i2 = B.tmp();
|
|
846
|
-
B.line(`${i2} = fadd double ${i}, ${f64Lit(1)}`);
|
|
847
|
-
B.line(`store double ${i2}, ptr ${iSlot}`);
|
|
848
|
-
B.br(lc);
|
|
849
|
-
B.startBlock(le);
|
|
822
|
+
});
|
|
850
823
|
const r = B.tmp();
|
|
851
824
|
B.line(`${r} = call ptr @scr_jb_finish(ptr ${buf})`);
|
|
852
825
|
B.terminate(`ret ptr ${r}`);
|