mirror of
https://github.com/zrax/pycdc.git
synced 2026-06-23 11:34:07 +00:00
Python 3.11 compiles 'while cond:' with a bottom test: an entry guard (eval cond; POP_JUMP_FORWARD_IF_FALSE end) before the body, and a back-edge (eval cond; POP_JUMP_BACKWARD_IF_TRUE loop_start) at the end. pycdc rendered both halves as separate 'if' blocks, so EVERY while loop came out as 'if cond: ... if not cond: pass' and never looped. - New ScanWhileLoops pre-pass pairs each conditional backward jump with the forward guard immediately preceding its target (guard skipping to the instruction after the back-edge) to identify genuine while loops. - At the guard, open a BLK_WHILE with the condition instead of an if. - At the back-edge, discard the duplicated condition and close the loop, but only when a BLK_WHILE is actually open (guard against a misidentified back-edge collapsing the block stack and crashing). Fixes while loops across all files (including nested loops and continue). decompilation target: 237/239 files, corpus 41/95 (+1: signature; 0 regressions). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| ASTNode.cpp.o | ||
| ASTNode.cpp.o.d | ||
| ASTree.cpp.o | ||
| ASTree.cpp.o.d | ||
| build.make | ||
| cmake_clean.cmake | ||
| compiler_depend.internal | ||
| compiler_depend.make | ||
| compiler_depend.ts | ||
| depend.make | ||
| DependInfo.cmake | ||
| flags.make | ||
| link.txt | ||
| progress.make | ||
| pycdc.cpp.o | ||
| pycdc.cpp.o.d | ||