From 5343a269cfcfdfe412e1549e1605a93ca3d416de Mon Sep 17 00:00:00 2001 From: Xinlong Hu Date: Fri, 8 Aug 2025 15:36:01 -0500 Subject: [PATCH] Continue/Break distinctions --- pylingual/control_flow_reconstruction/templates/Loop.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylingual/control_flow_reconstruction/templates/Loop.py b/pylingual/control_flow_reconstruction/templates/Loop.py index 77358f3..21735a3 100644 --- a/pylingual/control_flow_reconstruction/templates/Loop.py +++ b/pylingual/control_flow_reconstruction/templates/Loop.py @@ -186,7 +186,7 @@ class BreakTemplate(ControlFlowTemplate): while i >= 0: instruction = node.get_instructions()[i].opname if instruction in {"POP_TOP", "LOAD_FAST", "LOAD_CONST", "RETURN_VALUE", "RETURN_CONST", "JUMP_ABSOLUTE", "JUMP_FORWARD", "JUMP_BACKWARD", "BREAK_LOOP", "POP_BLOCK"}: - if node.get_instructions()[i].starts_line is not None and node.get_instructions()[i].source_line not in {"pass", "...", "return"}: + if node.get_instructions()[i].starts_line is not None and not any(node.get_instructions()[i].source_line.strip().startswith(word) for word in {"pass", "...", "return"}): return condense_mapping(cls, cfg, {"child": node}, "child") else: i -= 1 @@ -209,7 +209,7 @@ class ContinueTemplate(ControlFlowTemplate): while i >= 0: instruction = node.get_instructions()[i].opname if instruction in {"JUMP_ABSOLUTE", "JUMP_BACKWARD", "CONTINUE_LOOP", "POP_EXCEPT", "POP_BLOCK"}: - if node.get_instructions()[i].starts_line is not None and node.get_instructions()[i].source_line not in {"pass", "...", "return"}: + if node.get_instructions()[i].starts_line is not None and not any(node.get_instructions()[i].source_line.strip().startswith(word) for word in {"pass", "...", "return"}): return condense_mapping(cls, cfg, {"child": node}, "child") else: i -= 1