php-cfg icon indicating copy to clipboard operation
php-cfg copied to clipboard

Protobuf printer refactor

Open eric-therond opened this issue 3 months ago • 3 comments

Added a protobuf printer. To do this, I had to slightly modify the base printer class and renderers:

  • Everything specific to a "format" is now handled by the child classes. Rendering methods return a "low level structure" and it's up to the child class to format it according to the printer type. For instance, in renderer/Operand/Temporary.php, we previously returned an id prefixed with #, this kind of transformation in now performed in Printer/Text.php.
  • A bit out by laziness, but it's maybe not a bad thing, most of the op are rendered in a similar way. In the past, we had specific style for Phi, Assertion or AttributesGroup, with this PR, we have the same style of rendering. That's why you'll see diff in code tests related to these ops. We lose a bit of readability for Text printer but I think we have a more generic rendering, and it could be ok?
  • I don't know exactly how to test this new protobuf printer class, I didn't want to duplicate all the "code tests" (but maybe we should?) so I took only two test code files for the moment.

eric-therond avatar Oct 26 '25 12:10 eric-therond