Revise and generalize for Python 3.6+ instructions vs < 3.6 instuctions.
Used more of the generalized methods in xdis and remove some (but not
all) of the magic numbers.
This is a lot of changes, but not all of the refactoring needed. Much
crap still remains. Also, there are still bugs in handling 3.6 bytecodes.
Start adding COME_FROMs for POP_EXCEPT in preparation for
getting tryelse blocks correct.
Simpler opname access functions:
- self.op_name(op) is self.opc.opname[op]
- self.op_name_from_offset(offset) is self.opc.opname[self.code[offset]]
verify.py: not all offsets are ints
Wasn't limiting exception clause to try finally. Probably still has bugs
in try-finally nesting
Add another 2.6/2.7 COME_FROM to try to limit if/end scope better
scanner26.py: make scanner2.py and scanner26.py more alike
scanner2.py: check that return stmt is last in list. (May change)
main.py: show filename on verify error
test/*: add more
Add debug flag to find_jump_targets to show the structure we found.
When there are control-flow bugs, it's often reflected here.
scanner3.py: make code make more similar to 2.x code
- Use xdis 3.0.0 protocol load_module. Needs bump in requirements.txt
and _pkg_info_.py
- Start Python 1.5 decompiling - another round of work is needed to remove
bugs
- small cleanups
As part of tokenization for (de)parsing, we need to do something like a
disassembly, but is is really a little different.
Disassembly, strictly speaking, is done by the xdis module now.
What "ingestion" does is massage the instruction tokens to a form that is
more amenable for parsing.
In sum, ingestion is different than disassembly, although disassembly is
generally the first part of ingestion.
If 2.6 or before POP_BLOCK after a JUMP_IF_FALSE does not
constitute a new statement. The POP_BLOCK is really part
of the JUMP_IF_FALSE. In Python 2.7+ it's a single op.
scanner3.py: bug in 3.x detecting "if" structure
Make scanner2.py look more like scanner3.py
verify.py: add weak-verify which tests Pytyon syntax, but not code