
    ^h>                     d    S SK r S SKJrJrJrJr   " S S\5      r " S S\ R                  5      rg)    N)Dict
NamedTupleOptionalTuplec                   8   \ rS rSr% \\S'   \\S'   \\\R                  4   \S'   \\\R                  4   \S'   \\\R                  4   \S'   \\\R                  4   \S'   \\\R                  4   \S'   S	\S
\S \\\4   4   4S jr\S\S\S
S 4S j5       rSrg)AstBookkeeper   path	module_idast_node_by_idcontaining_ast_by_idcontaining_stmt_by_idparent_stmt_by_idstmt_by_linenonew_module_idreturnc           	         U R                   U0n0 n0 n0 n0 nU R                  R                  5        Hz  u  px[        U5      n	XU'   XU	'   XpR                  ;   a  U R                  U   XI'   XpR
                  ;   a  U R
                  U   XY'   XpR                  ;   d  Mi  U R                  U   Xi'   M|     [        U R                  UUUUUU R                  5      U4$ )z
After unpickling, the ast nodes will have different ids than before.
This method will compuate a new bookkeeper to reflect the new ids, as well
as return a mapping from the old ids to the new ids.
)
r   r   itemsidr   r   r   r   r
   r   )
selfr   	remappingnew_ast_node_by_idnew_containing_ast_by_idnew_containing_stmt_by_idnew_parent_stmt_by_idold_idast_nodenew_ids
             Q/home/james-whalen/.local/lib/python3.13/site-packages/pyccolo/ast_bookkeeping.pyremapAstBookkeeper.remap   s     &*^^]$C	1379 9;!57 $ 3 3 9 9 ;F\F &f)1v&222373L3LV3T(0333484N4Nv4V)1///040F0Fv0N%- !< 		"()%## 
 	
    c           	          U " X0 0 0 0 0 5      $ N )clsr
   r   s      r   createAstBookkeeper.create1   s    4BBB77r"   r%   N)__name__
__module____qualname____firstlineno__str__annotations__intr   astASTstmtr   r    classmethodr'   __static_attributes__r%   r"   r   r   r      s    
INcgg&&sCGG|,,SXX..CM**chh'' 
3  
5$sCx.1P+Q  
D 8# 8# 8/ 8 8r"   r   c                      ^  \ rS rSrS\\\R                  4   S\\\R                  4   S\\\R                  4   S\\\R                  4   S\\\R                  4   4
S jr	S\R                  4U 4S	 jjr
S
rU =r$ )BookkeepingVisitor6   r   r   r   r   r   c                 N    Xl         X l        X0l        X@l        XPl        S U l        g r$   )r   r   r   r   r   _current_containing_stmt)r   r   r   r   r   r   s         r   __init__BookkeepingVisitor.__init__7   s*     -$8!%:"!2,<@%r"   nodec                   > [        U[        R                  5      (       a  Xl        U R                  b/  U R                  R                  [        U5      U R                  5        XR                  [        U5      '   [        U[        R                  5      (       aD  XR                  UR                  '   [        US/ 5       H  nXR                  UR                  '   M     [        R                  " U5       H  u  p4[        U[        R                  5      (       aJ  XR                  [        U5      '   U R                  b$  U R                  U R                  [        U5      '   Ml  Mn  [        U[        5      (       d  M  U Hs  n[        U[        R                  5      (       d  M$  XR                  [        U5      '   [        U[        R                  5      (       d  M\  XR                  [        U5      '   Mu     GM     [         TU ]E  U5        g )Ndecorator_list)
isinstancer0   r2   r9   r   
setdefaultr   r   r   linenogetattriter_fieldsr1   r   listr   supergeneric_visit)r   r<   	decoratornamefieldsubfield	__class__s         r   rF    BookkeepingVisitor.generic_visitF   s   dCHH%%,0)((4&&114$77 )-BtH%dCHH%%/3, %T+;R@	8<##I$4$45 A??40KD%))7;))"U)400<55 ..r%y9 = E4(( %H!(CGG44BF11"X,?%dCHH55CG222h<@	 !& 1 	d#r"   )r9   r   r   r   r   r   )r)   r*   r+   r,   r   r/   r0   r1   r2   r:   rF   r4   __classcell__)rK   s   @r   r6   r6   6   s    AS#''\*A #3<0A  $CM2	A
  SXX.A S#((]+A$#'' $ $r"   r6   )	r0   typingr   r   r   r   r   NodeVisitorr6   r%   r"   r   <module>rP      s+    
 4 4-8J -8`+$ +$r"   