MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _add_new_node

Method _add_new_node

tensorflow/python/autograph/pyct/cfg.py:324–346  ·  view source on GitHub ↗

Grows the graph by adding a CFG node following the current leaves.

(self, ast_node)

Source from the content-addressed store, hash-verified

322 self._connect_nodes(node, second)
323
324 def _add_new_node(self, ast_node):
325 """Grows the graph by adding a CFG node following the current leaves."""
326 if ast_node is self.node_index:
327 raise ValueError('%s added twice' % ast_node)
328 # Assumption: All CFG nodes have identical life spans, because the graph
329 # owns them. Nodes should never be used outside the context of an existing
330 # graph.
331 node = Node(next_=set(), prev=weakref.WeakSet(), ast_node=ast_node)
332 self.node_index[ast_node] = node
333 self.owners[node] = frozenset(self.active_stmts)
334
335 if self.head is None:
336 self.head = node
337
338 for leaf in self.leaves:
339 self._connect_nodes(leaf, node)
340
341 # If any finally section awaits its first node, populate it.
342 for section_id in self.pending_finally_sections:
343 self.finally_section_subgraphs[section_id][0] = node
344 self.pending_finally_sections = set()
345
346 return node
347
348 def begin_statement(self, stmt):
349 """Marks the beginning of a statement.

Callers 2

add_ordinary_nodeMethod · 0.95
_add_jump_nodeMethod · 0.95

Calls 2

_connect_nodesMethod · 0.95
NodeClass · 0.70

Tested by

no test coverage detected