Commit 6ee5d335 authored by Tom Niget's avatar Tom Niget

Fix SearchVisitor not properly visiting all nodes

parent c919c104
......@@ -4,17 +4,15 @@ import ast
from transpiler.phases.emit_cpp import NodeVisitor
class SearchVisitor(NodeVisitor):
def missing_impl(self, node):
if not hasattr(node, "__dict__"):
return
for val in node.__dict__.values():
if isinstance(val, list):
for item in val:
if isinstance(val, ast.AST):
class SearchVisitor(ast.NodeVisitor):
def generic_visit(self, node):
for field, value in ast.iter_fields(node):
if isinstance(value, list):
for item in value:
if isinstance(item, ast.AST):
yield from self.visit(item)
elif isinstance(val, ast.AST):
yield from self.visit(val)
elif isinstance(value, ast.AST):
yield from self.visit(value)
def match(self, node) -> bool:
return next(self.visit(node), False)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment