
    h\0                     J   S SK Jr  S SK Jr  S SKJr  S SKJr  S SKJrJr   " S S5      r " S S	\5      r	 " S
 S\5      r
 " S S\5      r " S S5      r " S S\R                  \5      r\r " S S\R                   \5      r " S S\R                  5      r " S S\5      rg)   )Nodes)	ExprNodes)Node)AtomicExprNode)
c_ptr_type
c_int_typec                   ,    \ rS rSrSrSrSS jrS rSrg)
TempHandle   NFc                 F    Xl         Uc  UR                  U l        g X l        g N)typeis_pyobjectneeds_cleanup)selfr   r   s      S/var/www/fran/franai/venv/lib/python3.13/site-packages/Cython/Compiler/UtilNodes.py__init__TempHandle.__init__   s!    	 !%!1!1D!.    c                 *    [        XU R                  S9$ )N)handler   )TempRefNoder   )r   poss     r   refTempHandle.ref   s    3$))<<r   )r   r   r   )	__name__
__module____qualname____firstlineno__tempneeds_xdecrefr   r   __static_attributes__ r   r   r
   r
      s    DM/=r   r
   c                   <    \ rS rSrS rS rS rS rS rS
S jr	Sr
g	)r      c                 R    U R                   U R                  R                   :X  d   eU $ r   r   r   r   envs     r   analyse_typesTempRefNode.analyse_types"   #    yyDKK,,,,,r   c                 R    U R                   U R                  R                   :X  d   eU $ r   r'   r(   s     r   analyse_target_types TempRefNode.analyse_target_types&   r,   r   c                     g r   r#   r(   s     r   analyse_target_declaration&TempRefNode.analyse_target_declaration*       r   c                 <    U R                   R                  nUc  SnU$ )Nz<error>)r   r    )r   results     r   calculate_result_code!TempRefNode.calculate_result_code-   s    !!>I6r   c                     g r   r#   r   codes     r   generate_result_code TempRefNode.generate_result_code2   r3   r   c                    U R                   R                  (       a?  UR                  U5        UR                  U R	                  5       U R                  5       5        UR                  U R	                  5       < SU(       a  UR	                  5       OUR                  U R                  5       5      < S35        UR                  U5        UR                  U5        g N = ;)
r   r   make_owned_referenceput_xdecrefr5   ctypeputln	result_asgenerate_post_assignment_code
free_tempsr   rhsr:   overloaded_assignments       r   generate_assignment_code$TempRefNode.generate_assignment_code5   s    99  $$T*T[[]DJJL9

KKM1CJJLs}}TZZ\7RR
 	 	))$/tr   r#   NF)r   r   r   r   r*   r.   r1   r6   r;   rK   r"   r#   r   r   r   r      s     

r   r   c                   <    \ rS rSrSrS/rS rS rS rS r	S r
S	rg
)TempsBlockNodeB   aC  
Creates a block which allocates temporary variables.
This is used by transforms to output constructs that need
to make use of a temporary variable. Simply pass the types
of the needed temporaries to the constructor.

The variables can be referred to using a TempRefNode
(which can be constructed by calling get_ref_node).
bodyc                    U R                    H6  nUR                  R                  UR                  UR                  S9Ul        M8     U R                  R                  U5        U R                    H  nUR                  (       a^  UR                  (       a'  UR                  UR
                  UR                  5        O&UR                  UR
                  UR                  5        UR                  R                  UR
                  5        M     g )N
manage_ref)temps	funcstateallocate_tempr   r   r    rQ   generate_execution_coder!   put_xdecref_clearput_decref_clearrelease_temp)r   r:   r   s      r   rX   &TempsBlockNode.generate_execution_codeT   s    jjF..66(<(< 7 >FK ! 			))$/jjF##''**6;;D))&++v{{CNN''4 !r   c                 :    U R                   R                  U5        g r   rQ   analyse_declarationsr(   s     r   r_   #TempsBlockNode.analyse_declarationsa       		&&s+r   c                 F    U R                   R                  U5      U l         U $ r   rQ   analyse_expressionsr(   s     r   rd   "TempsBlockNode.analyse_expressionsd       II11#6	r   c                 :    U R                   R                  X5        g r   rQ   generate_function_definitionsr   r)   r:   s      r   ri   ,TempsBlockNode.generate_function_definitionsh       		//:r   c                 :    U R                   R                  U5        g r   )rQ   annotater9   s     r   rn   TempsBlockNode.annotatek   s    		4 r   )rQ   N)r   r   r   r   __doc__child_attrsrX   r_   rd   ri   rn   r"   r#   r   r   rO   rO   B   s)     (K5,;!r   rO   c                       \ rS rSr/ rSrSS jrS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rSS jrS rS rS rSrg)ResultRefNodeo   FNc                     Xl         S U l        X@l        Ub#  UR                  U l        [        USS 5      U l        Ub  X l        Ub  X0l        U(       a  SU l        U R                  c   eg )Nr   T)
expressionr   may_hold_nonegetattrr   is_temp)r   rv   r   r   rw   ry   s         r   r   ResultRefNode.__init__v   sd    $*!!~~DH
FD9DI?HIDLxx###r   c                     U $ r   r#   r   s    r   
clone_nodeResultRefNode.clone_node   s    r   c                 \    U R                   (       a  U R                   R                  U5      $ g)Nr#   )rv   type_dependenciesr(   s     r   r   ResultRefNode.type_dependencies   s!    ????44S99r   c                 F    Xl         [        USS 5      nU(       a  X l        g g )Nr   )rv   rx   r   )r   rv   r   s      r   update_expressionResultRefNode.update_expression   s"    $z640I r   c                     g r   r#   r(   s     r   r1   (ResultRefNode.analyse_target_declaration   r3   r   c                     U R                   bV  U R                   R                  (       d   U R                   R                  U5      U l         U R                   R                  U l        U $ r   )rv   r   r*   r(   s     r   r*   ResultRefNode.analyse_types   sE    ??&??''"&//"?"?"D,,DIr   c                     U R                   b  U R                   $ U R                  bH  U R                  R                   b  U R                  R                   $ U R                  R                  U5      $  S5       e)Nz"cannot infer type of ResultRefNode)r   rv   
infer_typer(   s     r   r   ResultRefNode.infer_type   s`    99 99??&##/+++??--c22:::ur   c                 R    U R                   R                  (       d  gU R                  $ )NF)r   r   rw   r|   s    r   may_be_noneResultRefNode.may_be_none   s    yy$$!!!r   c                     U R                   b  U R                   R                  5       $ U R                  b  U R                  R                  $ gNT)rv   r   r   r   r|   s    r   _DISABLED_may_be_none#ResultRefNode._DISABLED_may_be_none   s>     ??&??..0099 99(((r   c                     gr   r#   r|   s    r   	is_simpleResultRefNode.is_simple   s    r   c                      U R                   $ ! [         a:    U R                  b  U R                  R                  5       U l          U R                   $ f = fr   )result_codeAttributeErrorrv   r5   r|   s    r   r5   ResultRefNode.result   sN    	<### 	<*#'??#9#9#; 	<s    6AAc                     g r   r#   r9   s     r   generate_evaluation_code&ResultRefNode.generate_evaluation_code   r3   r   c                     g r   r#   r9   s     r   r;   "ResultRefNode.generate_result_code   r3   r   c                     g r   r#   r9   s     r   generate_disposal_code$ResultRefNode.generate_disposal_code   r3   r   c                    U R                   R                  (       aP  UR                  U5        U R                  (       d.  UR	                  U R                  5       U R                  5       5        UR                  U R                  5       < SU(       a  UR                  5       OUR                  U R                  5       5      < S35        UR                  U5        UR                  U5        g r>   )r   r   rA   lhs_of_first_assignment
put_decrefr5   rC   rD   rE   rF   rG   rH   s       r   rK   &ResultRefNode.generate_assignment_code   s    99  $$T*//tzz|<

KKM1CJJLs}}TZZ\7RR
 	 	))$/tr   c                     g r   r#   r(   s     r   allocate_tempsResultRefNode.allocate_temps   r3   r   c                     g r   r#   r(   s     r   r[   ResultRefNode.release_temp   r3   r   c                     g r   r#   r9   s     r   rG   ResultRefNode.free_temps   r3   r   )rv   ry   rw   r   r   r   )NNNTFrM   )r   r   r   r   subexprsr   r   r}   r   r   r1   r*   r   r   r   r   r5   r   r;   r   rK   r   r[   rG   r"   r#   r   r   rs   rs   o   si     H#$;"
 
r   rs   c                   &    \ rS rSrS rS rS rSrg)LetNodeMixin   c                 2    Xl         UR                  U l        g r   )	lazy_temprv   temp_expression)r   r   s     r   set_temp_exprLetNodeMixin.set_temp_expr   s    "(33r   c                    U R                   R                  U5        U R                   R                  U l        U R                  R                  (       a$  [        U R                  R                  5      U l        U R                   R                  5       U l        U R                  (       a   U R                   R                  5       U l
        OU R                  R                  (       a  U R                   R                  U5        OU R                   R                  U5        UR                  R                  U R                  SS9U l
        UR!                  U R                  < SU R                   R                  5       < S35        U R                   R#                  U5        U R                   R%                  U5        U R                  U R&                  l        g )NTrS   r?   r@   )r   r   r   	temp_typeis_arrayr   	base_typeresult_in_temp_result_in_tempr5   r    is_memoryviewslicemake_owned_memoryviewslicerA   rV   rW   rD   r   rG   r   r   r9   s     r   setup_temp_exprLetNodeMixin.setup_temp_expr   s7   55d;--22>>""'(@(@ADN#33BBD,,335DI~~00$$??E$$99$?444 5 1DIJJTYY0D0D0K0K0MNO  77=  ++D1%)YY"r   c                 `   U R                   (       a7  U R                  R                  U5        U R                  R                  U5        g U R                  R
                  (       a&  UR                  U R                  U R                  5        UR                  R                  U R                  5        g r   )
r   r   r   rG   r   needs_refcountingrZ   r    rV   r[   r9   s     r   teardown_temp_exprLetNodeMixin.teardown_temp_expr   sn      77=  ++D1~~//%%dii@NN''		2r   )r   r   r    r   r   N)r   r   r   r   r   r   r   r"   r#   r   r   r   r      s    4/(3r   r   c                   L    \ rS rSrSS/rS rS rS rS rS r	S	 r
S
 rS rSrg)EvalWithTempExprNodei  r   subexpressionc                     U R                  U5        UR                  U l        X l        U R                  R                  U l        g r   )r   r   r   r   )r   r   r   s      r   r   EvalWithTempExprNode.__init__	  s6    9% $$*&&++	r   c                 8    U R                   R                  U5      $ r   )r   r   r(   s     r   r   EvalWithTempExprNode.infer_type  s    !!,,S11r   c                 6    U R                   R                  5       $ r   )r   r   r|   s    r   r    EvalWithTempExprNode.may_be_none  s    !!--//r   c                 6    U R                   R                  5       $ r   )r   r5   r|   s    r   r5   EvalWithTempExprNode.result  s    !!((**r   c                    U R                   R                  U5      U l         U R                  R                  U R                   5        U R                  R                  U5      U l        U R                  R
                  U l        U $ r   )r   r*   r   r   r   r   r(   s     r   r*   "EvalWithTempExprNode.analyse_types  sd    #33AA#F(()=)=>!//==cB&&++	r   c                 :    U R                   R                  U5        g r   )r   rG   r9   s     r   free_subexpr_temps'EvalWithTempExprNode.free_subexpr_temps   s    %%d+r   c                 :    U R                   R                  U5        g r   )r   r   r9   s     r   generate_subexpr_disposal_code3EvalWithTempExprNode.generate_subexpr_disposal_code#  s    11$7r   c                 ~    U R                  U5        U R                  R                  U5        U R                  U5        g r   )r   r   r   r   r9   s     r   r   -EvalWithTempExprNode.generate_evaluation_code&  s2    T"33D9%r   )r   r   r   r   N)r   r   r   r   r   r   r   r   r5   r*   r   r   r   r"   r#   r   r   r   r     s6     "?3H,20+,8&r   r   c                   :    \ rS rSrSS/rS rS rS rS rS r	S	r
g
)LetNodei/  r   rQ   c                 T    U R                  U5        UR                  U l        X l        g r   )r   r   rQ   )r   r   rQ   s      r   r   LetNode.__init__;  s     9%88	r   c                 p    U R                   R                  U5        U R                  R                  U5        g r   )r   r_   rQ   r(   s     r   r_   LetNode.analyse_declarations@  s(    11#6		&&s+r   c                     U R                   R                  U5      U l         U R                  R                  U5      U l        U $ r   )r   rd   rQ   r(   s     r   rd   LetNode.analyse_expressionsD  s6    #33GGLII11#6	r   c                 ~    U R                  U5        U R                  R                  U5        U R                  U5        g r   )r   rQ   rX   r   r9   s     r   rX   LetNode.generate_execution_codeI  s0    T"		))$/%r   c                 p    U R                   R                  X5        U R                  R                  X5        g r   )r   ri   rQ   rj   s      r   ri   %LetNode.generate_function_definitionsN  s(    ::3E		//:r   )rQ   r   r   N)r   r   r   r   rq   r   r_   rd   rX   ri   r"   r#   r   r   r   r   /  s'     %f-K
,
&
;r   r   c                   B    \ rS rSr/ rS/rS rS rS rS r	S r
S rS	rg
)TempResultFromStatNodeiS  rQ   c                 n    Xl         UR                  U l        X l        UR                  U l        SU l        g )Nr   )
result_refr   rQ   r   ry   )r   r   rQ   s      r   r   TempResultFromStatNode.__init__\  s)    $88	OO	r   c                 :    U R                   R                  U5        g r   r^   r(   s     r   r_   +TempResultFromStatNode.analyse_declarationsc  ra   r   c                 F    U R                   R                  U5      U l         U $ r   rc   r(   s     r   r*   $TempResultFromStatNode.analyse_typesf  rf   r   c                 6    U R                   R                  5       $ r   )r   r   r|   s    r   r   "TempResultFromStatNode.may_be_nonej  s    **,,r   c                 x    U R                  5       U R                  l        U R                  R	                  U5        g r   )r5   r   r   rQ   rX   r9   s     r   r;   +TempResultFromStatNode.generate_result_codem  s&    &*kkm#		))$/r   c                 :    U R                   R                  X5        g r   rh   rj   s      r   ri   4TempResultFromStatNode.generate_function_definitionsq  rl   r   )rQ   ry   r   r   r   N)r   r   r   r   r   rq   r   r_   r*   r   r;   ri   r"   r#   r   r   r   r   S  s.     H(K,-0;r   r   c                   .    \ rS rSrSr\rS rS rS r	Sr
g)HasNoGilNodeiu  zH
Simple node that evaluates to
* 0 if gil
* 1 if nogil
* 2 if maybe gil
c                     U $ r   r#   r(   s     r   r*   HasNoGilNode.analyse_types~  s    r   c                     g r   r#   r9   s     r   r;   !HasNoGilNode.generate_result_code  r3   r   c                 >    [        [        U R                  5      5      $ r   )strintin_nogil_contextr|   s    r   r6   "HasNoGilNode.calculate_result_code  s    3t,,-..r   r#   N)r   r   r   r   rp   r   r   r*   r;   r6   r"   r#   r   r   r   r   u  s     D/r   r   N) r   r   r   r   
PyrexTypesr   r   r
   r   rO   rs   r   ExprNoder   
LetRefNodeStatNoder   r   r   r#   r   r   <module>r     s       % .= =!. !H*!T *!ZnN nb 3  3F&&9--| &&R 
!;ennl !;H;Y// ;D/> /r   