Open rocky opened 7 years ago
I have now done this in a hacky way in commit 449d74af5116aaaf59065c2600c1a5b017b041be and f8a40c1949dc1071cc27c26e19192cd4ca7a03a0 . We should have a more formal rewrite phase after tree generation and before text generation proper.
In Python 3 with jump optimization, uncomplyle6 often adds "continue" statements where it is not needed or where "pass" statements were probably used. https://github.com/rocky/python-uncompyle6/blob/master/test/simple_source/looping/12_if_while_true_pass.py is a good example.
We can probably use line number information to disambiguate. Often these instructions are
JUMP_ABSOLUTE
. If the offset that these appear at are at a line boundary then probably the source hadcontinue
, otherwisepass
, when a statement is needed, and nothing otherwise.We'll probably have to wait until we have a separate control flow pass for this.