Commit Graph

134 Commits

Author SHA1 Message Date
rocky
9e815d8d79 2.6 and before COME_FROM handling...
also, add in some of the test bytecode from the python-2.4 branch
2018-03-04 21:42:59 -05:00
rocky
26e1df835c Better "continue" detection for 2.7 2018-03-01 23:34:26 -05:00
rocky
e23315b2e6 Fallout from more precise token attributes 2018-02-28 23:35:52 -05:00
rocky
c43c9a19aa Move to GPL3 license 2018-02-27 06:40:36 -05:00
rocky
8c0f256b78 Sync python2 and python3 scanner/injest code more 2018-02-25 09:42:04 -05:00
rocky
67ad08fd4a Beter 2.7 end_if and COME_FROM determination
Fixes #149

... Add more tests too
2018-02-17 07:16:14 -05:00
rocky
50e9a9102b One more change to revert 2018-02-04 17:02:58 -05:00
rocky
a8051f049f Revert most of last change 2018-02-04 15:08:23 -05:00
rocky
4cbba3d46e 2.7 control flow futzing.
Some overall cleanup. But again we need to attack all of this more head on.

Closes Issue #149
2018-02-04 14:20:11 -05:00
rocky
296fcd89ce Add self.offset2inst_index and document more 2018-02-04 09:13:49 -05:00
rocky
106a325ef1 Fix Python 2.7 try: try: else: bug 2018-01-29 08:47:53 -05:00
rocky
185ec4e306 Fix 2.6 IF/THEN misclassification..
with an exception condition
2018-01-13 00:58:16 -05:00
rocky
b0d18cae6a Fix bug in 2.5- try/else inside ifelsestmt 2018-01-06 22:19:44 -05:00
rocky
15057bed1d Fix bugs in scanner.last_instr()...
And ave instruction stream self.insts like we do in Python 3 so we
can start simplifying code.
2017-12-15 20:34:34 -05:00
rocky
3ce5e0ab0e Update comment 2017-12-14 05:22:59 -05:00
rocky
63820c4300 Continue parse2/scanner2 refactor 2017-12-14 04:00:22 -05:00
rocky
94a18c1a95 Back off of previous refactor a little bit 2017-12-13 21:26:52 -05:00
rocky
303e134359 Simplify scanner2 so it relies less on custimize dict 2017-12-13 21:02:40 -05:00
rocky
acc3e441ac Fix "or" bug in 2.6- seen via chained comparisons 2017-12-13 07:27:10 -05:00
rocky
32f3d947bb Grammar "COME_FROM"_from cleanups ...
tryelse constructs in 2.x fixed up
_come_from -> _come_froms (COME_FROM*)
consolidate come_froms rule into sincle parser.py
2017-12-03 05:10:59 -05:00
rocky
93949e8222 Small grammar isolation bugs 2017-12-02 10:57:32 -05:00
rocky
5872caee54 Correct hacky version number 2017-12-02 09:53:05 -05:00
rocky
a7005f6a77 2.7 exec stmt grammar rule isolation/reduction 2017-12-02 09:23:18 -05:00
rocky
6d0f72f13b Fix bug in 2.6 tryelse get test_grammar working...
localize grammar rules
2017-12-02 01:35:43 -05:00
rocky
bf5a6237d8 Isolate listcomp rule in 2.7 2017-11-30 10:30:08 -05:00
rocky
2674ec893a Grammar reduction 2017-11-27 04:56:01 -05:00
rocky
17f5b35b1d More grammar isolation 2017-11-26 16:34:10 -05:00
rocky
b7003914c9 localize 2 and 3 argument BUILD_SLICE...
Nontermninal name matches AST anme now. Add test.
2017-11-25 21:10:11 -05:00
rocky
902941102f 2.7 continue-detection bug 2017-11-16 00:22:24 -05:00
rocky
dea17cd7f1 xdis _disassemble->disassemble 2017-11-06 00:38:22 -05:00
rocky
5df09540b5 Python 3.6-inspired instruction size cleanup
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.
2017-10-29 11:46:28 -04:00
rocky
1d7a3c6444 Document hacky customize arg count better. 2017-09-30 18:02:35 -04:00
rocky
d138a01bf1 xdis's "exception match" is now "exception-match" 2017-07-17 22:42:57 -04:00
rocky
27ab6fe2f5 Use xdis 3.5.0's opcode sets 2017-07-08 20:41:46 -04:00
rocky
0893652943 Work around not having real flow-control analysis 2017-06-29 20:49:01 -04:00
rocky
6efd7afda3 continue non-detection in Python 2.7
fixes issue 122
2017-06-29 20:27:07 -04:00
rocky
af3d46b35c Use xdis' instruction offset calculation fns..
next_offset, op_size, has_argument
2017-06-24 06:43:04 -04:00
rocky
c7f8edd5ef Simplify access to L65536 ...
and fix use in scanner26.py. Thanks to AnythingTechPro
2017-06-09 18:22:02 -04:00
rocky
160ec0d9cc COME_FROM for 3.x POP_EXCEPT, DRY with op_name() ...
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
2017-03-01 05:50:31 -05:00
rocky
1cb2cd7a82 More 2.6, 2.7 control flow
Todo more COME_FROMs but now need to check targets better. In some cases
we're relying on grammar ambiguity to work out right and in 2.7 it doesn't
2017-01-24 01:21:28 -05:00
rocky
9ec312ba5e More 2.6, 2.7 control-flow bugs
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
2017-01-24 00:53:30 -05:00
rocky
597d51951e Improve Python 2.6 & 2.7 verification 2017-01-23 02:32:09 -05:00
rocky
8dc23e2cdc Python 2.1 doesn't have FOR_ITER or GET_ITER...
adjust locgic for this fact
2017-01-15 09:50:38 -05:00
rocky
ec0669367f Towards better 3.0 decompilation
Sync scanner2 and scanner3 better
2017-01-08 17:40:57 -05:00
rocky
6f097ff1ca dectect_structure() -> detect_control_flow() 2016-12-29 07:32:36 -05:00
rocky
8eb1a16f5b DRY code and emitted Python 3 source
* Python 3: break; continue -> break
* Use variable in detect_structure for pre[rtarget]
* Make Python 2 and Python 3 detect_structure more alie
2016-12-29 07:28:37 -05:00
rocky
6c546fe6e1 WIP : Add THEN to disambigute from "and" 2016-12-27 22:45:08 -05:00
rocky
e3f4beeb74 Lint 2016-12-24 07:45:02 -05:00
rocky
e6761e13bb Python flake8 crap
Was testing realgud's C-x!8 (goto flake8 warning/error)
2016-12-18 20:18:19 -05:00
rocky
eebec48308 show-asm on python2.5 is optional
make scanner2 look a little more like scanner3
2016-12-17 08:01:25 -05:00