M5: extract render_compute_function to free functions; drop friend CodeEmitPass - #51
Merged
Conversation
This was referenced Jun 1, 2026
This was referenced Jun 3, 2026
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.
Addresses M5 from tracking issue #48 (multi-lens review of stack #44-#47).
What
Promotes the function-frame rendering helpers (`render_compute_function`, `param_decl`, `output_decl`, `tensor_arg_count`) from private members of `ConstitutiveModel` to free functions in a new `include/numsim_codegen/recipe_render.h`. Drops the `friend class CodeEmitPass;` declaration.
Why
The friend declaration was a one-way ratchet: every future emit pass (`TangentEmitPass`, `MoosePropertyEmitPass`, `StateVarEmitPass`, `AbaqusEmitPass`) would either need to be friended on `ConstitutiveModel` or route through `CodeEmitPass`. O(passes) friends on the user-facing recipe class.
The render helpers only needed `ConstitutiveModel`'s read-only public accessors (`name()`, `symbols()`, `outputs()`) — they never touched private state. Friend access was leakage from the original single-emitter monolith. Promoting to free functions is a pure refactor with no API change for users.
Why M5 first in the issue #48 sequence
Pure refactor, no API change, smallest blast radius. Unlocks M4 (`RecipeView` to decouple `PassContext` from raw `ConstitutiveModel`) by establishing the public-accessor-only contract that emit passes use.
Verification
Files
Sequence
Per #48 follow-up plan: M5 → M4 → M3 → M2 → M6, all stacked on `main`. Each will be a small focused PR with verification.