From ee1af8903de739e76d2323b210f1858512a50380 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:49:37 -0500 Subject: [PATCH 1/2] Fix missing `ast.Name(ctx=...)` --- numba_rvsdg/core/datastructures/ast_transforms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/numba_rvsdg/core/datastructures/ast_transforms.py b/numba_rvsdg/core/datastructures/ast_transforms.py index f5fd1c4..f158b2e 100644 --- a/numba_rvsdg/core/datastructures/ast_transforms.py +++ b/numba_rvsdg/core/datastructures/ast_transforms.py @@ -770,12 +770,12 @@ def codegen_view() -> list[Any]: # update __scfg_loop_continue__. rval = [ ast.Assign( - [ast.Name("__scfg_loop_cont__")], + [ast.Name("__scfg_loop_cont__", ctx=ast.Store())], ast.Constant(True), lineno=0, ), ast.While( - test=ast.Name("__scfg_loop_cont__"), + test=ast.Name("__scfg_loop_cont__", ctx=ast.Load()), body=codegen_view(), orelse=[], ), @@ -788,7 +788,7 @@ def codegen_view() -> list[Any]: # Synthetic assignments just create Python assignments, one for # each variable.. return [ - ast.Assign([ast.Name(t)], ast.Constant(v), lineno=0) + ast.Assign([ast.Name(t, ctx=ast.Store())], ast.Constant(v), lineno=0) for t, v in block.variable_assignment.items() ] elif type(block) is SyntheticTail: @@ -801,7 +801,7 @@ def codegen_view() -> list[Any]: elif type(block) is SyntheticReturn: # Synthetic return blocks must re-assigne the return value to a # special reserved variable. - return [ast.Return(ast.Name("__scfg_return_value__"))] + return [ast.Return(ast.Name("__scfg_return_value__", ctx=ast.Load()))] elif type(block) is SyntheticExitingLatch: # The synthetic exiting latch simply assigns the negated value of # the exit variable to '__scfg_loop_cont__'. @@ -809,8 +809,8 @@ def codegen_view() -> list[Any]: assert len(block.backedges) == 1 return [ ast.Assign( - [ast.Name("__scfg_loop_cont__")], - ast.UnaryOp(ast.Not(), ast.Name(block.variable)), + [ast.Name("__scfg_loop_cont__", ctx=ast.Store())], + ast.UnaryOp(ast.Not(), ast.Name(block.variable, ctx=ast.Load())), lineno=0, ) ] @@ -844,7 +844,7 @@ def if_cascade( # compare to all variable values that point to this # jump_target if_test = ast.Compare( - left=ast.Name(block.variable), + left=ast.Name(block.variable, ctx=ast.Load()), ops=[ast.In()], comparators=[ ast.Tuple( From 5f6792bb23bb9a72a51c5fe3669b785c3a0530c1 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam <1929845+sklam@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:56:48 -0500 Subject: [PATCH 2/2] Black --- numba_rvsdg/core/datastructures/ast_transforms.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/numba_rvsdg/core/datastructures/ast_transforms.py b/numba_rvsdg/core/datastructures/ast_transforms.py index f158b2e..7036623 100644 --- a/numba_rvsdg/core/datastructures/ast_transforms.py +++ b/numba_rvsdg/core/datastructures/ast_transforms.py @@ -788,7 +788,9 @@ def codegen_view() -> list[Any]: # Synthetic assignments just create Python assignments, one for # each variable.. return [ - ast.Assign([ast.Name(t, ctx=ast.Store())], ast.Constant(v), lineno=0) + ast.Assign( + [ast.Name(t, ctx=ast.Store())], ast.Constant(v), lineno=0 + ) for t, v in block.variable_assignment.items() ] elif type(block) is SyntheticTail: @@ -801,7 +803,9 @@ def codegen_view() -> list[Any]: elif type(block) is SyntheticReturn: # Synthetic return blocks must re-assigne the return value to a # special reserved variable. - return [ast.Return(ast.Name("__scfg_return_value__", ctx=ast.Load()))] + return [ + ast.Return(ast.Name("__scfg_return_value__", ctx=ast.Load())) + ] elif type(block) is SyntheticExitingLatch: # The synthetic exiting latch simply assigns the negated value of # the exit variable to '__scfg_loop_cont__'. @@ -810,7 +814,9 @@ def codegen_view() -> list[Any]: return [ ast.Assign( [ast.Name("__scfg_loop_cont__", ctx=ast.Store())], - ast.UnaryOp(ast.Not(), ast.Name(block.variable, ctx=ast.Load())), + ast.UnaryOp( + ast.Not(), ast.Name(block.variable, ctx=ast.Load()) + ), lineno=0, ) ]