Codegen: engine setup seam + consistent _block_key#313
Merged
Conversation
…sistently in the node-id map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related codegen cleanups, no behaviour change for the default (pathsim) build.
1. Engine codegen seam. New
engineCodegen.tsexportsgenerateEngineSetup(importGroups), returningnullby default (no extra code).pathsimRunner.tscalls it right after the imports in both the runtime and the export generators; when non-null it emits a# <header>section (banner on export) with the engine's setup lines. This is the codegen counterpart to the worker-sideengineInstallseam: an alternate engine can inject setup (e.g. class-levelport()wraps for toolbox blocks) without forking the shared codegen.2. Consistent block identity. The generated
_node_id_mapkeyed on rawid(var), while_apply_mutations(dynamic add/remove) and the scope/spectrum extraction already key on_block_key(...)._block_keyreturns a stableblock_idwhen the engine exposes one and falls back toid()otherwise — so for pathsim this is identical, but it removes the static/dynamic inconsistency (a latent bug for any engine whereid()isn't stable across wrappers).svelte-check: 0 errors/0 warnings.