MCPcopy Index your code
hub / github.com/evalplus/evalplus / FunctorTransformer

Class FunctorTransformer

tools/collect_valid_solutions.py:60–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 changed = False
59
60 class FunctorTransformer(ast.NodeTransformer):
61 def __init__(self, target_functors):
62 super().__init__()
63 self.target_functors = target_functors
64
65 # visit func def
66 def visit_FunctionDef(self, node: ast.FunctionDef):
67 if skip_main_fn and node.name == "main":
68 return node
69 # visit child nodes
70 return self.generic_visit(node)
71
72 def visit_Call(self, node):
73 if isinstance(node.func, ast.Name) and node.func.id in self.target_functors:
74 nonlocal changed
75 changed = True
76 return ast.Expr(value=ast.Constant(value=None))
77 return node
78
79 tree = ast.parse(source)
80 code = astor.to_source(FunctorTransformer(functors).visit(tree))

Callers 1

void_callsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected