Visitor that handles both statements and expressions
| 168 | |
| 169 | @tirx.functor.visitor |
| 170 | class SimpleStmtExprVisitor(PyStmtExprVisitor): |
| 171 | """Visitor that handles both statements and expressions""" |
| 172 | |
| 173 | def __init__(self): |
| 174 | super().__init__() |
| 175 | self.expr_count = 0 |
| 176 | self.stmt_count = 0 |
| 177 | self.var_names = set() |
| 178 | |
| 179 | def visit_var_(self, op: Var): |
| 180 | self.var_names.add(op.name) |
| 181 | self.expr_count += 1 |
| 182 | |
| 183 | def visit_evaluate_(self, op: Evaluate): |
| 184 | self.stmt_count += 1 |
| 185 | # Visit the expression |
| 186 | self.visit_expr(op.value) |
| 187 | |
| 188 | |
| 189 | @tirx.functor.mutator |
no outgoing calls
searching dependent graphs…