Protobuf printer refactor#114
Conversation
|
I will check later why CI is failing, I suspect something not working with |
|
@ircmaxell perhaps this protobuf printer shouldn't be part of the ircmaxell/php-cfg repository (I can create a new one on my side to host it (eric-therond/php-cfg-protobuf-printer for instance)), as it can be difficult to manage different types of printers in the same place. However, I think the other changes I've made are necessary to facilitate support for a wider variety of printers. What do you think? |
|
I updated the protobuf schema, nothing important, I try to find the more efficient one. Something more important, boolean and null literals were not generated correctly due to a bug in constfetch parsing, I think I have fixed that. |
remove protobuf from repository
| public ?Block $defaultBlock; | ||
|
|
||
| public ?Operand $defaultVar; | ||
| public ?Operand $defaultVar = null; |
There was a problem hiding this comment.
bug fix not related to printer
| { | ||
| public function handleExpr(Node\Expr $expr): Operand | ||
| { | ||
| if ($expr->name->isUnqualified()) { |
There was a problem hiding this comment.
bug fix not related to printer
|
@ircmaxell Following my previous comment, I have removed protobuf from this merge request. A dedicated repository is now available: https://github.com/eric-therond/php-cfg-protobuf-printer The remaining changes are needed to create a more generic printer on which we can plug various subprinters (like the protobuf one) Your help would be greatly appreciated! |
Added a protobuf printer. To do this, I had to slightly modify the base printer class and renderers:
renderer/Operand/Temporary.php, we previously returned anidprefixed with#, this kind of transformation in now performed inPrinter/Text.php.opare rendered in a similar way. In the past, we had specific style forPhi,AssertionorAttributesGroup, with this PR, we have the same style of rendering. That's why you'll see diff in code tests related to theseops. We lose a bit of readability for Text printer but I think we have a more generic rendering, and it could be ok?