Skip to content

[NFC] Split responsibilities of Mapper - #434

Open
lucic71 wants to merge 8 commits into
Cpp2Rust:masterfrom
lucic71:split-mapper
Open

lucic71 wants to merge 8 commits into
Cpp2Rust:masterfrom
lucic71:split-mapper

Conversation

@lucic71

@lucic71 lucic71 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Mapper grew too big. It has 4 responsibilities at the same time:

  1. Map expressions or types to a rust string
  2. Match expressions or types against translation rules
  3. Answer queries about the translation rules (ParamIsPointer, IsLibcPassthrough, etc)
  4. Print string representation of expressions or types

Only the first should be in Mapper, the rest should be split.

For (2) I plan to add a new tree matcher instead of the current string matcher. To make the transition smooth I extracted the matching logic form Mapper into cpp2rust/converter/rules/matcher.h.

For (3) I added cpp2rust/converter/rules/registry.h which keeps the exprs_ and rules_ multimaps + handles queries about the translation rules.

For (4) I added cpp2rust/converter/printer.h which should BTW disappear after we switch to tree matching instead of string matching.

This is a building block for fixing #435

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant