def visit_FunctionDef(self, node): graph = programslice.graph.Graph(node.name) graph.add(node.lineno) self.scope.append(graph) [self.visit(x) for x in ast.iter_child_nodes(node)] self.reset()
def reset(self): graph = self.scope.popleft() for key, linenumbers in self.variables.items(): while linenumbers: lineno = linenumbers.popleft() if lineno not in graph.edges: graph.add(lineno) if linenumbers: graph.connect(lineno, linenumbers[0]) lineno = self.calls.get(graph.name) if lineno is not None: for g in self.graphs: if lineno in range(g.first, g.last + 1): g.add(lineno) g.connect(lineno, graph) del self.calls[graph.name] self.graphs.append(graph)