
    ^h
                         S r SSKr\R                  " \R                  R
                  SSS9r " S S\R                  5      rg)zq
Example of null coalescing implementing with Pyccolo;
  e.g., foo?.bar resolves to `None` when `foo` is `None`.
    Nz?..)aug_typetokenreplacementc                   L  ^  \ rS rSr " S S5      rSU 4S jjr\" 5       rS\S\4S jr	\
S 5       r\R                  " \R                  5      S	 5       r\R                  " \R                   5      S
 5       r\R                  " \R$                  5      S 5       r\R                  " \R(                  5      S 5       r\R                  " \R,                  5      S 5       r\R                  " \R0                  5      S 5       r\R                  " \R4                  5      S 5       rSrU =r$ )OptionalChainer   c                   0    \ rS rSrS\SS4S jrSS jrSrg)	OptionalChainer.ResolvesToNone   _itemreturnNc                     g N )selfr   s     \/home/james-whalen/.local/lib/python3.13/site-packages/pyccolo/examples/optional_chaining.py__getattr__*OptionalChainer.ResolvesToNone.__getattr__           c                     g r   r   r   ___s      r   __call__'OptionalChainer.ResolvesToNone.__call__   r   r   r   r   N)__name__
__module____qualname____firstlineno__strr   r   __static_attributes__r   r   r   ResolvesToNoner      s    	S 	T 		r   r%   r   c                    > [         TU ]  " U0 UD6  S U l        U R                  5       U l        U R                  R                  5          SU l        S S S 5        g ! , (       d  f       g = f)NF)super__init___saved_ret_expr
make_stacklexical_call_stackregister_stack_statecur_call_is_none_resolver)r   argskwargs	__class__s      r   r(   OptionalChainer.__init__   sR    $)&)#26//2C$$99;38D* <;;s   A
A'filenamec                     g)NTr   )r   r2   s     r   should_instrument_file&OptionalChainer.should_instrument_file   s    r   c                     [         /$ r   )optional_chaining_spec)r   s    r   syntax_augmentation_specs)OptionalChainer.syntax_augmentation_specs"   s    &''r   c                     Xl         g r   )r)   )r   retr   r   s       r   handle_after_stmt!OptionalChainer.handle_after_stmt&   s    "r   c                     [        U R                  5      S:  a5  U R                  R                  5         [        U R                  5      S:  a  M5  U R                  nS U l        U$ )Nr   )lenr+   popr)   )r   r   r   r;   s       r   handle_after_module_stmt(OptionalChainer.handle_after_module_stmt*   sT    $))*Q.##'') $))*Q.""#
r   c                 V    Uc%  [         U R                  U5      ;   a  U R                  $ U$ r   r7   get_augmentationsresolves_to_none)r   objnode_idr   r   s        r   handle_before_attr"OptionalChainer.handle_before_attr2   s+    ;1T5K5KG5TT(((Jr   c                     U R                   R                  5          XR                  L U l        S S S 5        g ! , (       d  f       g = fr   )r+   pushrF   r-   )r   funcr   r   s       r   handle_before_call"OptionalChainer.handle_before_call9   s1    $$))+-15J5J-JD* ,++s	   7
Ac                 .    U R                   (       a  S $ U$ )Nc                      g r   r   r   r   r   <lambda>3OptionalChainer.handle_before_arg.<locals>.<lambda>A   s    4r   )r-   )r   
arg_lambdar   r   s       r   handle_before_arg!OptionalChainer.handle_before_arg>   s    ))r   c                 8    U R                   R                  5         g r   )r+   r@   r   s      r   handle_after_call!OptionalChainer.handle_after_callE   s    ##%r   c                d    Uc,  [         U R                  U5      ;   a  U(       a  U R                  $ U$ r   rD   )r   r;   rH   call_contextr   r   s         r   handle_after_attr!OptionalChainer.handle_after_attrI   s0     K&$*@*@*II(((Jr   )r)   r-   r+   r   )r   r    r!   r"   r%   r(   rF   r#   boolr4   propertyr8   pycregister_raw_handler
after_stmtr<   after_module_stmtrA   before_attribute_loadrI   before_callrN   before_argumentrU   
after_callrX   after_attribute_loadr\   r$   __classcell__)r0   s   @r   r   r      sC    9 &'s t  ( ( 	cnn-# .# 	c334 5 	c778 9 	coo.K /K 	c112 3 	cnn-& .& 	c667 8r   r   )	__doc__pyccolor`   AugmentationSpecAugmentationTypedotr7   
BaseTracerr   r   r   r   <module>rp      sE    --!!%%Ts 
Ecnn Er   