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 ...@@ -4,17 +4,15 @@ import ast
from transpiler.phases.emit_cpp import NodeVisitor from transpiler.phases.emit_cpp import NodeVisitor
class SearchVisitor(NodeVisitor): class SearchVisitor(ast.NodeVisitor):
def missing_impl(self, node): def generic_visit(self, node):
if not hasattr(node, "__dict__"): for field, value in ast.iter_fields(node):
return if isinstance(value, list):
for val in node.__dict__.values(): for item in value:
if isinstance(val, list): if isinstance(item, ast.AST):
for item in val:
if isinstance(val, ast.AST):
yield from self.visit(item) yield from self.visit(item)
elif isinstance(val, ast.AST): elif isinstance(value, ast.AST):
yield from self.visit(val) yield from self.visit(value)
def match(self, node) -> bool: def match(self, node) -> bool:
return next(self.visit(node), False) 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