From da1f44caff8efe481d00e5229f37b798aeb4aebc Mon Sep 17 00:00:00 2001 From: caandt Date: Fri, 25 Jul 2025 16:26:03 -0500 Subject: [PATCH] format --- .../control_flow_reconstruction/templates/Block.py | 14 +++++++++----- .../templates/Exception.py | 2 +- .../control_flow_reconstruction/templates/Loop.py | 2 +- test/Conditional.py | 10 ++++++---- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pylingual/control_flow_reconstruction/templates/Block.py b/pylingual/control_flow_reconstruction/templates/Block.py index 0398879..1788a43 100644 --- a/pylingual/control_flow_reconstruction/templates/Block.py +++ b/pylingual/control_flow_reconstruction/templates/Block.py @@ -58,14 +58,17 @@ class RemoveUnreachable(ControlFlowTemplate): class JumpTemplate(ControlFlowTemplate): template = T( body=~N("jump", None).with_cond(without_instructions("CLEANUP_THROW")), - jump=N("tail", "block?").with_in_deg(1).with_cond( + jump=N("tail", "block?") + .with_in_deg(1) + .with_cond( exact_instructions("JUMP_BACKWARD_NO_INTERRUPT"), - exact_instructions("POP_JUMP_IF_TRUE"), + exact_instructions("POP_JUMP_IF_TRUE"), exact_instructions("JUMP_FORWARD"), exact_instructions("JUMP_BACKWARD"), - exact_instructions("POP_JUMP_IF_NOT_NONE"), - exact_instructions("POP_JUMP_IF_NONE"), - exact_instructions("POP_JUMP_IF_FALSE")), + exact_instructions("POP_JUMP_IF_NOT_NONE"), + exact_instructions("POP_JUMP_IF_NONE"), + exact_instructions("POP_JUMP_IF_FALSE"), + ), block=N.tail(), tail=N.tail(), ) @@ -81,6 +84,7 @@ class JumpTemplate(ControlFlowTemplate): to_indented_source = defer_source_to("body") + @register_template(0, 0, *versions_from(3, 11)) class NopTemplate(ControlFlowTemplate): template = T( diff --git a/pylingual/control_flow_reconstruction/templates/Exception.py b/pylingual/control_flow_reconstruction/templates/Exception.py index 1956553..7aa5619 100644 --- a/pylingual/control_flow_reconstruction/templates/Exception.py +++ b/pylingual/control_flow_reconstruction/templates/Exception.py @@ -107,7 +107,7 @@ class TryElse3_12(ControlFlowTemplate): else: {try_else} """ - + @register_template(0, 0, (3, 11)) class Try3_11(ControlFlowTemplate): diff --git a/pylingual/control_flow_reconstruction/templates/Loop.py b/pylingual/control_flow_reconstruction/templates/Loop.py index 3faeca4..fbdf78c 100644 --- a/pylingual/control_flow_reconstruction/templates/Loop.py +++ b/pylingual/control_flow_reconstruction/templates/Loop.py @@ -160,7 +160,7 @@ class FixLoop(ControlFlowTemplate): if cfg.get_edge_data(candidate_end, ss).get("kind") != EdgeKind.Exception: candidate_end = ss break - + if encompassed_nodes is not None: for succ in encompassed_nodes: if cfg.get_edge_data(succ, candidate_end) != None: diff --git a/test/Conditional.py b/test/Conditional.py index 1362445..03394cc 100644 --- a/test/Conditional.py +++ b/test/Conditional.py @@ -306,18 +306,20 @@ def f_nofallthru_if_pass(): def g1_ifElseLoop(): for a in range(3): - if a> b: + if a > b: print(1) - + + def g2_ifElseLoop(): for a in range(3): - if a> b: + if a > b: print(1) print(2) + def g3_ifElseLoop(): for a in range(3): - if a> b: + if a > b: print(1) else: print(2)