@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
|
@@ -39,10 +39,11 @@
|
|
|
39
39
|
import * as ts from "../ts7/adapter.js";
|
|
40
40
|
import { dynFallbackType, newFnCtx } from "./lowerer.js";
|
|
41
41
|
import { isJsSourceFile, locOf } from "../program.js";
|
|
42
|
-
import { arrayOf, BOOL, canBoxFuncIntoDyn, canConvertToDyn, DYN, F64, isUnitType, STRING, typeEquals, typeKey, VOID } from "../../ir/
|
|
42
|
+
import { arrayOf, BOOL, canBoxFuncIntoDyn, canConvertToDyn, DYN, F64, isUnitType, STRING, typeEquals, typeKey, VOID } from "../../ir/ir.js";
|
|
43
43
|
import { streamForcedTuple, streamSidesOf } from "./lower-stream.js";
|
|
44
|
+
import { boolLit, strLit, varRef } from "../../ir/build.js";
|
|
44
45
|
/** True when the class descends from (or is) the runtime emitter. */
|
|
45
|
-
export function emitterRooted(
|
|
46
|
+
export function emitterRooted(lowerer, info) {
|
|
46
47
|
for (let c = info ?? null; c; c = c.base) {
|
|
47
48
|
if (c.builtinEmitter)
|
|
48
49
|
return true;
|
|
@@ -58,8 +59,8 @@ const META_EVENTS = new Set(["newListener", "removeListener"]);
|
|
|
58
59
|
* receiver classes resolve). The scan is DIAGNOSTIC-FREE: unmappable
|
|
59
60
|
* types and non-literal names are simply not candidates — the touching
|
|
60
61
|
* sites speak for themselves when they lower. */
|
|
61
|
-
function emitterEvents(
|
|
62
|
-
const holder =
|
|
62
|
+
function emitterEvents(lowerer) {
|
|
63
|
+
const holder = lowerer;
|
|
63
64
|
if (holder.emitterEventTable)
|
|
64
65
|
return holder.emitterEventTable;
|
|
65
66
|
const table = new Map();
|
|
@@ -73,7 +74,7 @@ function emitterEvents(L) {
|
|
|
73
74
|
table.set("error", { tuple: [{ kind: "object", className: "%Error" }], fromEmit: true, conflict: null, dynListener: false });
|
|
74
75
|
table.set("newListener", { tuple: [STRING], fromEmit: true, conflict: null, dynListener: false });
|
|
75
76
|
table.set("removeListener", { tuple: [STRING], fromEmit: true, conflict: null, dynListener: false });
|
|
76
|
-
const fmt = (t) =>
|
|
77
|
+
const fmt = (t) => lowerer.fmt(t);
|
|
77
78
|
const mergeEmit = (name, args) => {
|
|
78
79
|
if (args.some((a) => a === null))
|
|
79
80
|
return; // its own site will diagnose
|
|
@@ -139,7 +140,7 @@ function emitterEvents(L) {
|
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
};
|
|
142
|
-
for (const sf of
|
|
143
|
+
for (const sf of lowerer.program.getSourceFiles()) {
|
|
143
144
|
if (sf.isDeclarationFile)
|
|
144
145
|
continue;
|
|
145
146
|
const walk = (node) => {
|
|
@@ -156,13 +157,13 @@ function emitterEvents(L) {
|
|
|
156
157
|
let recvT = null;
|
|
157
158
|
let nameT = null;
|
|
158
159
|
try {
|
|
159
|
-
recvT =
|
|
160
|
-
nameT =
|
|
160
|
+
recvT = lowerer.mapTypeOf(lowerer.typeOf(node.expression.expression));
|
|
161
|
+
nameT = lowerer.typeOf(arg0);
|
|
161
162
|
}
|
|
162
163
|
catch {
|
|
163
164
|
return; // checker trouble is the lowering's business, not the scan's
|
|
164
165
|
}
|
|
165
|
-
if (recvT?.kind !== "object" || !emitterRooted(
|
|
166
|
+
if (recvT?.kind !== "object" || !emitterRooted(lowerer, lowerer.classes.get(recvT.className)))
|
|
166
167
|
return;
|
|
167
168
|
if (!nameT.isStringLiteralType())
|
|
168
169
|
return;
|
|
@@ -173,15 +174,15 @@ function emitterEvents(L) {
|
|
|
173
174
|
// tuples (lower-stream.ts) — their sites never join the program-
|
|
174
175
|
// global table, so a stream's 'data' cannot collide with a user
|
|
175
176
|
// event named 'data' on a plain emitter.
|
|
176
|
-
if (streamForcedTuple(
|
|
177
|
+
if (streamForcedTuple(lowerer, lowerer.classes.get(recvT.className), name) !== null)
|
|
177
178
|
return;
|
|
178
179
|
try {
|
|
179
180
|
if (isEmit) {
|
|
180
|
-
mergeEmit(name, node.arguments.slice(1).map((a) =>
|
|
181
|
+
mergeEmit(name, node.arguments.slice(1).map((a) => lowerer.mapTypeOf(lowerer.typeOf(a))));
|
|
181
182
|
}
|
|
182
183
|
else if (node.arguments[1]) {
|
|
183
|
-
const cbCt =
|
|
184
|
-
const cbT =
|
|
184
|
+
const cbCt = lowerer.typeOf(node.arguments[1]);
|
|
185
|
+
const cbT = lowerer.mapTypeOf(cbCt) ?? dynFallbackType(lowerer, node.arguments[1], cbCt);
|
|
185
186
|
// Dyn-flavored listeners (a checked-dynamic value, or a func
|
|
186
187
|
// with dyn parameters — the JS lane) register through the
|
|
187
188
|
// adapter and constrain nothing: a dyn parameter accepts any
|
|
@@ -207,21 +208,19 @@ function emitterEvents(L) {
|
|
|
207
208
|
/** The compile-time event name of the first argument, or a pointed fence
|
|
208
209
|
* (string-literal TYPE, so const bindings and literal unions of one
|
|
209
210
|
* member count — the staticHeaderKeyOf stance). */
|
|
210
|
-
function eventNameOf(
|
|
211
|
-
const t =
|
|
211
|
+
function eventNameOf(lowerer, member, arg) {
|
|
212
|
+
const t = lowerer.typeOf(arg);
|
|
212
213
|
if (t.isStringLiteralType())
|
|
213
214
|
return t.value;
|
|
214
|
-
|
|
215
|
+
lowerer.noLowering(`${member} with a non-literal event name`, arg, "event names must be compile-time string literals (each event's argument tuple is unified statically; symbol names have no lowering)");
|
|
215
216
|
}
|
|
216
|
-
const strLit = (value, loc) => ({ kind: "strLit", value, type: STRING, loc });
|
|
217
|
-
const boolLit = (value, loc) => ({ kind: "boolLit", value, type: BOOL, loc });
|
|
218
217
|
/** The event's unified tuple, with conflicts reported at this site. */
|
|
219
|
-
function tupleOf(
|
|
218
|
+
function tupleOf(lowerer, table, name, blame) {
|
|
220
219
|
const sig = table.get(name);
|
|
221
220
|
if (!sig)
|
|
222
221
|
return [];
|
|
223
222
|
if (sig.conflict) {
|
|
224
|
-
|
|
223
|
+
lowerer.noLowering(`the event '${name}' with conflicting argument types`, blame, `every emit site and listener of one event name must agree on one argument tuple — ${sig.conflict}`);
|
|
225
224
|
}
|
|
226
225
|
return sig.tuple;
|
|
227
226
|
}
|
|
@@ -230,15 +229,15 @@ function tupleOf(L, table, name, blame) {
|
|
|
230
229
|
* "func" for a function whose parameters include dyn (the JS lane's
|
|
231
230
|
* unannotated listeners — their checker type is any). Null for everything
|
|
232
231
|
* else (the static path, with its own diagnostics). */
|
|
233
|
-
function dynListenerFlavor(
|
|
232
|
+
function dynListenerFlavor(lowerer, node) {
|
|
234
233
|
let t;
|
|
235
234
|
try {
|
|
236
|
-
const ct =
|
|
235
|
+
const ct = lowerer.typeOf(node);
|
|
237
236
|
// The JS declaration fallback is what the EXPRESSION lowering applies
|
|
238
237
|
// to inference residue (an inline `(a) => {}` maps null as a checker
|
|
239
238
|
// type but lowers as a dyn-parameter function) — classify by the same
|
|
240
239
|
// rule, so the flavor always matches what lowerExpr will produce.
|
|
241
|
-
t =
|
|
240
|
+
t = lowerer.mapTypeOf(ct) ?? dynFallbackType(lowerer, node, ct);
|
|
242
241
|
}
|
|
243
242
|
catch {
|
|
244
243
|
return null;
|
|
@@ -251,7 +250,7 @@ function dynListenerFlavor(L, node) {
|
|
|
251
250
|
// null): route it through the dyn path too — the registration helper's
|
|
252
251
|
// checkListener throws Node's exact ERR_INVALID_ARG_TYPE TypeError
|
|
253
252
|
// (the TS lane never reaches this: tsc rejects the argument first).
|
|
254
|
-
if (t && t.kind !== "jsval" && (isUnitType(t) || canConvertToDyn(t, (id) =>
|
|
253
|
+
if (t && t.kind !== "jsval" && (isUnitType(t) || canConvertToDyn(t, (id) => lowerer.shapes.get(id), (id) => lowerer.unions.get(id)))) {
|
|
255
254
|
return "dyn";
|
|
256
255
|
}
|
|
257
256
|
return null;
|
|
@@ -277,25 +276,25 @@ function dynListenerFlavor(L, node) {
|
|
|
277
276
|
* payloads — 'error' events), and the meta events (Node passes the
|
|
278
277
|
* listener FUNCTION second, which has no dyn conversion — a dyn listener
|
|
279
278
|
* reading it would see undefined). */
|
|
280
|
-
function lowerDynListenerCall(
|
|
279
|
+
function lowerDynListenerCall(lowerer, member, name, tuple, receiver, cbNode, flavor, registering, once, prepend, loc,
|
|
281
280
|
/** Stream 'data': the adapter registers through emitter.onDataDyn so
|
|
282
281
|
* the backend emits the two-slot DATA thunk (box by runtime tag); the
|
|
283
282
|
* tuple is [DYN] — the adapter passes the boxed chunk through. */
|
|
284
283
|
streamData) {
|
|
285
284
|
if (META_EVENTS.has(name)) {
|
|
286
|
-
|
|
285
|
+
lowerer.noLowering(`'${member}' of '${name}' with a checked-dynamic listener`, cbNode, "Node passes the listener FUNCTION as the meta event's second argument, which has no dynamic conversion — annotate the listener's parameter as a string");
|
|
287
286
|
}
|
|
288
|
-
const getRecord = (id) =>
|
|
289
|
-
const getUnion = (id) =>
|
|
287
|
+
const getRecord = (id) => lowerer.shapes.get(id);
|
|
288
|
+
const getUnion = (id) => lowerer.unions.get(id);
|
|
290
289
|
for (let i = 0; i < tuple.length; i++) {
|
|
291
290
|
const p = tuple[i];
|
|
292
291
|
if (p.kind !== "dyn" && !canConvertToDyn(p, getRecord, getUnion)) {
|
|
293
|
-
|
|
292
|
+
lowerer.noLowering(`'${member}' of '${name}' with a checked-dynamic listener`, cbNode, `the event's argument ${i} is '${lowerer.fmt(p)}', which cannot box into a dynamic value — annotate the listener's parameters with the emitted types`);
|
|
294
293
|
}
|
|
295
294
|
}
|
|
296
295
|
let cbDyn;
|
|
297
296
|
if (flavor === "dyn") {
|
|
298
|
-
const v =
|
|
297
|
+
const v = lowerer.lowerExpr(cbNode);
|
|
299
298
|
if (v.type.kind === "dyn") {
|
|
300
299
|
cbDyn = v;
|
|
301
300
|
}
|
|
@@ -306,13 +305,13 @@ streamData) {
|
|
|
306
305
|
cbDyn = { kind: "dynFrom", value: v, type: DYN, loc };
|
|
307
306
|
}
|
|
308
307
|
else {
|
|
309
|
-
|
|
308
|
+
lowerer.noLowering(`'${member}' with a non-function listener`, cbNode);
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
else {
|
|
313
|
-
const cb =
|
|
312
|
+
const cb = lowerer.lowerExpr(cbNode);
|
|
314
313
|
if (cb.type.kind !== "func" || !canBoxFuncIntoDyn(cb.type, getRecord, getUnion)) {
|
|
315
|
-
|
|
314
|
+
lowerer.noLowering(`'${member}' with a listener of this signature`, cbNode, "a checked-dynamic listener's own parameters and return must box across the dynamic boundary");
|
|
316
315
|
}
|
|
317
316
|
cbDyn = { kind: "dynFrom", value: cb, type: DYN, loc };
|
|
318
317
|
}
|
|
@@ -322,15 +321,14 @@ streamData) {
|
|
|
322
321
|
const key = registering
|
|
323
322
|
? `${onFn}:${typeKey(recvT)}:${typeKey(adapterT)}`
|
|
324
323
|
: `emitter.offDyn:${typeKey(recvT)}`;
|
|
325
|
-
const existing =
|
|
324
|
+
const existing = lowerer.arrHofHelpers.get(key);
|
|
326
325
|
let helper = existing;
|
|
327
326
|
if (!helper) {
|
|
328
|
-
helper = `%emitter.${registering ? "onDyn" : "offDyn"}.${
|
|
329
|
-
|
|
330
|
-
const ref = (localId, type) => ({ kind: "varRef", localId, type, loc });
|
|
327
|
+
helper = `%emitter.${registering ? "onDyn" : "offDyn"}.${lowerer.arrHofHelpers.size}`;
|
|
328
|
+
lowerer.arrHofHelpers.set(key, helper);
|
|
331
329
|
const check = {
|
|
332
330
|
kind: "exprStmt",
|
|
333
|
-
expr: { kind: "libCall", fn: "emitter.checkListener", args: [
|
|
331
|
+
expr: { kind: "libCall", fn: "emitter.checkListener", args: [varRef("cb.0", DYN, loc)], type: VOID, loc },
|
|
334
332
|
loc,
|
|
335
333
|
};
|
|
336
334
|
const params = [
|
|
@@ -350,13 +348,13 @@ streamData) {
|
|
|
350
348
|
locals.push({ id: "a.0", name: "a", type: adapterT, mutable: false });
|
|
351
349
|
body = [
|
|
352
350
|
check,
|
|
353
|
-
{ kind: "varDecl", localId: "a.0", init: { kind: "dynCheck", value:
|
|
351
|
+
{ kind: "varDecl", localId: "a.0", init: { kind: "dynCheck", value: varRef("cb.0", DYN, loc), type: adapterT, loc }, loc },
|
|
354
352
|
{
|
|
355
353
|
kind: "return",
|
|
356
354
|
value: {
|
|
357
355
|
kind: "libCall",
|
|
358
356
|
fn: onFn,
|
|
359
|
-
args: [
|
|
357
|
+
args: [varRef("r.0", recvT, loc), varRef("n.0", STRING, loc), varRef("cb.0", DYN, loc), varRef("a.0", adapterT, loc), varRef("o.0", BOOL, loc), varRef("p.0", BOOL, loc)],
|
|
360
358
|
type: recvT,
|
|
361
359
|
loc,
|
|
362
360
|
},
|
|
@@ -372,7 +370,7 @@ streamData) {
|
|
|
372
370
|
value: {
|
|
373
371
|
kind: "libCall",
|
|
374
372
|
fn: "emitter.offDyn",
|
|
375
|
-
args: [
|
|
373
|
+
args: [varRef("r.0", recvT, loc), varRef("n.0", STRING, loc), varRef("cb.0", DYN, loc)],
|
|
376
374
|
type: recvT,
|
|
377
375
|
loc,
|
|
378
376
|
},
|
|
@@ -380,7 +378,7 @@ streamData) {
|
|
|
380
378
|
},
|
|
381
379
|
];
|
|
382
380
|
}
|
|
383
|
-
|
|
381
|
+
lowerer.liftedFns.push({ name: helper, params, returnType: recvT, locals, body, loc });
|
|
384
382
|
}
|
|
385
383
|
return {
|
|
386
384
|
kind: "call",
|
|
@@ -394,7 +392,7 @@ streamData) {
|
|
|
394
392
|
}
|
|
395
393
|
/** A listener argument: lowered, checked void-returning, and its
|
|
396
394
|
* parameters checked as a typeEquals PREFIX of the event tuple. */
|
|
397
|
-
function lowerListenerArg(
|
|
395
|
+
function lowerListenerArg(lowerer, member, name, node, tuple) {
|
|
398
396
|
// Unannotated non-empty parameter lists have no static types (checker
|
|
399
397
|
// `any`; dyn in JS sources) — say so before the blanket type fence speaks.
|
|
400
398
|
if ((ts.isArrowFunction(node) || ts.isFunctionExpression(node)) && node.parameters.length > 0) {
|
|
@@ -402,21 +400,21 @@ function lowerListenerArg(L, member, name, node, tuple) {
|
|
|
402
400
|
if (p.type === undefined && ts.isIdentifier(p.name)) {
|
|
403
401
|
const mapped = (() => {
|
|
404
402
|
try {
|
|
405
|
-
return
|
|
403
|
+
return lowerer.mapTypeOf(lowerer.typeOf(p.name));
|
|
406
404
|
}
|
|
407
405
|
catch {
|
|
408
406
|
return null;
|
|
409
407
|
}
|
|
410
408
|
})();
|
|
411
409
|
if (mapped === null || mapped.kind === "dyn" || mapped.kind === "jsval") {
|
|
412
|
-
|
|
410
|
+
lowerer.noLowering(`'${member}' listeners with unannotated parameters`, p, "EventEmitter's declared listener type is (...args: any[]) — annotate each parameter with the emitted argument's type");
|
|
413
411
|
}
|
|
414
412
|
}
|
|
415
413
|
}
|
|
416
414
|
}
|
|
417
|
-
const cb =
|
|
415
|
+
const cb = lowerer.lowerExpr(node);
|
|
418
416
|
if (cb.type.kind !== "func") {
|
|
419
|
-
|
|
417
|
+
lowerer.noLowering(`'${member}' with a non-function listener`, node);
|
|
420
418
|
}
|
|
421
419
|
const cbT = cb.type;
|
|
422
420
|
// Node ignores listener return values, so value-returning listeners
|
|
@@ -425,14 +423,14 @@ function lowerListenerArg(L, member, name, node, tuple) {
|
|
|
425
423
|
// and discards (releasing refcounted results). An async listener's
|
|
426
424
|
// promise is abandoned unobserved (SEMANTICS.md).
|
|
427
425
|
if (META_EVENTS.has(name) && cbT.params.length > 1) {
|
|
428
|
-
|
|
426
|
+
lowerer.noLowering(`'${name}' listeners taking the listener-function argument`, node, "meta-event listeners take at most the event name (the listener argument has no unified static type)");
|
|
429
427
|
}
|
|
430
428
|
if (cbT.params.length > tuple.length) {
|
|
431
|
-
|
|
429
|
+
lowerer.noLowering(`a '${name}' listener declaring ${cbT.params.length} parameters where the event's tuple has ${tuple.length}`, node, "listeners may declare a prefix of the event's emitted arguments");
|
|
432
430
|
}
|
|
433
431
|
for (let i = 0; i < cbT.params.length; i++) {
|
|
434
432
|
if (!typeEquals(cbT.params[i], tuple[i])) {
|
|
435
|
-
|
|
433
|
+
lowerer.noLowering(`a '${name}' listener whose parameter ${i} is '${lowerer.fmt(cbT.params[i])}' where the event's tuple has '${lowerer.fmt(tuple[i])}'`, node, "every emit site and listener of one event name must agree on one argument tuple");
|
|
436
434
|
}
|
|
437
435
|
}
|
|
438
436
|
return cb;
|
|
@@ -446,11 +444,11 @@ function lowerListenerArg(L, member, name, node, tuple) {
|
|
|
446
444
|
* NEVER dispatches through an override at-or-below the lexical class —
|
|
447
445
|
* JS's static super dispatch (the nearest override STRICTLY ABOVE the
|
|
448
446
|
* lexical class still answers, exactly like a prototype-chain walk). */
|
|
449
|
-
export function lowerEmitterMethodCall(
|
|
447
|
+
export function lowerEmitterMethodCall(lowerer, call, access, info, superRecv) {
|
|
450
448
|
const member = access.name.text;
|
|
451
449
|
const loc = locOf(call);
|
|
452
450
|
const args = call.arguments;
|
|
453
|
-
const lowerReceiver = () => superRecv?.thisRef ??
|
|
451
|
+
const lowerReceiver = () => superRecv?.thisRef ?? lowerer.lowerExpr(access.expression);
|
|
454
452
|
// The class VALUE, not an instance (`EventEmitter.setMaxListeners(n)` —
|
|
455
453
|
// the receiver's checker type carries construct signatures; mapType
|
|
456
454
|
// answers the instance object for every EventEmitter-symbol type, so the
|
|
@@ -459,13 +457,13 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
459
457
|
// are a DIFFERENT surface: setMaxListeners(n) writes the process-wide
|
|
460
458
|
// defaultMaxListeners (validated at runtime — Node's ERR_OUT_OF_RANGE);
|
|
461
459
|
// everything else fences by its static name.
|
|
462
|
-
if (superRecv === undefined &&
|
|
460
|
+
if (superRecv === undefined && lowerer.checker.getConstructSignatures(lowerer.typeOf(access.expression)).length > 0) {
|
|
463
461
|
if (member === "setMaxListeners" && args.length === 1) {
|
|
464
|
-
if (
|
|
462
|
+
if (lowerer.mapTypeOf(lowerer.typeOf(args[0]))?.kind !== "f64") {
|
|
465
463
|
// Node's runtime ladder over the dyn value ("setMaxListeners" is
|
|
466
464
|
// the message's slot for the static form).
|
|
467
|
-
const raw =
|
|
468
|
-
if (raw.type.kind === "dyn" || raw.kind === "unitLit" ||
|
|
465
|
+
const raw = lowerer.lowerExpr(args[0]);
|
|
466
|
+
if (raw.type.kind === "dyn" || raw.kind === "unitLit" || lowerer.dynConvertible(raw.type)) {
|
|
469
467
|
const n = raw.type.kind === "dyn" ? raw : { kind: "dynFrom", value: raw, type: DYN, loc };
|
|
470
468
|
return {
|
|
471
469
|
kind: "libCall",
|
|
@@ -476,9 +474,9 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
476
474
|
};
|
|
477
475
|
}
|
|
478
476
|
}
|
|
479
|
-
const n =
|
|
477
|
+
const n = lowerer.lowerExprExpecting(args[0], F64);
|
|
480
478
|
if (n.type.kind !== "f64") {
|
|
481
|
-
|
|
479
|
+
lowerer.noLowering(`EventEmitter.setMaxListeners with a '${lowerer.fmt(n.type)}' argument`, args[0], "the lowered form takes a number (Node throws ERR_INVALID_ARG_TYPE at runtime for other values)");
|
|
482
480
|
}
|
|
483
481
|
return { kind: "libCall", fn: "emitter.setDefaultMax", args: [n], type: VOID, loc };
|
|
484
482
|
}
|
|
@@ -489,14 +487,14 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
489
487
|
// when n is a pure read (identifier/literal — nothing to evaluate)
|
|
490
488
|
// and the target crosses into the checked-dynamic tree for the Received tail.
|
|
491
489
|
if (args.length === 2 && !args.some(ts.isSpreadElement)) {
|
|
492
|
-
const nT =
|
|
493
|
-
const tT =
|
|
490
|
+
const nT = lowerer.mapTypeOf(lowerer.typeOf(args[0]));
|
|
491
|
+
const tT = lowerer.mapTypeOf(lowerer.typeOf(args[1]));
|
|
494
492
|
const nPure = ts.isIdentifier(args[0]) || ts.isLiteralExpression(args[0]);
|
|
495
493
|
const targetNotEmitter = tT !== null && tT.kind !== "dyn" && tT.kind !== "jsval" &&
|
|
496
494
|
!(tT.kind === "object");
|
|
497
495
|
if (nT?.kind === "f64" && nPure && targetNotEmitter) {
|
|
498
|
-
const raw =
|
|
499
|
-
if (raw.type.kind === "dyn" || raw.kind === "unitLit" ||
|
|
496
|
+
const raw = lowerer.lowerExpr(args[1]);
|
|
497
|
+
if (raw.type.kind === "dyn" || raw.kind === "unitLit" || lowerer.dynConvertible(raw.type)) {
|
|
500
498
|
const got = raw.type.kind === "dyn" ? raw : { kind: "dynFrom", value: raw, type: DYN, loc };
|
|
501
499
|
return {
|
|
502
500
|
kind: "libCall",
|
|
@@ -512,20 +510,20 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
512
510
|
}
|
|
513
511
|
}
|
|
514
512
|
}
|
|
515
|
-
|
|
513
|
+
lowerer.noLowering(`EventEmitter.setMaxListeners with ${args.length} arguments`, call, "the lowered static form is EventEmitter.setMaxListeners(n) — per-target application (…, ...eventTargets) has no lowering; call target.setMaxListeners(n) instead");
|
|
516
514
|
}
|
|
517
|
-
|
|
515
|
+
lowerer.noLowering(`the static EventEmitter.${member} form`, call, "instance emitters lower this member; the class-value statics have no lowering yet");
|
|
518
516
|
}
|
|
519
|
-
const table = emitterEvents(
|
|
517
|
+
const table = emitterEvents(lowerer);
|
|
520
518
|
if (REGISTER_MEMBERS.has(member) || member === "off" || member === "removeListener") {
|
|
521
519
|
// Node's (type, listener) signature IGNORES extra arguments — admit
|
|
522
520
|
// pure-read extras (literals/identifiers: nothing to evaluate) and
|
|
523
521
|
// drop them; anything with effects keeps the fence.
|
|
524
522
|
const extrasPure = args.slice(2).every((a) => ts.isIdentifier(a) || ts.isLiteralExpression(a));
|
|
525
523
|
if (args.length < 2 || !extrasPure) {
|
|
526
|
-
|
|
524
|
+
lowerer.noLowering(`${member} with ${args.length} arguments`, call, "the supported form is (eventName, listener)");
|
|
527
525
|
}
|
|
528
|
-
const name = eventNameOf(
|
|
526
|
+
const name = eventNameOf(lowerer, member, args[0]);
|
|
529
527
|
const registering = REGISTER_MEMBERS.has(member);
|
|
530
528
|
// The runtime fires the meta events INTERNALLY (scr_ee_emit_meta —
|
|
531
529
|
// Node calls this.emit, which would dispatch through an emit
|
|
@@ -535,7 +533,7 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
535
533
|
if (registering && META_EVENTS.has(name)) {
|
|
536
534
|
const ov = emitOverrideComparable(info);
|
|
537
535
|
if (ov) {
|
|
538
|
-
|
|
536
|
+
lowerer.noLowering(`'${member}' of '${name}' while '${ov.def.jsName || ov.def.name}' overrides emit`, call, "the runtime fires meta events internally, which cannot route through an emit override");
|
|
539
537
|
}
|
|
540
538
|
}
|
|
541
539
|
const receiver = lowerReceiver();
|
|
@@ -545,23 +543,23 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
545
543
|
// encoded streams deliver strings; scr_stream_emit_data): listeners
|
|
546
544
|
// on readable-sided receivers register through DATA thunks that
|
|
547
545
|
// unwrap the declared side (typed) or box by tag (dyn).
|
|
548
|
-
const sides = streamSidesOf(
|
|
546
|
+
const sides = streamSidesOf(lowerer, info);
|
|
549
547
|
if (name === "data" && (sides === "r" || sides === "rw")) {
|
|
550
|
-
const dynFlavor = dynListenerFlavor(
|
|
548
|
+
const dynFlavor = dynListenerFlavor(lowerer, args[1]);
|
|
551
549
|
if (dynFlavor !== null) {
|
|
552
|
-
return lowerDynListenerCall(
|
|
550
|
+
return lowerDynListenerCall(lowerer, member, name, [DYN], receiver, args[1], dynFlavor, registering, once, prepend, loc, true);
|
|
553
551
|
}
|
|
554
|
-
const cb =
|
|
552
|
+
const cb = lowerer.lowerExpr(args[1]);
|
|
555
553
|
if (cb.type.kind !== "func") {
|
|
556
|
-
|
|
554
|
+
lowerer.noLowering(`'${member}' with a non-function listener`, args[1]);
|
|
557
555
|
}
|
|
558
556
|
const cbT = cb.type;
|
|
559
557
|
if (cbT.params.length > 1) {
|
|
560
|
-
|
|
558
|
+
lowerer.noLowering(`a 'data' listener declaring ${cbT.params.length} parameters where the event carries one chunk`, args[1]);
|
|
561
559
|
}
|
|
562
560
|
const p = cbT.params[0];
|
|
563
561
|
if (p !== undefined && !(p.kind === "bytes" && p.elem === "u8") && p.kind !== "string") {
|
|
564
|
-
|
|
562
|
+
lowerer.noLowering(`a 'data' listener whose chunk parameter is '${lowerer.fmt(p)}'`, args[1], "chunks are Buffers — or strings once setEncoding/the encoding option applies");
|
|
565
563
|
}
|
|
566
564
|
if (!registering) {
|
|
567
565
|
return {
|
|
@@ -583,12 +581,12 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
583
581
|
// Stream-rooted receivers consult the per-base FORCED tuples first
|
|
584
582
|
// (runtime-emitted 'end'/'pipe'/... payloads); the dyn-listener check
|
|
585
583
|
// below then sees the forced tuple exactly like a table one.
|
|
586
|
-
const tuple = streamForcedTuple(
|
|
587
|
-
const dynFlavor = dynListenerFlavor(
|
|
584
|
+
const tuple = streamForcedTuple(lowerer, info, name) ?? tupleOf(lowerer, table, name, call);
|
|
585
|
+
const dynFlavor = dynListenerFlavor(lowerer, args[1]);
|
|
588
586
|
if (dynFlavor !== null) {
|
|
589
|
-
return lowerDynListenerCall(
|
|
587
|
+
return lowerDynListenerCall(lowerer, member, name, tuple, receiver, args[1], dynFlavor, registering, once, prepend, loc, false);
|
|
590
588
|
}
|
|
591
|
-
const cb = lowerListenerArg(
|
|
589
|
+
const cb = lowerListenerArg(lowerer, member, name, args[1], tuple);
|
|
592
590
|
return {
|
|
593
591
|
kind: "libCall",
|
|
594
592
|
fn: registering ? "emitter.on" : "emitter.off",
|
|
@@ -601,41 +599,41 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
601
599
|
}
|
|
602
600
|
if (member === "emit") {
|
|
603
601
|
if (args.length === 0) {
|
|
604
|
-
|
|
602
|
+
lowerer.noLowering("emit without an event name", call);
|
|
605
603
|
}
|
|
606
|
-
const name = eventNameOf(
|
|
604
|
+
const name = eventNameOf(lowerer, member, args[0]);
|
|
607
605
|
const receiver = lowerReceiver();
|
|
608
606
|
if (name === "error") {
|
|
609
607
|
// The special event: exactly one %Error-rooted payload; no listener
|
|
610
608
|
// means the runtime THROWS it (emitter.emitError, may-throw).
|
|
611
609
|
if (args.length !== 2) {
|
|
612
|
-
|
|
610
|
+
lowerer.noLowering(`emit('error') with ${args.length - 1} payload arguments`, call, "the supported form is emit('error', err) with an Error-hierarchy payload (non-Error payloads would need Node's ERR_UNHANDLED_ERROR wrapping — no lowering yet)");
|
|
613
611
|
}
|
|
614
|
-
const err =
|
|
612
|
+
const err = lowerer.lowerExpr(args[1]);
|
|
615
613
|
const rootsAtError = (t) => {
|
|
616
614
|
if (t.kind !== "object")
|
|
617
615
|
return false;
|
|
618
|
-
for (let c =
|
|
616
|
+
for (let c = lowerer.classes.get(t.className) ?? null; c; c = c.base) {
|
|
619
617
|
if (c.def.name === "%Error")
|
|
620
618
|
return true;
|
|
621
619
|
}
|
|
622
620
|
return false;
|
|
623
621
|
};
|
|
624
622
|
if (!rootsAtError(err.type)) {
|
|
625
|
-
|
|
623
|
+
lowerer.noLowering(`emit('error') with a '${lowerer.fmt(err.type)}' payload`, args[1], "the supported payload is an Error-hierarchy instance");
|
|
626
624
|
}
|
|
627
|
-
return emitDispatchExpr(
|
|
625
|
+
return emitDispatchExpr(lowerer, info, name, [{ kind: "object", className: "%Error" }], receiver, [lowerer.upcastTo(err, "%Error")], superRecv?.cls, loc);
|
|
628
626
|
}
|
|
629
627
|
// Stream 'data' rides the two-slot payload ABI: a user emit fills
|
|
630
628
|
// the chunk's slot (bytes or string), NULLs the other.
|
|
631
|
-
const emitSides = streamSidesOf(
|
|
629
|
+
const emitSides = streamSidesOf(lowerer, info);
|
|
632
630
|
if (name === "data" && (emitSides === "r" || emitSides === "rw")) {
|
|
633
631
|
if (args.length !== 2) {
|
|
634
|
-
|
|
632
|
+
lowerer.noLowering(`emit('data') with ${args.length - 1} payload arguments`, call, "the event carries one chunk (a Buffer or string)");
|
|
635
633
|
}
|
|
636
|
-
const chunk =
|
|
634
|
+
const chunk = lowerer.lowerExpr(args[1]);
|
|
637
635
|
if (!(chunk.type.kind === "bytes" && chunk.type.elem === "u8") && chunk.type.kind !== "string") {
|
|
638
|
-
|
|
636
|
+
lowerer.noLowering(`emit('data') with a '${lowerer.fmt(chunk.type)}' chunk`, args[1], "chunks are Buffers or strings");
|
|
639
637
|
}
|
|
640
638
|
return {
|
|
641
639
|
kind: "libCall",
|
|
@@ -645,25 +643,25 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
645
643
|
loc,
|
|
646
644
|
};
|
|
647
645
|
}
|
|
648
|
-
const tuple = streamForcedTuple(
|
|
646
|
+
const tuple = streamForcedTuple(lowerer, info, name) ?? tupleOf(lowerer, table, name, call);
|
|
649
647
|
if (args.length - 1 !== tuple.length) {
|
|
650
|
-
|
|
648
|
+
lowerer.noLowering(`emit('${name}') with ${args.length - 1} arguments where the event's tuple has ${tuple.length}`, call, "every emit site of one event name must supply the same argument tuple (listeners may declare a prefix)");
|
|
651
649
|
}
|
|
652
|
-
const payload = args.slice(1).map((a, i) =>
|
|
653
|
-
return emitDispatchExpr(
|
|
650
|
+
const payload = args.slice(1).map((a, i) => lowerer.lowerExprExpecting(a, tuple[i]));
|
|
651
|
+
return emitDispatchExpr(lowerer, info, name, tuple, receiver, payload, superRecv?.cls, loc);
|
|
654
652
|
}
|
|
655
653
|
// The pure-introspection members take ANY string-typed name — no tuple
|
|
656
654
|
// is involved, so the literal rule has nothing to protect (a meta
|
|
657
655
|
// listener naturally passes its name parameter along).
|
|
658
656
|
if (member === "removeAllListeners") {
|
|
659
657
|
if (args.length > 1) {
|
|
660
|
-
|
|
658
|
+
lowerer.noLowering(`removeAllListeners with ${args.length} arguments`, call);
|
|
661
659
|
}
|
|
662
660
|
const all = args.length === 0;
|
|
663
661
|
const receiver = lowerReceiver();
|
|
664
|
-
const name = all ? strLit("", loc) :
|
|
662
|
+
const name = all ? strLit("", loc) : lowerer.lowerExprExpecting(args[0], STRING);
|
|
665
663
|
if (name.type.kind !== "string") {
|
|
666
|
-
|
|
664
|
+
lowerer.noLowering(`removeAllListeners with a '${lowerer.fmt(name.type)}' event name`, args[0] ?? call);
|
|
667
665
|
}
|
|
668
666
|
return {
|
|
669
667
|
kind: "libCall",
|
|
@@ -675,19 +673,19 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
675
673
|
}
|
|
676
674
|
if (member === "listenerCount") {
|
|
677
675
|
if (args.length !== 1 && args.length !== 2) {
|
|
678
|
-
|
|
676
|
+
lowerer.noLowering(`listenerCount with ${args.length} arguments`, call);
|
|
679
677
|
}
|
|
680
678
|
const receiver = lowerReceiver();
|
|
681
|
-
const name =
|
|
679
|
+
const name = lowerer.lowerExprExpecting(args[0], STRING);
|
|
682
680
|
if (name.type.kind !== "string") {
|
|
683
|
-
|
|
681
|
+
lowerer.noLowering(`listenerCount with a '${lowerer.fmt(name.type)}' event name`, args[0]);
|
|
684
682
|
}
|
|
685
683
|
if (args.length === 2) {
|
|
686
684
|
// The fn filter matches by identity — the listener's own type is
|
|
687
685
|
// its word; no tuple check is needed to count.
|
|
688
|
-
const cb =
|
|
686
|
+
const cb = lowerer.lowerExpr(args[1]);
|
|
689
687
|
if (cb.type.kind !== "func") {
|
|
690
|
-
|
|
688
|
+
lowerer.noLowering(`listenerCount with a non-function filter`, args[1]);
|
|
691
689
|
}
|
|
692
690
|
return { kind: "libCall", fn: "emitter.countFn", args: [receiver, name, cb], type: F64, loc };
|
|
693
691
|
}
|
|
@@ -704,16 +702,16 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
704
702
|
// once wrapper is runtime-internal, so rawListeners' wrapper identity
|
|
705
703
|
// is a documented divergence (SEMANTICS.md).
|
|
706
704
|
if (args.length !== 1) {
|
|
707
|
-
|
|
705
|
+
lowerer.noLowering(`${member} with ${args.length} arguments`, call, "the supported form is (eventName)");
|
|
708
706
|
}
|
|
709
|
-
const name = eventNameOf(
|
|
707
|
+
const name = eventNameOf(lowerer, member, args[0]);
|
|
710
708
|
const sig = table.get(name);
|
|
711
709
|
if (sig?.dynListener) {
|
|
712
710
|
// A dyn-adapted registration means the runtime bucket can hold
|
|
713
711
|
// originals of MIXED signatures — no one honest element type.
|
|
714
|
-
|
|
712
|
+
lowerer.noLowering(`${member} of the event '${name}'`, call, "a listener of this event is checked-dynamic (unannotated parameters), so the listener array has no one static element type — listenerCount(name) counts");
|
|
715
713
|
}
|
|
716
|
-
const tuple = tupleOf(
|
|
714
|
+
const tuple = tupleOf(lowerer, table, name, call);
|
|
717
715
|
const receiver = lowerReceiver();
|
|
718
716
|
return {
|
|
719
717
|
kind: "libCall",
|
|
@@ -725,30 +723,30 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
725
723
|
}
|
|
726
724
|
if (member === "eventNames") {
|
|
727
725
|
if (args.length !== 0)
|
|
728
|
-
|
|
726
|
+
lowerer.noLowering(`eventNames with ${args.length} arguments`, call);
|
|
729
727
|
const receiver = lowerReceiver();
|
|
730
728
|
return { kind: "libCall", fn: "emitter.names", args: [receiver], type: arrayOf(STRING), loc };
|
|
731
729
|
}
|
|
732
730
|
if (member === "setMaxListeners") {
|
|
733
731
|
if (args.length !== 1)
|
|
734
|
-
|
|
732
|
+
lowerer.noLowering(`setMaxListeners with ${args.length} arguments`, call);
|
|
735
733
|
const receiver = lowerReceiver();
|
|
736
|
-
if (
|
|
734
|
+
if (lowerer.mapTypeOf(lowerer.typeOf(args[0]))?.kind !== "f64") {
|
|
737
735
|
// The invalid-input probes (string n, dyn helpers): Node's ladder
|
|
738
736
|
// runs at runtime — ERR_INVALID_ARG_TYPE for non-numbers,
|
|
739
737
|
// ERR_OUT_OF_RANGE below zero, and a well-typed dyn still applies.
|
|
740
|
-
const raw =
|
|
741
|
-
if (raw.type.kind === "dyn" || raw.kind === "unitLit" ||
|
|
738
|
+
const raw = lowerer.lowerExpr(args[0]);
|
|
739
|
+
if (raw.type.kind === "dyn" || raw.kind === "unitLit" || lowerer.dynConvertible(raw.type)) {
|
|
742
740
|
const n = raw.type.kind === "dyn" ? raw : { kind: "dynFrom", value: raw, type: DYN, loc };
|
|
743
741
|
return { kind: "libCall", fn: "emitter.setMaxChk", args: [receiver, n], type: receiver.type, loc };
|
|
744
742
|
}
|
|
745
743
|
}
|
|
746
|
-
const n =
|
|
744
|
+
const n = lowerer.lowerExprExpecting(args[0], F64);
|
|
747
745
|
return { kind: "libCall", fn: "emitter.setMax", args: [receiver, n], type: receiver.type, loc };
|
|
748
746
|
}
|
|
749
747
|
if (member === "getMaxListeners") {
|
|
750
748
|
if (args.length !== 0)
|
|
751
|
-
|
|
749
|
+
lowerer.noLowering(`getMaxListeners with ${args.length} arguments`, call);
|
|
752
750
|
const receiver = lowerReceiver();
|
|
753
751
|
return { kind: "libCall", fn: "emitter.getMax", args: [receiver], type: F64, loc };
|
|
754
752
|
}
|
|
@@ -757,7 +755,7 @@ export function lowerEmitterMethodCall(L, call, access, info, superRecv) {
|
|
|
757
755
|
/** Why a subclass `emit` declaration is NOT the forwarding shape, or null
|
|
758
756
|
* when it conforms. Checked at class collection; the recorded override
|
|
759
757
|
* then lowers per event with no further shape questions. */
|
|
760
|
-
export function emitOverrideShapeReason(
|
|
758
|
+
export function emitOverrideShapeReason(lowerer, member) {
|
|
761
759
|
if (!member.body)
|
|
762
760
|
return "the declaration has no body";
|
|
763
761
|
if (member.asteriskToken !== undefined)
|
|
@@ -793,14 +791,14 @@ export function emitOverrideShapeReason(L, member) {
|
|
|
793
791
|
// lowering anyway). JS: unannotated is the only spelling (checker
|
|
794
792
|
// `any`); the specialization binds it as the string it always is —
|
|
795
793
|
// event names are compile-time literals program-wide.
|
|
796
|
-
const p0T =
|
|
794
|
+
const p0T = lowerer.mapTypeOf(lowerer.typeOf(p0.name));
|
|
797
795
|
const jsUnannotated = p0.type === undefined && isJsSourceFile(member.getSourceFile()) &&
|
|
798
796
|
(p0T === null || p0T.kind === "dyn" || p0T.kind === "jsval");
|
|
799
797
|
if (p0T?.kind !== "string" && !jsUnannotated) {
|
|
800
798
|
return "the event parameter must be typed 'string' (symbol event names have no lowering)";
|
|
801
799
|
}
|
|
802
|
-
const sig =
|
|
803
|
-
const ret = sig ?
|
|
800
|
+
const sig = lowerer.checker.getSignatureFromDeclaration(member);
|
|
801
|
+
const ret = sig ? lowerer.mapTypeOf(lowerer.checker.getReturnTypeOfSignature(sig)) : null;
|
|
804
802
|
if (ret?.kind !== "bool") {
|
|
805
803
|
return "every code path must return a boolean (emit's contract)";
|
|
806
804
|
}
|
|
@@ -808,8 +806,8 @@ export function emitOverrideShapeReason(L, member) {
|
|
|
808
806
|
catch {
|
|
809
807
|
return "its signature does not resolve statically";
|
|
810
808
|
}
|
|
811
|
-
const eventSym =
|
|
812
|
-
const restSym =
|
|
809
|
+
const eventSym = lowerer.checker.getSymbolAtLocation(p0.name);
|
|
810
|
+
const restSym = lowerer.checker.getSymbolAtLocation(p1.name);
|
|
813
811
|
if (!eventSym || !restSym)
|
|
814
812
|
return "its parameters do not resolve statically";
|
|
815
813
|
let reason = null;
|
|
@@ -819,12 +817,12 @@ export function emitOverrideShapeReason(L, member) {
|
|
|
819
817
|
if (ts.isIdentifier(n)) {
|
|
820
818
|
let s;
|
|
821
819
|
try {
|
|
822
|
-
s =
|
|
820
|
+
s = lowerer.checker.getSymbolAtLocation(n) ?? undefined;
|
|
823
821
|
}
|
|
824
822
|
catch {
|
|
825
823
|
s = undefined;
|
|
826
824
|
}
|
|
827
|
-
if (s === restSym && !isEmitForwardSpread(
|
|
825
|
+
if (s === restSym && !isEmitForwardSpread(lowerer, member, n, eventSym)) {
|
|
828
826
|
reason = "the rest parameter may only forward through super.emit(event, ...args) in the method's own body";
|
|
829
827
|
}
|
|
830
828
|
else if (s === eventSym && n !== p0.name && isWriteTarget(n)) {
|
|
@@ -840,7 +838,7 @@ export function emitOverrideShapeReason(L, member) {
|
|
|
840
838
|
* `super.emit(<event param>, ...<this identifier>)`, two arguments, sitting
|
|
841
839
|
* in the override method's OWN body (a nested function could not reach the
|
|
842
840
|
* specialization's tuple parameters). */
|
|
843
|
-
function isEmitForwardSpread(
|
|
841
|
+
function isEmitForwardSpread(lowerer, method, id, eventSym) {
|
|
844
842
|
const sp = id.parent;
|
|
845
843
|
if (!ts.isSpreadElement(sp) || sp.expression !== id)
|
|
846
844
|
return false;
|
|
@@ -857,7 +855,7 @@ function isEmitForwardSpread(L, method, id, eventSym) {
|
|
|
857
855
|
if (!ts.isIdentifier(a0))
|
|
858
856
|
return false;
|
|
859
857
|
try {
|
|
860
|
-
if (
|
|
858
|
+
if (lowerer.checker.getSymbolAtLocation(a0) !== eventSym)
|
|
861
859
|
return false;
|
|
862
860
|
}
|
|
863
861
|
catch {
|
|
@@ -903,7 +901,7 @@ function isWriteTarget(id) {
|
|
|
903
901
|
}
|
|
904
902
|
}
|
|
905
903
|
/** The nearest class at-or-above `info` declaring an emit override. */
|
|
906
|
-
|
|
904
|
+
function emitOverrideAtOrAbove(info) {
|
|
907
905
|
for (let c = info ?? null; c; c = c.base) {
|
|
908
906
|
if (c.emitOverride)
|
|
909
907
|
return c;
|
|
@@ -937,7 +935,7 @@ function topmostEmitOverridesBelow(info) {
|
|
|
937
935
|
/** An emit-override class COMPARABLE to `info` (ancestor-or-self or
|
|
938
936
|
* descendant — a dynamic instance under this static type could dispatch
|
|
939
937
|
* through it), or null. The meta-registration fence's test. */
|
|
940
|
-
|
|
938
|
+
function emitOverrideComparable(info) {
|
|
941
939
|
const above = emitOverrideAtOrAbove(info);
|
|
942
940
|
if (above)
|
|
943
941
|
return above;
|
|
@@ -949,12 +947,12 @@ export function emitOverrideComparable(info) {
|
|
|
949
947
|
* method on the class (vtable participation — the ABI is `(this, ...tuple)
|
|
950
948
|
* => bool` for every declarer of one event, override-exact by
|
|
951
949
|
* construction) and queues the body for the drive loop's fixpoint. */
|
|
952
|
-
|
|
950
|
+
function ensureEmitSpec(lowerer, info, event, tuple) {
|
|
953
951
|
const mName = `emit:${event}`;
|
|
954
952
|
const key = `%${info.def.name}.${mName}`;
|
|
955
|
-
if (
|
|
953
|
+
if (lowerer.emitSpecDone.has(key))
|
|
956
954
|
return;
|
|
957
|
-
|
|
955
|
+
lowerer.emitSpecDone.add(key);
|
|
958
956
|
if (!info.methods.has(mName)) {
|
|
959
957
|
info.methods.set(mName, { params: tuple.map((t) => ({ type: t, mode: "required" })), ret: BOOL });
|
|
960
958
|
if (info.def.methods)
|
|
@@ -962,56 +960,56 @@ export function ensureEmitSpec(L, info, event, tuple) {
|
|
|
962
960
|
else
|
|
963
961
|
info.def.methods = [mName];
|
|
964
962
|
}
|
|
965
|
-
const ordinal =
|
|
966
|
-
|
|
963
|
+
const ordinal = lowerer.emitSpecQueue.filter((q) => q.info === info).length;
|
|
964
|
+
lowerer.emitSpecQueue.push({ info, event, tuple, ordinal });
|
|
967
965
|
}
|
|
968
966
|
/** One specialization body: the override method's statements lowered with
|
|
969
967
|
* `event` bound to the name and hidden tuple parameters standing in for
|
|
970
968
|
* the rest parameter (readable ONLY through the super-forward, which the
|
|
971
969
|
* collection shape check guaranteed). */
|
|
972
|
-
export function lowerEmitOverrideSpec(
|
|
970
|
+
export function lowerEmitOverrideSpec(lowerer, req) {
|
|
973
971
|
const { info, event, tuple, ordinal } = req;
|
|
974
972
|
const ov = info.emitOverride;
|
|
975
973
|
if (!ov?.decl.body)
|
|
976
974
|
return null;
|
|
977
975
|
const className = info.def.name;
|
|
978
976
|
const thisType = { kind: "object", className };
|
|
979
|
-
const prevClass =
|
|
980
|
-
const prevSpec =
|
|
981
|
-
const prevSuppress =
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
977
|
+
const prevClass = lowerer.currentClass;
|
|
978
|
+
const prevSpec = lowerer.emitSpecCtx;
|
|
979
|
+
const prevSuppress = lowerer.suppressStats;
|
|
980
|
+
lowerer.currentClass = info;
|
|
981
|
+
lowerer.suppressStats = prevSuppress || ordinal > 0;
|
|
982
|
+
lowerer.fnStack.push(newFnCtx(false, null, null, BOOL));
|
|
985
983
|
try {
|
|
986
984
|
const loc = locOf(ov.decl);
|
|
987
|
-
const thisLocal =
|
|
985
|
+
const thisLocal = lowerer.declareThis(thisType);
|
|
988
986
|
const params = [{ localId: thisLocal.id, name: "this", type: thisType }];
|
|
989
987
|
const tupleParams = tuple.map((t, i) => {
|
|
990
|
-
const p =
|
|
988
|
+
const p = lowerer.declareHiddenLocal(`%ee${i}`, t);
|
|
991
989
|
params.push({ localId: p.id, name: `%ee${i}`, type: t });
|
|
992
990
|
return p;
|
|
993
991
|
});
|
|
994
992
|
const eventDecl = ov.decl.parameters[0];
|
|
995
|
-
const eventLocal =
|
|
993
|
+
const eventLocal = lowerer.declareLocal(eventDecl.name, ts.isIdentifier(eventDecl.name) ? eventDecl.name.text : "event", STRING, true);
|
|
996
994
|
const prologue = [
|
|
997
995
|
{ kind: "varDecl", localId: eventLocal.id, init: strLit(event, loc), loc },
|
|
998
996
|
];
|
|
999
|
-
|
|
1000
|
-
const body = [...prologue, ...
|
|
997
|
+
lowerer.emitSpecCtx = { info, event, tuple, eventSym: ov.eventSym, restSym: ov.restSym, tupleParams };
|
|
998
|
+
const body = [...prologue, ...lowerer.lowerStmts(ov.decl.body.statements)];
|
|
1001
999
|
return {
|
|
1002
1000
|
name: `%${className}.emit:${event}`,
|
|
1003
1001
|
params,
|
|
1004
1002
|
returnType: BOOL,
|
|
1005
|
-
locals:
|
|
1003
|
+
locals: lowerer.ctx.locals,
|
|
1006
1004
|
body,
|
|
1007
1005
|
loc,
|
|
1008
1006
|
};
|
|
1009
1007
|
}
|
|
1010
1008
|
finally {
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1009
|
+
lowerer.emitSpecCtx = prevSpec;
|
|
1010
|
+
lowerer.fnStack.pop();
|
|
1011
|
+
lowerer.currentClass = prevClass;
|
|
1012
|
+
lowerer.suppressStats = prevSuppress;
|
|
1015
1013
|
}
|
|
1016
1014
|
}
|
|
1017
1015
|
/** The specialization body's `super.emit(event, ...args)` — matched
|
|
@@ -1020,30 +1018,30 @@ export function lowerEmitOverrideSpec(L, req) {
|
|
|
1020
1018
|
* override ancestor's specialization (JS's super chain) or the runtime
|
|
1021
1019
|
* emit. Null when the call is not the forward (a literal-name super.emit
|
|
1022
1020
|
* rides the general super-emitter route). */
|
|
1023
|
-
export function emitSpecSuperForward(
|
|
1024
|
-
const ctx =
|
|
1021
|
+
export function emitSpecSuperForward(lowerer, call, access) {
|
|
1022
|
+
const ctx = lowerer.emitSpecCtx;
|
|
1025
1023
|
if (!ctx || access.name.text !== "emit" || call.arguments.length !== 2)
|
|
1026
1024
|
return null;
|
|
1027
1025
|
const a0 = call.arguments[0];
|
|
1028
1026
|
const a1 = call.arguments[1];
|
|
1029
1027
|
if (!ts.isIdentifier(a0) || !ts.isSpreadElement(a1) || !ts.isIdentifier(a1.expression))
|
|
1030
1028
|
return null;
|
|
1031
|
-
if (
|
|
1029
|
+
if (lowerer.checker.getSymbolAtLocation(a0) !== ctx.eventSym)
|
|
1032
1030
|
return null;
|
|
1033
|
-
if (
|
|
1031
|
+
if (lowerer.checker.getSymbolAtLocation(a1.expression) !== ctx.restSym)
|
|
1034
1032
|
return null;
|
|
1035
1033
|
const loc = locOf(call);
|
|
1036
|
-
const thisLocal =
|
|
1034
|
+
const thisLocal = lowerer.resolveThis();
|
|
1037
1035
|
if (!thisLocal)
|
|
1038
1036
|
return null;
|
|
1039
1037
|
const thisRef = { kind: "varRef", localId: thisLocal.id, type: thisLocal.type, loc };
|
|
1040
1038
|
const payload = ctx.tupleParams.map((p) => ({ kind: "varRef", localId: p.id, type: p.type, loc }));
|
|
1041
1039
|
const anc = emitOverrideAtOrAbove(ctx.info.base);
|
|
1042
1040
|
if (anc) {
|
|
1043
|
-
ensureEmitSpec(
|
|
1041
|
+
ensureEmitSpec(lowerer, anc, ctx.event, ctx.tuple);
|
|
1044
1042
|
const callee = `%${anc.def.name}.emit:${ctx.event}`;
|
|
1045
|
-
|
|
1046
|
-
return { kind: "call", callee, args: [
|
|
1043
|
+
lowerer.noteEdge(callee);
|
|
1044
|
+
return { kind: "call", callee, args: [lowerer.upcastTo(thisRef, anc.def.name), ...payload], type: BOOL, loc };
|
|
1047
1045
|
}
|
|
1048
1046
|
if (ctx.event === "error") {
|
|
1049
1047
|
return { kind: "libCall", fn: "emitter.emitError", args: [thisRef, strLit(ctx.event, loc), payload[0]], type: BOOL, loc };
|
|
@@ -1054,20 +1052,20 @@ export function emitSpecSuperForward(L, call, access) {
|
|
|
1054
1052
|
* with the current method's `this` as the receiver and STATIC dispatch
|
|
1055
1053
|
* (an emit override at-or-below the lexical class never answers a super
|
|
1056
1054
|
* call — JS's prototype-chain rule). */
|
|
1057
|
-
export function lowerEmitterSuperCall(
|
|
1058
|
-
const thisLocal =
|
|
1055
|
+
export function lowerEmitterSuperCall(lowerer, call, access, cls) {
|
|
1056
|
+
const thisLocal = lowerer.resolveThis();
|
|
1059
1057
|
if (!thisLocal)
|
|
1060
1058
|
return null;
|
|
1061
1059
|
const loc = locOf(call);
|
|
1062
1060
|
const thisRef = { kind: "varRef", localId: thisLocal.id, type: thisLocal.type, loc };
|
|
1063
|
-
return lowerEmitterMethodCall(
|
|
1061
|
+
return lowerEmitterMethodCall(lowerer, call, access, cls, { thisRef, cls });
|
|
1064
1062
|
}
|
|
1065
1063
|
/** One emit site's dispatch: the plain runtime libCall when no override
|
|
1066
1064
|
* is comparable to the receiver's static class; a direct or virtual
|
|
1067
1065
|
* specialization call when an override sits at-or-above it; an interned
|
|
1068
1066
|
* instanceOf-branch helper when overrides exist only strictly below
|
|
1069
1067
|
* (evaluating receiver and payload exactly once as its arguments). */
|
|
1070
|
-
function emitDispatchExpr(
|
|
1068
|
+
function emitDispatchExpr(lowerer, info, name, tuple, receiver, payload, superOf, loc) {
|
|
1071
1069
|
const method = `emit:${name}`;
|
|
1072
1070
|
const runtime = (recv, args) => name === "error"
|
|
1073
1071
|
? { kind: "libCall", fn: "emitter.emitError", args: [recv, strLit(name, loc), args[0]], type: BOOL, loc }
|
|
@@ -1077,10 +1075,10 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
|
|
|
1077
1075
|
const anc = emitOverrideAtOrAbove(superOf.base);
|
|
1078
1076
|
if (!anc)
|
|
1079
1077
|
return runtime(receiver, payload);
|
|
1080
|
-
ensureEmitSpec(
|
|
1078
|
+
ensureEmitSpec(lowerer, anc, name, tuple);
|
|
1081
1079
|
const callee = `%${anc.def.name}.${method}`;
|
|
1082
|
-
|
|
1083
|
-
return { kind: "call", callee, args: [
|
|
1080
|
+
lowerer.noteEdge(callee);
|
|
1081
|
+
return { kind: "call", callee, args: [lowerer.upcastTo(receiver, anc.def.name), ...payload], type: BOOL, loc };
|
|
1084
1082
|
}
|
|
1085
1083
|
const above = emitOverrideAtOrAbove(info);
|
|
1086
1084
|
const below = [];
|
|
@@ -1091,25 +1089,25 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
|
|
|
1091
1089
|
// gets the event's specialization (descendants intercept via the vtable;
|
|
1092
1090
|
// the super-forward chain above `above` is ensured as each body lowers).
|
|
1093
1091
|
if (above)
|
|
1094
|
-
ensureEmitSpec(
|
|
1092
|
+
ensureEmitSpec(lowerer, above, name, tuple);
|
|
1095
1093
|
for (const c of below)
|
|
1096
|
-
ensureEmitSpec(
|
|
1094
|
+
ensureEmitSpec(lowerer, c, name, tuple);
|
|
1097
1095
|
if (above) {
|
|
1098
1096
|
if (below.length > 0) {
|
|
1099
|
-
|
|
1097
|
+
lowerer.noteVirtualEdge(info, method);
|
|
1100
1098
|
return { kind: "virtualCall", className: info.def.name, method, args: [receiver, ...payload], type: BOOL, loc };
|
|
1101
1099
|
}
|
|
1102
1100
|
const callee = `%${above.def.name}.${method}`;
|
|
1103
|
-
|
|
1104
|
-
return { kind: "call", callee, args: [
|
|
1101
|
+
lowerer.noteEdge(callee);
|
|
1102
|
+
return { kind: "call", callee, args: [lowerer.upcastTo(receiver, above.def.name), ...payload], type: BOOL, loc };
|
|
1105
1103
|
}
|
|
1106
1104
|
// Overrides only strictly below: the interned dispatch helper.
|
|
1107
1105
|
const recvT = receiver.type;
|
|
1108
1106
|
const key = `emitter.emitDispatch:${typeKey(recvT)}:${name}`;
|
|
1109
|
-
let helper =
|
|
1107
|
+
let helper = lowerer.arrHofHelpers.get(key);
|
|
1110
1108
|
if (!helper) {
|
|
1111
|
-
helper = `%emitter.emitDispatch.${
|
|
1112
|
-
|
|
1109
|
+
helper = `%emitter.emitDispatch.${lowerer.arrHofHelpers.size}`;
|
|
1110
|
+
lowerer.arrHofHelpers.set(key, helper);
|
|
1113
1111
|
const params = [
|
|
1114
1112
|
{ localId: "r.0", name: "r", type: recvT },
|
|
1115
1113
|
...tuple.map((t, i) => ({ localId: `a${i}.0`, name: `a${i}`, type: t })),
|
|
@@ -1125,12 +1123,12 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
|
|
|
1125
1123
|
collectEmitOverridesBelow(o, oBelow);
|
|
1126
1124
|
let target;
|
|
1127
1125
|
if (oBelow.length > 0) {
|
|
1128
|
-
|
|
1126
|
+
lowerer.noteVirtualEdge(o, method);
|
|
1129
1127
|
target = { kind: "virtualCall", className: o.def.name, method, args: [down, ...argRefs()], type: BOOL, loc };
|
|
1130
1128
|
}
|
|
1131
1129
|
else {
|
|
1132
1130
|
const callee = `%${o.def.name}.${method}`;
|
|
1133
|
-
|
|
1131
|
+
lowerer.noteEdge(callee);
|
|
1134
1132
|
target = { kind: "call", callee, args: [down, ...argRefs()], type: BOOL, loc };
|
|
1135
1133
|
}
|
|
1136
1134
|
body.push({
|
|
@@ -1142,8 +1140,8 @@ function emitDispatchExpr(L, info, name, tuple, receiver, payload, superOf, loc)
|
|
|
1142
1140
|
});
|
|
1143
1141
|
}
|
|
1144
1142
|
body.push({ kind: "return", value: runtime(rRef(), argRefs()), loc });
|
|
1145
|
-
|
|
1143
|
+
lowerer.liftedFns.push({ name: helper, params, returnType: BOOL, locals, body, loc });
|
|
1146
1144
|
}
|
|
1147
1145
|
return { kind: "call", callee: helper, args: [receiver, ...payload], type: BOOL, loc };
|
|
1148
1146
|
}
|
|
1149
|
-
//# sourceMappingURL=lower-emitter.js.map
|
|
1147
|
+
//# sourceMappingURL=lower-event-emitter.js.map
|