
    BVh                         d Z ddlZddlZ G d dej                        Z G d de      Z G d de      Z e       Zdd
Z	ed	fdZ
ddZddZddZddZddZy)z4AST node annotation support.

Adapted from Tangent.
    Nc                   *    e Zd ZdZddZd Zd Zd Zy)NoValuez2Base class for different types of AST annotations.Nc                     t        || |      S )N)default)getanno)selfnoder   s      U/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/autograph/pyct/anno.pyofz
NoValue.of$   s    4w//    c                     t        || |       y N)setanno)r   r	   values      r
   add_tozNoValue.add_to'   s    D$r   c                     t        ||       S r   )hasanno)r   r	   s     r
   existszNoValue.exists*   s    4r   c                 ,    t        | j                        S r   )strname)r   s    r
   __repr__zNoValue.__repr__-   s    tyy>r   r   )__name__
__module____qualname____doc__r   r   r   r    r   r
   r   r   !   s    :0r   r   c                   (    e Zd ZdZdZdZdZdZdZdZ	y)	BasiczhContainer for basic annotation keys.

  The enum values are used strictly for documentation purposes.
  z>Qualified name, as it appeared in the code. See qual_names.py.zBThis node should be preserved as is and not processed any further.zWhen a node is annotated with this, the remainder of the block should be indented below it. The annotation contains a tuple (new_body, name_map), where `new_body` is the new indented block and `name_map` allows renaming symbols.zaInformation about the source code that converted code originated from. See origin_information.py.zvUser directives associated with a statement or a variable. Typically, they affect the immediately-enclosing statement.zQA special annotation containing additional test code to be executed in for loops.N)
r   r   r   r   QNSKIP_PROCESSINGINDENT_BLOCK_REMAINDERORIGIN
DIRECTIVESEXTRA_LOOP_TESTr   r   r
   r   r   1   s:    
 H"J - 
0&O* r   r   c                   L    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y)StaticzrContainer for static analysis annotation keys.

  The enum values are used strictly for documentation purposes.
  z5Symbol is a parameter to the function being analyzed.z2The scope for the annotated node. See activity.py.z3The scope for the argument list of a function call.z7The scope for the test node of a conditional statement.z`The scope for the main body of a statement (True branch for if statements, main body for loops).zeThe scope for the orelse body of a statement (False branch for if statements, orelse body for loops).z=Reaching definition information. See reaching_definitions.py.zQThe value of DEFINITIONS that applied to the original code before any conversion.zWLocal function definitions that may exist when exiting the node. See reaching_fndefs.pyzDSymbols defined when entering the node. See reaching_definitions.py.z4Symbols live when exiting the node. See liveness.py.z5Symbols live when entering the node. See liveness.py.z/Static type information. See type_inference.py.z4Types of closure symbols at each detected call site.z0Static value information. See type_inference.py.N)r   r   r   r   IS_PARAMSCOPE
ARGS_SCOPE
COND_SCOPE
BODY_SCOPEORELSE_SCOPEDEFINITIONSORIG_DEFINITIONSDEFINED_FNS_INDEFINED_VARS_INLIVE_VARS_OUTLIVE_VARS_INTYPESCLOSURE_TYPESVALUEr   r   r
   r'   r'   I   sw     E( ?%D*H** ,  F    M I-I,
;%H-
<%r   r'   ___pyct_annoc                 t    t        | |      s
t               S t        t        | |      j                               S r   )hasattr	frozensetgetattrkeys)r	   
field_names     r
   r<   r<   u   s/    	z	";	74,113	44r   c                 h    |t         u st        | |      r|t        | |      v rt        | |      |   S |S r   )FAILr9   r;   )r	   keyr   r=   s       r
   r   r   {   s8    o'$
3'$
";;4$S))	.r   c                 :    t        | |      xr |t        | |      v S r   )r9   r;   )r	   r@   r=   s      r
   r   r      s     	z	"	GsgdJ.G'GGr   c                     t        | |i       }t        | ||       |||<   || j                  vr| xj                  |fz  c_        y y r   )r;   setattr_fields)r	   r@   r   r=   annotationss        r
   r   r      sI    j"-+	$
K(+c t||#LLZM!L $r   c                     t        |       }||= |s0t        |        t        fd| j                  D              | _        y y )Nc              3   .   K   | ]  }|k7  s	|  y wr   r   ).0fr=   s     r
   	<genexpr>zdelanno.<locals>.<genexpr>   s     DqAODs   
)r;   delattrtuplerD   )r	   r@   r=   rE   s     ` r
   delannorM      s?    j)+#	D*DDLLDDDL 
r   c           	      X    t        | ||      rt        ||t        | ||      |       y y )N)r=   )r   r   r   )	from_nodeto_noder@   r=   s       r
   copyannorQ      s0    Y
3	3:6	 4r   c                     t        j                  |       D ]3  }|D ],  }t        |||      st        |||   t	        |||      |       . 5 y)a+  Recursively copies annotations in an AST tree.

  Args:
    node: ast.AST
    copy_map: Dict[Hashable, Hashable], maps a source anno key to a destination
        key. All annotations with the source key will be copied to identical
        annotations with the destination key.
    field_name: str
  N)gastwalkr   r   r   )r	   copy_mapr=   nks        r
   duprX      sU     99T? Ga G	Az	"8A;1j 9:FGGr   )r7   )r   enumrS   Enumr   r   r'   objectr?   r<   r   r   r   rM   rQ   rX   r   r   r
   <module>r\      ss   
  dii  G 0&=W &=R x5  $ H"EGr   