
    BVh_~              	          d Z ddlZddlZddlZddlZddlZddlmZ  G d de      Z	 G d d ej                  dg d            Z G d	 d
ej                        Z G d de      Z G d de      Z G d dej                         Zd Zy)a  Control flow graph (CFG) structure for Python AST representation.

The CFG is a digraph with edges representing valid control flow. Each
node is associated with exactly one AST node, but not all AST nodes may have
a corresponding CFG counterpart.

Once built, the CFG itself is immutable, but the values it holds need not be;
they are usually annotated with information extracted by walking the graph.

Tip: Use `Graph.as_dot` to visualize the CFG using any DOT viewer.

Note: the CFG tries to include all code paths that MAY be taken, with a single
notable exception:
 * function calls do not generate edges corresponding to exceptions they may
   raise (i.e. a function call in the middle of a block does not return or jump
   to any except or finally block)
TODO(mdan): Consider adding the edges above. They'd only add ~O(n) edges.
TODO(mdan): Alternatively, consider adding an edge from try to all its excepts.
    N)annoc                   "    e Zd ZdZd Zd Zd Zy)Nodea  A node in the CFG.

  Although new instances of this class are mutable, the objects that a user
  finds in the CFG are typically not.

  The nodes represent edges in the CFG graph, and maintain pointers to allow
  efficient walking in both forward and reverse order. The following property
  holds for all nodes: "child in node.next" iff "node in child.prev".

  Attributes:
    next: FrozenSet[Node, ...], the nodes that follow this node, in control flow
      order
    prev: FrozenSet[Node, ...], the nodes that precede this node, in reverse
      control flow order
    ast_node: ast.AST, the AST node corresponding to this CFG node
  c                 .    || _         || _        || _        y N)nextprevast_node)selfnext_r	   r
   s       T/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/autograph/pyct/cfg.py__init__zNode.__init__C   s    DIDIDM    c                     t        | j                        | _        t        j                  | j                        | _        y r   )	frozensetr   weakrefWeakSetr	   r   s    r   freezezNode.freezeH   s(    $))$DI 		*DIr   c                    t        | j                  t        j                        rd| j                  j                  z  S t        | j                  t        j
                        rd| j                  j                  z  S t        | j                  t        j                        r7t        j                  | j                  j                        j                         S t        j                  | j                        j                         S )Nzdef %szclass %s)
isinstancer
   gastFunctionDefnameClassDefwithitem
astunparseunparsecontext_exprstripr   s    r   __repr__zNode.__repr__O   s    $--!1!12****	DMM4==	1$--,,,,	DMM4==	1 : :;AACCdmm,2244r   N)__name__
__module____qualname____doc__r   r   r!    r   r   r   r   1   s    "
+5r   r   c                       e Zd ZdZd Zd Zy)GraphaR  A Control Flow Graph.

  The CFG maintains an index to allow looking up a CFG node by the AST node to
  which it is associated. The index can also be enumerated in top-down, depth
  first order.

  Walking the graph in forward or reverse order is supported by double
  parent-child links.

  Note: the error nodes are not wired to their corresponding finally guards,
  because these are shared, and wiring them would create a reverse path from
  normal control flow into the error nodes, which we want to avoid.

  The graph also maintains edges corresponding to higher level statements
  like for-else loops. A node is considered successor of a statement if there
  is an edge from a node that is lexically a child of that statement to a node
  that is not. Statement predecessors are analogously defined.

  Attributes:
    entry: Node, the entry node
    exit: FrozenSet[Node, ...], the exit nodes
    error: FrozenSet[Node, ...], nodes that exit due to an explicitly raised
      error (errors propagated from function calls are not accounted)
    index: Dict[ast.Node, Node], mapping AST nodes to the respective CFG node
    stmt_prev: Dict[ast.Node, FrozenSet[Node, ...]], mapping statement AST nodes
      to their predecessor CFG nodes
    stmt_next: Dict[ast.Node, FrozenSet[Node, ...]], mapping statement AST nodes
      to their successor CFG nodes
  c                 "    | j                         S r   )as_dotr   s    r   r!   zGraph.__repr__|   s    ;;=r   c           	         d}| j                   j                         D ]  }|dt        |      d|dz  } | j                   j                         D ]1  }|j                  D ]   }|dt        |      dt        |      dz  }" 3 |dz  }|S )zPrint CFG in DOT format.zdigraph CFG {
z  z	 [label="z"];
z -> z;
})indexvaluesidr   )r   resultnoder   s       r   r*   zGraph.as_dot   s    F

!!# :"T(D99f:

!!# :99 :%RXr%y99:: cMFMr   N)r"   r#   r$   r%   r!   r*   r&   r   r   r(   r(   Z   s    <	r   r(   entryexiterrorr-   	stmt_prev	stmt_nextc                       e Zd ZdZdZy)	_WalkMode      N)r"   r#   r$   FORWARDREVERSEr&   r   r   r9   r9      s    ''r   r9   c                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)GraphVisitora9  Base class for a CFG visitors.

  This implementation is not thread safe.

  The visitor has some facilities to simplify dataflow analyses. In particular,
  it allows revisiting the nodes at the decision of the subclass. This can be
  used to visit the graph until the state reaches a fixed point.

  For more details on dataflow analysis, see
  https://www.seas.harvard.edu/courses/cs252/2011sp/slides/Lec02-Dataflow.pdf

  Note: the literature generally suggests visiting successor nodes only when the
  state of the current node changed, regardless of whether that successor has
  ever been visited. This implementation visits every successor at least once.

  Attributes:
    graph: Graph
    in_: Dict[Node, Any], stores node-keyed state during a visit
    out: Dict[Node, Any], stores node-keyed state during a visit
  c                 2    || _         | j                          y r   )graphreset)r   rA   s     r   r   zGraphVisitor.__init__   s    DJJJLr   c                     t        d      )zState initialization function.

    Optional to overload.

    An in/out state slot will be created for each node in the graph. Subclasses
    must overload this to control what that is initialized to.

    Args:
      node: Node
    Subclasses must implement this.NotImplementedErrorr   r1   s     r   
init_statezGraphVisitor.init_state   s     ?
@@r   c                     t        d      )zVisitor function.

    Args:
      node: Node

    Returns:
      bool, whether the node should be revisited; subclasses can visit every
          reachable node exactly once by always returning False
    rD   rE   rG   s     r   
visit_nodezGraphVisitor.visit_node   s     ?
@@r   c                 4   | j                   j                  j                         D ci c]  }|| j                  |       c}| _        | j                   j                  j                         D ci c]  }|| j                  |       c}| _        y c c}w c c}w r   )rA   r-   r.   rH   in_outrG   s     r   rB   zGraphVisitor.reset   s~    04

0@0@0G0G0I(,dood##DH 15

0@0@0G0G0I(,dood##DHs   B.Bc                    |j                   }t        j                  |t        j                  j                        ryt        |t        j                  t        j                  t        j                  t        j                  f      S )zFReturns True if the node can safely be assumed not to touch variables.T)r
   r   hasannoBasicSKIP_PROCESSINGr   r   BreakContinueRaisePass)r   r1   r
   s      r   
can_ignorezGraphVisitor.can_ignore   sS    }}H||Hdjj889hzz4==$**diiHJ Jr   c                 H   |t         j                  t         j                  fv sJ |t         j                  k(  r| j                  j                  g}n2|t         j                  k(  rt        | j                  j                        }t               }r|j                  d      }|j                  |       | j                  |      }|t         j                  k(  r|j                  }n|t         j                  k(  r|j                  }D ]  }|s||vs
|j                  |        |ryy)zVisits the CFG, breadth-first.r   N)r9   r<   r=   rA   r3   listr4   setpopaddrJ   r   r	   append)r   modeopen_closedr1   should_revisitchildrenr   s           r   _visit_internalzGraphVisitor._visit_internal   s    I%%y'8'89999y   zz e	""	"4::??#eUF
YYq\djjt,n	""	"999$$$99 %U&0
,,u
 r   c                 B    | j                  t        j                         y r   )rb   r9   r<   r   s    r   visit_forwardzGraphVisitor.visit_forward       **+r   c                 B    | j                  t        j                         y r   )rb   r9   r=   r   s    r   visit_reversezGraphVisitor.visit_reverse   re   r   N)r"   r#   r$   r%   r   rH   rJ   rB   rV   rb   rd   rg   r&   r   r   r?   r?      s2    *A
AJ0,,r   r?   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)GraphBuildera  Builder that constructs a CFG from a given AST.

  This GraphBuilder facilitates constructing the DAG that forms the CFG when
  nodes
  are supplied in lexical order (i.e., top-down, depth first). Under these
  conditions, it supports building patterns found in typical structured
  programs.

  This builder ignores the flow generated by exceptions, which are assumed to
  always be catastrophic and present purely for diagnostic purposes (e.g. to
  print debug information). Statements like raise and try/catch sections are
  allowed and will generate control flow edges, but ordinary statements are
  assumed not to raise exceptions.

  Finally sections are also correctly interleaved between break/continue/return
  nodes and their subsequent statements.

  Important concepts:
   * nodes - nodes refer to CFG nodes; AST nodes are qualified explicitly
   * leaf set - since the graph is constructed gradually, a leaf set maintains
     the CFG nodes that will precede the node that the builder expects to
     receive next; when an ordinary node is added, it is connected to the
     existing leaves and it in turn becomes the new leaf
   * jump nodes - nodes that should generate edges other than what
     ordinary nodes would; these correspond to break, continue and return
     statements
   * sections - logical delimiters for subgraphs that require special
     edges; there are various types of nodes, each admitting various
     types of jump nodes; sections are identified by their corresponding AST
     node
  c                 2    | j                          || _        y r   )rB   parent)r   parent_ast_nodes     r   r   zGraphBuilder.__init__  s    JJL!DKr   c                 B   d| _         t               | _        i | _        t               | _        t               | _        i | _        t               | _        i | _        i | _	        i | _
        t               | _        i | _        i | _        i | _        i | _        i | _        i | _        y)z!Resets the state of this factory.N)headrY   errors
node_indexleavesactive_stmtsownersforward_edgesfinally_sectionsfinally_section_subgraphsfinally_section_has_direct_flowpending_finally_sectionsexitssection_entry	continuesraises
cond_entrycond_leavesr   s    r   rB   zGraphBuilder.reset  s    DI%DKDO %DK DDKDD&D" ,.D($'ED! DJ DDN DK DODr   c                     t        |t              rT|j                  j                  |       |j                  j                  |       | j
                  j                  ||f       y|D ]  }| j                  ||        y)zConnects nodes to signify that control flows from first to second.

    Args:
      first: Union[Set[Node, ...], Node]
      second: Node
    N)r   r   r   r[   r	   rt   _connect_nodes)r   firstsecondr1   s       r   r   zGraphBuilder._connect_nodesF  se     %jjnnVkkooe
eV_- *$D&)*r   c                    || j                   v rt        d|z        t        t               t	        j
                         |      }|| j                   |<   t        | j                        | j                  |<   | j                  || _	        | j                  D ]  }| j                  ||        | j                  D ]  }|| j                  |   d<    t               | _        |S )zBGrows the graph by adding a CFG node following the current leaves.z%s added twice)r   r	   r
   r   )rp   
ValueErrorr   rY   r   r   r   rr   rs   rn   rq   r   rx   rv   )r   r
   r1   leaf
section_ids        r   _add_new_nodezGraphBuilder._add_new_nodeU  s    4??"'(233 ce'//"3hGD $DOOH!$"3"34DKKyydi &
$%& 33 ;
6:d$$Z03;$'ED!Kr   c                 :    | j                   j                  |       y)zMarks the beginning of a statement.

    Args:
      stmt: Hashable, a key by which the statement can be identified in the
        CFG's stmt_prev and stmt_next attributes
    N)rr   r[   r   stmts     r   begin_statementzGraphBuilder.begin_statementm  s     	$r   c                 :    | j                   j                  |       y)zMarks the end of a statement.

    Args:
      stmt: Hashable, a key by which the statement can be identified in the
        CFG's stmt_prev and stmt_next attributes; must match a key previously
        passed to begin_statement.
    N)rr   remover   s     r   end_statementzGraphBuilder.end_statementv  s     	T"r   c                 J    | j                  |      }t        |f      | _        |S )zGrows the graph by adding an ordinary CFG node.

    Ordinary nodes are followed by the next node, in lexical order, that is,
    they become the new leaf set.

    Args:
      ast_node: ast.AST

    Returns:
      Node
    )r   rY   rq   )r   r
   r1   s      r   add_ordinary_nodezGraphBuilder.add_ordinary_node  s&     h'Dtg,DKKr   c                 d    | j                  |      }t               | _        || j                  |<   |S )a  Grows the graph by adding a jump node.

    Jump nodes are added to the current leaf set, and the leaf set becomes
    empty. If the jump node is the last in a cond section, then it may be added
    back to the leaf set by a separate mechanism.

    Args:
      ast_node: ast.AST
      guards: Tuple[ast.AST, ...], the finally sections active for this node

    Returns:
      Node
    )r   rY   rq   ru   )r   r
   guardsr1   s       r   _add_jump_nodezGraphBuilder._add_jump_node  s2     h'D%DK"(D$Kr   c                     t        |f      }|| j                  vr|S | j                  |   D ](  }| j                  |   \  }}| j                  ||       |}* | j                  |= |S )z;Connects a jump node to the finally sections protecting it.)rY   ru   rv   r   )r   r1   cursorguard_section_idguard_begin
guard_endss         r   !_connect_jump_to_finally_sectionsz.GraphBuilder._connect_jump_to_finally_sections  s{    $\F4(((m 11$7  $ > >?O Pk:
&+.f 	d#Mr   c                 f    | j                  ||      }| j                  |   j                  |       |S )aT  Grows the graph by adding an exit node.

    This node becomes an exit for the current section.

    Args:
      ast_node: ast.AST
      section_id: Hashable, the node for which ast_node should be considered to
        be an exit node
      guards: Tuple[ast.AST, ...], the finally sections that guard ast_node

    Returns:
      Node
    )r   ry   r[   r   r
   r   r   r1   s        r   add_exit_nodezGraphBuilder.add_exit_node  s2     x0DJJzt$Kr   c                 d    | j                  ||      }| j                  |   j                  |       y)aP  Grows the graph by adding a reentry node.

    This node causes control flow to go back to the loop section's entry.

    Args:
      ast_node: ast.AST
      section_id: Hashable, the node for which ast_node should be considered to
        be an exit node
      guards: Tuple[ast.AST, ...], the finally sections that guard ast_node
    N)r   r{   r[   r   s        r   add_continue_nodezGraphBuilder.add_continue_node  s-     x0DNN:""4(r   c                     |D ]?  }|| j                   v r| j                   |   j                  |       0|g| j                   |<   A y)zAdds extra connection between a raise node and containing except guards.

    The node is a graph node, not an ast node.

    Args:
      node: Node
      except_guards: Tuple[ast.AST, ...], the except sections that guard node
    N)r|   r\   )r   r1   except_guardsguards       r   connect_raise_nodezGraphBuilder.connect_raise_node  sF      $	$++	E!!$'"VE	$r   c                 R    || j                   vsJ t               | j                   |<   y)zEnters a regular section.

    Regular sections admit exit jumps, which end the section.

    Args:
      section_id: Hashable, the same node that will be used in calls to the
        ast_node arg passed to add_exit_node
    N)ry   rY   r   r   s     r   enter_sectionzGraphBuilder.enter_section  s&     TZZ''' UDJJzr   c                     | j                   |   D ]&  }| xj                  | j                  |      z  c_        ( | j                   |= y)zExits a regular section.N)ry   rq   r   )r   r   exit_s      r   exit_sectionzGraphBuilder.exit_section  sE     J' C
kkT;;EBBkC 	

:r   c                     || j                   vsJ || j                  vsJ t               | j                  |<   | j                  |      }|| j                   |<   y)a  Enters a loop section.

    Loop sections define an entry node. The end of the section always flows back
    to the entry node. These admit continue jump nodes which also flow to the
    entry node.

    Args:
      section_id: Hashable, the same node that will be used in calls to the
        ast_node arg passed to add_continue_node
      entry_node: ast.AST, the entry node into the loop (e.g. the test node for
        while loops)
    N)rz   r{   rY   r   )r   r   
entry_noder1   s       r   enter_loop_sectionzGraphBuilder.enter_loop_section  sZ     T/////T^^+++!$DNN:!!*-D%)Dz"r   c                 N   | j                  | j                  | j                  |          | j                  |   D ]2  }| j	                  |      }| j                  || j                  |          4 t        | j                  |   f      | _        | j                  |= | j                  |= y)zExits a loop section.N)r   rq   rz   r{   r   rY   )r   r   reentryr   s       r   exit_loop_sectionzGraphBuilder.exit_loop_section  s    T%7%7
%CD >>*- F99'Bj
*d&8&8&DEF
 t))*578DKz":&r   c                 b    || j                   vsJ || j                  vsJ g | j                  |<   y)zEnters a conditional section.

    Conditional sections define an entry node, and one or more branches.

    Args:
      section_id: Hashable, the same node that will be used in calls to the
        section_id arg passed to new_cond_branch
    N)r}   r~   r   s     r   enter_cond_sectionzGraphBuilder.enter_cond_section  s:     T__,,,T-----#%DZ r   c                     || j                   v sJ || j                  v r=| j                   |   j                  | j                         | j                  |   | _        y| j                  | j                  |<   y)z&Begins a new branch in a cond section.N)r~   r}   r\   rq   r   s     r   new_cond_branchzGraphBuilder.new_cond_branch%  se    )))))T__$ z"))$++6OOJ/dk %)KKdooj!r   c                     | j                   |   D ]  }| xj                  |z  c_         | j                  |= | j                   |= y)zExits a conditional section.N)r~   rq   r}   )r   r   splits      r   exit_cond_sectionzGraphBuilder.exit_cond_section3  sD    !!*- 
kkUk
#$r   c                 r    || j                   v r)| j                  j                  | j                   |          yy)zEnters an except section.N)r|   rq   updater   s     r   enter_except_sectionz!GraphBuilder.enter_except_section:  s.    T[[ 
kkZ01 !r   c                     ddg| j                   |<   | j                  rd| j                  |<   nd| j                  |<   | j                  j	                  |       y)zEnters a finally section.NTF)rv   rq   rw   rx   r[   r   s     r   enter_finally_sectionz"GraphBuilder.enter_finally_section?  sS     37D"":.{{9=d**:69>d**:6!!%%j1r   c                     || j                   vsJ d       | j                  | j                  |   d<   | j                  |   st	               | _        | j                  |= y)zExits a finally section.zEmpty finally?r:   N)rx   rq   rv   rw   rY   r   s     r   exit_finally_sectionz!GraphBuilder.exit_finally_sectionI  s\    T:::L<LL:48KKD"":.q1 //
;Edk,,Z8r   c                    | j                   j                         D ]  }|j                           i }i }| j                   j                         D ]9  }| j                  |   D ]%  }||vrt	               ||<   ||vst	               ||<   ' ; | j
                  D ]y  \  }}| j                  |   | j                  |   z
  }|D ]  }||   j                  |        | j                  |   | j                  |   z
  }|D ]  }||   j                  |        { |D ]  }t        ||         ||<    |D ]  }t        ||         ||<    t        | j                  | j                  | j                  | j                   ||      }	| j                          |	S )zYReturns the CFG accumulated so far and resets the builder.

    Returns:
      Graph
    r2   )rp   r.   r   rs   rY   rt   r[   r   r(   rn   rq   ro   rB   )
r   r1   r7   r6   r   r   r   stmts_exitedstmts_enteredr0   s
             r   buildzGraphBuilder.buildS  s    &&( 
kkm II&&( "++d# "$y E)D/y E)D/	"" ++ #v[['$++f*==l $$$F#$kk&)DKK,>>m #$$E"##  3!)D/2io3 3!)D/2io3 ii[[kkooF 	JJLMr   N)r"   r#   r$   r%   r   rB   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r&   r   r   ri   ri      s|    F"'R*0 # ($)$
#*&'&0%2
29-r   ri   c                        e Zd ZdZ fdZd Zd Zd Zd Zd Z		 d%dZ
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z& xZ'S )&AstToCfgzTConverts an AST to CFGs.

  A separate CFG will be constructed for each function.
  c                 b    t         t        |           g | _        d | _        i | _        g | _        y r   )superr   r   builder_stackbuildercfgslexical_scopes)r   	__class__s    r   r   zAstToCfg.__init__  s.    	(D"$DDLDIDr   c                 :    | j                   j                  |       y r   )r   r\   rG   s     r   _enter_lexical_scopezAstToCfg._enter_lexical_scope  s    t$r   c                 F    | j                   j                         }||k(  sJ y r   )r   rZ   )r   r1   leaving_nodes      r   _exit_lexical_scopezAstToCfg._exit_lexical_scope  s$    &&**,L<r   c                     g }t        | j                        D ]K  }t        |t        j                        r|j
                  r|j                  |       t        ||      sG||fc S  d |fS r   )reversedr   r   r   Try	finalbodyr\   r   stop_atincludedr1   s       r   _get_enclosing_finally_scopesz&AstToCfg._get_enclosing_finally_scopes  sa    H,,- 	D$((	#	D'	"X~	
 >r   c                     g }t        | j                        D ]R  }t        |t        j                        r'|j
                  r|j                  |j
                         t        ||      sQ |S  |S r   )r   r   r   r   r   handlersextendr   s       r   _get_enclosing_except_scopesz%AstToCfg._get_enclosing_except_scopes  s^    H,,- 	D$((	#&	D'	"O
 Or   c                 \    | j                  |       | j                  j                  |       y r   )generic_visitr   r   rG   s     r   _process_basic_statementz!AstToCfg._process_basic_statement  s"    tLL""4(r   c                    | j                  |       | j                  |      \  }}|J dj                  ||             | j                  j	                  |||      }|r.| j                  |      }| j                  j                  ||       y y )Nz${} that is not enclosed by any of {})r   r   formatr   r   r   r   )r   r1   exits_nodes_of_typemay_exit_via_excepttry_noder   r   s          r   _process_exit_statementz AstToCfg._process_exit_statement  s     	t99:MNHf #!G!N!N!"# # <<%%dHf=D778KLm
ll%%dM: r   c                     | j                  t        |            \  }}|t        |d|      | j                  j	                  |||       y )Nz  that is not enclosed by any of )r   tupler   r   r   )r   r1   loops_to_nodes_of_typer   r   s        r   _process_continue_statementz$AstToCfg._process_continue_statement  sT    99$%'Hf46 7 7LL""46:r   c                    | j                   | j                  |       y | j                   j                  |       | j                  j	                  | j                          t        |      | _         | j                  |       | j                  |       | j                  |       | j                  j                         | _         y r   )
r   r   r   r   r\   ri   r   r   r   rZ   rG   s     r   visit_ClassDefzAstToCfg.visit_ClassDef  s     ||
LL""4(dll+%DLd#!!$'T"%%))+DLr   c                    | j                   | j                   j                  |       | j                  j                  | j                          t	        |      | _         | j                  |       | j                   j                  |       | j                  |j                         |r,| j                  |j                  t        j                  f       n"|j                  D ]  }| j                  |        | j                   j                  |       | j                  |       | j                   j!                         | j"                  |<   | j                  j%                         | _         y r   )r   r   r   r\   ri   r   r   r   argsr   bodyr   Lambdavisitr   r   r   r   rZ   )r   r1   	is_lambdar   s       r   _process_function_defzAstToCfg._process_function_def  s    ||
ll$$T*dll+%DLd#LLt$!!$)),
""499t{{n=)) $

4 	LLd#T"ll((*DIIdO%%))+DLr   c                 *    | j                  |d       y )NFr   r   rG   s     r   visit_FunctionDefzAstToCfg.visit_FunctionDef  s    tu5r   c                 *    | j                  |d       y )NTr   r   rG   s     r   visit_LambdazAstToCfg.visit_Lambda   s    tt4r   c                 F    | j                  |t        j                  f       y r   )r   r   r   rG   s     r   visit_ReturnzAstToCfg.visit_Return  s      (8(8':;r   c                 &    | j                  |       y r   r   rG   s     r   visit_ImportzAstToCfg.visit_Import      !!$'r   c                 &    | j                  |       y r   r   rG   s     r   visit_ImportFromzAstToCfg.visit_ImportFrom	  r   r   c                 &    | j                  |       y r   r   rG   s     r   
visit_ExprzAstToCfg.visit_Expr  r   r   c                 &    | j                  |       y r   r   rG   s     r   visit_NamedExprzAstToCfg.visit_NamedExpr  s     	!!$'r   c                 &    | j                  |       y r   r   rG   s     r   visit_AssignzAstToCfg.visit_Assign  r   r   c                 &    | j                  |       y r   r   rG   s     r   visit_AnnAssignzAstToCfg.visit_AnnAssign  r   r   c                 &    | j                  |       y r   r   rG   s     r   visit_AugAssignzAstToCfg.visit_AugAssign  r   r   c                 &    | j                  |       y r   r   rG   s     r   
visit_PasszAstToCfg.visit_Pass  r   r   c                 &    | j                  |       y r   r   rG   s     r   visit_GlobalzAstToCfg.visit_Global   r   r   c                 &    | j                  |       y r   r   rG   s     r   visit_NonlocalzAstToCfg.visit_Nonlocal#  r   r   c                 &    | j                  |       y r   r   rG   s     r   visit_PrintzAstToCfg.visit_Print&  r   r   c                     | j                  |t        j                  fd       | j                  j                  j                  |       y )NT)r   )r   r   r   r   ro   r[   rG   s     r   visit_RaisezAstToCfg.visit_Raise)  s=      t!t ! =LLD!r   c                 &    | j                  |       y r   r   rG   s     r   visit_AssertzAstToCfg.visit_Assert.  s    !!$'r   c                 &    | j                  |       y r   r   rG   s     r   visit_DeletezAstToCfg.visit_Delete2  r   r   c                    | j                   j                  |       | j                   j                  |       | j                  |j                         | j                   j                  |       |j                  D ]  }| j                  |        | j                   j                  |       |j                  D ]  }| j                  |        | j                   j                  |       | j                   j                  |       y r   )r   r   r   r   testr   r   r   orelser   r   r   r1   r   s      r   visit_IfzAstToCfg.visit_If5  s     	LL  &LL##D)!!$)),LL  &		 
jj 	LL  & 
jj 	LL""4(LLt$r   c                 `   | j                   j                  |       | j                  |       | j                   j                  |       | j	                  |j
                         | j                   j                  ||j
                         |j                  D ]  }| j                  |        | j                   j                  |       | j                  |       |j                  D ]  }| j                  |        | j                   j                  |       | j                   j                  |       y r   )r   r   r   r   r   r  r   r   r   r   r   r  r   r   r  s      r   visit_WhilezAstToCfg.visit_WhileK  s    LL  &d#LLt$tyy!LL##D$))4		 
jjLL""4(
 	T" 
jj 	LLd#LLt$r   c                 6   | j                   j                  |       | j                  |       | j                   j                  |       | j	                  |j
                         | j                   j                  ||j
                         t        j                  |t        j                  j                        r=| j                  t        j                  |t        j                  j                               |j                  D ]  }| j                  |        | j                   j                  |       | j!                  |       |j"                  D ]  }| j                  |        | j                   j%                  |       | j                   j'                  |       y r   )r   r   r   r   r   iterr   r   rO   rP   EXTRA_LOOP_TESTr   getannor   r   r   r   r  r   r   r  s      r   	visit_ForzAstToCfg.visit_Forb  s&   LL  &d#LLt$
 	tyy!LL##D$))4 ||D$**445
##
,,tTZZ77
8:		 
jjLL""4(
 	T" 
jj 	LLd#LLt$r   c                 d    | j                  |t        j                  t        j                  f       y r   )r   r   WhileForrG   s     r   visit_BreakzAstToCfg.visit_Break  s%      

( r   c                 d    | j                  |t        j                  t        j                  f       y r   )r   r   r$  r%  rG   s     r   visit_ContinuezAstToCfg.visit_Continue  s%    $$T

, r   c                    | j                   j                  |       | j                   j                  |       |j                  | j	                  |j                         |j
                  | j	                  |j
                         |j                  D ]  }| j	                  |        | j                   j                  |       y r   )r   r   r   typer   r   r   r   r  s      r   visit_ExceptHandlerzAstToCfg.visit_ExceptHandler  s    LL  &LL%%d+yy
jjyy
jj		 
jj 	LLt$r   c                 d   | j                   j                  |       | j                  |       |j                  D ]  }| j	                  |        |j
                  r|j
                  d   }| j                   j                  |       | j                   j                  |       |j
                  D ]  }| j	                  |        | j                   j                  |       | j                   j                  |       | j                  |       |j                  r|j                  d   }| j                   j                  |       |j                  D ].  }| j                   j                  |       | j	                  |       0 | j                   j                  |       | j                   j                  |       |j                  rX| j                   j                  |       |j                  D ]  }| j	                  |        | j                   j                  |       | j                   j                  |       y )Nr   )r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   )r   r1   r   block_representativeblocks        r   	visit_TryzAstToCfg.visit_Try  s   LL  &d# 		 
jj {{![[^
ll%%&:;
ll""#78++ $

4
ll""#78
ll$$%9:T"}} "]]1-
ll%%&:;== %$$%9:

5 ll""#78
ll$$%9:~~
ll((... $

4
ll''-LLt$r   c                     |j                   D ]  }| j                  |        |j                  D ]  }| j                  |        y r   )itemsr   r   r   )r   r1   itemr   s       r   
visit_WithzAstToCfg.visit_With  sB    

 *
##D)*		 
jjr   )F)(r"   r#   r$   r%   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r
  r  r  r  r  r  r  r  r  r"  r&  r(  r+  r/  r3  __classcell__)r   s   @r   r   r     s    
% ) 38; ;,8,265<((((
((((((("
((%,%.%>%(%Tr   r   c                 P    t               }|j                  |        |j                  S r   )r   r   r   )r1   visitors     r   r   r     s    J'	--	r   )r%   collectionsenumr   r   r    tensorflow.python.autograph.pyctr   objectr   
namedtupler(   Enumr9   r?   ri   NodeVisitorr   r   r&   r   r   <module>r>     s   0      1&56 &5R.KEG.b		 `,6 `,FK6 K\Gt GT
r   