google / tangent

Source-to-Source Debuggable Derivatives in Pure Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How are CFG.visit_Break and CFG.visit_Continue get called?

wangkuiyi opened this issue · comments

Hello Tangent Authors,

I got a question as the title of this issue.

I see that class CFG is a subclass of gast.NodeVisitor and it has some visit methods. The only place I noticed that would get these visit methods called is in the CFG.visit_statements method:

tangent/tangent/cfg.py

Lines 112 to 113 in 3318eca

if isinstance(node, grammar.CONTROL_FLOW):
self.visit(node)

where gast.NodeVisitor.visit is called only if the current statement under interest is a control-flow, which includes the following kinds of statements:

CONTROL_FLOW = (gast.For, gast.AsyncFor, gast.While, gast.If, gast.Try)

My question is that the above tuple doesn't include Break or Continue, whereas the class CFG has visit_Break and visit_Continue:

def visit_Break(self, node):

def visit_Continue(self, node):

Are these two visit methods get called from somewhere else I didn't notice?

Thank you!

Sorry for bothering. I just realized that the invocation to visit inside visit_statements would check inside the loop and conditional structures.