
    -Ph{	                       d dl Z  e j        di dededededededed	ed
edededededededededededededededededededededed ed!ed"ed#ed$ed%ed&ed'ed(ed)e d dlZd dl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mZmZmZmZmZmZmZ d*d,lmZmZ d*d-lmZ d*d.lmZ d*d/lmZ d*d0lmZ d*d1lmZmZ d*d2lmZ d*d3lm Z m!Z!m"Z"m#Z#m$Z$ d*d4lm%Z% d*d5l&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z1m2Z2 d*d6lm&Z& d*d7lm3Z3 d8d9lm4Z4 d*d:l5m6Z6 d*d;lm7Z7 d8d<l8m9Z9 d*d=l:m;Z;m<Z< d*d>l=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZL d*d?lmMZM eNeOfZP G d@ dA          ZQ eQ            ZR e            ZSe,e-fdBe,ej         fdCe,ejT        fdCe,ejU        fdCe,ejV        fdCe-e,fdDe-ejW        fdEe-ejX        fdEej         e,fdFejT        e,fdFejU        e,fdFejV        e,fdFejY        ejY        fdGejZ        ejZ        fdHiZ[dI Z\dJ Z]dK Z^ddLZ_dM Z`dN ZadO ZbdP ZcdQ ZddR Ze G dS dTe          Zf G dU dVef          Zg G dW dXef          Zh G dY dZeh          Zi G d[ d\ei          Zj G d] d^ei          Zk G d_ d`eh          Zl G da dbel          Zm G dc ddel          Zn G de dfel          Zo G dg dhel          Zp G di djel          Zqdk Zr G dl dmel          Zs G dn doel          Zt G dp dqet          Zu G dr dseh          Zv G dt dueh          Zw G dv dweh          Zx G dx dyef          Zy G dz d{ef          Zz G d| d}ef          Z{ G d~ de{          Z| G d def          Z} G d deh          Z~ G d de{          Z G d deh          Z G d def          Z G d deh          Z G d def          Z G d de          Z G d def          Z G d def          Z G d def          Z G d deh          Z G d deh          Z G d def          Z G d de          Z G d de          Z G d de          Z G d de          Z G d def          Z G d de          Z G d de          Z G d def          Z G d def          Z G d de          Z G d def          Z G d de          Z G d def          Z G d de          Z G d de          Z G d def          Z G d de          Z G d de          Z G d de          Z G d def          Z G dĄ def          Z G dƄ def          Z G dȄ def          Z G dʄ def          Z G d̄ de          Z G d΄ de          Z G dЄ de{          Z G d҄ de          Z G dԄ de          Z G dք def          Z G d؄ def          Z G dڄ def          Z G d܄ def          Z G dބ def          Z G d def          Z G d deg          Z G d d          Z G d defe          Z G d def          Z G d def          Z G d defe          Z G d def          Z G d def          Z G d defe          Z G d de          Z G d d          Z G d def          Z G d def          Z G d def          Z G d de          Z G d  de          Z G d de          Z G d de          Z G d def          Z G d d	e          Z G d
 de          Z G d de          Z G d deæ          Z G d deh          Z G d de          Z G d de          Z G d deh          ZȐd Zej        ej        ej        ej        dZ G d def          Z G d deϦ          Z G d deϦ          Z G d  d!eϦ          Z G d" d#eϦ          Z G d$ d%eϦ          Z G d& d'eԦ          Z G d( d)eԦ          Z֐d* Z G d+ d,eԦ          ZeeeӐd-Zِd. Z G d/ d0ef          Zېd1Zܐd2Zݐd3Zސd4Zߐd5Z G d6 d7ef          Z G d8 d9ef          Z G d: d;e          Z G d< d=e          Z G d> d?ef          Z G d@ dAef          Z	 ej        Zn# e$ r dB ZY nw xY wi dCej        dDej        dEej        dFej        dGej        dHej        dIej        dJej        dKej        dLej        dMej        dNej        dOej        dPej        dQej        dRej        dSej        ej        ej        ej        edT dU dVZdW Z G dX dYef          Z  G dZ d[e           Zd\ Z G d] d^e           Z G d_ d`e          Z G da dbe          Z G dc dde          Z G de dfe          Z G dg dhe          Z G di dje          Z	 G dk dle          Z
 e	j        dm          j        Z eh dn          Z G do dpe
          Z G dq dre          Z G ds dtef          Z G du dvef          Z G dw dxef          Zdydzd{d|d|d}d~d{d|d	Z G d d          Z G d defe          Z G d dee          Zeeeeeeeeeee	e
e
eedZddZ G d def          Z G d de          Z G d de          Z G d de          Z G d deg          Z G d de          Z  G d de           Z! G d de          Z" G d de          Z# G d de          Z$d Z% G d de          Z& G d de          Z' G d de          Z( G d de          Z) G d de(          Z* G d def          Z+ G d def          Z, G d def          Z- G d def          Z. G d def          Z/dS (      Nerrorwarning	warn_onceInternalErrorCompileErrorUtilityCodeTempitaUtilityCodeStringEncodingoperatorlocal_errorsreport_errorNamingNodes
PyrexTypespy_object_type	list_type
tuple_typeset_type	dict_typeunicode_type
bytes_type	type_typeBuiltinSymtabUtilsfind_coercion_errordebug_disposal_codedebug_temp_allocdebug_coercionbytearray_type
slice_typememoryview_typebuiltin_sequence_typesbuild_line_tableinspectcopyospathlibresys   )r   r   r   r   r   r   CannotSpecializeperformance_hint)r   r	   )r$   )r
   )r   )r   )NodeSingleAssignmentNode)r   )c_char_ptr_typer   typecast
error_typeunspecified_type)	TypeSlots)r   r   r   r   r   r   r   r    r!   sequence_typesr"   )r   )r      )r   )AnnotationItem)Future)print_call_chain)r   r   )
to_pythranis_pythran_supported_type#is_pythran_supported_operation_typeis_pythran_exprpythran_func_typepythran_binop_typepythran_unaryop_typehas_np_pythranpythran_indexing_codepythran_indexing_type!is_pythran_supported_node_or_nonepythran_typepythran_is_numpy_func_supportedpythran_get_func_include_filepythran_functor)PythranExprc                   (     e Zd ZdZ fdZd Z xZS )NotConstantNc                     t           j        +t                                          |           t           _        t           j        S N)rK   _objsuper__new__)cls	__class__s    Y/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Compiler/ExprNodes.pyrP   zNotConstant.__new__B   s-    #$wws33K    c                     dS )Nz<NOT CONSTANT> selfs    rS   __repr__zNotConstant.__repr__H   s    rT   )__name__
__module____qualname__rN   rP   rY   __classcell__rR   s   @rS   rK   rK   ?   sL        D                      rT   rK   zGCannot convert Unicode string to 'bytes' implicitly, encoding required.z5Unicode objects only support coercion to Py_UNICODE*.zBCannot convert 'bytes' object to str implicitly, decoding requiredz8Cannot convert 'bytes' object to Py_UNICODE*, use 'str'.z?Cannot convert 'char*' to unicode implicitly, decoding requiredzcython.pymutex cannot be copiedz*cython.pythread_type_lock cannot be copiedc                 L    t                                          }||S |j        d         rwt           fdt          j        t          j        t          j        t          j        fD                       r0 d         j	        r|S |j        d         dv r|S d d         j
        z  S |S )Nc_string_encodingc              3       K   | ]}|v V  	d S rM   rV   ).0t
type_tuples     rS   	<genexpr>z&find_coercion_error.<locals>.<genexpr>k   s?       r ra!z/ r r r r r rrT   r+   )asciiutf8z\'%s' objects do not support coercion to C types with non-ascii or non-utf8 c_string_encodingr   )coercion_error_dictget
directivesanyr   r0   c_uchar_ptr_typec_const_char_ptr_typec_const_uchar_ptr_typeis_pyobjectname)rd   defaultenverrs   `   rS   r   r   f   s    

!
!*
-
-C
{
.,
- 
 r r r rJ,F
Hc,6,LjNo,q r r r r r
 a=$ 	GN^/04EEENqt~  @A  uB  uG  G  G
rT   c                 t    t           t          t          t          d                    | j        d                   S )N)bytes	bytearraystrunicodec_string_type)r   r    r   ri   rj   )rr   s    rS   default_str_typerz   w   s3    #	 
 
c#.
)**+rT   c                      | D ]H}|!t          |j        t          t          f          s&|j        dk     rt	          |j        dd           IdS )z
    Raise a warning on nodes that are known to have negative numeric values.
    Used to find (potential) bugs inside of "wraparound=False" sections.
    Nr   zfthe result of using negative indices inside of code sections marked as 'wraparound=False' is undefinedr+   level)
isinstanceconstant_resultintfloatr   pos)nodesnodes     rS   check_negative_indicesr      sl    
  * *<z$*>eMM<!##DH '(* * * *	* *rT   c                     |j         sc||                               }|t          u rC|j        r<t	          |j                  dk    r$	 |j        d         j        }n# t          $ r Y nw xY w||j         r|Y|                                rE	 |j        |j	                 }|                               S # t          t          t          f$ r Y nw xY w fd|j        D             }t	          |          dk    r|                                S d S )Nr+   r   c                 h    h | ].}|j         rt          |          n|                              /S rV   )
is_starredinfer_sequence_item_type
infer_typerb   itemrr   s     rS   	<setcomp>z+infer_sequence_item_type.<locals>.<setcomp>   sM     
 
 
 48?\$S$///X[H\H\
 
 
rT   )is_sequence_constructorr   r   cf_statelenrhsAttributeErrorhas_constant_resultargsr   
ValueError	TypeError
IndexErrorpop)rr   seq_node
index_nodeseq_typer   
item_typess   `     rS   r   r      sQ   + 	**3//Hz!!  S):%;%;q%@%@'037HH%   D @!j&D&D&F&F!,}Z%?@ s+++ 	:6   

 
 
 
 
 
 

 z??a>>###4s$   	A 
A)(A)B3 3CCc                 H    d |D             }d|v rdS | t          |          fS )a  
    Recursively generate a deduplication key from a sequence of values.
    Includes Cython node types to work around the fact that (1, 2.0) == (1.0, 2), for example.

    @param outer_type: The type of the outer container.
    @param item_nodes: A sequence of constant nodes that will be traversed recursively.
    @return: A tuple that can be used as a dict key for deduplication.
    c                    g | ]}|t           d t          d           fn|j        r,t          |j        |j        r|j        nd g|j        z             nt|j        r't          |j        |j        |j	        |j
        f          nF|                                r1|j        |j        |j        t           u rt          |j                  nd fnd S rM   )r   typer   make_dedup_key
is_literalmult_factorr   is_slicestartstopstepr   r   )rb   r   s     rS   
<listcomp>z"make_dedup_key.<locals>.<listcomp>   s     
 
 
  /3ltDzz**gk  hD ^DIDO(U(8(8QU'VY]Yb'bcccNRm ^DI
DIty'IJJJ W[VnVnVpVpdi-,0I,G,Gd4'(((TS S
 
 
rT   N)tuple)
outer_type
item_nodes	item_keyss      rS   r   r      sG    
 
 
 
 
I ytuY''''rT   c                     | dS | j         t          j        k    r| j        dk    rdS | j         j        rd| j        j        d| j        j        ddfS d| j        j        z  dfS )	N)__Pyx_CppExn2PyErr();F*)r   TzAtry { throw; } catch(const std::exception& exn) {PyErr_SetString(z+, exn.what());} catch(...) { PyErr_SetNone(z); }Fzc%s(); if (!PyErr_Occurred())PyErr_SetString(PyExc_RuntimeError, "Error converting c++ exception.");)r   r   c_char_typevaluero   entrycname)exception_values    rS   get_exception_handlerr      s    --

*"8
8
8#s**,,			)  
  %+++%+++	-
  	2  %+-  	rT   c                    |r|rX| j                             t          j        dd                     |                     |                     d|                     d S |                     |                     d|                     d S d S )NErrOccurredWithGILExceptions.c__Pyx_ErrOccurredWithGIL()PyErr_Occurred())globalstateuse_utility_coder   load_cachedputlnerror_goto_if)codecheck_py_exceptionr   nogils       rS   maybe_check_py_errorr      s     D 	D--'(<nMMO O OJJt))*FLLMMMMMJJt))*<cBBCCCCCD DrT   c                 (   t          |          \  }}|                     d           |                     d|z             |r)|                     |                     ||                     t          | |||           |                     d           |r|                     d           |                     |           |r|                                  |                     |                     |                     |                     d           d S )Ntry {z%s} catch(...) {Tdeclare_gilstate})r   r   error_goto_if_nullr   put_ensure_gilput_release_ensured_gil
error_goto)r   r   inside	py_resultr   r   raise_py_exceptionr   s           rS   translate_cpp_exceptionr      s   -B?-S-S**JJwJJtf} <

4**9c::;;;13>>>JJ    3T222JJ!""" '$$&&&JJts##$$$JJsOOOOOrT   c                     | j         dk    sJ | j        dS | j        j        rdS t          | j        t                    r| j        j        dk    rdS dS )N+TFr   )exception_checkr   is_namer~   CharNoder   )r   s    rS   needs_cpp_exception_conversionr      si    3&&&&#t # u$&11 d6J6PTW6W6Wt5rT   c                    t          |          \  }}	t          |          \  }
}|                     d           |                     |                    d|z                       t          | |	||           |                     d           |                     d|z             t          | |||           |                     d           |r|                     d           |                     |
           |r|                                  |                     |                     |                     |                     d           |                     d           |r|                     d           |                     |           |r|                                  |                     |                     |                     |                     d           d S )Nr   z__pyx_local_lvalue = %s;r   Tr   r   )r   r   declaration_coder   r   r   r   )r   r   lhs_typelhs_coderhs_codelhs_exc_valassign_exc_valr   handle_lhs_exclhc_check_py_exchandle_assignment_excassignment_check_py_excs               rS   translate_double_cpp_exceptionr   	  s   '<['I'I$N$5J>5Z5Z22JJwJJx(()Ch)NOOPPP/e<<<JJwJJ)H45556UCCCJJ    3T222JJ$%%% '$$&&&JJts##$$$JJsOOOJJ    3T222JJ~ '$$&&&JJts##$$$JJsOOOOOrT   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dZeZej        j         dk    r e! e"j#        d                    Z$ne!d             Z$d Z%d	 Z&d
 Z'd Z(d Z)d Z*d Z+d_dZ,d Z-d Z.d`dZ/d Z0d`dZ1d Z2d Z3d Z4d Z5d Z6d Z7d Z8d Z9d Z:d Z;d Z<d  Z=d! Z>d" Z?d# Z@d$ ZAd% ZBd& ZCdad(ZDd) ZEd* ZFd+ ZGd, ZHd- ZId. ZJd/ ZKd0 ZLd1 ZMd2 ZNd3 ZOd4 ZPd5 ZQd6 ZRd7 ZSd8 ZTd9 ZUd: ZVd; ZWd< ZXd= ZYd> ZZd? Z[d@ Z\dA Z]	 	 dbdBZ^d_dCZ_dD Z`dE ZadF ZbdG ZcdH Zd	 	 dcdIZedJ ZfdK ZgdL ZhdM ZidN ZjdO ZkdddPZldQ ZmdR ZndS ZodT ZpdU ZqdV ZrdW ZsdX ZtdY Zuded\Zvewd]             Zxd^ ZydS )fExprNodeNTFcpythonsubexprs)fgetc                     | j         S rM   )r   rW   s    rS   child_attrszExprNode.child_attrs  s
    = rT   c                     d S rM   rV   rX   rr   s     rS   analyse_annotationszExprNode.analyse_annotations      rT   c                 `    t          |d           t          | j        j        d|d          )Nznot implemented.z not implemented)r9   r   rR   rZ   )rX   method_names     rS   not_implementedzExprNode.not_implemented  s?    &7888'+~'>'>'>LN N 	NrT   c                     dS Nr   rV   rW   s    rS   	is_lvaluezExprNode.is_lvalue      qrT   c                 D    |                                  o| j        j         S rM   )r   r   is_memoryviewslicerW   s    rS   is_addressablezExprNode.is_addressable  s    ~~D	(D$DDrT   c                 (    | j         j        o| j        S rM   )r   ro   is_temprW   s    rS   is_ephemeralzExprNode.is_ephemeral  s     y$55rT   c                     g }| j         D ]U}t          | |          }|At          |          t          u r|                    |           @|                    |           V|S rM   )r   getattrr   listextendappend)rX   r   rp   r   s       rS   subexpr_nodeszExprNode.subexpr_nodes  sm     M 	' 	'D4&&D::%%LL&&&&LL&&&rT   c                 F    | j         r| j        S |                                 S rM   )r   	temp_codecalculate_result_coderW   s    rS   resultzExprNode.result  s(    < 	0
 >!--///rT   c                     |r!| j         r| j        j        r| j        j        r|S d| _        d                    |rdnd|          S )NTz{}({})__PYX_STD_MOVE_IF_SUPPORTEDz	std::move)r   r   is_cpp_classis_referencehas_temp_movedformat)rX   r  optionals      rS   _make_move_result_rhszExprNode._make_move_result_rhs  sX     	T\ 	di.D 	TYMc 	M"Y<<k[abbbrT   c                 T    |                      |                                 d          S )NTr  )r  r  rW   s    rS   move_result_rhszExprNode.move_result_rhs  s#    ))$++--$)GGGrT   c                     |                      |          }|j        s-|j        s&|j        o| j        }|                     ||           }|S )Nr  )	result_asr	  needs_refcountingis_rvalue_referencer   r  )rX   r   r  requires_moves       rS   move_result_rhs_aszExprNode.move_result_rhs_as  sY    %%! 	TT%; 	T 4EM//]AR/SSFrT   c                 f    t          |           rt          |           S |J t          | |          S rM   )rD   r:   )rX   type_s     rS   pythran_resultzExprNode.pythran_result  s<    ,T22 	$d###   $&&&rT   c                     dS )zZ
        Subtypes may return False here if result temp allocation can be skipped.
        TrV   rW   s    rS   is_c_result_requiredzExprNode.is_c_result_required  s	     trT   c                     | j         r?| j        j        r3|t          k    r(t	          |t          |                                           S t	          ||                                 |                                           S rM   )r   r   ro   r   r1   r  ctyperX   r   s     rS   r  zExprNode.result_as  sc    L 	ATY2 	A&& D.$++--@@@djjllDKKMM:::rT   c                 6    |                      t                    S rM   )r  r   rW   s    rS   r   zExprNode.py_result!  s    ~~n---rT   c                     | j         p| j        S rM   )result_ctyper   rW   s    rS   r  zExprNode.ctype%  s      -DI-rT   c                     d S rM   rV   rW   s    rS   get_constant_c_result_codez#ExprNode.get_constant_c_result_code*  s	     trT   c                     d S rM   rV   rW   s    rS   calculate_constant_resultz"ExprNode.calculate_constant_result5  s	     	rT   c                 :    | j         t          uo| j         t          uS rM   r   constant_value_not_setnot_a_constantrW   s    rS   r   zExprNode.has_constant_resultA  #    #+AA :#>9	:rT   c                 0    t          | j        d           d S )NzInvalid compile-time expressionr   r   rX   denvs     rS   compile_time_valuezExprNode.compile_time_valueE  s    dh9:::::rT   c                 P    t          | j        d|j        j        d|           d S )Nz"Error in compile-time expression: : )r   r   rR   rZ   )rX   es     rS   compile_time_value_errorz!ExprNode.compile_time_value_errorI  s;    dhhK   !!% 	& 	& 	& 	& 	&rT   c                     |                                  r| j        S |                                 }||S t          | j        d           d S )Nz Exception value must be constant)r   r   r#  r   r   rX   rr   r  s      rS   as_exception_valuezExprNode.as_exception_valueM  sX    
 ##%% 	('' 0022Mdh:;;;;;rT   c                 0    t          | j        d           d S )NzCannot assign to or delete thisr,  r   s     rS   analyse_target_declarationz#ExprNode.analyse_target_declaration^  s    dh9:::::rT   c                 0    t          | j        d           d S )Nz=Cannot use anything except a name in an assignment expressionr,  r   s     rS   0analyse_assignment_expression_target_declarationz9ExprNode.analyse_assignment_expression_target_declarationa  s    dhWXXXXXrT   c                 X    |                      |          }|                                 |S rM   )analyse_typescheck_constrX   rr   r   s      rS   analyse_const_expressionz!ExprNode.analyse_const_expressionf  s.    
 !!#&&rT   c                 ,    |                      |          S rM   r<  r   s     rS   analyse_expressionszExprNode.analyse_expressionso  s     !!#&&&rT   c                 ,    |                      |          S rM   )analyse_target_types)rX   rr   r   s      rS   analyse_target_expressionz"ExprNode.analyse_target_expressionu  s     ((---rT   c                 Z    |                      |          }|                    |          }|S rM   )r<  coerce_to_boolean)rX   rr   r   bools       rS   analyse_boolean_expressionz#ExprNode.analyse_boolean_expression{  s-    !!#&&%%c**rT   c                 |    |                      |          }|                    |                              |          S rM   )r<  rG  coerce_to_simpler>  s      rS   analyse_temp_boolean_expressionz(ExprNode.analyse_temp_boolean_expression  s9     !!#&&%%c**;;C@@@rT   c                     t          | dd           dS t          fd|                                 D             d          S )Nr   rV   c                 :    g | ]}|                               S rV   )type_dependencies)rb   r   rr   s     rS   r   z.ExprNode.type_dependencies.<locals>.<listcomp>  s'    QQQDD**3//QQQrT   )r   sumr  r   s    `rS   rO  zExprNode.type_dependencies  sN     4&&22QQQQD<N<N<P<PQQQSUVVVrT   c                     t          | dd           }||S t          | dd           }||j        S |                     d           d S )Nr   r   r   )r   r   r   rX   rr   r   r   s       rS   r   zExprNode.infer_type  sY    
 tVT**Kgt,,:\*****rT   c                 N    | j         p| j        p| j        j        p| j        j        S rM   )r   r   r   is_arrayis_cfunctionrW   s    rS   nonlocally_immutablezExprNode.nonlocally_immutable  s'     ^$,^$)2D^	H^^rT   r   c           
          t          | j        | t          | j        t          |          |t          j                            S )z
        Return a node that represents the (type) result of an indexing operation,
        e.g. for tuple unpacking or iteration.
        r   r   r   baseindex)	IndexNoder   IntNoderw   r   c_py_ssize_t_typerX   r[  s     rS   inferable_item_nodezExprNode.inferable_item_node  sM    
 GHCJJJD`5b 5b 5b c c c 	crT   c                     d S rM   rV   r   s     rS   analyse_as_modulezExprNode.analyse_as_module  	     trT   c                     d S rM   rV   r   s     rS   analyse_as_typezExprNode.analyse_as_type  rc  rT   c                     |                      |          }|r9|j        r2|j        r+	 |                    |j                  S # t          $ r Y nw xY w|r|j        rt          | j        d           |S )NzType is not specific)re  is_fusedfused_to_specific
specializeKeyErrorr   r   )rX   rr   r   s      rS   analyse_as_specialized_typez$ExprNode.analyse_as_specialized_type  s    ##C(( 	DM 	c&; 	s'<===    	4DM 	4$(2333s   A 
AAc                     d S rM   rV   r   s     rS   analyse_as_extension_typez"ExprNode.analyse_as_extension_type  rc  rT   c                 0    |                      d           d S )Nr<  r   r   s     rS   r<  zExprNode.analyse_types  s    _-----rT   c                 ,    |                      |          S rM   rA  r   s     rS   rD  zExprNode.analyse_target_types  s    !!#&&&rT   c                 \    | j         r"| j         j        r|                                  d S d S d S rM   )r   ro   	gil_errorr   s     rS   nogil_checkzExprNode.nogil_check  sD     9 	. 	NN	 	 	 	rT   c                 ^    |j         r#| j        j        rt          | j        d           d S d S d S )Nz3Assignment of Python object not allowed without gil)r   r   ro   r   r   r   s     rS   gil_assignment_checkzExprNode.gil_assignment_check  sK    9 	S. 	S$(QRRRRR	S 	S 	S 	SrT   c                 .    |                                   dS NF)	not_constrW   s    rS   r=  zExprNode.check_const  s    urT   c                 0    t          | j        d           d S )Nz$Not allowed in a constant expressionr,  rW   s    rS   rx  zExprNode.not_const  s    dh>?????rT   c                 .    |                                   dS rw  )addr_not_constrW   s    rS   check_const_addrzExprNode.check_const_addr  s    urT   c                 0    t          | j        d           d S )NzAddress is not constantr,  rW   s    rS   r{  zExprNode.addr_not_const  s    dh122222rT   c                     | j         S rM   r   rW   s    rS   result_in_tempzExprNode.result_in_temp  s    
 |rT   c                 *    |                                  S rM   r  rW   s    rS   target_codezExprNode.target_code  s    ))+++rT   c                 0    |                      d           d S )Nr  ro  rW   s    rS   r  zExprNode.calculate_result_code  s    455555rT   c                 T   | j         r$t          d| j        j        d| j                  | j        }|j        sg|j        rt          j	        }n+| j
        s$|j        s|                                 s	d | _         d S |j                            || j                  | _         d S d | _         d S )Nz!Temp allocated multiple times in r1  
manage_ref)r  RuntimeErrorrR   rZ   r   r   is_voidro   r   r   result_is_usedr   r  	funcstateallocate_tempuse_managed_ref)rX   r   r   s      rS   allocate_temp_resultzExprNode.allocate_temp_result   s    > 	p,DNLcLcLceiememnoooy| 		" !0) T-D HaHaHcHc !%!^99!5 : 7 7DNNN "DNNNrT   c                    | j         s| j        sd S | j        rMt          j                            | j        d                                                   f| j        dd          z   nd}| j        r't          d| j        d| j	        j
        d|          t          d| j	        j
        d|          |j                            | j                    | j         | _        d | _         d S )Nr   r+   z(?)ztemp z released multiple times in z at z"no temp, but release requested in )r  r  r   r'   pathbasenameget_descriptionold_tempr  rR   rZ   r  release_temp)rX   r   r   s      rS   release_temp_resultzExprNode.release_temp_result  s    ~ 
	3& W[W_j27##DHQK$?$?$A$ABBDtxPQPRPR|SSejC} 3"lMMM4>#:#:#:CC$A B B B #lN+++SS$2 3 3 3##DN333rT   c                     |                                  s<|                    |                                 |                                            dS dS )z|
        Make sure we own a reference to result.
        If the result is in a temp, it is already a new reference.
        N)r  
put_increfr  r  rX   r   s     rS   make_owned_referencezExprNode.make_owned_reference!  sL    
 ""$$ 	9OODKKMM4::<<88888	9 	9rT   c                     |                                  s7|                    |                                 | j        | j                    dS dS )zJ
        Make sure we own the reference to this memoryview slice.
        have_gilN)r  put_incref_memoryviewslicer  r   in_nogil_contextr  s     rS   make_owned_memoryviewslicez#ExprNode.make_owned_memoryviewslice)  sh    
 ""$$ 	P++DKKMM499=9N5N , P P P P P	P 	PrT   c                 d   |                      |           |                    | j                   | j        r|                     |           |                     |           | j        rD| j        j        s:| j        j        s0| 	                    |           | 
                    |           d S d S d S d S rM   ) generate_subexpr_evaluation_codemark_posr   r   r  generate_result_coder   	is_stringis_pyunicode_ptrgenerate_subexpr_disposal_codefree_subexpr_tempsr  s     rS   generate_evaluation_codez!ExprNode.generate_evaluation_code2  s     	--d333dh< 	,%%d+++!!$'''< 	*!4 	*	8R 	* //555##D)))))		* 	* 	* 	* 	* 	*rT   c                 ^    |                                  D ]}|                    |           d S rM   )r  r  rX   r   r   s      rS   r  z)ExprNode.generate_subexpr_evaluation_codeC  s>    &&(( 	0 	0D))$////	0 	0rT   c                 0    |                      d           d S )Nr  ro  r  s     rS   r  zExprNode.generate_result_codeG  s    344444rT   c                    | j         r-|j                            t          j        dd                     | j        r| j        j        s| j        j        r*| 	                    |           | 
                    |           |                                 rD|                    |                                 |                                 | j                    d S d S | 	                    |           d S )NMoveIfSupportedCppSupport.cppr  )r
  r   r   r   r   r   r   r  r  r  r  r  put_decref_clearr  r  r  s     rS   generate_disposal_codezExprNode.generate_disposal_codeJ  s    	R--+,=?OPPR R R< 
	6y" .di&@ .33D999''---{{}} L%%dkkmmTZZ\\595J1J & L L L L LL L
 //55555rT   c                 ^    |                                  D ]}|                    |           d S rM   )r  r  r  s      rS   r  z'ExprNode.generate_subexpr_disposal_codeZ  s@     &&(( 	. 	.D''----	. 	.rT   c                 d   | j         r| j        j        s| j        j        r+|                     |           |                     |           n| j        j        r+|                    d|                                 z             n`| j        j	        rT|                    d|                                 z             |                    d|                                 z             | j
        r/|j                            t          j        dd                     d S d S |                     |           d S )N%s = 0;z%s.memview = NULL;z%s.data = NULL;r  r  )r   r   r  r  r  r  ro   r   r  r   r
  r   r   r   r   r  s     rS   generate_post_assignment_codez&ExprNode.generate_post_assignment_code`  s<   < 	6y" >di&@ >33D999''----& >

9t{{}}45555- >

/$++--?@@@

,t{{}}<===" R 11+,=?OPPR R R R RR R //55555rT   c                     d S rM   rV   )rX   r   r   overloaded_assignmentr   r   s         rS   generate_assignment_codez!ExprNode.generate_assignment_coder  s	    
 	rT   c                     d S rM   rV   rX   r   ignore_nonexistings      rS   generate_deletion_codezExprNode.generate_deletion_codey  s	     	rT   c                     | j         r%| j        j        s|                     |           d S d S |                     |           d S rM   )r   r   r  r  r  r  s     rS   
free_tempszExprNode.free_temps  sY    < 	*9$ /((...../ / ##D)))))rT   c                 ^    |                                  D ]}|                    |           d S rM   )r  r  )rX   r   subs      rS   r  zExprNode.free_subexpr_temps  s<    %%'' 	! 	!CNN4    	! 	!rT   c                     d S rM   rV   rX   rr   r   s      rS   generate_function_definitionsz&ExprNode.generate_function_definitions  r   rT   c                 |    |                     |                                 |                                 |           d S rM   )put_decref_setr  r  rX   r   r   s      rS   generate_decref_setzExprNode.generate_decref_set  s0    DKKMM4::<<=====rT   c                 |    |                     |                                 |                                 |           d S rM   )put_xdecref_setr  r  r  s      rS   generate_xdecref_setzExprNode.generate_xdecref_set  s0    T[[]]DJJLL#>>>>>rT   c                     |r| j         s^|r | j        r|r|                     |           d S |                    |                                 |                                            d S d S rM   )
cf_is_nullcf_maybe_nullgenerate_xgotref
put_gotrefr  r  )rX   r   handle_nullmaybe_null_extra_checks       rS   generate_gotrefzExprNode.generate_gotref  s{     	= 	= = 2 =.=%%d+++++tzz||<<<<<	= 	=rT   c                 z    |                     |                                 |                                            d S rM   )put_xgotrefr  r  r  s     rS   r  zExprNode.generate_xgotref  .    

55555rT   c                 z    |                     |                                 |                                            d S rM   )put_giverefr  r  r  s     rS   generate_giverefzExprNode.generate_giveref  r  rT   c                 z    |                     |                                 |                                            d S rM   )put_xgiverefr  r  r  s     rS   generate_xgiverefzExprNode.generate_xgiveref  s.    $++--66666rT   c                 ^    |                                  D ]}|                    |           d S rM   )r  annotater  s      rS   r  zExprNode.annotate  s<    &&(( 	  	 DMM$	  	 rT   c                 J	   | }| j         }|                     ||          r| S |j        }|r|j        s|j        }|j        r|j        }|j        s|j        r|j        ru|j        sn|j        rg|j	        j        r[|j	        }|
                                D ]?}|                    |          r(||_         |j         j        |_        d|j        _        | c S @|j        rt          | j        d           n%|j        r	|j        r| S t          | j        d           t"          | _         | S | j        2t'          | j        d| j                  }|                    ||           |j        r)ddlm} |j         j        s~|j         j        rt3          |||          }n|j         j        r1t6                              ||                              ||          }n|j        st          | j        d|d	           n|j         j        rd|_        |j                             || j         | j!        
          s]|j         j"                            |j"                  rd}	|j         |f}
nd}	|j         j"        |j"        f}
t          | j        |	|
z             n|j        r|j#        rn|j$        *tK          |j                                      ||          }n|j         j        s8|tL          u r|j         j'        rtQ          ||          }ntS          |||          }|j         *                    |          stW          |||          }nftY          |          rt[          |j                   r|S tY          |j                   r%t[          |          r|S tS          |||          }n|j         j        r3|r|j.        rt_          | j        d|z             ta          |||          }n|j1        r-||k    r'|2                    |          rtg          |||          }n|th          j5        u r-||k    r'|2                    |          stm          |||          }nZ|j         |k    sOto          |j                   to          |          k    s*|2                    |          s| 8                    |           |S )NTzType is not specializedz/Cannot coerce to a type that is not specialized )rp   r   r+   
MemoryViewzCannot convert 'z' to memoryviewslice)	broadcastcopyingz3Memoryview '%s' not conformable to memoryview '%s'.z-Different base types for memoryviews (%s, %s)r   zTCannot pass Python object as C++ data structure reference (%s &), will pass by copy.)9r   check_for_coercion_errorr	  ref_base_typeis_cv_qualifiedcv_base_typerg  rU  is_ptr	base_type"get_all_specialized_function_typessame_asr   usedr   r   is_null_ptrr2   coercion_typeNameNode	coerce_tor   r  r  ro   CoerceToMemViewSliceNoderT  CythonArrayNodefrom_carrayis_errorwritable_neededconforms_tois_memview_broadcastis_memview_copy_assignmentdtypeis_noner   NoneNoder   is_intCoerceIntToBytesNodeCoerceToPyTypeNode
subtype_ofPyTypeTestNoder=   r;   r  r   CoerceFromPyTypeNode
is_complexassignable_fromCoerceToComplexNoder   soft_complex_typecoerce_from_soft_complexrw   fail_assignment)rX   dst_typerr   srcsrc_typeused_as_reference	signaturer   r  msgtups              rS   r  zExprNode.coerce_to  s<     9((377 	K$1 	.X%: 	.-H# 	-,H 	 1 	 % 
$h.? 
$O
$(0(:(G
$ $-!)!L!L!N!N $ $I ((22 $#,$'HN	)-	#	$   Sdh 9::::% S(/ Sdh QRRR"DIK)DH2D4FGGGDNN8S)))& I	/$$$$$$8. /8' R23#FFCCX& R)55c3??II(TWXXCC!* R$((FNhhPR R R 8+ 4/3H,x++H@Y484S , U U 	/x~--hn== =S!h0M!hnhn<$(C#I...! 1	/{ =$,sw''11(C@@x+ J:--#(/-23<<0cIII
 x**844 =(h<<CX&& 	/+DSX+N+N 	/JSX&& 	/(22  
$S#H===CCX! 	/  wX%: wHjmuuw w w 'xc::CC! 	/h&&**844 '%c8S99CC*666h&&..x88 '*3#>>CC H((CMMS]],J,JhNfNfgoNpNp,J$$X...
rT   c                 l   t          | d          r| j        j        nd }| j        j        rd| j                                         dnd}|j        rd|                                 dnd}|                    | j        |          }t          | j        d| j         d| d| d| |rdnd | 
           d S )	Nr   z (alias of '')r  zCannot assign type ''z to 'r   )	hasattrr   rp   r   
is_typedefresolveassignment_failure_extra_infor   r   )rX   r  src_namesrc_resolveddst_resolvedextra_diagnosticss         rS   r  zExprNode.fail_assignment7  s   &-dG&<&<F4:??$AEAU]=di&7&7&9&9====[]@H@S[<h&6&6&8&8<<<<Y[$BB49hWWdhGTY G G G GG G!-G)1rG3DG G	
 	
 	
 	
 	
rT   c                     |r|sd}t          | j        |f||          }|"t          | j        || j        |dz             dS |r|                     |           dS dS )Nz)Cannot assign type '%(FROM)s' to '%(TO)s')FROMTOTF)r   r   r   r   r  )rX   r  rr   failrq   messages         rS   r  z!ExprNode.check_for_coercion_errorB  s     	B 	BAG%ty(&;WcJJ$(Gty&I&IIJJJ4 	  ***4urT   c                 B    |                      t          j        |          S rM   )r  r   r   r   s     rS   coerce_to_pyobjectzExprNode.coerce_to_pyobjectN  s    ~~j7===rT   c           
         |                                  r+t          | j                  }t          | j        ||          S | j        }|j        s|j        r| S |t          j	        u r| S |j
        s|j        s|j        s|j        rt          | |          S |j        rr|j        rk|j                            d          rQt%          | j        t'          | j        | t)          j        d                    g                               |          S |j        r/t1          |j                  dk    }t          | j        ||          S t5          | j        d|z             | S )Nr   r   zoperator bool)obj	attributefunctionr   r   z%Type '%s' not acceptable as a boolean)r   rH  r   BoolNoder   r   is_enumr  r   c_bint_typero   r  r  is_floatCoerceToBooleanNoder  scopelookupSimpleCallNodeAttributeNoder
   EncodedStringr<  	is_ctupler   
componentsr   )rX   rr   
bool_valuer   s       rS   rG  zExprNode.coerce_to_booleanQ  s   
 ##%% 	8d233JDHJ,68 8 8 8 y< 	4= 	KZ+++K 	 	 	t} 	&tS111 	4: 	$*2C2CO2T2T 	!&H$.2N2_2_a a a	   's++	,
 ^ 	T_--2JDHJ,68 8 8 8 $(CdJKKKKrT   c                 ^    | j         j        r| n|                     t          j        |          S rM   )r   r  r  r   r^  r   s     rS   coerce_to_indexzExprNode.coerce_to_indexp  s(    y'^ttT^^J<XZ]-^-^^rT   c                 N    |                                  r| S t          | |          S rM   )r  CoerceToTempNoder   s     rS   coerce_to_tempzExprNode.coerce_to_tempt  s+       	/K#D#...rT   c                 X    |                                  r| S |                     |          S rM   )	is_simpler8  r   s     rS   rK  zExprNode.coerce_to_simple{  s-    >> 	,K&&s+++rT   c                 *    |                                  S rM   )r  rW   s    rS   r:  zExprNode.is_simple  s    
 ""$$$rT   c                 N    	 |                                  S # t          $ r Y dS w xY wrw  )r:  	ExceptionrW   s    rS   try_is_simplezExprNode.try_is_simple  s9    	>>### 	 	 	55	s    
$$c                     | j         r| j         j        s| j         j        sdS |                                 r	| j        d uS dS NFT)r   ro   r   r   r   rW   s    rS   may_be_nonezExprNode.may_be_none  sQ    9 	di3 	"i:	5##%% 	4't33trT   c                     d S rM   rV   rW   s    rS   as_cython_attributezExprNode.as_cython_attribute      trT   PyExc_TypeErrorrV   c                 R    |                                  rt          | |||          S | S rM   )rA  NoneCheckNode)rX   r  r   format_argss       rS   as_none_safe_nodezExprNode.as_none_safe_node  s1      	 ug{CCCKrT   c                     d                                 }|D ]-}||v r	 t          ||          }|||<   # t          $ r Y *w xY w | |j        fi |S )zInstantiate this node class from another node, properly
        copying over all attributes that one would forget otherwise.
        z1cf_state cf_maybe_null cf_is_null constant_result)splitr   r   r   )rQ   r   kwargs
attributes	attr_namer   s         rS   	from_nodezExprNode.from_node  s    
 INNPP
# 	* 	*IF""*i00 %*y!! "    s48&&v&&&s   5
AAc                     dS )z
        Gets the module.path that this node was imported from.

        Many nodes do not have one, or it is ambiguous, in which case
        this function returns a false value.
        NrV   rW   s    rS   !get_known_standard_library_importz*ExprNode.get_known_standard_library_import  s	     trT   FrM   r   FNN)FTFN)rE  rV   )zrZ   r[   r\   r!  r   
annotationr  r  r  r  is_numpy_attributegenerator_arg_tagr   is_dict_literalis_set_literalis_string_literalis_attributeis_subscriptr   is_buffer_accessis_memview_indexis_memview_slicer  r  r   r
  	is_targetr   r(  r   r*   implementationrp   propertyr   
attrgetterr   r   r   r   r   r   r  r  r  r  r  r  r  r  r   r  r#  r%  r   r/  r3  r6  r8  r:  r?  rB  rE  rI  rL  rO  r   rV  r`  rb  re  rk  rm  r<  rD  rs  ru  r=  rx  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   rG  r5  r8  rK  r:  r>  rA  rC  rI  classmethodrO  rQ  rV   rT   rS   r   r   &  sT       " LDJIHONf $ONLLH !&GNIJ,O
)++h$7H$7
$C$CDDD		! 	! 
	!  N N N
  E E E6 6 6  0 0 0c c c cH H H  ' ' ' '  ; ; ; ;. . .. . .
	 	 	
 
 
: : :; ; ;& & &< < <"; ; ;Y Y Y
  ' ' '. . .  	A 	A 	AW W W+ + +_ _ _
c c c c  
  
    
. . .' ' '  S S S  @ @ @  3 3 3
  , , ,6 6 6" " "  $9 9 9P P P* * *"0 0 05 5 56 6 6 . . .6 6 6$ INGK      * * *! ! !  
> > >? ? ? 16/3= = = =6 6 66 6 67 7 7
     F F FP	
 	
 	

 
 
 
> > >  >_ _ _/ / /, , ,% % %          ' ' ['     rT   r   c                        e Zd ZdZdgZdZ fdZe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 )_TempModifierNodez[Base class for nodes that inherit the result of their temp argument and can modify it.
    argFc                 N    t                                          ||           d S Nrh  )rO   __init__rX   r   rh  rR   s      rS   rl  z_TempModifierNode.__init__  s&    #&&&&&rT   c                     | j         j        S rM   rh  r   rW   s    rS   r   z_TempModifierNode.type      x}rT   c                 6    | j                             |          S rM   rh  r   r   s     rS   r   z_TempModifierNode.infer_type      x""3'''rT   c                 D    | j                             |          | _         | S rM   )rh  r<  r   s     rS   r<  z_TempModifierNode.analyse_types  s    8))#..rT   c                 4    | j                                         S rM   )rh  r%  rW   s    rS   r%  z+_TempModifierNode.calculate_constant_result  s    x11333rT   c                 4    | j                                         S rM   rh  rA  rW   s    rS   rA  z_TempModifierNode.may_be_none      x##%%%rT   c                 4    | j                                         S rM   rh  r:  rW   s    rS   r:  z_TempModifierNode.is_simple      x!!###rT   c                 4    | j                                         S rM   rh  r  rW   s    rS   r  z _TempModifierNode.result_in_temp      x&&(((rT   c                 4    | j                                         S rM   rh  rV  rW   s    rS   rV  z&_TempModifierNode.nonlocally_immutable      x,,...rT   c                 4    | j                                         S rM   rh  r  rW   s    rS   r  z'_TempModifierNode.calculate_result_code      x   rT   c                     d S rM   rV   r  s     rS   r  z&_TempModifierNode.generate_result_code  r   rT   c                 :    | j                             |           d S rM   rh  r  r  s     rS   r  z/_TempModifierNode.generate_post_assignment_code      ..t44444rT   c                 6    | j                             |          S rM   )rh  r  r  s     rS   r  z&_TempModifierNode.allocate_temp_result  s    x,,T222rT   c                 :    | j                             |           d S rM   rh  r  r  s     rS   r  z_TempModifierNode.free_temps      D!!!!!rT   )rZ   r[   r\   __doc__r   r   rl  rc  r   r   r<  r%  rA  r:  r  rV  r  r  r  r  r  r]   r^   s   @rS   rg  rg    s        wHG' ' ' ' '   X( ( (  4 4 4& & &$ $ $) ) )/ / /! ! !  5 5 53 3 3" " " " " " "rT   rg  c                       e Zd Zg Zd Zd ZdS )AtomicExprNodec                     d S rM   rV   r  s     rS   r  z/AtomicExprNode.generate_subexpr_evaluation_code  r   rT   c                     d S rM   rV   r  s     rS   r  z-AtomicExprNode.generate_subexpr_disposal_code   r   rT   N)rZ   r[   r\   r   r  r  rV   rT   rS   r  r    s9         H      rT   r  c                   8    e Zd ZdZeZdZd Zd Zd Z	d Z
d ZdS )PyConstNoder+   Nc                     dS Nr+   rV   rW   s    rS   r:  zPyConstNode.is_simple  r   rT   c                     dS rw  rV   rW   s    rS   rA  zPyConstNode.may_be_none      urT   c                     | S rM   rV   r   s     rS   r<  zPyConstNode.analyse_types      rT   c                     | j         S rM   r   rW   s    rS   r  z!PyConstNode.calculate_result_code  
    zrT   c                     d S rM   rV   r  s     rS   r  z PyConstNode.generate_result_code  r   rT   )rZ   r[   r\   r   r   r   rs  r:  rA  r<  r  r  rV   rT   rS   r  r    sp         JDK            rT   r  c                   6     e Zd ZdZdZdZd Zd Z fdZ xZ	S )r  r+   Py_NoneNc                     d S rM   rV   r-  s     rS   r/  zNoneNode.compile_time_value#  rD  rT   c                     dS NTrV   rW   s    rS   rA  zNoneNode.may_be_none&  rD  rT   c                     |j         s&|j        s|j        st          | j        d|z             t                                          ||          S )NzCannot assign None to %s)ro   r   r  r   r   rO   r  rX   r  rr   rR   s      rS   r  zNoneNode.coerce_to)  sW    $ 	C(C 	CxGX 	C$(6ABBBww  3///rT   )
rZ   r[   r\   r  r   r   r/  rA  r  r]   r^   s   @rS   r  r    sg         GEO    0 0 0 0 0 0 0 0 0rT   r  c                       e Zd ZdZeZd ZdS )EllipsisNodePy_Ellipsisc                     t           S rM   )Ellipsisr-  s     rS   r/  zEllipsisNode.compile_time_value7  s    rT   N)rZ   r[   r\   r   r  r   r/  rV   rT   rS   r  r  0  s/         EO    rT   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eefd            ZdS )	ConstNoder+   Nc                     dS r  rV   rW   s    rS   r:  zConstNode.is_simpleC  r   rT   c                     dS r  rV   rW   s    rS   rV  zConstNode.nonlocally_immutableF  r   rT   c                     dS rw  rV   rW   s    rS   rA  zConstNode.may_be_noneI  r  rT   c                     | S rM   rV   r   s     rS   r<  zConstNode.analyse_typesL  r  rT   c                     dS r  rV   rW   s    rS   r=  zConstNode.check_constO  rD  rT   c                 *    |                                  S rM   r  rW   s    rS   r#  z$ConstNode.get_constant_c_result_codeR  s    ))+++rT   c                 *    t          | j                  S rM   )rw   r   rW   s    rS   r  zConstNode.calculate_result_codeU      4:rT   c                     d S rM   rV   r  s     rS   r  zConstNode.generate_result_codeX  r   rT   c                 X   t           }|t          j        u s|dk    s|dk    r|j        rt	          |           S |j        st          j        rt          }n0|j        rt          }n!|t          u rt          }n|t          u rt          }|j        |u r || ||          }n || |||          }|S )NNULLr   r"  r   r   r   )r  r   c_null_ptr_typer  NullNoder  r)  r]  r*  	FloatNoder   	BytesNoder   UnicodeNoder   )r   r   r   r   rQ   r  s         rS   for_typezConstNode.for_type[  s    :---&EQJJDKJC== [ 
	J2 
	 CC] 	CCZCC\!!C8tSE?KKKFFSEoVVVFrT   )rZ   r[   r\   r   rs  r:  rV  rA  r<  r=  r#  r  r  staticmethodr(  r  rV   rT   rS   r  r  ;  s        
 JK          , , ,     3I    \  rT   r  c                   4    e Zd Zej        Zd Zd Zd Zd Z	dS )r'  c                     | j         | _        d S rM   r"  rW   s    rS   r%  z"BoolNode.calculate_constant_resultz      #zrT   c                     | j         S rM   r  r-  s     rS   r/  zBoolNode.compile_time_value}  r  rT   c                 r    | j         j        r| j        rdndS t          t	          | j                            S )NPy_TruePy_False)r   ro   r   rw   r   rW   s    rS   r  zBoolNode.calculate_result_code  s6    9  	( $
:99
:s4:'''rT   c                    || j         k    r| S |t          u r| j         t          j        u r| S |j        r8| j         j        r,t          | j        | j        | j	        t          j                  S |j        r8| j         j        r,t          | j        | j        | j	        t          j                  S t                              | ||          S NrX  )r   r   r   	bool_typero   r  r'  r   r   r   r   r)  r  r  rX   r  rr   s      rS   r  zBoolNode.coerce_to  s    ty  K~%%$)w7H*H*HK 	(DI$4 	(
 $ 4&( ( ( ( ? 	-ty4 	-
 $ 4+- - - - ""43777rT   N)
rZ   r[   r\   r   r)  r   r%  r/  r  r  rV   rT   rS   r'  r'  v  sX        !D* * *  ( ( (8 8 8 8 8rT   r'  c                   *    e Zd Zej        ZdZdZd ZdS )r  r  r   c                     | j         S rM   r  rW   s    rS   r#  z#NullNode.get_constant_c_result_code  r  rT   N)	rZ   r[   r\   r   r  r   r   r   r#  rV   rT   rS   r  r    s5        %DEO    rT   r  c                   .    e Zd Zej        Zd Zd Zd ZdS )r   c                 8    t          | j                  | _        d S rM   )ordr   r   rW   s    rS   r%  z"CharNode.calculate_constant_result  s    "4:rT   c                 *    t          | j                  S rM   )r  r   r-  s     rS   r/  zCharNode.compile_time_value  r  rT   c                 :    dt          j        | j                  z  S )Nz'%s')r
   escape_charr   rW   s    rS   r  zCharNode.calculate_result_code  s    24:>>>>rT   N)	rZ   r[   r\   r   r   r   r%  r/  r  rV   rT   rS   r   r     sI        !D/ / /  ? ? ? ? ?rT   r   c                       e Zd ZdZdZdZed             Zed             Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd ZdS )r]  r  Nc                 r    t          j        t          t          j        | j                                      S rM   )r   strip_py2_long_suffixhexstr_to_numberr   rW   s    rS   	hex_valuezIntNode.hex_value  s(    *3u/B4:/N/N+O+OPPPrT   c                 N    t          t          j        | j                            S rM   )rw   r   r  r   rW   s    rS   base_10_valuezIntNode.base_10_value  s    5&tz22333rT   c                 j    t          j        | |fi | d|vr|                                 | _        d S d S )Nr   )r   rl  find_suitable_type_for_valuer   )rX   r   kwdss      rS   rl  zIntNode.__init__  sG    $,,t,,,99;;DIII rT   c                    | j         t          u r&	 |                                  n# t          $ r Y nw xY w| j        s&|                                 r| j        s| j        dk    rL| j        dk    rdpd}t          j	        | j         |df         }| j
        rt          j        || j
                  }nId| j         cxk    rdk     r+n n(| j
        r| j
        j        r| j
        }nt          j        }nt          j        }|S )NLLr6   r+   r   i   l        )r   r(  r%  r   is_c_literalr   unsignedlongnessr   modifiers_and_name_to_typer   widest_numeric_typer  c_long_typer   int_type)rX   ranksuitable_types      rS   r  z$IntNode.find_suitable_type_for_value  s2   #999..0000     	1++--	1}	1 $ 5 5MT)0q5AD&AdmBSUY[`B`aMy Y * >}di X X -5555555559 ;!1 ;$(IMM$.$:MM ' 0s   % 
22c           	         | j         |u r| S |j        s|t          j        u ru|                                 r?t          | j        dt          | j                  z  |t          | j                            S t          | j        | j
        |t                    S |j        r8|j        s1t          | j        | j
        | j        |d| j        | j                  }|S |j        r:t          | j        | j
        | j        t          j        d| j        | j                  }n-t          | j        | j
        | j        | j        | j                  }t&                              |||          S )Nz%d.0r  T)r   r   r   r  r  r  F)r   r   r  r  )r   r*  r   
float_typer   r  r   r   r   r   r   r)  
is_numericr  r]  r  r  ro   r  r  r  rX   r  rr   r   s       rS   r  zIntNode.coerce_to  s   9  K 	K(g.@"@"@'')) A #d>R:S:S1SZb16t7K1L1LN N N N !(1?A A A A  	K)< 	K484:tG[ (t$(MDMK K KD K! 	K484:tG[ ' 0u$(MDMK K KDD 484:tG[$(MDMK K KD
 ""43777rT   c                 r    t          | j        | j        | j        t          j        | j        | j                  S )N)r   r   r   r  r  )r]  r   r   r   r   r)  r  r  r   s     rS   rG  zIntNode.coerce_to_boolean  s7    HDJ 0']T]	< < < 	<rT   c                 ,   | j         j        rnt          j        | j                  }|dk    rt
          nt          } ||          }t          j        |          }|                    || j	                  | _
        d S |                                 | _
        d S )Nl     a$)r   ro   r   r  r   r  rw   r  
get_py_intr  result_coder#  )rX   r   r   	formatterplain_integer_strings        rS   r  z IntNode.generate_evaluation_code  s    9  	A
 '
33E$//SI#,9U#3#3 #(#>?S#T#T #/CT]SSD#>>@@DrT   c                 ,   | j         | j        }}|                                 }|si|sg| j        j        r[|d         dk    rO|d         dk    rC| j        j        t          j        j        k    rd}n!| j        j        t          j        j        k    rd}||z   |z   S )Nr   -r+   0r  L)	r  r  value_as_c_integer_stringr   r  r  r   c_longlong_typer  )rX   r  r  literals       rS   r#  z"IntNode.get_constant_c_result_code  s    !]DM(0022 	H 	$)*: 	wqzS?P?PU\]^U_cfUfUfy~!;!@@@:#9#>>>!H,,rT   c                    | j         }t          |          dk    r|S d}|d         dk    rd}|dd          }|d         dk    r|d         }|rB|dv r>|dd                                          r"t          t	          j        |                    }nr|dv rd|dd          z   }n`|d	v r%t          t          |dd          d                    }n6|                                r"| j        s| j        s|sd
t          |          z  }||z   S )Nr6   r  r   r  r+   r  oOxX0123456789oObBz0x%X)	r   r   isdigitrw   r   r  r   r  r  )rX   r   neg_signliteral_types       rS   r  z!IntNode.value_as_c_integer_string  s1   
u::??L8s??H!""IE8s?? 8L  /L,<<<qrrARARATAT< E/6677%%eABBi%%Cabb	1--..]]__ 	,T] 	,4= 	, , U+%rT   c                     | j         S rM   r  rW   s    rS   r  zIntNode.calculate_result_code;      rT   c                 B    t          j        | j                  | _        d S rM   )r   r  r   r   rW   s    rS   r%  z!IntNode.calculate_constant_result>  s    $24:>>rT   c                 4    t          j        | j                  S rM   )r   r  r   r-  s     rS   r/  zIntNode.compile_time_valueA  s    "4:...rT   )rZ   r[   r\   r  r  r  rc  r  r  rl  r  r  rG  r  r#  r  r  r%  r/  rV   rT   rS   r]  r]    s         HHL Q Q XQ 4 4 X4< < <
  68 8 8:< < <A A A	- 	- 	-     8     ? ? ?/ / / / /rT   r]  c                   @    e Zd Zej        Zd Zd Zd Zd Z	d Z
d ZdS )r  c                 8    t          | j                  | _        d S rM   )r   r   r   rW   s    rS   r%  z#FloatNode.calculate_constant_resultG  s    $TZ00rT   c                    t          | j                  }d|z                      d          }t          j        | j                  }||t          |                              d          fvrt          | j        d|z             |S )Nz%.330fr  zEUsing this floating point value with DEF may lose precision, using %r)	r   r   stripr   normalise_float_reprreprlstripr   r   )rX   r.  float_valuestr_float_value	str_values        rS   r/  zFloatNode.compile_time_valueJ  s    DJ''#k188==.tz::	_d;.?.?.F.Fs.K.KLLLDHehsstttrT   c                 "   |j         r8| j        j        r,t          | j        | j        | j        t          j                  S |j        r.| j        j         r"t          | j        | j        | j        |          S t          
                    | ||          S r  )ro   r   r*  r  r   r   r   r   r  r  r  r  s      rS   r  zFloatNode.coerce_toR  s     	)DI$6 	)
 $ 4') ) ) )  	!6 	
 $ 4    ""43777rT   c                     | j         S rM   r  rW   s    rS   r  zFloatNode.calculate_result_code_  r  rT   c                     | j         }t          |t                    sJ t          t	          |                    }|dk    rdS |dk    rdS |dk    rdS |S )Nnanz(Py_HUGE_VAL * 0)infPy_HUGE_VALz-infz(-Py_HUGE_VAL))r   r~   rw   r
  r   )rX   strvalcmpvals      rS   r#  z$FloatNode.get_constant_c_result_codeb  se    &#&&&&&eFmm$$U??&&u__ =v##MrT   c                     |                                  }| j        j        r"|                    | j        |          | _        d S || _        d S rM   )r#  r   ro   get_py_floatr   r  )rX   r   c_values      rS   r  z"FloatNode.generate_evaluation_codeo  sN    11339  	'#00WEED&DrT   N)rZ   r[   r\   r   c_double_typer   r%  r/  r  r  r#  r  rV   rT   rS   r  r  D  sv        #D1 1 1  8 8 8       ' ' ' ' 'rT   r  c                    t          j        |           }|	|j        r|S |                                }|                    |           }|r$|j        r|j        }|r|j        s|j        r|S |p|}ddlm} t          d          5  |d         |d         |d         dz
  f}	  |d| z  |d         j
        |	          }|j        j        d         j        }	t          |	t                    rS|	                    |          }	t          |	t                    r)|	j        }|r|j        s|j        r|cd d d            S |p|}n# t$          $ r Y nw xY wd d d            n# 1 swxY w Y   |S )
Nr+   )TreeFragmentTignorer   r6      
sizeof(%s))rp   initial_pos)r   parse_basic_typein_c_type_contextglobal_scoper-  is_typer   ro   r  r   filenamerootstatsexprr~   SizeofTypeNoder<  arg_typer   )
rp   r   rr   r  r$  global_entryr   r  declarationsizeof_nodes
             rS   _analyse_name_as_typer/  w  s   '--ES2##%%L&&t,,L ,   	T% 	)> 	K +*****	T	"	"	" * *1vs1vs1vax(	*&,|d':Q^abbbK &*038K+~66 *)77<<k>:: *&/D $!1 $S5J $#* * * * * * * * "MTE  	 	 	D		* * * * * * * * * * * * * * * Ls=   E!D==A.E8E=
E
E	E

EE Ec                   T    e Zd ZdZeZd ZddZd Zd Z	d Z
d Zd	 Zd
 Zd Zd ZdS )r  Tc                     | j         | _        d S rM   r"  rW   s    rS   r%  z#BytesNode.calculate_constant_result  r  rT   Nc                     t          j        | j        |||         | j        j                  }t	          | j        ||          S Nr"  )r
   bytes_literalr   encodingr  r   )rX   r   r   r   r   s        rS   as_sliced_nodezBytesNode.as_sliced_node  s=    ,TZd4-H$*J]^^FFFFrT   c                 4    | j                                         S rM   )r   
byteencoder-  s     rS   r/  zBytesNode.compile_time_value  s    z$$&&&rT   c                 ^    t          | j                            d          | j        |          S )Nz	ISO8859-1)r/  r   decoder   r   s     rS   re  zBytesNode.analyse_as_type  s&    $TZ%6%6{%C%CTXsSSSrT   c                 2    t          | j                  dk    S r  r   r   rW   s    rS   can_coerce_to_char_literalz$BytesNode.can_coerce_to_char_literal      4:!##rT   c                 X    t          | j                  }t          | j        ||          S r3  rH  r   r'  r   rX   rr   r3  s      rS   rG  zBytesNode.coerce_to_boolean  s*     $*%%

JOOOOrT   c                    | j         |k    r| S |j        rw|                                 st          | j        d           | S |j        rt          | j        d           | S t          | j        | j        t          | j                            S t          | j        | j        | j
                  }|j        rA|t          t          j        fv rt          j        |_         n|                     ||d           |S |t           j        t           j        fv r	||_         |S |t           j        t           j        t           j        fv r=|t           j        k    rt           j        nt           j        |_         t-          ||          S |                    t           j                  r|j        r|j        r	||_         |S t4                              |||          S )Nz?Only single-character string literals can be coerced into ints.zRBytes literals cannot coerce to Py_UNICODE/Py_UCS4, use a unicode literal instead.r"  Tr  )r   r  r=  r   r   is_unicode_charr   r   r  r  r   ro   r   r   r   r  r   r0   rm   rl   rn   c_void_ptr_typeCastNoder  r  is_constr  r  r  s       rS   r  zBytesNode.coerce_to  s   9  K? 	=2244 dh abbb' dh tuuuDHDJ,/
OO= = = = TEYZZZ 	NG,>???#.		--h$-GGGK*4j6VWWW DIK*5z7XZdZtuuu=EIj=j=j99(8 ID(+++%%j&@AA 	( H,= $	
 ""43777rT   c                 "   | j         j        r|                    | j                  }n`| j         j        r|                    | j                  }n9| j                                        }t          | j         t          j	        |          }|| _
        d S rM   )r   ro   get_py_string_constr   rG  get_string_constas_c_string_literalr1   r   rE  r  )rX   r   r  r  s       rS   r  z"BytesNode.generate_evaluation_code  s    9  	N--dj99FFY 	N**4:66FF j4466Gdi)CWMMF!rT   c                     d S rM   rV   rW   s    rS   r#  z$BytesNode.get_constant_c_result_code  rD  rT   c                     | j         S rM   r  rW   s    rS   r  zBytesNode.calculate_result_code  r  rT   rM   )rZ   r[   r\   r[  r   r   r%  r6  r/  re  r=  rG  r  r  r#  r  rV   rT   rS   r  r    s        
 D* * *G G G G' ' 'T T T$ $ $P P P$8 $8 $8L
" 
" 
"           rT   r  c                   t     e Zd ZdZdZdZeZd f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 xZS )r  TNc                     t                                          |||           ||| _        ||t          ur|| _        d S d S d S r3  )rO   rl  bytes_valuer   r   )rX   r   r   rP  r   rR   s        rS   rl  zUnicodeNode.__init__  sY    E5AAA"*DL 8 8DIII  8 8rT   c                     | j         | _        d S rM   r"  rW   s    rS   r%  z%UnicodeNode.calculate_constant_result  r  rT   c                 8    t          | j        | j        |          S rM   )r/  r   r   r   s     rS   re  zUnicodeNode.analyse_as_type  s    $TZ3???rT   c                     t          j        | j        |||         | j        j                  }| j        .t          j        | j        |||         | j        j                  }nd }t          | j        ||          S )N)r   rP  )r
   encoded_stringr   r5  rP  r4  r  r   )rX   r   r   r   r   rP  s         rS   r6  zUnicodeNode.as_sliced_node
  s    -JuT$')<> >'(6 tD143C3LN NKK K485kJJJJrT   c                 8   || j         u rn|j        rd|                                 st          | j        d           | S t          | j                  }t          | j        |t          |          |          S |j	        rt          | j        | j        |          S |j        sW|j        s#|j        s|j        s|j        r$|j        j        r| j        /t'          | j        | j                                      ||          S |j        d         rg	 | j                            |j        d                   }t'          | j        |                              ||          S # t.          t0          f$ r Y nw xY w| j                                        rTt'          | j        t5          j        | j                            d                                                  ||          S t          | j        d           n!|t8          ur|                     ||d	           | S )
NzhOnly single-character Unicode string literals or surrogate pairs can be coerced into Py_UCS4/Py_UNICODE.r   r   r   r   r   r  r`   rf   zUnicode literals do not support coercion to C types other than Py_UCS4/Py_UNICODE (for characters), Py_UNICODE* (for strings) or char*/void* (for auto-encoded strings).TrC  )r   rD  r=  r   r   r  r   r]  rw   r  r  ro   r  is_cpp_stringr  r  r  r  rP  r  r  rj   encodeUnicodeEncodeErrorLookupErrorisasciir
   BytesLiteralr   r  )rX   r  rr   	int_valuebyte_strings        rS   r  zUnicodeNode.coerce_to  sh   ty  %  	D2244 dhPQ Q Q DJI48(#i..+46 6 6 6& 	DtxtzIIII% 	D! @X%; @x @O@(0(:(B@ #/$TXT5EFFFPPQY[^___>"56 __&*j&7&7GZ8[&\&\  )EEEOOPXZ]^^^ /<    :%%'' @$TX^5PQUQ[QbQbcjQkQk5l5l ' ' ''0y3'?'?@$(MN N N N ^++))(Cd)CCCs   %E E32E3c                 2    t          | j                  dk    S r  r<  rW   s    rS   r=  z&UnicodeNode.can_coerce_to_char_literal:  r>  rT   c                 X    t          | j                  }t          | j        ||          S r3  r@  rA  s      rS   rG  zUnicodeNode.coerce_to_boolean=  s(    $*%%

JOOOOrT   c                     | j                                         rdS t          t          | j                             }|dk    rdS |dk    rdS dS )N      i  i )r   r\  r  max)rX   max_charvals     rS   estimate_max_charvalz UnicodeNode.estimate_max_charvalA  sW    : 	3#dj//**#3E!!57rT   c                 4    t          j        | j                  S rM   )r
   string_contains_surrogatesr   rW   s    rS   contains_surrogateszUnicodeNode.contains_surrogatesM  s    8DDDrT   c                    | j         j        r[t          j        | j                  r|                    d          | _        |                    t          j        | j        	                    d                              }|
                    | j                  }|d S |                    | j                   |                    | j        d|d|d|                    | j        | j                             |                    | j        d| j        z             d S | j        r!|                    | j                  | _        d S |                    | j                  | _        d S |                    | j                  | _        d S )Nustringunicode_escapez! = PyUnicode_DecodeUnicodeEscape(	, sizeof(z) - 1, NULL); z__Pyx_PyUnicode_READY(%s))r   ro   r
   string_contains_lone_surrogatesr   get_py_constr  rJ  r]  rY  get_cached_constants_writerr  r   r   r   put_error_if_negis_identifierintern_identifierrI  get_pyunicode_ptr_const)rX   r   
data_cname
const_codes       rS   r  z$UnicodeNode.generate_evaluation_codeP  s   9  	H=djII H $(#4#4Y#?#? !22"/
0A0ABR0S0STTV V
!==d>NOO
%F##DH---  ((("

"

"55d6FQQQ	ST T T ++H9D<LLN N N N N# H#'#9#9$*#E#E   #'#;#;DJ#G#G   #;;DJGGDrT   c                     | j         S rM   r  rW   s    rS   r  z!UnicodeNode.calculate_result_codek  r  rT   c                     | j         S rM   r  r-  s     rS   r/  zUnicodeNode.compile_time_valuen  r  rT   NNrM   )rZ   r[   r\   r[  rs  rP  r   r   rl  r%  re  r6  r  r=  rG  rg  rj  r  r  r/  r]   r^   s   @rS   r  r    s        MKD     * * *@ @ @K K K K$ $ $L$ $ $P P P
 
 
E E EH H H6           rT   r  c                       e Zd ZdZdS )IdentifierStringNodeTN)rZ   r[   r\   rs  rV   rT   rS   r|  r|  r  s        MMMrT   r|  c                   J    e Zd Zej        Zd Zd Zd Zd Z	d Z
dZd Zd Zd	S )
ImagNodec                 T    t          dt          | j                            | _        d S Ng        )complexr   r   r   rW   s    rS   r%  z"ImagNode.calculate_constant_result~  s$    &sE$*,=,=>>rT   c                 F    t          dt          | j                            S r  )r  r   r   r-  s     rS   r/  zImagNode.compile_time_value  s    sE$*--...rT   c                 :    | j                             |           | S rM   )r   create_declaration_utility_coder   s     rS   r<  zImagNode.analyse_types  s    	11#666rT   c                     dS rw  rV   rW   s    rS   rA  zImagNode.may_be_none  r  rT   c                     | j         |u r| S t          | j        | j                  }|j        rd|_        t          j        |_         t          	                    |||          S )Nr  r+   )
r   r~  r   r   ro   r   r   complex_typer  r  r  s       rS   r  zImagNode.coerce_to  s`    9  K
333 	-DL,DI ''h<<<rT   zConstructing complex numberc                     | j         j        r|                                 S | j         j        dt	          | j                  dS )Nz(0, ))r   ro   r  
from_partsr   r   rW   s    rS   r  zImagNode.calculate_result_code  sD    9  	K;;== "&)"6"6"6dj8I8I8I8IJJrT   c           
      $   | j         j        r|                    |                                 dt	          | j                  d|                    |                                 | j                             |                     |           d S d S )Nz = PyComplex_FromDoubles(0.0, ); )	r   ro   r   r  r   r   r   r   r  r  s     rS   r  zImagNode.generate_result_code  s    9  	'JJKKMMMM$*%%%%++DKKMM48DDDFG G G
   &&&&&	' 	'rT   N)rZ   r[   r\   r   c_double_complex_typer   r%  r/  r<  rA  r  gil_messager  r  rV   rT   rS   r~  r~  w  s        
 +D? ? ?/ / /    
= 
= 
= 0KK K K' ' ' ' 'rT   r~  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )NewExprNodeNc                 .   | j                             |          }||j        s#t          | j        d           t
          | _        d S |                     |           |                    | j                  }|| _	        || _
        |j        | _        | j        S )Nz/new operator can only be applied to a C++ class)cppclassre  r  r   r   r2   r   	cpp_checkget_constructor
class_typer   )rX   rr   r   constructors       rS   r   zNewExprNode.infer_type  s    },,S11<t0<$(MNNN"DIFs**4844 
$	yrT   c                 >    | j         |                     |           | S rM   )r   r   r   s     rS   r<  zNewExprNode.analyse_types  s!    9OOC   rT   c                     dS rw  rV   rW   s    rS   rA  zNewExprNode.may_be_none  r  rT   c                     d S rM   rV   r  s     rS   r  z NewExprNode.generate_result_code  r   rT   c                 :    d| j                                         z   S )Nznew )r  empty_declaration_coderW   s    rS   r  z!NewExprNode.calculate_result_code  s    >>@@@@rT   )	rZ   r[   r\   r   r   r<  rA  r  r  rV   rT   rS   r  r    sk         D    
    A A A A ArT   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 f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,dZ"d Z#d Z$d Z% fdZ&d Z'd Z(d Z)d  Z*d! Z+d" Z,d# Z-d$ Z.d% Z/	 	 d-d&Z0d' Z1d( Z2d,d)Z3d* Z4d+ Z5 xZ6S ).r  TFNr   r  c                     | j         S rM   )cython_attributerW   s    rS   rC  zNameNode.as_cython_attribute  s    $$rT   c                     | j         |                    | j                  | _         | j         | j         j        j        r| fS dS NrV   )r   r-  rp   r   is_unspecifiedr   s     rS   rO  zNameNode.type_dependencies  s?    :DI..DJ:!djo&D!7N2rT   c                    | j         |                    | j                  | _         | j         | j         j        t          u r| j        | j        S t          S | j         j        j        s| j         j        j        r!| j         | j         j        j         k    rt          S | j         j        t          u r*| j         | j         j        j         k    r| j        dv rt          S | j         j        j        r6| j         j        j        rt          S t          j        | j         j                  S | j         j        j        r&| j        r| j        j        r| j         j        s| j        S | j         j        S )N)rx   
basestring)r   r-  rp   r   r3   inferred_typer   is_extension_typeis_builtin_typer   r   rU  r,  is_builtin_scoper   CPtrTypero   r  might_overflowr   s     rS   r   zNameNode.infer_type  sA   :DI..DJ:4D!D!D!-))!!jo/ 	#4:?3R 	#
djo333 jo--
djo333	E^8^8^Z_) 	#z0 <%% "*4:?;;; z* .t/A .*1 .dj6O .--:?"rT   c                     	 |                     | j                  S # t          $ r! t          | j        d| j        z             Y d S w xY w)Nz"Compile-time name '%s' not defined)r-  rp   rj  r   r   r-  s     rS   r/  zNameNode.compile_time_value  s^    	N;;ty))) 	N 	N 	N$(@49LMMMMMM	Ns    'AAc                 N    | j         r| j         j        j        rd S | j         j        S rM   )r   r   ro   r   rW   s    rS   r#  z#NameNode.get_constant_c_result_code  s*    z 	TZ_8 	4zrT   c                 Z   |t           u r| j        }|rw|j        rp|j        }|rg|j        r'|j        r |                    |j        | j                  }t          | j        | j                  }||_        |
                    |           |S t                                          ||          S )Nrp   )r   r   rU  as_variable
is_builtinrG  declare_builtinrp   r   r  analyse_rvalue_entryrO   r  )rX   r  rr   r   	var_entryr   rR   s         rS   r  zNameNode.coerce_to#  s    
 ~%%JE  +  !-	   + R	0B R$'$7$7	$Q$Q	#DHTY???D!*DJ--c222Kww  3///rT   c                 L   | j         }| j        }| j        p|                    |          }|sb|j        rdS d}|j        j        s|j        d         sd}n'|j        rt          }n|
                    |          \  }}|"|r|j        d         dk    rt          nt          }n^|j        rW|j        rP	 |                    |j                  }n4# t          $ r' t!          | j        d| j         z             t$          }Y nw xY wd}|j        r-|j        dk    }	|j        s|                    |          r|	rd	nd
}|r2|j        r+|j        s$|j        st          }t1          |j        dd           |                    ||| j        | ||          x}| _        |r|j        s||_        dS dS dS )as  Implements PEP 526 annotation typing in a fairly relaxed way.

        Annotations are ignored for global variables.
        All other annotations are stored on the entry in the symbol table.
        String literals are allowed and not evaluated.
        The ambiguous Python types 'int' and 'long' are not evaluated - the 'cython.int' form must be used instead.
        NrV   annotation_typinginfer_typesFzR'%s' cannot be specialized since its type is not a fused argument to this functionprivatefrozenreadonlypubliczxAnnotation ignored since class-level attributes must be Python objects. Were you trying to set up an instance attribute?r6   )is_cdef
visibilitypytyping_modifiers)rp   rV  r   lookup_hereis_module_scoper)  r[  rj   is_py_class_scoper   analyse_type_annotationr3   rg  rh  ri  r,   r   r   r2   is_c_dataclass_scopero   can_coerce_to_pyobjectis_c_class_scoper  r   declare_var)
rX   rr   	as_targetrp   rV  r   	modifiersatyper  	is_frozens
             rS   declare_from_annotationz NameNode.declare_from_annotation6  sS    y_

3cood33 /	." I 1K ~&9:	K & K&#-#E#Ec#J#J 	5},5t#.:W[`:`:`((ft 'C$9 ''!,,S-BCCEE' ' ' '$(n)$% % % 'EEE	' #J' G  4@	$ G(D(DS(I(I G/8!FhJ  OS1 O5;L OPUP^ O&
 )KLMO O O "%eTX9}#, "1 ". ". .EDJ
  	*e. 	*)E	* 	* 	* 	*s   /C
 
.C;:C;c                     | j         }|s|                    | j                  }|r|j        r|j        S |r+|j        r$t          j        |j                  }|r	|j        r|S d S rM   )r   r-  rp   	as_moduleknown_standard_library_importr   'get_known_standard_library_module_scoper  )rX   rr   r   r,  s       rS   rb  zNameNode.analyse_as_modulev  s     
 	*JJty))E 	#U_ 	#?" 	U8 	CEDghhE . trT   c                 *   d }| j         rt          j        | j                   }n |j        rt          j        | j                  }|r|S | j        }|s|                    | j                  }|r'|j        s |j        rt          j
        |j                  }|r%|j        r|j        }|j        r|j        r|j        }|S | j        dk    rt          S |j        s?t          j        | j                  r&t          | j        d| j        d| j        d           d S )NobjectzFound C type name 'z6' in a Python annotation. Did you mean to use 'cython.z'?)r  r   r"  r#  rp   r   r-  r%  r  r    get_known_standard_library_entryr   ro   equivalent_typer   r   r   rR  s       rS   re  zNameNode.analyse_as_type  sb     	:.t/DEEDD" 	:.ty99D 	K
 	*JJty))E 	b 	b5+N 	b<U=`aaE 	U] 	:D ,D$8 ,+K9  !! $ 	J)DTY)O)O 	JDHHsws|s|s|  C  H  H  H  I  J  J  JtrT   c                     | j         }|s|                    | j                  }|r&|j        r|j        j        s|j        j        r|j        S d S rM   )r   r-  rp   r%  r   r  r  rX   rr   r   s      rS   rm  z"NameNode.analyse_as_extension_type  s]     
 	*JJty))E 	"U] 	"z+ "uz/I "z!trT   c                 0    |                      |d          S )NFis_assignment_expression_analyse_target_declarationr   s     rS   r8  z#NameNode.analyse_target_declaration  s    //e/TTTrT   c                 0    |                      |d          S )NTr  r  r   s     rS   r:  z9NameNode.analyse_assignment_expression_target_declaration  s    //d/SSSrT   c                 8   d| _         | j        sA|r |                    | j                  | _        n|                    | j                  | _        | j        rd| j        _        | j        s'| j         |j        }|                     ||            n6| j        r/| j        j	        r#| j        r|j        rt          | j        d           | j        s|j        d         rt          | j        d| j        z  d           |j        d         d	k    rt          }nt          }|r'|                    | j        || j                  | _        n&|                    | j        || j                  | _        | j        j        rt          | _        | j        j        rd| j        _        d S d S )
NTr  )r  z7Cannot redeclare inherited fields in Cython dataclasseszwarn.undeclaredzimplicit declaration of '%s'r+   r  F)ra  r   #lookup_assignment_expression_targetrp   r  r  rV  r  r  is_inheritedr   r   rj   r   r3   r   $declare_assignment_expression_targetr  is_declared_genericr!  r  is_variable)rX   rr   r  is_dataclassr   s        rS   r  z$NameNode._analyse_target_declaration  s   z 	8' 8 DDTYOO

 __TY77
: 	:79DJ4z 	Wdo93L ((L8H(IIIIj 	WTZ4 	W	W$'$<	W$(UVVVz 
	H~/0 Q"@49"LaPPP~m,55'%' H EEdiQUW[W_``

 __TYdhGG
:) 	/ .D: 	'%&DJ"""	' 	'rT   c                    |j         d         | _        | j        }|o|                    | j                  }|s7|                    | j        | j                  }|r|j        r|j        rd| _	        |st          j        | _        | S || _        d|_        |j        j        rddlm} |                    |           |                     |           | S )NinitializedcheckTr+   Buffer)rj   initialized_checkr   r-  rp   r  r   r  rG  r   r   r2   r   r  	is_bufferr  r  used_buffer_aux_varsr  rX   rr   r   r  s       rS   r<  zNameNode.analyse_types  s    !$0B!C
=JJty))E +++DItx@@ +U- +%. +&*DO &1	DJ
: 	/      ''...!!#&&&rT   c                    |                      |d           | j        }|j        rO|j        rH|j        s'|j        j        s|                                 s!|j        r|j        x}| _        |j        | _        |                                 s.t          | j	        d| j
        z             t          j        | _        d|_        |j        j        rddlm} |                    |           | S )NTra  zAssignment to non-lvalue '%s'r+   r  )analyse_entryr   rU  r  is_overridabler   r   fused_cfunctionr   r   rp   r   r2   r  r  r  r  r  r  s       rS   rD  zNameNode.analyse_target_types  s    3$///
 	'%"3 	'$ '
(A '$..JZJZ '_d_t '%*%66
!J	~~ 	.$(;diGHHH"-DI
: 	/      ''...rT   c                    |                      |           | j        }|j        rt          | _        |j        s|j        r%|j        r|j        rd| _        nd| _        d| _	        n!|j
        j        rd| _        d| _	        d| _        | S )Nr   r+   FT)r  r   r  r   r!  is_pyglobalr  rG  r   is_used_as_rvaluer   r   r  r  s      rS   r  zNameNode.analyse_rvalue_entry  s     	3
$ 	/ .D 
	( 0 
	( !EN !  %&D""Z* 	( DL%)D"#'D rT   c                     d| _         | j        rJ| j        }|j        r|j        s|                                  d S d S |j        r|                                  d S d S d S r  )r   r  r   r  rG  rr  r  r  s      rS   rs  zNameNode.nogil_check	  s    
! 	!JE !~ %NN$$$$$% %" !     	! 	!
! !rT   z"Accessing Python global or builtinc                    |                                   | j        }|j        }|s!|j        r| j        r| j        j        r| j        }|| _        |j        j        r*|j        s|j	        r|
                    d          | _        d S d S d S Nr  )check_identifier_kindr   r   ro   r  r  r,  r  r  is_cclass_var_entryname_in_module_statemodule_state_lookup)rX   rr   ra  r   r   s        rS   r  zNameNode.analyse_entry 	  s    ""$$$
z 	&d. 	&43E 	&"2	& %D	;& 	D!	D%*%>	D (+'?'?'C'CD$$$	D 	D 	D 	DrT   c                    | j         }|j        r|j        j        r|| _        |j        r`|j        j        s|j        j        rH|j        rAt          j	        | j
        d t                    }d|_        | j         j        |_        || _         d S |j        sa|j        s\|j        sW|j        sR|j        sM| j         j        r| j         j        | _         d S | j        s)t+          | j        d| j
        z             d S d S d S d S d S d S d S )NTz7'%s' is not a constant, variable or function identifier)r   r%  r   r  
type_entryr(  is_cpp_enumcreate_wrapperr   Entryrp   r   r  r,  rG  r  r  rU  r  r  is_cython_moduler   r   )rX   r   py_entrys      rS   r  zNameNode.check_identifier_kind/	  s]    
= 	$UZ9 	$#DO= 	gej0 	gEJ4J 	gPUPd 	g|DIt^DDH#'H !Z-HN!DJJJ. 	gE$5 	g"	g&+&8	g$	g z% g!Z3


* gdh Y\`\e efffff	g 	g 	g 	g 	g 	g 	g 	g 	g 	g
g grT   c                     | j         s| j        rdS | j        p|                    | j                  }|j        o|j         S rw  )r  r  r   r-  rp   r  r  r  s      rS   "is_cimported_module_without_shadowz+NameNode.is_cimported_module_without_shadowC	  sI      	D$9 	5
3cjj338u'8#88rT   c                     dS r  rV   rW   s    rS   r:  zNameNode.is_simpleI	  s    qrT   c                    | j         rf| j        r_| j        j        s| j        j        rGt	          | dd          rdS d| _        d}| j         D ]}|j                                        rd} n | `|S t                                                      S )N_none_checkingFT)	r   r   ro   r   r   r  r   rA  rO   )rX   rA  
assignmentrR   s      rS   rA  zNameNode.may_be_noneM	  s    = 	TY 	DI,A 	,0I,H	 t-u55  u"&D  K"m  
>--// "&KE #ww""$$$rT   c                     t                               |           rdS | j        }|r|j        rdS |j        p|j        p|j        p|j        S NTF)r   rV  r   
in_closureis_localis_argr  is_readonlyrX   r   s     rS   rV  zNameNode.nonlocally_immutableb	  sZ    ((.. 	4
 	( 	5~VV1AVUEVVrT   c                     d S rM   rV   r   s     rS   calculate_target_resultsz!NameNode.calculate_target_resultsj	  r   rT   c                     | j         }|7|j        s0|j        s)|j        s"|j        j        s|                                  dS dS r@  )r   rG  rU  r  r   rx  r  s     rS   r=  zNameNode.check_constm	  s\    
 "     
#	 
 NN5trT   c                 j    | j         }|j        s$|j        s|j        s|                                  dS dS r@  )r   
is_cglobalrU  r  r{  r  s     rS   r|  zNameNode.check_const_addrx	  sD    
  	E$6 	%:J 	!!!5trT   c                 d    | j         j        o| j         j         p| j         j        o| j         j        S rM   )r   r  r
  rU  r  rW   s    rS   r   zNameNode.is_lvalue	  s;    J" '
&&
 J# &J%	
rT   c                 4    | j         j        o| j        j         S rM   )r   r  r   r   rW   s    rS   r   zNameNode.is_addressable	  s    z%Jdi.J*JJrT   c                     dS r   rV   rW   s    rS   r   zNameNode.is_ephemeral	  s	     qrT   c                 p    | j         }|sdS | j         j        r| j        s
d|j        z  S | j        |j        z   S )N<error>(*%s))r   is_cpp_optionalra  r   r  r  s     rS   r  zNameNode.calculate_result_code	  sI    
 	9:% 	)dn 	)U[(('%+55rT   c                 r   | j         }|d S |j        r|j                            |j                   |j        r	|j        rd S |j        r|j        j        s
J d            |	                    | j         j
                  }|j        rt          j        }n|j        j        }| j        so|                    |                                 d|d|d           |                    d|                                 z             |                    d           |j                            t%          j        dd                     |                    d	|                                 d|d           | j        s|                    d
           |                    |                    |                                 | j                             |                     |           d S |j        r|j        j        s|j        j        s
J d            |	                    | j         j
                  }|j                            t%          j        dd                     |                    |                                 d|d|                    |                                 | j                             |                     |           d S |j        s|j        r|j        j        r|j        j        s
J d            |	                    | j         j
                  }|j        j        r|j                            t%          j        dd                     |                    d	|                                 d|d|                    |                                 | j                             n|                    |j                  }| j         j        j        }|j                            t%          j        dd                     |                    d|                                 d|rdnd|d|d|                    |                                 | j                  	           |                     |           d S |j        s|j        s|j        s|j        j        r| j        s| j        o| j          }|j        j        o| j!        }|j"        o| j!        }	|	r |j        #                    |j$                  }
n|j        %                    |j$                  }
|
r7|r7|j        j        s|s|	r)|&                    | j        || j'        |
           d S d S d S d S |j(        rR|j"        rM| j!        rH|j        #                    |j$                  }
|&                    | j        || j'        |
           d S d S d S d S )N,Python global or builtin not a Python objectz = PyObject_GetItem(, );if (unlikely(!%s)) {PyErr_Clear();GetModuleGlobalNameObjectHandling.cz__Pyx_GetModuleGlobalName(r   GetBuiltinNamez = __Pyx_GetBuiltinName(r  GetNameInClassz__Pyx_GetNameInClass(z(PyObject*)r  unbound_check_code))r   utility_coder   r   r  rG  is_pyclass_attrr   ro   rt  rp   r   builtins_cnamer,  namespace_cnamer  r   r  r   r   r   r   r  r  r  namespace_cname_in_module_statenamespace_cname_is_typer  r  from_closurer   r  
allow_nullr  r   cpp_optional_check_for_null_coder   check_for_null_codeput_error_if_unboundr  r  )rX   r   r   interned_cname	namespacer'  r)  raise_unboundmemslice_checkoptional_cpp_checkr#  s              rS   r  zNameNode.generate_result_code	  s\   
=F 	B--e.@AAA V	u V	uF" T	u:)YY+YYYY!33DJODDN 8"1		!K7	? -

!		&() ) )
 

1DKKMMABBB

+,,,--'(=?QRRT T TJJJKKMMMM"NN$% % % ?  

3JJt..t{{}}dhGGHHH  &&&&& :	uek&A :	u:)YY+YYYY!33DJODDN--'(8:LMMO O OJJ''tx@@@BC C C
   &&&&& -	u5#3 -	u8S -	u:)YY+YYYY!33DJODDN{* K 11+,ACUVVX X X


&//txHHHJK K K K #'"F"Fu{"S"S*.**:*R' 11+,<>PQQS S S


)@HbH'&//txHHHJK K K   &&&&&^ 	uu/ 	u53E 	uIf 	u #6tO<O  #Z:Ut?UN!&!6!Q4;Q! Q%*Z%P%PQVQ\%]%]""%*Z%C%CEK%P%P"! ym y9O ySa yew y))$(E4;Pew)xxxxxy y y y y y  	u%"7 	uD<R 	u!&!L!LU[!Y!Y%%dht7Las%ttttt	u 	u 	u 	u 	u 	urT   c                 l   | j         }|d S | j         j        j        r8t          |t                    r#| j        s|j        st          | j        d           |j	        r|j        j
        s
J d            |                    | j         j                  }|                    | j         j                  }| j         j        j        }	d}
|j        r2d}d}
|j                            t'          j        dd                     n|j        j        r"d}|                    t.          j                  }n`|j        rB| j        d	k    rd
nd}|j                            t'          j        |d                     d|z   }nJ t5          |                      |	r|
sd| d}|
r|	sJ |                    | j        |d|d|d|                                d           t:          r!t=          d           t=          d|z             |                    |           |                     |           d S | j        j!        r| "                    ||           n"| j        j#        r| $                    ||           d}| j        j%        rd}| j        j
        r9| j&        r1|'                    |           |j(        p| j         j)        p| j         j*        }|r| +                    |d           d}|j(        r<| ,                    ||-                    | .                                                     n| j/        s| j0        r<| 1                    ||-                    | .                                                     n>| ,                    ||-                    | .                                                     nd}|r|2                    |           | j        j!        s|se|r|3                                }|dk    rWti          || j        | 5                                d|d| j        j
        r| 5                                nd || j6                   n|7                    | 5                                d|d           n|8                    | .                                          }ts          | j                  rD|7                    d| 5                                d| 5                                d|d           nE|| 5                                k    r-|7                    | 5                                d|d           t:          r!t=          d           t=          d|z             |:                    |           n)|;                                r|:                    |           |                     |           d S )Nz?Literal list must be assigned to pointer at time of declarationr  F__Pyx_SetItemOnTypeDictTSetItemOnTypeDictzExtensionTypes.cPyDict_SetItemrP   SetNewInClassSetNameInClassr  __Pyx_z((PyObject*)r  (r  z"NameNode.generate_assignment_code:z"...generating disposal code for %s)r  r    = ;new (&) decltype(){};z)...generating post-assignment code for %s)<r   r   r  r~   ListNodelhs_of_first_assignmentin_module_scoper   r   r  ro   rt  rp   r(  r,  r)  	is_memberr   r   r   r   r  r  r   moddict_cnamer%  r
  rr  r   r   printr  r  r    generate_acquire_memoryviewslicer  generate_acquire_bufferrG  r  r  r  r  r*  r  r  r  r  r  r  r  r  r  r   r  r  r   r  r=   r  r  )rX   r   r   r  r   r   r   r/  r0  namespace_is_typenamespace_needs_typesetternassignedis_external_refr  s                   rS   r  z!NameNode.generate_assignment_code	  s
    
=FJO" 	_z#x'@'@ 	_4	_=@=P	_$(]^^^  i	!:)YY+YYYY!33DJODDN<<TZ=MNNI $
 0 H#(  * 3'+$ 11+,?ASTTV V V V, 	*) 55f6JKK		& *'+yI'='=OOCS 11+2I!M_2`2`aaa!A)d5kk)))  8)= 879777	,G5FGGG!!FFII"NNMMOOOO	%& & & # B:;;;:S@AAA&&t,,,NN4     y+ 855c4@@@@$ 8 ,,S$777Hy!  y$ 3
 ' 3,,T222&+&6&j$*:O&jSWS]SjO& E,,Tt,DDD#H' 	-00s}}TZZ\\7R7RSSSS# -#1 \ $ 9 9$djjll@[@[ \ \ \ \ $ 8 8s}}TZZ\\?Z?Z [ [ [ [',H& 3,,T2229/ 8 M, M!$!4!4!6!6*c113 $dh.2kkmmmmVVV D151F PD /1F	H H H H !JJT[[]]]]FFF'KLLLL!$!7!7

!E!E*4955 M JJJW[WbWbWdWdWdWdflflfl'mnnnn#t{{}}44 JJT[[]]]]FFF'KLLL& M>???EKLLL11$7777##%% 811$777NN4     rT   c           	          ddl m} |                    |                                 | j        | j        ||| j         | j                   dS )z
        Slices, coercions from objects, return values etc are new references.
        We have a borrowed reference in case of dst = src
        r+   r  )	lhs_cnamer   lhs_posr   r   r  first_assignmentN)r  r  put_acquire_memoryviewslicer  r   r   r  r  )rX   r   r   r  s       rS   rH  z)NameNode.generate_acquire_memoryviewslicen
  sf    
 	!     ..kkmmYH..!_ 	/ 	. 	. 	. 	. 	.rT   c                 j   t          |t                    p|                                }|r(|                    |                                           }nf|j                            | j        j        d          }|	                    |d|                    |                                           d           ddl
m} |                    |                                 || j        | j         | j        |           |s4|	                    d|z             |j                            |           d S d S )	NFr  r<  r=  r+   r  )is_initializedr   r   r  )r~   r  r  r  r  r  r  r   r   r   r  r  put_assign_to_bufferr  rC  r   r  )rX   r   r   
pretty_rhsrhstmpr  s         rS   rI  z NameNode.generate_acquire_buffer~
  s1     X..F#2D2D2F2F
 	K]]4::<<00FF^11$*/e1TTFJJVVVS]]4::<<-H-H-H-HIJJJ##DKKMM64:7;7S3S(,t 	$ 	= 	= 	=  	0JJy6)***N''/////	0 	0rT   c                    | j         d S | j         j        r| j         j        j        }|                    | j         j                  }|rd}nd| j         j        z  }|                    d|d|d|d|                    | j                  d	           d S | j         j	        r|j
                            t          j        dd	                     |                    | j         j                  }d
t          j        d|d}|r6|                    d|d|                    | j                  d           d S |                    | j        |           d S | j         j        j        s| j         j        j        r| j        s| j        r(|s&|                    | j        | j         | j                   | j         j        r|                     |d|           |rK| j        rD|                    |                                 |                                 | j                    d S |                    |                                 |                                 | j                    d S d S t?          | j        d           d S )NzPyErr_Clear(); elsezT{ PyErr_Clear(); PyErr_Format(PyExc_NameError, "name '%%s' is not defined", "%s"); }zif (unlikely(PyObject_DelItem(r  z>) < 0)) { if (likely(PyErr_ExceptionMatches(PyExc_KeyError)))   }PyObjectSetAttrStrr  __Pyx_PyObject_DelAttrStr(r  if (unlikely(zW < 0)) { if (likely(PyErr_ExceptionMatches(PyExc_AttributeError))) PyErr_Clear(); else T)r  r  r  z!Deletion of C names not supported) r   r%  r,  r'  rt  rp   r   r   r   r  r   r   r   r   r   module_cnamerr  r   ro   r   r  r  r.  r  r  r  put_xdecref_clearr  r  r   r  r   )rX   r   r  r0  r/  key_error_codedel_codes          rS   r  zNameNode.generate_deletion_code
  s   :FZ' -	A
(8I!33DJODDN! %!6 mJO$  JJJ !yy...%~~tx000023 3 3 3 3 Z# 	A--'(<>PQQS S S!33DJODDNN###^^^5H! :


 $88T__TX%>%>%>%>@A A A A A
 %%dh99999Z_( 	ADJO,N 	A? C% [.@ [--dh
DDYZZZ:( l((4Xj(kkk% C$*< C**4;;==$**,,59Z + A A A A A ))$++--7;z> * C C C C CC C $(?@@@@@rT   c           
      V   t          | dd          r| j        d         | j        d         | j        d         t          | j                  z
  dz
  f}| j        j        rd\  }}nd\  }}|                    |t          ||| j        z  t          | j                                       d S d S )	N	is_calledFr   r+   r6   )py_callzpython function (%s))c_callzc function (%s)size)r   r   r   rp   r   ro   r  r7   )rX   r   r   styletexts        rS   r  zNameNode.annotate
  s    4e,, 	]8A;TXa[3ty>>-IA-MNCy$ :?tt9tMM#~eTDI5ECPTPYNN[[[\\\\\	] 	]rT   c                 ,    | j         r| j         j        S d S rM   )r   r  rW   s    rS   rQ  z*NameNode.get_known_standard_library_import
  s    : 	<:;;trT   rR  rT  )7rZ   r[   r\   r   r  r  rC  r  r   r  r  r  r+  r   r  r  rC  rO  r   r/  r#  r  r  rb  re  rm  r8  r:  r  r<  rD  r  rs  r  r  r  r   r:  rA  rV  r  r=  r|  r   r   r   r  r  r  rH  rI  r  r  rQ  r]   r^   s   @rS   r  r    s        G#EJMJJEM% % %  # # #BN N N     
0 0 0 0 0&>* >* >* >*@    <	 	 	U U UT T T!' !' !'F  (  (  ,! ! ! 7KD D D Dg g g(9 9 9  % % % % %*W W W  	 	 	  
 
 
K K K  
6 6 6\u \u \u| INGKv! v! v! v!p. . . 0 0 0(0A 0A 0A 0Ad] ] ]      rT   r  c                   .    e Zd ZeZdgZd ZdZd Zd Z	dS )BackquoteNoderh  c                     | j                             |          | _         | j                             |          | _         d| _        | S r  )rh  r<  r   r   r   s     rS   r<  zBackquoteNode.analyse_types
  s<    8))#..8..s33rT   zBackquote expressionc                 B    t          | j        j                  | _        d S rM   )r
  rh  r   rW   s    rS   r%  z'BackquoteNode.calculate_constant_result
  s    #DH$<==rT   c           
         |                     |                                 d| j                                        d|                    |                                 | j                             |                     |           d S )Nz = PyObject_Repr(r  )r   r  rh  r   r   r   r  r  s     rS   r  z"BackquoteNode.generate_result_code
  s    

""$$$$''tx@@@B	C 	C 	C
 	T"""""rT   N)
rZ   r[   r\   r   r   r   r<  r  r%  r  rV   rT   rS   rn  rn  
  sV        
 DwH   )K> > ># # # # #rT   rn  c                   <    e Zd ZeZdZdZdZg dZd Z	dZ
d Zd ZdS )	
ImportNodeNFT)module_name	name_listmodule_namesc           
           j         M|                                j        r-|j        d         st          j        |j        j        vrd _         nd _          j        	                    |          }|
                    |           _         j        j        sJ  j        r5 j        	                    |          }|
                    |           _        nd j        j        v rtt           j        j         fdt!          t"          j         j        j                            d                    D                       	                    |           _         S )N
py2_importr   r   c                 F    g | ]}t          j        j        |           S r  )r|  rt  r   )rb   partrX   s     rS   r   z,ImportNode.analyse_types.<locals>.<listcomp>   sB     F F F %T%5%9FFFF F FrT   r   )r}   r$  parent_modulerj   r8   absolute_importcontextfuture_directivesrt  r<  r   r[  ru  r   	TupleNoder   mapr
   r0  rK  rv  )rX   rr   rt  ru  s   `   rS   r<  zImportNode.analyse_types  s`   :!!/ N<0*#+2OOO


&44S99&99#>>1111> 	"44S99I&99#>>DNND$*** )$*:*> F F F F <d>N>T>Z>Z[^>_>_``F F F ! ! ! }S!!  rT   zPython importc           
         | j         j        sJ | j         j        }| j        dk    r| j        s| j        s| j        r| j        j        sJ | j        dk    rt          j	        dd          }d}nt          j	        dd          }d}|j
                            |           |d| j                                         d| j        r| j                                        nd	d
}nq|j
                            t          j	        dd                     d| j                                         | j        r| j                                        nd| j        fz  }|                    |                                 d|d|                    |                                 | j                             |                     |           d S )Nr   ImportDottedModulezImportExport.c__Pyx_ImportDottedModuleImportDottedModuleRelFirst __Pyx_ImportDottedModuleRelFirstr;  r  r  r  Importz__Pyx_Import(%s, %s, %d)r  r<  ; )rt  r[  r   r}   ru  get_top_level_modulerv  r   r   r   r   r   r   r   r  r   r   r  )rX   r   rt  r$  helper_funcimport_codes         rS   r  zImportNode.generate_result_code(  s   1111&,:??4>?$:S?  4(3333zQ*67KM]^^8*67SUeff@--l;;; **,,,,151BN!++---NNKK --k.EhP`.a.abbb4 **,,.2nE((***#
8 K
 	

KKMMMMKK##DKKMM48<<<> 	? 	? 	? 	T"""""rT   c                     | j         j        S rM   )rt  r   rW   s    rS   rQ  z,ImportNode.get_known_standard_library_importH  s    %%rT   )rZ   r[   r\   r   r   rv  r  r   r   r<  r  r  rQ  rV   rT   rS   rs  rs  
  sk        & DL G;;;H  , "K# # #@& & & & &rT   rs  c                   P     e Zd Zg ZdZdZd
dZd Zd Zd Z	d Z
 fdZd	 Z xZS )ScopedExprNodeNTc                     |	|| _         d S | j        rt          j        |          | _         d S | j         s	d | _         d S d S rM   )
expr_scopehas_local_scoper   ComprehensionScope)rX   outer_scoper  s      rS   
init_scopezScopedExprNode.init_scope[  sS    !(DOOO! 	#$7DDDOOO 	#"DOOO	# 	#rT   c                 0    |                      |           d S rM   )r  r   s     rS   analyse_declarationsz#ScopedExprNode.analyse_declarationsc  s    rT   c                     d S rM   rV   r   s     rS   analyse_scoped_declarationsz*ScopedExprNode.analyse_scoped_declarationsf      rT   c                     | S rM   rV   r   s     rS   r<  zScopedExprNode.analyse_typesj      rT   c                     | S rM   rV   r   s     rS   analyse_scoped_expressionsz)ScopedExprNode.analyse_scoped_expressionsn  r  rT   c                 T   t                      j        }| j        r| j        j        s ||           d S |                    d           g }t          d | j        j                                        D                       D ]4\  }}|j	        s(|j
        j        r|j        r|                    |           5|s" ||           |                    d           d S |                                }|                                } ||           |                     ||           |                    d          }|                    |           |j        |fgt)          t+          |                                |                    z   D ]Z\  }	}
|                    |	          r@|                    |	           |                     ||           |                    |
           [|                    |           |                    d           |                    |           ||_        d S )Nz{ /* enter inner scope */c              3   *   K   | ]}|d          
|V  dS )r   NrV   rb   r   s     rS   re   z:ScopedExprNode.generate_evaluation_code.<locals>.<genexpr>|  s.      [[SWXYSZ[t[[[[[[rT   z} /* exit inner scope */
exit_scope)rO   r  r  r  var_entriesr   sortedentriesitemsr  r   ro   r  r   new_loop_labelsnew_error_label_generate_vars_cleanup	new_labelput_gotoerror_labelr   zipget_loop_labels
label_used	put_labelset_loop_labels)rX   r   generate_inner_evaluation_code
py_entries_r   old_loop_labelsold_error_labelr  label	old_labelrR   s              rS   r  z'ScopedExprNode.generate_evaluation_coder  sE   ).)I&# 	4?+F 	**4000F

.///
[[0G0M0M0O0O[[[[[ 	- 	-HAu# -:) -ej -%%e,,, 	**4000JJ1222F ..00..00&&t,,, 	##D*555 ^^L11
j!!!#'#3_"E!F!%c$*>*>*@*@/&R&R!S!S"T 	) 	)E9u%% )u%%%++D*===i(((z"""

-..._---*rT   c                     |D ]J}|j         r,|                    |           |                    |d           5|                    |           Kd S )Nr  )r  put_var_gotrefput_var_decref_setput_var_xdecref_clear)rX   r   r  r   s       rS   r  z%ScopedExprNode._generate_vars_cleanup  sj     	2 	2E 2##E***''y9999**51111	2 	2rT   rM   )rZ   r[   r\   r   r  r  r  r  r  r<  r  r  r  r]   r^   s   @rS   r  r  L  s         HJ O# # # #        *+ *+ *+ *+ *+X2 2 2 2 2 2 2rT   r  c            
           e Zd ZeZdZdZdZdZdZ	dgZ
d ZdZ ej         ej        ej         ej        dej        d          g                    Zd Zd Zd	 Zd
 Zd Zd Zd Zd ZdS )IteratorNodeNFsequencec                    | j         r| j         }| j                            |          | _        | j        j        j        s| j        j        j        r#| j        j        j        s| j        j        | _        n| j        j        j        r.t          | j	        | j                                      |          S | 
                                rF| j        j        j        d         j        }t          | j	        |d                              |          S | j                            |          | _        | j        j        t          t           fv r| j                            d          | _        d| _        | S )N)r  r   T)r  reversed!'NoneType' object is not iterabler+   )r  r  r<  r   rT  r  r  r  CppIteratorNoder   is_reversed_cpp_iteration	arg_tupler   rh  r   r   r   rI  r   )rX   rr   r  s      rS   r<  zIteratorNode.analyse_types  sC   ? 	"/C33C88M' 	e4=+=+D 	eM&0	e *DII], 	e"48dmDDDRRSVWWW++-- 	e}.3A6:H"48hNNN\\]`aaa M<<SAADM}!i%<<< $ ? ?@c d drT   zIterating over Python objectitc                    t          | j        t                    r.| j        j        r"t	          | j        j        j                  dk    sdS | j        j        }|j        ri|j        dk    r^|j	        j
        sdS | j        j        j        d         }t          |t                    r$|j        j        r|j        j	        }|j        j        S dS )z
        Returns True if the 'reversed' function is applied to a C++ iterable.

        This supports C++ classes with reverse_iterator implemented.
        r+   Fr  r   )r~   r  r.  r  r   r   r&  r   rp   r   r  CoercionNoderh  r   r  )rX   funcrh  s      rS   r  z&IteratorNode.is_reversed_cpp_iteration  s     4=.99 	'	,/0G0L,M,MQR,R,R5}%< 	-DI33:( u-).q1C#|,, - -gmx,,urT   c                 D    | j                             | j        p|          S rM   )r  rO  r  r   s     rS   rO  zIteratorNode.type_dependencies  s    }..t/E#FFFrT   c                     | j                             |          }|j        s|j        r|S |j        r)|j                            d          }||j        j        S n	|j	        r|S t          S )Nbegin)r  r   rT  r  r  r,  r-  r   return_typero   r   )rX   rr   sequence_typer  s       rS   r   zIteratorNode.infer_type  s    0055! 	!]%9 	!  ' 	!!'..w77E z-- !& 	!  rT   c           
      l   | j         j        }|j        r
J d            |j        s|j        rt          d          |t          t          fv }|s| j        r
J d            |j	         | _
        | j
        rJ|                    d| j                                         d| j                                         d           |s| j
        rf|                    |                                 d| j                                         d	|                                 d
           |j                            t           j        d          | _        | j        r|t          u rd}nd}|                    | j        d|d|                                 d
           |                    d           |                    |                    | j        | j                             |                    d           |                    d| j        z             n|                    d| j        z             |sg|j                            | j        d          | _        | j
        rO|                    d| j        z             |                    d           |                    d| j        z             |                    |                                 d| j                                         d|                    |                                 | j                             |                     |           |                    | j         d|                                  d           |                    |                    | j        | j                             | j
        r|                    d           d S d S )NFz+Should have been changed to CppIteratorNodez#for in carray slice not transformedzBinternal error: reversed() only implemented for list/tuple objectszif (likely(PyList_CheckExact(z)) || PyTuple_CheckExact(z)) {r<  z; __Pyx_INCREF(r  r  __Pyx_PyList_GET_SIZE__Pyx_PyTuple_GET_SIZEr;  #if !CYTHON_ASSUME_SAFE_SIZE#endifz--%s;r  
%s = NULL;} else {z	%s = -1;  = PyObject_GetIter(r  T = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(r   )r  r   r  rT  r  r   r   r   r  r  may_be_a_sequencer   r   r  r  r  r   r^  counter_cnameerror_goto_if_negr   _func_iternext_typeiter_func_ptrputr   r  )rX   r   r  is_builtin_sequencelen_funcs        rS   r  z!IteratorNode.generate_result_code  s   *% 	HGGGGG! 	G]%9 	G EFFF+	:/FF" 	k}jj&jjjj%2%B!B! 	0JJJM++----M++----/0 0 0
  	;$"8 	;JJ''))))   
 "&!=!=, "> "@ "@D} ; I--6HH7H

T-?-?-?4;;====YZZZ

9:::

411$2DdhOOPPP

8$$$

7T%778888

9t'99:::" 	N!%!=!=d>Vch!=!i!iD% ;

<$*<<===

:&&&t'99:::JJ''))))''tx@@@B C C C   &&&
 HH% V V@D@P@PV V V   JJt..t/A48LLMMM! 	JJsOOOOO	 	rT   c                 0    |                     d           d S Nz;;r  r  s     rS   generate_for_loop_headerz%IteratorNode.generate_for_loop_header3      rT   c                 n   | j         s
J d            |dv sJ d| d|                                  d}d}| j        j        rdt	          | j        j                  }| j        j        |}d}n:t          | j        j        j        t                    r|| j        j        j        z  }d}|r"|
                    d| j         d	|d
           n|
                    d           |
                    dt          j        d|d           |
                    d           |
                    |                    t          j        | j                             |
                    d           |
                    d| j         d	t          j        d
           |
                    d           | j        rdnd}|dk    r6|
                    | d|                                  d| j          d           n|
                    d           |
                    | d|                                  d| j          d           |
                    d           |
                    | d|                                  d| j          d           |
                    d           |
                    | | j          d           d S )Nz/internal error: counter_cname temp not prepared)ListTuple__Pyx_Pyz
_GET_SIZE(r  FTif (z >= z) break;{zPy_ssize_t r<  r=  r  r  r   z--++r  z = __Pyx_PyList_GetItemRef(r  r  <#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFSz! = __Pyx_NewRef(PyTuple_GET_ITEM());#elsez = __Pyx_PySequence_ITEM()r  r   r  r   r   r   r   r~   r   r   r   r   quick_temp_cnamer  r   r  )rX   	test_nameresult_namer   
final_sizesize_is_safe
item_countinc_decs           rS   generate_next_sequence_itemz(IteratorNode.generate_next_sequence_item6  s   !TT#TTTT-----H	HHT^^5E5EHHH
=0 	$T]/00J}(0'
#DM5EsKK $'$-*C*SS
# 		JJJ1C1C1CZZZPQQQQJJsOOOJJJ0G0G0GTUUUJJ5666JJt--f.EtxPPQQQJJx   JJJ1C1C1CVE\E\E\]^^^JJsOOO-1$$TJJ+ll$..BRBRllVZVhlllmmmmJJUVVVJJ+ssHXHXss\`\nssstttJJwJJ+jj@P@PjjTXTfjjjkkkJJx   

g4t144455555rT   c                 b   | j         j        }| j        r|                    d| j         d           |t
          u rb|                     d||           |                    |                    || j                             |	                    |t                     d S |t          u rb|                     d||           |                    |                    || j                             |	                    |t                     d S | j        r|                    d| j        z             |                    d|                                 z             |                     d||           |                    d           |                     d||           |                    d           |                    |                    || j                             |                    d	           |                    d
           |                    | d| j         d|                                  d           |                    d|z             |                    d           |                    d           |                    |                    d| j                             |                    d           |                    d           |                    d           |                    d           |                    d           |	                    |t                     d S )Nr  z < 0) break;r  r  zif (likely(!%s)) {z$if (likely(PyList_CheckExact(%s))) {r  r   z} else r  r<  r;  r  r  z&PyObject* exc_type = PyErr_Occurred();zif (exc_type) {zA!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)r  break;)r  r   r  r   r  r   r  r   r   r  r   r   r  r  r   r  r   )rX   r  r   r  s       rS   generate_iter_next_result_codez+IteratorNode.generate_iter_next_result_code\  s   *= 	@JJ>d0>>>???I%%,,V[$GGGJJt..{DHEEFFFOOK888Fj((,,Wk4HHHJJt..{DHEEFFFOOK888F! 	 JJ+d.@@AAAJJ=@P@PPQQQ,,V[$GGGJJz""",,Wk4HHHJJsOOOJJt..{DHEEFFFHHY

3

kOOd&8OO4>>;K;KOOOPPP

)K7888

;<<<

$%%%

4%%&ikoksttuuu

#$$$

3

8

3

3^44444rT   c                     | j         r|j                            | j                    | j        r&|j                            | j                   d | _        t                              | |           d S rM   )r  r  r  r  r   r  r  s     rS   r  zIteratorNode.free_temps  sn     	<N''(:;;; 	&N''(:;;;!%DD$'''''rT   )rZ   r[   r\   r   r   r  r  r  is_asyncr  r   r<  r  r   r  	CFuncTypeCFuncTypeArgr  r  rO  r   r  r  r  r  r  rV   rT   rS   r  r    s        DMMHHO|H  ( 1K-*-.Bj.B!#J#D**CTJJ$/ /  
  &G G G
 
 
= = =~  $6 $6 $6L$5 $5 $5L( ( ( ( (rT   r  c                   ^    e Zd ZdZdZdZdZdZdgZd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd ZdS )r  Nr   r  TFr  c                     | j         sdndS )N)r  end)rbeginrend)r  rW   s    rS   get_iterator_func_namesz'CppIteratorNode.get_iterator_func_names  s    '+}L:LLrT   c                 6   | j         j        }|j        r|j        }|                                 \  }}|j                            |          }|j                            |          }||j        j        r|j        j        r3t          | j
        d|d| j         j                   t          | _        | S ||j        j        r|j        j        r3t          | j
        d|d| j         j                   t          | _        | S |j        j        }|j        r|j        d         rd| _        |                    | j
        d||j        j        g          	 3t          | j
        d|d| j         j                   t          | _        | S |                    | j
        d|g          3t          | j
        d|d| j         j                   t          | _        | S |                    | j
        d|g          3t          | j
        d	|d| j         j                   t          | _        | S || _        nm|j        r4||j        j        k    st          | j
        d
|d|d           || _        n2t          | j
        d|d| j         j        d           t          | _        | S )Nzmissing z() on 
cpp_localsr   !=z missing operator!= on result of r  z missing operator++ on result of zmissing operator* on result of zincompatible types for z() and z()zresult type of z must be a C++ class or pointer)r  r   r  r  r  r,  r-  rU  r   r   r   r2   r  r  rj   extra_dereferencelookup_operator_for_types)rX   rr   r  
begin_nameend_namer  r  	iter_types           rS   r<  zCppIteratorNode.analyse_types  s   * 	4)3M#;;==
H#**:66!((22Mz. :?  $((JJJ@R@RSTTT"DIKKx, 8=  $((HHHdm>P>PQRRR"DIKJ*	! 	#~l+ -),&,,H 457 7 ;?? dhhPZPZPZ\`\i\n\n oppp&	,,TXti[IIQdhhPZPZPZ\`\i\n\n oppp&	,,TXsYKHHPdhhzzz[_[h[m[m nooo&	!DII 	#!555dhh***V^V^V^ _```!DII$((ZdZdZdfjfsfxfxfxyzzz"DIrT   c                    | j         j        }|                                 \  }}| j                                         rO|                    |                                 d| j                                         | j        |d           d S |}|j        rt          j	        |j
                  }|j        s|j        j        d         rd| _        |j                            |d          | _        |                    | j        d|j        rdnd| j                                         d	           |                    |                                 d| j        | j        |d           d S )
Nr<  z();r  ->Fr  &r  r=  )r  r   r  r:  r   r  cpp_attribute_opr	  r   r  r  r  r   rj   r  r  cpp_sequence_cnamer  )rX   r   r  r
  r  	temp_types         rS   r  z$CppIteratorNode.generate_result_code  s   *4466
A=""$$ 	! JJ$$&&&%%

	      *	) Q !+ 3M4O P PI# 1t'7'B<'P 1,0D) +/.*F*Fy]b*F*c*c'

4+B+B+B2;2B+J33+J+/=+H+H+J+J+J+JL M M M 

KKMMMM++))JJ	  ! ! ! ! !rT   c                 "   |                                  \  }}|                    d| j        |                                 d| j        p| j                                        | j        |d| j        |                                 
           d S )Nr  z != z(); ++)r  r  r  r  r  r  r  )rX   r   r  r  s       rS   r  z(CppIteratorNode.generate_for_loop_header  s     22448""KKMMMM#=t}';';'='==!!HH""KKMMM 	 	 	 	 	rT   c                 n    |                     |d| j        |                                 d           d S )Nz = *r=  )r   r  r  )rX   r  r   s      rS   r  z.CppIteratorNode.generate_iter_next_result_code  sF    

#..' 	( 	( 	( 	( 	(rT   c                 N    | j         sd S t                              | |           d S rM   )r  r   r  r  s     rS   r  z.CppIteratorNode.generate_subexpr_disposal_code   s0    & 	 F//d;;;;;rT   c                 N    | j         sd S t                              | |           d S rM   )r  r   r  r  s     rS   r  z"CppIteratorNode.free_subexpr_temps  s0    & 	 F##D$/////rT   c                     | j         s6t                              | |           t                              | |           t                              | |           d S rM   )r  r   r  r  r  r  s     rS   r  z&CppIteratorNode.generate_disposal_code  sW    & 	4 33D$???''d333''d33333rT   c                     | j         r|j                            | j                    t                              | |           d S rM   )r  r  r  r   r  r  s     rS   r  zCppIteratorNode.free_temps  sC    " 	AN''(?@@@D$'''''rT   )rZ   r[   r\   r  r  r  r   r  r   r  r<  r  r  r  r  r  r  r  rV   rT   rS   r  r    s         GH|HM M M. . .`"! "! "!H  ( ( (< < <0 0 04 4 4( ( ( ( (rT   r  c                   4    e Zd Zd Zd Zd ZddZd Zd ZdS )	NextNodec                 T    t                               | |j                   || _        d S rM   r  rl  r   iteratorrX   r  s     rS   rl  zNextNode.__init__%  %    hl333 rT   c                     d S rM   rV   r   s     rS   rs  zNextNode.nogil_check)  r  rT   c                 6    | j                             |          S rM   )r  rO  r   s     rS   rO  zNextNode.type_dependencies-  s    }..s333rT   Nc           	         || j                             |          }|j        s|j        r|j        S |j        r?|                    | j        d|g          j        j	        }t          j        |d          }|S t          | j        | j         j        t          | j        dt          j                            }|                    |          S )Nr   Tremove_fakerefPY_SSIZE_T_MAXrW  rY  )r  r   r  rT  r  r  r	  r   r   r  r   remove_cv_refr\  r  r]  r^  )rX   rr   iterator_type	item_typefake_index_nodes        rS   r   zNextNode.infer_type0  s      M44S99M 	3=#9 	3 **' 	355dhm_UUZfI"04PPPI (]+dh.>#-#?A A AB B BO
 #--c222rT   c                 ^    |                      || j        j                  | _        d| _        | S r  )r   r  r   r   r   s     rS   r<  zNextNode.analyse_typesB  s(    OOC);<<	rT   c                 `    | j                             |                                 |           d S rM   )r  r  r  r  s     rS   r  zNextNode.generate_result_codeG  s(    44T[[]]DIIIIIrT   rM   )	rZ   r[   r\   rl  rs  rO  r   r<  r  rV   rT   rS   r  r    sx        ! ! !  4 4 43 3 3 3$  
J J J J JrT   r  c                   <    e Zd ZdgZdZeZdZdZd Z	d Z
d Zd Zd	S )
AsyncIteratorNoder  Tr+   Fc                     t           S rM   r   r   s     rS   r   zAsyncIteratorNode.infer_typeY      rT   c                     | j         r| j         }| j                            |          | _        | j        j        j        s4t          | j        d           | j                            |          | _        | S )Nz*async for loops not allowed on C/C++ types)r  r  r<  r   ro   r   r   r   r   s     rS   r<  zAsyncIteratorNode.analyse_types\  sj    ? 	"/C33C88}!- 	B$(HIII M<<SAADMrT   c           
      l   |j                             t          j        dd                     |                    |                                 d| j                                        d|                    |                                 | j	                             | 
                    |           d S )N	AsyncIterCoroutine.cz  = __Pyx_Coroutine_GetAsyncIter(r  )r   r   r   r   r   r  r  r   r   r   r  r  s     rS   r  z&AsyncIteratorNode.generate_result_codee      ))+*A+}*]*]^^^

KKMMMMM##%%%%##DKKMM48<<<> 	? 	? 	? 	T"""""rT   c                 0    |                     d           d S r  r  r  s     rS   r  z*AsyncIteratorNode.generate_for_loop_headerm  r  rT   N)rZ   r[   r\   r   r  r   r   r   r  r   r<  r  r  rV   rT   rS   r-  r-  K  sm         |HHDGO    # # #    rT   r-  c                   .    e Zd ZeZdZd Zd Zd Zd Z	dS )AsyncNextNoder+   c                 T    t                               | |j                   || _        d S rM   r  r  s     rS   rl  zAsyncNextNode.__init__|  r  rT   c                     t           S rM   r/  r   s     rS   r   zAsyncNextNode.infer_type  r0  rT   c                     | S rM   rV   r   s     rS   r<  zAsyncNextNode.analyse_types  r  rT   c           
      l   |j                             t          j        dd                     |                    |                                 d| j                                        d|                    |                                 | j	                             | 
                    |           d S )Nr3  r4  z! = __Pyx_Coroutine_AsyncIterNext(r  )r   r   r   r   r   r  r  r   r   r   r  r  s     rS   r  z"AsyncNextNode.generate_result_code  r5  rT   N)
rZ   r[   r\   r   r   r   rl  r   r<  r  rV   rT   rS   r8  r8  q  s\         DG! ! !    # # # # #rT   r8  c                   *    e Zd ZddgZdZdZd Zd ZdS )WithExitCallNoder   
await_exprTNc                     | j                             |          | _         | j        r| j                            |          | _        t          j        | _        d| _        | S r  )r   r<  r?  r   r)  r   r   r   s     rS   r<  zWithExitCallNode.analyse_types  sQ    I++C00	? 	A"o;;C@@DO*	rT   c                    | j         r"|                    d| j        j        z             | j                            |           |j                            t          d          }|	                    | j
                   |j                            t          j        dd                     |                    |d| j        j        d| j                                        d           |                    | j        j        t          	           | j                            |           | j                            |           |                    |                    || j
                             |                    |t                     | j        r| j                            ||d
           |                    |d| j                                        d           | j                            |           | j                            |           | j        rB|                     |           |                    |                                 d|d           |                    |t          	           | j        r-|                    | j
        |                                            |j                            |           | j         r|                    d           d S d S )N	if (%s) {Fr  PyObjectCallr   = __Pyx_PyObject_Call(r  z, NULL);r  T)source_cnamedecref_sourcer<  r=   = __Pyx_PyObject_IsTrue(r  r   )test_if_runr   	with_statexit_varr   r  r  r  r   r  r   r   r   r   r   r  r  r  r  r   r  r?  r   r  r  r  rr  r  )rX   r   
result_vars      rS   r  z)WithExitCallNode.generate_evaluation_code  s    	>JJ{T^%<<===	**4000^11.U1SS
dh))+*A.+0 +0 	1 	1 	1

JJN###I  	! 	! 	! 	dn5NKKK	((...	T"""

4**:tx@@AAA
N333? 	-O44T
bf4gggJJZZZ1J1J1L1L1L1LMNNNO99$???O&&t,,, 	X%%d+++JJDKKMMMM:::VWWWj~>>> 	;!!$(DKKMM:::##J/// 	JJsOOOOO	 	rT   )rZ   r[   r\   r   rH  r?  r<  r  rV   rT   rS   r>  r>    sH         %HKJ  % % % % %rT   r>  c                   0    e Zd ZeZd Zd Zd Zd Zd Z	dS )ExcValueNodec                 <    t                               | |           d S rM   r   rl  )rX   r   s     rS   rl  zExcValueNode.__init__  s    $$$$$$rT   c                     || _         d S rM   var)rX   rR  s     rS   set_varzExcValueNode.set_var  s    rT   c                     | j         S rM   rQ  rW   s    rS   r  z"ExcValueNode.calculate_result_code  s	    xrT   c                     d S rM   rV   r  s     rS   r  z!ExcValueNode.generate_result_code  r   rT   c                     | S rM   rV   r   s     rS   r<  zExcValueNode.analyse_types  r  rT   N)
rZ   r[   r\   r   r   rl  rS  r  r  r<  rV   rT   rS   rM  rM    sf        
 D% % %          rT   rM  c                   J    e Zd Zg ZddZd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TempNodeNc                 ~    t                               | |           || _        |j        rt          | _        d| _        d S r  )r   rl  r   ro   r   r!  r   )rX   r   r   rr   s       rS   rl  zTempNode.__init__  s=    $$$$	 	/ .DrT   c                     | S rM   rV   r   s     rS   r<  zTempNode.analyse_types  r  rT   c                     d| _         d S r  r  r   s     rS   r8  z#TempNode.analyse_target_declaration      rT   c                     d S rM   rV   r  s     rS   r  zTempNode.generate_result_code  r   rT   c                 R    |j                             | j        d          | _        d S )NTr  )r  r  r   
temp_cnamer  s     rS   allocatezTempNode.allocate  s$    .66tyT6RRrT   c                 R    |j                             | j                   d | _        d S rM   )r  r  r_  r  s     rS   releasezTempNode.release   s%    ##DO444rT   c                 0    	 | j         S #  J d            xY w)NFz-Remember to call allocate/release on TempNode)r_  rW   s    rS   r  zTempNode.result  s'    	?"	IIIIIs   	 c                     d S rM   rV   r  s     rS   r  zTempNode.allocate_temp_result  r   rT   c                     d S rM   rV   r  s     rS   r  zTempNode.release_temp_result  r   rT   rM   )rZ   r[   r\   r   rl  r<  r8  r  r`  rb  r  r  r  rV   rT   rS   rX  rX    s         H         S S S          rT   rX  c                       e Zd Zd ZdS )
PyTempNodec                 T    t                               | |t          j        |           d S rM   )rX  rl  r   r   )rX   r   rr   s      rS   rl  zPyTempNode.__init__  s%    $Z%>DDDDDrT   NrZ   r[   r\   rl  rV   rT   rS   rg  rg    s(        E E E E ErT   rg  c                   2    e Zd Zg ZddZd Zd Zd Zd ZdS )RawCNameExprNodeNc                 V    t                               | ||           |	|| _        d S d S )Nr  )r   rl  r   )rX   r   r   r   s       rS   rl  zRawCNameExprNode.__init__  s6    $$///DJJJ rT   c                     | S rM   rV   r   s     rS   r<  zRawCNameExprNode.analyse_types   r  rT   c                     || _         d S rM   r   )rX   r   s     rS   	set_cnamezRawCNameExprNode.set_cname#  s    


rT   c                     | j         S rM   ro  rW   s    rS   r  zRawCNameExprNode.result&  r  rT   c                     d S rM   rV   r  s     rS   r  z%RawCNameExprNode.generate_result_code)  r   rT   rz  )	rZ   r[   r\   r   rl  r<  rp  r  r  rV   rT   rS   rk  rk    si        H   
          rT   rk  c                   2    e Zd ZeZdZdZdgZd Zd Z	d Z
dS )JoinedStrNodeTzString concatenationvaluesc                 8    fd| j         D             | _         | S )Nc                 `    g | ]*}|                                                             +S rV   )r<  r   )rb   vrr   s     rS   r   z/JoinedStrNode.analyse_types.<locals>.<listcomp>B  s3    YYYqs++>>sCCYYYrT   )ru  r   s    `rS   r<  zJoinedStrNode.analyse_typesA  s%    YYYYT[YYYrT   c                     dS rw  rV   rW   s    rS   rA  zJoinedStrNode.may_be_noneE      urT   c           
         |                     | j                   t          | j                  }|dk     }t	                      }d}| j        D ]}t          |t                    r#t          ||                                          }:t          |t                    r|j
        j        j        rat          |t                    rw|                    |           g }i t          |          g}| j        D ]}|                    |           t          |t                    r"t          t          |j
                            }	nGd|                                 d}	||v r+|                    d|                                 d           |	v r|	xx         dz  cc<   |                    |	           d|	<   |r:|j                            t+          j        t*          j        |          d          }
n|j                            t+          j        t*          j                  d          }
|                    d	|
|fz             |                    d
|
z             |                    d|                    | j                  z             |                    d           t7          | j                  D ]2\  }}|                    d|
||                                fz             3fd|D             }|                     | j                   |                     |           |j                            t?          j         dd                     |                    d| !                                |
|d"                    |          d"                    |          fz             |s|                    d|
z             |j        #                    |
           |                    |$                    |                                 | j                             | %                    |           | j        D ],}|&                    |           |'                    |           -d S )N    rc  z__Pyx_PyUnicode_GET_LENGTH(r  z__Pyx_PyUnicode_MAX_CHAR_VALUE(r+   Fr  z7%s = (PyObject **) PyMem_Calloc(%d, sizeof(PyObject*));r  zPyErr_NoMemory(); %sr   z%s[%d] = %s;c                 F    g | ]}|         d k    r| d|          n|S )r+    * rV   )rb   r|  countss     rS   r   z:JoinedStrNode.generate_evaluation_code.<locals>.<listcomp>~  sN     
 
 
 +1,*:*:t&&t&&&
 
 
rT   JoinPyUnicodeStringTools.cz*%s = __Pyx_PyUnicode_Join(%s, %d, %s, %s); +  | zPyMem_Free(%s);)(r  r   r   ru  setr~   r  re  rg  FormattedValueNoder   r   r  	CloneNodeaddrw   r  r   r   r  r  r   c_array_typer   r  r   r   	enumerater  r   r   r   r   r  joinr  r   r  r  r  )rX   r   	num_itemsuse_stack_memoryunknown_nodesmax_char_valuer   length_partscharval_partslength_partvalues_arrayir  s               @rS   r  z&JoinedStrNode.generate_evaluation_codeI  s   dh$$	$r>K 
	( 
	(D$,, 	(!$^T5N5N5P5P!Q!QD"455 ($*/:T (D),, (!!$''''^,,-K 	( 	(D))$///$,, `!#dj//22 PDNN<L<LOOO=((!(()^4>>K[K[)^)^)^___f$${###q(######K000&'{## 		>77'
(A9MMZ_ 8 a aLL  >77#J$=>>5 8 R RLJJPT`bkSllmmmJJ-<===JJ-0I0IIJJJJJsOOO -- 	M 	MGAtJJ~q$..:J:J(KKLLLL
 
 
 
$
 
 

 	dh!!$'''))+*A/Sb*c*cddd

?KKMMJJ|$$ JJ}%%C
 
 	 	 	   	9JJ(<7888##L111

4**4>>+;+;TXFFGGGT"""K 	" 	"D''---OOD!!!!	" 	"rT   N)rZ   r[   r\   r   r   r   r  r   r<  rA  r  rV   rT   rS   rt  rt  4  s^         DG(KzH    P" P" P" P" P"rT   rt  c                   P    e Zd ZddgZeZdZdZdZdddd	d
j	        Z
d Zd Zd ZdS )r  r   format_specTNzString formattingPyObject_StrPyObject_ReprPyObject_ASCII__Pyx_PyNumber_Long)sradc                     dS rw  rV   rW   s    rS   rA  zFormattedValueNode.may_be_none  rz  rT   c                 X   | j                             |          | _         | j        r| j        j        rL| j        r| j        j         n| j         j        j        }| j         j                            ||          r|| _        | j        r2| j                            |                              |          | _        | j        k| j                             |          | _         | j        sE| j	        r| j	        dk    r3| j         j        t          u r | j                                         s| j         S | S )N)r  r  )r   r<  r  r[  r   default_format_speccan_coerce_to_pystringc_format_specr   conversion_charr   rA  )rX   rr   r  s      rS   r<  z FormattedValueNode.analyse_types  s   Z--c22
 	34#3#E 	36:6FoD,22DJOLoMz55c}5UU 3%2" 	[#/==cBBUUVYZZD%66s;;DJ# &T-A &TEY]`E`E`:?l224:;Q;Q;S;S2:%rT   c                 8   | j         | j        j        j        s| j        j                            | j                                        || j                   }|                    |                                 d|d|                    |                                 | j                             | 	                    |           d S | j        
                                }| j        j        t          u o| j                                         }| j        rd}| j        
                                }n!d}|                    t          j                  }| j        }|dk    r|rd }|r_|                     |          }|J d|z              |d|d}|j                            t+          j        d	d
                     |dz  }nb| j        r.|j                            t+          j        dd
                     n-|j                            t+          j        dd
                     |                    |                                 d|d|d|d|                    |                                 | j                  	           | 	                    |           d S )Nr<  r  __Pyx_PyObject_Format__Pyx_PyObject_FormatSimpler  z(invalid conversion character found: '%s'r;  r  PyObjectFormatAndDecrefr  	AndDecrefPyObjectFormatPyObjectFormatSimpler  r  )r  r   r   ro   convert_to_pystringr  r   r   r   r  r   r   rA  r  r  r   empty_unicoder  find_conversion_funcr   r   r   r   )	rX   r   convert_func_callvalue_resultvalue_is_unicodeformat_funcr  r  fns	            rS   r  z'FormattedValueNode.generate_result_code  s   )$*/2M) $
 C C
!!##T4+=!? !?JJ!!!''tx@@@B C C C   &&&Fz++--:?l:[4:CYCYC[C[?[ 	J1K*4466KK 8K33F4HIIK.c!!&6!"O 	R**?;;B>>#MP_#_>>>')rr<<<8L--'(A?SSU U U;&KK 	R--'(8/JJL L L L --'(>PPR R R 	

KKMMMMKKLLKK##DKKMM48<<<> 	? 	? 	? 	T"""""rT   )rZ   r[   r\   r   r   r   r   r  r  ri   r  rA  r<  r  rV   rT   rS   r  r    s         'HDGM%K "	 
 
     "/# /# /# /# /#rT   r  c                   2    e Zd ZdZej        Zd Zd Zd Z	dS )ParallelThreadsAvailableNodea*  
    Note: this is disabled and not a valid directive at this moment

    Implements cython.parallel.threadsavailable(). If we are called from the
    sequential part of the application, we need to call omp_get_max_threads(),
    and in the parallel part we can just call omp_get_num_threads()
    c                     d| _         | S r  r  r   s     rS   r<  z*ParallelThreadsAvailableNode.analyse_types
      rT   c                 2   |                     d           |                     d| j        z             |                     d| j        z             |                     d           |                     d| j        z             |                     d           d S )N#ifdef _OPENMPz2if (omp_in_parallel()) %s = omp_get_max_threads();z else %s = omp_get_num_threads();r  z%s = 1;r  r   r  r  s     rS   r  z1ParallelThreadsAvailableNode.generate_result_code  s    

#$$$

G<@NK 	L 	L 	L

5FGGG

7

9t~-...

8rT   c                     | j         S rM   r  rW   s    rS   r  z#ParallelThreadsAvailableNode.result  
    ~rT   N
rZ   r[   r\   r  r   
c_int_typer   r<  r  r  rV   rT   rS   r  r    sU           D  
      rT   r  c                   2    e Zd ZdZej        Zd Zd Zd Z	dS )ParallelThreadIdNodez/
    Implements cython.parallel.threadid()
    c                     d| _         | S r  r  r   s     rS   r<  z"ParallelThreadIdNode.analyse_types#  r  rT   c                     |                     d           |                     d| j        z             |                     d           |                     d| j        z             |                     d           d S )Nr  z%s = omp_get_thread_num();r  r  r  r  r  s     rS   r  z)ParallelThreadIdNode.generate_result_code(  sr    

#$$$

/$.@AAA

7

9t~-...

8rT   c                     | j         S rM   r  rW   s    rS   r  zParallelThreadIdNode.result/  r  rT   Nr  rV   rT   rS   r  r    sU           D  
      rT   r  c                        e Zd Zd Zd Zd ZdS )_IndexingBaseNodec                 t    | j                                         p| j         j        t          t          t
          fv S rM   )rZ  r   r   r   r   r    rW   s    rS   r   z_IndexingBaseNode.is_ephemeral?  s6     y%%'' 649>*n>6 ,6 	6rT   c                 f    | j                                         o| j                                        S rM   )rZ  r|  r[  r=  rW   s    rS   r|  z"_IndexingBaseNode.check_const_addrE  s)    y))++H
0F0F0H0HHrT   c                 b    | j         j        r| j         j        j        rdS n| j         j        rdS dS r@  )r   r	  r  rT  r  rW   s    rS   r   z_IndexingBaseNode.is_lvalueH  sF     9! 	y&/ u Y 	4 trT   N)rZ   r[   r\   r   r|  r   rV   rT   rS   r  r  :  sD        
6 6 6I I I    rT   r  c                       e Zd Zddg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#dZd Z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%d Z!d! Z"d&d"Z#dS )'r\  rZ  r[  NTFc                 H    | j         j        | j        j                 | _        d S rM   )rZ  r   r[  rW   s    rS   r%  z#IndexNode.calculate_constant_resulth  s    #y89STrT   c                     | j                             |          }| j                            |          }	 ||         S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )rZ  r/  r[  r=  r3  )rX   r.  rZ  r[  r2  s        rS   r/  zIndexNode.compile_time_valuek  s    y++D11
--d33	-; 	- 	- 	-))!,,,,,,,,,	-s   > 
A(A##A(c                     | j         }|                                o7| j                                        o|j        o|j        j        p|j        j        S rM   )rZ  r:  r[  r   r  rT  rX   rZ  s     rS   r:  zIndexNode.is_simples  sU    y   KTZ%9%9%;%; KIK#'9#3#Ity7I	LrT   c                     | j         j        }|rD|j        rdS |t          t          t
          fv rdS t          | j        t                    r	|j	        rdS t                              |           S rw  )rZ  r   r  r   r   r    r~   r[  	SliceNoder  r   rA  rX   r  s     rS   rA  zIndexNode.may_be_nonex  st    IN	 
	!" u\:~FFFu$*i00 !, ! !5##D)))rT   c                     d S rM   rV   r   s     rS   r8  z$IndexNode.analyse_target_declaration  r   rT   c                 d   | j                                         }||dv r| j                            |          }| t	          | j         j        d| d           d S |dk    rt          j        |          S |dk    }| }|j        rQ|j	        r|rt	          | j         j        d           d}|j
        r|rt	          | j         j        d           d}|j        }|j        r!t	          | j         j        d	| d
| d           t          j        |||           S | j                             |          }|r||j        s|j        rT| j        j        r| j        j        }n| j        g}t%          j        | j        |d           }|                    ||          S | j        j        s| j        j        rddlm} |                    |                    |j        j                             | j        j        r| j        gnt9          | j        j                  }	t          j        ||                    ||	                    S |j        sm| j                             |          }
|
<	 tC          |
          }
t          j"        ||
          S # tF          tH          f$ r Y nw xY wt	          | j        d           d S )N)pointerconstvolatilezinvalid use of 'z', argument is not a typer  r  zDuplicate 'const'TzDuplicate 'volatile'z(Cannot declare memory view variable as 'z'. Did you mean 'z[item_type][:]' ?)rG  is_volatile)r   positional_argskeyword_args)r  r+   r  z*Array size must be a compile time constant)%rZ  rC  r[  re  r   r   r   r  r  rG  r  r  r   c_const_or_volatile_typer  python_type_constructor_namer   r   r   TemplatedTypeNodeanalyser   r  r  r   get_view_utility_coder  shared_utility_qualified_namer   MemoryViewSliceTypeget_axes_specsro   r/  r   
CArrayTyper   r   )rX   rr   modifierr  rG  r  template_values	type_noder  axesr[  s              rS   re  zIndexNode.analyse_as_type  s6   90022H0P$P$P
22377I dim%[%[%[%[\\\t9$$!*9555  7*H&,K( 	3% $ Bdim-@AAA#H( '" Edim-CDDD"&K%2	+ ydimwww\dwwwy y y6Hh,H H H H I--c22	  	N% N)O N:5 3&*joOO'+zlO!3$3!%' ' '	 !((	(BBB$ N
(J N(((((($$44A   
 (,z':U
||TZ_@U@U!5iAZAZ[^`dAeAefff* 
N
55c::$G #E

  *4YFFF '	2    dh LMMMts    J JJc                     g }| }|j         rh|j                            |          }|r>|j        r7|j        r0|                    |                                rdn|j                   |j        }|j         h|S Nztyping.Optional)r]  rZ  re  r  modifier_namer   allows_noner[  )rX   rr   r  modifier_nodemodifier_types        rS   analyse_pytyping_modifiersz$IndexNode.analyse_pytyping_modifiers  s     	( 	0).>>sCCM t-"L t%3t  m6O6O6Q6Q!r!2!2WdWrsss)/M ( 	0 rT   c                 l    | j                             |          | j                            |          z   S rM   )rZ  rO  r[  r   s     rS   rO  zIndexNode.type_dependencies  s-    y**3//$*2N2Ns2S2SSSrT   c                 <   | j                             |          }| j        j        rP|j        rt
          S |j        rt          S |t          t
          t          t          t          fv r|S |j        r|S t          S | j                            |          }|r|j        st          | j        t                    rD|t          u rt           j        S |t          u s| j         t
          u rt           j        S |t          t          fv r"t'          || j         | j        |          }||S n|j        s|j        r|j        S |j        rrt          | j        t                    rX| j                                        r>| j        j        }|dk     r
||j        z  }d|cxk    r|j        k     rn nZ|j        |         S nL|j        rE|j        dk    r	 |j        dk    r|j        S t!          j        |j        |j        dd                    S | j        j         rf|j        r_|}| j        j!        D ]N}|j        s nFtE          | j#        tI          | j         j#        |          |                              |          }O|S |j%        rU G d d          } || j#        |           || j#        |          g}	|&                    d	|	          }
|
|
j'        j(        S tS          |          r6tS          |          r'| j        |f}tU          tW          ||g                    S |t          u r|S t          S )
Nr   r   r+   r  rY  c                       e Zd Zd ZdS ))IndexNode.infer_type.<locals>.FakeOperandc                 :    | j                             |           d S rM   )__dict__update)rX   r  s     rS   rl  z2IndexNode.infer_type.<locals>.FakeOperand.__init__"  s    M((.....rT   Nri  rV   rT   rS   FakeOperandr  !  s#        / / / / /rT   r  )r   r   []),rZ  r   r[  r   r  r   r  r   r    r   r   r   r   r  r~   r]  r   c_py_ucs4_typec_uchar_typer   r  rT  r  r1  r   r   ri  r2  ndimr  r  r  r   r   r\  r   r   r  lookup_operatorr   r  r=   rI   rC   )rX   rr   r  
index_typer(  r[  r  r  r  operands
index_funcindex_with_types               rS   r   zIndexNode.infer_type  s   I((--	: 	&" &!!+ 
&##|ZT^___  - &   &%Z**3//
 "	_*+ "	_z$*g/N/N "	_L(( "00n,,	Z0G0G!..z95554DJD D D	($$ )! _Y%7 _ **$ _DJ)H)H _:1133 ; J6Eqyy/E2222IN22222(3E::- _>Q&&>Q&&$?*%9)/9>Z[Z\Z\K]^^^:- 	%)2N 	%%MZ_ % %$7 E )$($)-Vc9d9d9d01!3 !3 !33=:c??  %$! 
	3/ / / / / / / / y999z:::H ,,T8<<J%!229%% 	T/**E*E 	T#z:6O4Y@QRRSSS $$ rT   c                 0    |                      |d          S )NTgetting)analyse_base_and_index_typesr   s     rS   r<  zIndexNode.analyse_types8  s    00d0CCCrT   c                     |                      |d          }|j        j        rt          | j        d           || u r1|                                st          | j        d|j        z             |S )NT)settingzAssignment to const dereference%Assignment to non-lvalue of type '%s')r  r   rG  r   r   r   r>  s      rS   rD  zIndexNode.analyse_target_types;  sp    00d0CC9 	?$(=>>>4<< 0 0<$(CdiOPPPrT   c                 @   |r| j                             |          | _         | j         j        j        rt          j        | _        | S | j        j        }|j        d         s;|r%t          | j        j
        | j        j                   nt          | j                   |sWt          | j        t                    r=t          j        | j        j                  r| j                            |          | _        | j         j        j        }|snt          | j         t&                    s|rR| j         j        j        s"| j         j        j        s0| j         j        j        s| j                             |          | _         |                     ||          }||S |j        | _        | j         j        }|j        s| j                            |          | _        | j        j        | _        | j        j        r| j        j        | _        |j        rZ|rt=          | j        dd           n| j        j         dv r| j         S | j                             |          | _         | j         j        }|j!        r| "                    ||||          S |j        s|j        r| #                    ||          S |j$        r| %                    ||          S |j        r| &                    |          S |j'        r| (                    |||          S tS          | j        d|z             t          j        | _        | S )N
wraparoundz%cannot assign to Unicode string indexr+   r|   )r   ry  z'Attempting to index non-array type '%s')*rZ  r<  r   r  r   r2   r[  r   rj   r   r   r   r~   r]  r   long_literalr   r   r   r  r  r  rT  analyse_as_buffer_operationr   rU  original_index_typer	  r  rD  r   r   r   ro   analyse_as_pyobjectanalyse_as_c_arrayr  analyse_as_cppanalyse_as_c_functionr1  analyse_as_c_tupler   )	rX   rr   r  r  analyse_baser   is_memslicereplacement_noder  s	            rS   r  z&IndexNode.analyse_base_and_index_typesC  s   
  	5	//44DI9>" 	 #-DIK:&~l+ 	3 3&tz'7IIII&tz222  	<Jtz7;; 	<@RSWS]Sc@d@d 	<66s;;DJin7 	>
49i @ @ 	>H 	>y~' >	0E >I` > I88==	;;CII'##Y
IN	% 	+11#66DJ'+zD$'4 R+/+C+Q(( 	+  %DH&MUVWWWWWZ/7::9$ I88==	 IN	  	++C7GLLL 	!3 	**3999# 	&&sG444# 		--c222  	**3AAA$(;   #-DIKrT   c                    | j         j        }| j        j        j        rH|t          ur?t          | j        dd           | j                            |          | _        d| _        n-| j        j        j	        r|t          ur|r|j
        d         s|t          t          t          fv ri| j        j        j        rP|j
        d         rCt          | j        t                     r1| j                                        r| j        j        dk    rd| _        nd| _        | j                            t(          j        |                              |          | _        | j                            |           n&| j                            |          | _        d| _        | j        j        j	        r|t2          u rt(          j        | _        n| j        j        j	        r/|t          u r&|rt(          j        | _        nt(          j        | _        n|r*|t:          t          t2          t          t          fv r|| _        nd }|t          t          fv r.| j        j        j	        rt=          || j         | j        |          }|t          t          t          fv r| j                             d          | _         ||j         stB          | _        n|| _        | "                    ||           | S )	NzItem lookup of unicode character codes now always converts to a Unicode string. Use an explicit C integer cast to get back the previous integer lookup behaviour.r+   r|   boundscheckr  r   r  &'NoneType' object is not subscriptable)#rZ  r   r[  rD  r   r   r   r   r   r  rj   r   r   r    signedr~   r]  r   r   r  r   r^  rK  r
  create_to_py_utility_coder   r  r  r  r   r   rI  ro   r   wrap_in_nonecheck_node)rX   rr   r   r  r  r  r(  s          rS   r  zIndexNode.analyse_as_pyobject  s   IN	:?* 	y	/I/IDHhopr r r r 66s;;DJDLLZ_# 		(B(B 
!N=9
!"y*n&MMM!Z_3 N #| < N (
G<< N "Z;;==	 N CG*B\`aBaBa  --j.JCPPaabeffDJ$>>sCCCC66s;;DJDL:?! 	&i<&?&? #1DIIZ_# 	&	^(C(C 2&3		 '1		 	&)
NLR[]g'hhh!DIIIY
333
8N34DJD D D	Y
I>>> I778`aa	 	(=  +		%	##C111rT   c                 |   | j         j        }|j        | _        | j        j        rt	          j        | j                  | _        |r|| _        no| j        j        j        r+| j                            t          j	        |          | _        n3| j        j        j
        s"t          | j        d| j        j        z             | S )NzInvalid index type '%s')rZ  r   r  r  r   CReferenceTyper[  ro   r  r^  r  r   r   )rX   rr   r   r  s       rS   r  zIndexNode.analyse_as_c_array  s    IN	'	9! 	="1$)<<DI 	I!DIIZ_( 	I--j.JCPPDJJ' 	I$(5
GHHHrT   c                    | j         j        }|                    d| j         | j        g          }|@t	          | j        d|d| j        j        d           t          j        | _        d| _        | S |j        }|j	        r|j
        }|j        | _        |j        | _        | j        r@|sd| _        t          |           r(|                    t!          j        dd                     | j                            |j        d	         j        |          | _        |j        | _        |r)|j        j        st	          | j        d
| j        z             | S )Nr  z
Indexing 'z ' not supported for index type 'r  r  TCppExceptionConversionr  r   z#Can't set non-reference result '%s')rZ  r   r  r[  r   r   r   r2   r  r  r  r   r   r   r   r   r   r   r  r   r  r	  )rX   rr   r  r  r&  	func_types         rS   r  zIndexNode.analyse_as_cpp  sU   IN	&&tdi-DEE$((QZQZQZ\`\f\k\k\klmmm"-DI(DKM	 	,!+I(8(8 	j $#-d33 j$$[%<=UWg%h%hiiiZ))).*;*@#FF
)	 	O90= 	O$(ADIMNNNrT   c           	         | j         j        }|j        r|                     |           n|                     |          | _        d | _        |j        "t          | j	        d           t          | _        n| j        t          | _        nt          |j                  t          | j                  k    rLt          | j	        dt          |j                  dt          | j                             t          | _        n?|                    t          t          |j        | j                                      | _        | S )Nz)Can only parameterize template functions.z-Wrong number of template arguments: expected , got )rZ  r   rg  parse_indexed_fused_cdefparse_index_as_typestype_indicesr[  	templatesr   r   r2   r   ri  dictr  rX   rr   r  s      rS   r  zIndexNode.analyse_as_c_function  s#   IN	 	d))#.... $ 9 9# > >DDJ"*dh KLLL&		"*&		Y())S1B-C-CCCdhhY011113t7H3I3I3I!L M M M&		%00c):MtO`6a6a1b1bcc	rT   c                    | j         j        }t          | j        t                    r| j                                        ry| j        j        }|j         |cxk    r|j        k     r&n n#|dk     r
||j        z  }|j        |         | _        n-t          | j
        d|d|d           t          j        | _        | S | j                             |          | _         |                     |||d          S )Nr   zIndex z out of bounds for 'r  Fr  r  r  )rZ  r   r~   r[  r]  r   r   ri  r2  r   r   r   r2   r   r  )rX   rr   r  r  r  r[  s         rS   r  zIndexNode.analyse_as_c_tuple   s    IN	dj'** 	ptz/M/M/O/O 	pJ.E%8888).88888199Y^+E%07		dhhuuiii)* * * '1	K	44S99DI44S'SZin4ooorT   c                    t          | j        t                    r| j        j        }n| j        g}| j        }|j        }d}|j        rddlm} |j	        r'|
                    |          }||j        }|j        }|}|                    ||j                  \  }	}}
|	rt          | j        ||          }n$t          | j        ||          }n|j        s|j        r|j        st%          |          |j        k    rd}fd|D             }|j        ryt'          d |D                       }|r]t)          |          D ]M\  }}|j        rAt-          |j        |j        |j        |j                  }|                              }|||<   Nnt'          d	 |D                       }|r3t7          | j        ||          }t          | j        t8                    rJ ||                    |          }|S )
zI
        Analyse buffer indexing and memoryview indexing/slicing
        Nr+   r  )indicesrZ  Tc                 :    g | ]}|                               S rV   rA  )rb   r[  rr   s     rS   r   z9IndexNode.analyse_as_buffer_operation.<locals>.<listcomp>1  s'    III5..s33IIIrT   c              3   T   K   | ]#}|j         j        p|j        p|j         j        V  $d S rM   )r   r  r   r=   rb   r[  s     rS   re   z8IndexNode.analyse_as_buffer_operation.<locals>.<genexpr>3  sL       ). ).! 
)YU^Yuz?Y). ). ). ). ). ).rT   r   r   r   c              3   .   K   | ]}|j         j        V  d S rM   r   r  r,  s     rS   re   z8IndexNode.analyse_as_buffer_operation.<locals>.<genexpr>=  s'      (P(Pu):(P(P(P(P(P(PrT   )r~   r[  r  r   rZ  r   r   r  r  r`  merged_indicesunellipsifyr  MemoryViewSliceNoder   MemoryViewIndexNoder  r=   r   allr  r   SliceIntNoder   r   r   r<  BufferIndexNoder  )rX   rr   r  r)  rZ  r  r  r  r0  have_slicesnewaxesr^  do_replacementr  r[  s    `             rS   r	  z%IndexNode.analyse_as_buffer_operation  sd    dj),, 	#joGGzlGyI	' #	A$$$$$$$ -!%!4!4W!=!=!-9D $	I,G,6,B,B7IN,[,[)K' ]#6txW[#\#\#\  #6txW[#\#\#\    	AI$= 	A( ACLLIN,J,J#' IIIIIII, Q%( ). ).%,). ). ). &. &.N & 3'0'9'9 3 3GAe$~ 3(4UYekX]Xbinis(t(t(t(-(;(;C(@(@-2
%((P(P(P(P(P%P%PN! A'6txW['\'\'\$)$*i@@@@@'/==c7KKrT   c                     |j         d         r| j                                        sd S | j                            d          | _        d S )N	nonecheckr  )rj   rZ  rA  rI  rX   rr   r  s      rS   r  z IndexNode.wrap_in_nonecheck_nodeG  sG    ~k* 	$)2G2G2I2I 	FI//0XYY			rT   c                    t          | j        t                    r| j        j        }n| j        g}g }|D ]L}|                    |                    |                     |d         |rt          |j        d            d S M|S )Nry  znot parsable as a type)r~   r[  r  r   r   re  r   r   )rX   rr   requiredr)  r"  r[  s         rS   r!  zIndexNode.parse_index_as_typesL  s    dj),, 	#joGGzlG 	 	E 5 5c : :;;;B' ?%)%=>>>tt ( rT   c                    t           j        | _        d| _        | j        j        }g }| j        j        s| j        j        r |                    | j        j	                   nCt          | j        t                    r)| j        j        D ]}|                    |j	                   |                     |d          }|| j                            |          | _        | j        j        j        st#          | j	        d           n^| j        j        j        x| j        _        | _        | j        j        x| j        _        | _        d| j        _        d| _        d| j        _        d| _        dS t)          |          D ]\  }}|                    |          ||<   |                                }t/          |          t/          |          k    rt#          | j	        d          S t/          |          t/          |          k     r-|t/          |                   }	t#          | j	        d|	z            S t1          |||          D ]D\  }
}t3          fd|j        D                       st#          |
d	          c S j        r dS Et9          t1          ||                    }|                    |          }|j        rt#          | j	        d
           dS | j        j                                        D ]}|                     |          rh|| _        | j        j        r$|j        | _        d| _        | j        j!        | _!        d| j        j        _        || j        _        |j        | j        _         dS tE          d          )aK  
        Interpret fused_cdef_func[specific_type1, ...]

        Note that if this method is called, we are an indexed cdef function
        with fused argument types, and this IndexNode will be replaced by the
        NameNode with specific entry just after analysis of expressions by
        AnalyseExpressionsTransform.
        TF)r>  Nz)Can only index fused functions with typeszToo many types specifiedzHNot enough types specified to specialize the function, %s is still fusedc                 :    g | ]}                     |          S rV   )r  )rb   rc   specific_types     rS   r   z6IndexNode.parse_indexed_fused_cdef.<locals>.<listcomp>  s'    KKKQ--a00KKKrT   zType not in fused typez6Index operation makes function only partially specificz!Couldn't find the right signature)#r   r2   r   is_fused_indexrZ  r[  r   r\  r   r   r~   r  r   r!  r<  r   r  r   r   r  r  specialize_fusedget_fused_typesr   r  rk   typesr  r$  ri  rg  r  r  r#  r   )rX   rr   r  	positionsrh  specific_typesr  r   fused_typesrc   r   
fused_typerh  r  rA  s                 @rS   r   z"IndexNode.parse_indexed_fused_cdefZ  s    )	"IN		: 	*!8 	*TZ^,,,,
I.. 	*z * *  ))))2232GG!11#66DJ9?. 
'dh KLLLL 04y/JJ	$*-1Z_<	$(	!#"&
"'DF 00 	; 	;GAt $ 5 5c : :N1//11~[!1!111#=>>>  3{#3#333C//0A $EGH$I J J J /2)2@2=/? /? 	 	*C
 KKKK*:JKKKLL <S":;;;;;$(>$ % ![.!A!ABB##$566= 	I$(JL L L L L "Y^NNPP I I	<<	**  )DIy- 1 &/_
,0)#'9=+/DIO(%.DIN&/oDIOEE" $$GHHHrT   zIndexing Python objectc                 >   | j         j        t          t          t          fv r\| j         j        t          u rd}n2| j         j        t          u rd}n| j         j        t          u rd}nJ d| j         j        z              | j         j        j        rA| j                                         dd                    d | j        D                       d	S | j         j        j	        rD| j
        j        }|d
k     r|| j         j        j        z  }| j                                         d|S | j        j        s| j        j        r,| j        | j         j        k    rt          | j        d           d S d}|| j                                         | j
                                        fz  S )Nz__Pyx_PyList_GET_ITEM(%s, %s)z__Pyx_PyTuple_GET_ITEM(%s, %s)z5((unsigned char)(__Pyx_PyByteArray_AsString(%s)[%s]))Fz$unexpected base type in indexing: %s<,c                 6    g | ]}|                                 S rV   )r  )rb   params     rS   r   z3IndexNode.calculate_result_code.<locals>.<listcomp>  s$    XXXU%6688XXXrT   >r   .fzInvalid use of pointer slicez(%s[%s]))rZ  r   r   r   r    rU  r  r  r"  r1  r[  r   ri  r  rT  r   r   )rX   
index_coder[  s      rS   r  zIndexNode.calculate_result_code  s   9>i^DDD y~**<

:--=

>11T

UDty~UUUUY^( 	$	  """"XXdFWXXXYYYY[ [ Y^% 		$J.Eqyy,,#y//11115599	  DI$6 DI<W<Wdh >???#JTY--//1B1B1D1DEEErT   c                    | j         j        j        r| j        j        t          u }t          |j        j        d                   o;| j        j	        o/t          | j         j        t                    o| j         j        dk     }t          |j        j        d                   }| j         }d| j                                        | j        j	        rdpd| j        j        ||||fz  S dS )Nr  r   r  z, %s, %d, %s, %d, %d, %d, %dr+   r  )r[  r   r  rZ  r   rH  r   rj   r
  r  r~   r   r   r  r  to_py_function)rX   r   is_listr  r  has_gils         rS   extra_index_paramszIndexNode.extra_index_params  s    :?! 	in	1GT%0>?? :(/:
 :C@@ 93q8: 
 t/:=IJJK//G1(??AA(/5A:(7['	5; ; ; 2rT   c                    | j         sd S | j        j        }d }d }| j        j        rd}| j        j        j        r1|t          u rd}n|t          u rd}nd}t          j	        dd          }nM|t          u rd}t          j	        dd          }n+|t          u r+| j        j        t          u rd	}t          j	        dd          }nd
}|j                            t          j	        dd                     t          j	        dd          }n| j        j        r6|t          u r-| j        j        j        sJ d}d}t          j	        dd          }np|t"          u r;| j        j        j        sJ | j        j        sJ d}d}t          j	        dd          }n,|j        r| j        sJ d| j        d|d| j        d            ||j                            |           | j        j        j        r| j                                        }n| j                                        }|j        r| j        rt/          || j        |                                 d| j                                        d| j                                        d| j        j        r|                                 nd | j        | j                   n|dk    rdnd|z  }|                    |                                 d|d| j                                        d||                     |          d|                    ||                                 z  | j                  
           | j        j        r|                     |           d S d S ) Nr  __Pyx_GetItemInt_List__Pyx_GetItemInt_Tuple__Pyx_GetItemInt
GetItemIntr  __Pyx_PyDict_GetItemDictGetItem__Pyx_PyObject_Dict_GetItem__Pyx_PyObject_GetItemObjectGetItem__Pyx_GetItemInt_Unicodez(Py_UCS4)-1GetItemIntUnicoder  __Pyx_GetItemInt_ByteArrayz-1GetItemIntByteArrayFzunexpected type z and base type z for indexing (r  r<  [z];!%sz	%%s == %sr;  r  r  )r   rZ  r   ro   r[  r  r   r   r	   r   r   r   r   r   r   r   rD  r    r  r   r   r  r   r   r   r  r   rV  r   r  )rX   r   r  r$  error_valuer&  rQ  error_checks           rS   r  zIndexNode.generate_result_code  s   | 	FIN	9  $	0 Kz% `	))6HH*,,7HH1H1=lL^__	))5H#.#:=J\#]#]LL.00TZ_5T5T<H#.#:=J\#]#]LL7H$55*6|EWXXZ Z Z#.#:?L^#_#_LLY& 	09+D+D:?))))1H'K&23FXXLL.((:?))))9####3HK&23H/ZZLL( 	0T-A 	00 0			999dhhh0 0 0 0 #--l;;;:?! 	0**,,JJ--//J! 	Pd&: 	P#D$("&++----1A1A1C1C1C1C"&*"3"3"5"5"5"57!%!6@D$d&;	= = = = $/&#8#8%%kK>WKJJKKMMMMHHI''))))J++D1111&&{T[[]]'BDHMMMOP P P 9  	'  &&&&&	' 	'rT   c                 n   | j         j        j        r| j        j        t          u r0|j                            t          j        dd                     d}n/|j                            t          j        dd                     d}| j         	                                }n1| j         
                                }| j        j        t          u rd}nd}|                    |                    |d	| j        
                                d
|d
||                     |          d	| j                             d S )NSetItemIntByteArrayr  __Pyx_SetItemInt_ByteArray
SetItemIntr  __Pyx_SetItemIntr7  PyObject_SetItemr;  r  r  )r[  r   r  rZ  r    r   r   r   r   r  r   r   r   r  rV  r   )rX   
value_coder   r&  rQ  s        rS   generate_setitem_codezIndexNode.generate_setitem_code/  sN   :?! 	.y~// 11+,A?SSU U U7 11+L:LMMO O O-**,,JJ--//Jy~**+ .

4))	##%%%%


''----/ H  	 	 	 	 	rT   c           
      "   |                      |           | j        j        r*|                     |                                |           no| j        j        t          u r.|                     ||          }|                     ||           n.| j        j        j        r| j	        r| j	        dk    r|r\|rZ| j
        |k    rOt          || j        | j        |                                 |                                | j
        || j                   nt          || j        |                                 d|                                d| j        j        r|                                 nd | j
        | j                   n?|                    |                                 d|                                d           |                     |           |                     |           |                    |           |                    |           d S )Nr   r<  r=  )r  r   ro   rp  r   rZ  r    _check_byte_valuer  r   r   r   r   r  r  r   r   r  r  r  r  )rX   r   r   r  r   r   ro  s          rS   r  z"IndexNode.generate_assignment_codeP  s   --d3339  	<&&s}}====Y^~--//c::J&&z48888Y^( 	<T-A 	<dFZ^aFaFa$ A AT=QUd=d=d /tTXtyKKMM3::<<1E#T%:< < < < (dh"&++---->%)Y%:DDKKMMM($*?A A A A
 JJ"kkmmmmSZZ\\\\:< < < 	++D111%%%""4(((trT   c                 V   |j         j        sJ t          |j                               |                                }|                                r9d|j        cxk    rdk     rn n|S d}t          |j        d|j        z  d           n|j         t          j	        k    }| j
        sg }|j        s|j         j        r|                    d|z             |j        s>|                                r*|j         t          j	        t          j        t          j        fv s|                    d|z             |rp|                    d	d
                    |          z             |                    d|                    | j                  z             |                    d           |rd|z  }|S )Nr      Tz9value outside of range(0, 256) when assigning to byte: %sr+   r|   z%s < 0z%s > 255if (unlikely(%s)) {z || zFPyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); %sr   z((unsigned char)%s))r   r  r
  r  r   r   r   r   r   r  r   r   r  r   r  r   c_schar_typer   r  r   )rX   r   r   ro  
needs_cast
conditionss         rS   rr  zIndexNode._check_byte_valueq  s   x..SX...ZZ\\
""$$ 		=C'----#-----!!JCG2474GH    
 Z%<<Jz 	 J~ 9 9!!(Z"7888 ;''));.1h"/1G"/;1 /1 /1 !!*z"9:::  

06;;z3J3JJKKK

<OODH--./ / / 

3 	<.;JrT   c                 `   |                      |           | j        j        j        rId}| j                                        }|j                            t          j        dd                     n1| j        	                                }| j
        j        t          u rd}nd}|                    |                    |d| j
        	                                d||                     |          d| j                             |                     |           |                     |           d S )	N__Pyx_DelItemInt
DelItemIntr  PyDict_DelItemPyObject_DelItemr;  r  r  )r  r[  r   r  r  r   r   r   r   r   rZ  r   r   r  rV  r   r  r  )rX   r   r  r&  rQ  s        rS   r  z IndexNode.generate_deletion_code  s@   --d333:?! 
	.)H**,,J--'6HIIK K K K --//Jy~**+-

4))	##%%%%
''----	/
 H  	 	 	 	++D111%%%%%rT   )FFTTrT  rR  )$rZ   r[   r\   r   r"  r]  rB  r%  r/  r:  rA  r8  re  r  rO  r   r<  rD  r  r  r  r  r  r  r	  r  r!  r   r  r  rV  r  rp  r  rr  r  rV   rT   rS   r\  r\  X  s4         HLLNU U U- - -L L L
* * *  A A AF  T T TX X XtD D D   HM26F F F FP8 8 8t    0  ,p p p$3  3  3 jZ Z Z
   YI YI YIv +KF F F:  $G' G' G'R  B INGK   B" " "H& & & & & &rT   r\  c                        e Zd ZdZddg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dZddZd Z fdZ xZS )r6  z
    Indexing of buffers and memoryviews. This node is created during type
    analysis from IndexNode and replaces it.

    Attributes:
        base - base node being indexed
        indices - list of indexing expressions
    rZ  r)  TFrV   c                 4    |                      |d           d S NFr   rA  r   s     rS   rD  z$BufferIndexNode.analyse_target_types  s!    3.....rT   c                    | j         j        s<t          | j         j                  s#t	          | j        d           t          | _        | S |sZ| j         j        j        j        st	          | j        d           n.d| _	        | j         j        j
        rd| j         j        j        _	        d| _        |                     ||           |                     |           | S )zz
        Analyse types for buffer indexing only. Overridden by memoryview
        indexing and slicing subclasses
        zCan only index buffer variableszWriting to readonly bufferTr  )rZ  r   r=   r   r   r   r2   r   writabler  r  
buffer_auxnone_error_messageanalyse_buffer_indexr  r<  s      rS   r<  zBufferIndexNode.analyse_types  s     y  	)H)H 	$(=>>>"DIK 	F9?'0 Fdh <===='+$9>+ FAEDIO.>"J!!#w///##C(((rT   c                    t          | j        j                  r>d | j        D             }t	          t          | j        j        |                    | _        n5| j                            |          | _        | j        j        j        | _        | j        j        | _        |r!| j        j	        s| j        j         rd| _
        d S d S d S )Nc                      g | ]}||j         fS rV   r  )rb   idxs     rS   r   z8BufferIndexNode.analyse_buffer_index.<locals>.<listcomp>  s    #L#L#LS#(O#L#L#LrT   T)r=   rZ  r   r)  rI   rC   rK  r  buffer_typero   r   )rX   rr   r  index_with_type_lists       rS   r  z$BufferIndexNode.analyse_buffer_index  s    49>** 	-#L#Lt|#L#L#L #$9$).J^$_$_``DII	22377DI	,DI9> 	 	- 	 1J 	 DLLL	  	  	  	 rT   c                     dS )zk
        Called by IndexNode when this node is assigned to,
        with the rhs of the assignment
        NrV   rX   r   s     rS   analyse_assignmentz"BufferIndexNode.analyse_assignment  s      rT   c                     |j         d         r| j                                        sd S | j                            | j                  | _        d S )Nr;  )rj   rZ  rA  rI  r  r   s     rS   r  z&BufferIndexNode.wrap_in_nonecheck_node  sI    ~k* 	$)2G2G2I2I 	FI//0GHH			rT   c                     | j         s| j        r1| j        j        r#t	          | j        d           t          | _        d S d S d S )Nz2Cannot access buffer with object dtype without gil)r^  r_  r   ro   r   r   r2   r   s     rS   rs  zBufferIndexNode.nogil_check  sV      	'D$9 	'y$ 'dh TUUU&			' '	' 	'rT   c                     d| j         z  S Nr  )buffer_ptr_coderW   s    rS   r  z%BufferIndexNode.calculate_result_code  s    ---rT   c                 j    | j         }| j         j        r|j        }|j                            |          S rM   )rZ  is_nonecheckrh  r   	get_entryr  s     rS   buffer_entryzBufferIndexNode.buffer_entry  s3    y9! 	8Dy""4(((rT   c                    |j                             t          j        |j        |j        j        rt          j        nt          j                  d          }|                    |d|	                                d           |S )NFr  r<  r=  )
r  r  r   r  r   r  c_ssize_t_typec_size_t_typer   r  )rX   r   ivarrets       rS   get_index_in_tempz!BufferIndexNode.get_index_in_temp  s    n***	-1Y-=[
)):C[] ] 	 +  
 	

dkkmmmm4555
rT   c                      j         r; j        s j        r-j        j        d         rt           j        dj                    fd j        D             x _        }ddl	m
}                                  }|j        j        r|j        j        }n|j        d         }||                    |d  j        D             |j        j         j        | j                   fS )	z8
        ndarray[1, 2, 3] and memslice[1, 2, 3]
        r  z(Use boundscheck(False) for faster accessc                 <    g | ]}                     |          S rV   )r  )rb   r  r   rX   s     rS   r   z6BufferIndexNode.buffer_lookup_code.<locals>.<listcomp>  s*    )e)e)ePT$*@*@d*K*K)e)e)erT   r+   r  negative_indicesc                 &    g | ]}|j         j        S rV   )r   r  )rb   r  s     rS   r   z6BufferIndexNode.buffer_lookup_code.<locals>.<listcomp>"  s    EEE49+EEErT   )r   index_signedsindex_cnamesrj   r   r   r  r  )r  r^  r_  r   rj   r-   r   r)  index_tempsr  r  r  r   r  r  buffer_defaultsput_buffer_lookup_code)rX   r   r  r  r  r  s   ``    rS   buffer_lookup_codez"BufferIndexNode.buffer_lookup_code  s)      	m$ m(= m#.}= m$TX/Y[_[klll *f)e)e)e)eX\Xd)e)e)ee; 	((**& 	J+0A%56HIV::EEEEE$'2t-!2 ; 4 4 4 	4rT   c                    |                      |           |                     ||           |                     |           |                     |           |                    |           |                    |           d S rM   )r  generate_buffer_setitem_coder  r  r  r  rX   r   r   r  s       rS   r  z(BufferIndexNode.generate_assignment_code)  s    --d333))#t444++D111%%%""4(((trT   r  c           	         | j         j        }t          |          rt          |j                  r|j                            t          t          | j         j                            d          }|                    d|z             |                    d|d|d| j         	                                d           |                    |t          | j                  d|d	|	                                d
           |j                            |           d S |                     |          \  }}| j        j        j        r|j                            |j        d          }|                                }	|                    |d|d
           |                    d|z  | j        j                   |                    d|	d|d           |                    d|d|d	|	d
           |                    d|z  | j        j                   |j                            |           d S |                    d|d|d	|                                d
           d S )NFr  __Pyx_call_destructor(%s);r>  r?  r@  rA  r[  z= r=  r<  z*%sz__Pyx_INCREF(z); __Pyx_XDECREF(*r  r   )rZ  r   r=   r;   r  r  rI   rE   r   r  rB   r)  r  r  r  r  ro   buf_ptr_typer  r  r  )
rX   r   r   opr  r#  r  ptrexprptrr   s
             rS   r  z,BufferIndexNode.generate_buffer_setitem_code1  s}   IN	9%% 	*CCH*M*M 	...{<	;W;W/X/Xej.kkC JJ3c9:::JJJSSS$)BZBZB\B\B\B\]^^^JJ%dl3333""$$$$	& ' ' '
 N'',,,F !% 7 7 = =g!- 	D ...|/H:? / A ACzz||HJJSSS'''2333US[$*:*@AAAJJJ###      JJJRRR:;;;eck4+;+ABBBN'',,,,, JJJSZZ\\\\BCCCCCrT   c                 N   t          | j        j                  rx|                                 }|                    d|z             |                    d|d|d| j                                        t          | j                  d           d S |                     |          \  }| _	        | j        j
        rj|                                 }|                    |d| j	        d           |                    d|d	|d
           |                    d|z             d S d S )Nr  r>  r?  r@  rA  z = (PyObject *) *r=  r_  z == NULL)) z = Py_None;z__Pyx_INCREF((PyObject*)%s);)r=   rZ  r   r  r   r  rB   r)  r  r  ro   )rX   r   resr  s       rS   r  z$BufferIndexNode.generate_result_code[  s8   49>** 	++--CJJ3c9:::JJJ	((***%dl3333	5 6 6 6
 F-1-D-DT-J-J*d*9  	= ++--CJJ3338L8L8LMNNNJJJCCCMNNNJJ5;<<<<<	= 	=rT   c                     | j         D ]}|j                            |           d| _         t                                          |           d S r  )r  r  r  rO   r  )rX   r   temprR   s      rS   r  z"BufferIndexNode.free_subexpr_tempsp  sT    $ 	. 	.DN''----""4(((((rT   r~  rR  )r  )rZ   r[   r\   r  r   r^  r  r  rD  r<  r  r  r  rs  r  r  r  r  r  r  r  r  r]   r^   s   @rS   r6  r6    s<         	"H O K/ / /   0
  
  
   I I I
' ' '. . .) ) )  4 4 4:   (D (D (D (DT= = =*) ) ) ) ) ) ) ) )rT   r6  c                   0    e Zd ZdZdZddZd Zd Zd ZdS )	r3  TFc                    ddl m} t          |          | _        | j        }|                    || j        j        j                  \  }}}|s5d| _	        | j        j
        s| j        j        rd| j        j        j        _	        | o!t          |          | j        j        j        k    | _        g }t          j        }g }	t          |          t          |          z
  | j        j        j        k    rEt"          | _        t%          || j        j        j                 j        d| j        j        z             | S d}
t)          |          D ]\  }}|                    |          }|j        r2d| _        |	                    |           |                    d           T| j        j        j        |
         \  }}|
dz  }
|j        rd| _        |j        j        r|                    ||f           n|                    |df           dD ]U}t9          ||          }|j        s<|                    ||          }t=          |||           |	                    |           V|j        j        s|j        j         r[|j        j         rtC          |j        d	|           d| _"        |                    ||          }|||<   |	                    |           t"          | _        t%          |j        d
|j        z             | c S | j"        o| j         | _"        |	| _        || _#        |j$        | _$        | %                    |||          }|&                    |           |S )Nr+   r  Tz&Too many indices specified for type %sr   )directstridedr  r-  z/Index should be typed for more efficient accessz/Invalid index for memoryview specified, type %s)'r  r  rA   is_pythran_moder)  r1  rZ  r   r  r  r   r\  r   r   memslice_indexr   r^  r2   r   r   r  r<  r  r`  r   r  r   r   r   r  setattrr  ro   r-   r_  original_indicesr   analyse_operationr  )rX   rr   r  r  r)  r7  r8  r  r  new_indicesaxis_idxr  r[  accesspackingattrr   r   s                     rS   r<  z!MemoryViewIndexNode.analyse_types|  sj         -c22,(2(>(>w	H[(\(\%Wg 	<#'D y  <DI$: <7;	$4#*{Rs7||ty~?R/R1
w<<#g,,&)<<<"DI'$).-.2:TY^KM M MK!'** '	 '	HAu'',,E} (,%""5)))1222"in1(;OFGMH~ (,%:% 5KK 12222KK 3444 6 2 2D#E400E = 2 %
C @ @tU333#**51112 " ej&< :) h$UY0acfggg(,%
C88"
""5)))) '	ei!RUZU_!_``` !% 5 Sd>S:S" !(Y
%%c7D99##C(((rT   c                 @    d| _         |                     ||           | S )Nz"Cannot index None memoryview slice)r  r  )rX   rr   r  r  s       rS   r  z%MemoryViewIndexNode.analyse_operation  s%    "F!!#w///rT   c                 b    | j         j        r | }|j        s|j        rd|_        d|_        dS dS dS )z
        Support broadcasting for slice assignment.
        E.g.
            m_2d[...] = m_1d  # or,
            m_1d[...] = m_2d  # if the leading dimension has extent 1
        TN)r   r   r  rX   r   lhss      rS   analyse_broadcast_operationz/MemoryViewIndexNode.analyse_broadcast_operation  sU     9' 	0C' 03+C 0+/(+/(((		0 	00 0rT   c                 P    |                      |          }|r|j        |_        |S | S rM   )r  r  r  s      rS   $analyse_as_memview_scalar_assignmentz8MemoryViewIndexNode.analyse_as_memview_scalar_assignment  s2    %%c** 	-0-KC*JrT   Nr~  )	rZ   r[   r\   r_  r^  r<  r  r  r  rV   rT   rS   r3  r3  w  sf        M M M M^  
0 0 0    rT   r3  c                   T    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d
ZdS )r2  TFc                     t          d | j        D                       | _        | j        r| j        j        | _        dS dS )z@Slicing operations needing no evaluation, i.e. m[...] or m[:, :]c              3   l   K   | ]/}|j         o#|j        j        o|j        j        o|j        j        V  0d S rM   )r   r   r  r   r   r,  s     rS   re   z<MemoryViewSliceNode.analyse_ellipsis_noop.<locals>.<genexpr>  sV       $' $' N`u{2`uz7I`ejN`$' $' $' $' $' $'rT   N)r4  r)  is_ellipsis_nooprZ  r   r<  s      rS   analyse_ellipsis_noopz)MemoryViewSliceNode.analyse_ellipsis_noop  sZ     !$ $' $'$' $' $' !' !'   	'	DIII	' 	'rT   c                    ddl m} |sd| _        d| _        nd| _        |                     ||           | j        r| S d | _        d| _        d| _        |	                    | j
        |          st          | _        | S t          j        | j        j        j        |          | _        | j                                        s8| j                                        s| j                            |          | _        | S )Nr+   r  Tz&Cannot assign to None memoryview slicez"Cannot slice None memoryview slice)r  r  r  r  r  r  r[  r   r  validate_axesr   r2   r   r   r  rZ  r  r:  r  r8  )rX   rr   r  r  r  s        rS   r  z%MemoryViewSliceNode.analyse_operation  s           	K(,D%&ND##&JD#""3000  	K
#''$77 	"DIK249>3GNN		##%% 	6)A)A)C)C 	6	0055DIrT   c                     |j         j        sE| j         j                            |j                   s|j         j        rt          | j        |           S t          | j        |           S rM   )r   r   r  r  ro   MemoryCopyScalarr   MemoryCopySlicer  s     rS   r  z&MemoryViewSliceNode.analyse_assignment  s^    x* 	3	//99	3$	3 $DHd333"48T222rT   c                    |sdS | j         dd         }|dd         }t          | j                   D ]i\  }}|j        rN|j        j        r?|j        j        r3|j        j        r'|d         ||<   |                    d           |s|c S W dS |j        j	        s dS j|r9t          |          t          |          z   | j        j        j        k    rdS ||z  }|S )a  Return a new list of indices/slices with 'indices' merged into the current ones
        according to slicing rules.
        Is used to implement "view[i][j]" => "view[i, j]".
        Return None if the indices cannot (easily) be merged at compile time.
        Nr   )r  r  r   r   r  r   r   r   r   r  r   rZ  r  )rX   r)  r  r  r  s        rS   r0  z"MemoryViewSliceNode.merged_indices  s     	4+AAA.!!!*d344 	 	DAqz 7?  qv~  !&.  %,QZKNKKNNN" +****+  44V] tt  	#;#g,,.1DDDt7"KrT   c                     | j         r2| j                                        p| j                                        S |                                 S rM   )r  rZ  r:  r  rW   s    rS   r:  zMemoryViewSliceNode.is_simple<  sG      	G9&&((FDI,D,D,F,FF""$$$rT   c                 4    | j                                         S )z3This is called in case this is a no-op slicing node)rZ  r  rW   s    rS   r  z)MemoryViewSliceNode.calculate_result_codeC  s    y!!!rT   c           	      (   | j         rd S |                                 }| j         }d}t          | j                  }| j        D ]{}|j        rcd}|j        j        st          |          |_        |j
        j        st          |          |_
        |j        j        st          |          |_        lt          |           |t          |          rJ |                    || j        |                                 | j        |||j        j                   d S )NFT)r  r7  rj   )r  r  r  iterr)  r  r   r   r  nextr   r   r   generate_buffer_slice_coder  r   r   rj   )rX   r   r  r  r7  r  r[  s          rS   r  z(MemoryViewSliceNode.generate_result_codeG  s     	F((**,, $,* 
	 
	E~ 	"{* +"&r((EKz) *!%bEJz) *!%bEJR88//$'	;'2 	0 	4 	4 	4 	4 	4rT   c                    | j         r|                     |           n|                     |           | j        r|                     ||           n|                     ||           | j         r|                     |           n|                     |           |                    |           |                    |           d S rM   )	r  r  r  is_memview_scalar_assignment+generate_memoryviewslice_assign_scalar_code&generate_memoryviewslice_setslice_coder  r  r  r  s       rS   r  z,MemoryViewSliceNode.generate_assignment_codec  s      	011$7777))$///, 	C<<S$GGGG77TBBB  	.//5555''---""4(((trT   NrR  )rZ   r[   r\   r`  r  r  r_  r  r  r  r  r0  r:  r  r  r  rV   rT   rS   r2  r2    s         #(  ' ' '  63 3 3  >% % %" " "4 4 48     rT   r2  c                   0     e Zd ZdZdgZ fdZddZ xZS )MemoryCopyNodeze
    Wraps a memoryview slice for slice assignment.

        dst: destination mememoryview slice
    dstc                 p    t                                          |           || _        |j        | _        d S rM   )rO   rl  r  r   rX   r   r  rR   s      rS   rl  zMemoryCopyNode.__init__  s/    H			rT   Fc                 "   | j                             |           |                     ||           | j                             |           | j                             |           |                    |           |                    |           d S rM   )r  r  _generate_assignment_coder  r  r  s       rS   r  z'MemoryCopyNode.generate_assignment_code  s    ))$///&&sD111''---D!!!""4(((trT   rR  )rZ   r[   r\   r  r   rl  r  r]   r^   s   @rS   r  r  w  s_          wH    
       rT   r  c                        e Zd ZdZdZdZd ZdS )r  z
    Copy the contents of slice src to slice dst. Does not support indirect
    slices.

        memslice1[...] = memslice2
        memslice1[:] = memslice2
    T__pyx_memoryview_copy_contentsc                    | j         }|j                            |j                   |j                            |j                   |                    |                    d| j        |                                |                                |j        j        |j        j        |j        j	        j
        fz  |j                             d S )Nz%s(%s, %s, %d, %d, %d))r  r   assert_direct_dimsr   r   r  copy_slice_cnamer  r  r  ro   )rX   r	  r   r  s       rS   r  z)MemoryCopySlice._generate_assignment_code  s    h##CG,,,##CG,,,

4))$(=(+

cjjll(+sx}(+(B(D D G  	 	 	 	 	rT   N)rZ   r[   r\   r  r  r  r  rV   rT   rS   r  r    s;          "&7    rT   r  c                   (     e Zd ZdZ fdZd Z xZS )r  z
    Assign a scalar to a slice. dst must be simple, scalar will be assigned
    to a correct type and not just something assignable.

        memslice1[...] = 0.0
        memslice1[:] = 0.0
    c                 n    t                                          ||           |j        j        | _        d S rM   )rO   rl  r   r  r  s      rS   rl  zMemoryCopyScalar.__init__  s,    c"""HN			rT   c                    ddl m} | j        j                            | j        j                   | j        j        j        }|                    d          }| j        j                            d          }|                                 |	                    |d|
                                d           | j                                        s| j                                        r| j        
                                }n4|	                    |d| j        
                                d           d}d}| j        j        }	|	D ]=}
t          |
t                    r&|
j        j        r|
j        j        r|
j        j        sd	}>|                    | j        j        || j        j        j        ||
          }|                                }|j        r|	                    d|z             |	                    d|d|d           |j        r|	                    d           |                                 |                                 d S )Nr+   r  r  z __pyx_temp_scalar = r=  z __pyx_temp_slice = __pyx_temp_sliceFT)force_stridedzPy_DECREF(*(PyObject **) %s);z*((z *) z) = __pyx_temp_scalar;zPy_INCREF(__pyx_temp_scalar);)r  r  r  r   r  r   r  r   begin_blockr   r  r  r:  r  r~   r  r   r  r   r   
slice_iterr  start_loopsro   	end_loops	end_block)rX   scalarr   r  r  	type_decl
slice_decldst_tempr  r)  r  slice_iter_objps                rS   r  z*MemoryCopyScalar._generate_assignment_code  s=         ((666#**2..	X]33B77


999fmmooooNOOO8""$$ 	*(:(:(<(< 	*x((HHJJjjj$(//BSBSBSBSTUUU)H(+ 	% 	%C#y)) %393D %3683C%3683C% !%#..tx}h/3x}/A4=J / L L &&(( 	<JJ6:;;;


)))QQQGHHH 	8JJ6777  """rT   )rZ   r[   r\   r  rl  r  r]   r^   s   @rS   r  r    sQ         # # # # #' ' ' ' ' ' 'rT   r  c                       e Zd Zg dZdZdZd Zd dZd Zd Z	d	 Z
d
 Zd Zd!dZd Z fdZdZ ej        ddddi          Z ej        ddddi          Z fdZd Z	 	 d"dZd#dZd Zd Zd Zd Zd Z xZS )$SliceIndexNode)rZ  r   r   sliceFNc                 "   | j                             |          }|j        s|j        rt          S |j        rt          S |t          t          t          t          t          fv r|S |j
        s|j        rt          j        |j        d           S t          S rM   )rZ  r   r  r  r   r  r   r    r   r   r  rT  r   r  r  r   r%  s      rS   r   zSliceIndexNode.infer_type  s    I((--	 	F)"8 	F' 	F:~|$j2 2 2 	F!3 	F*9+>EEErT   r   c                     |t           ur7| j        r0| j                                        r|| j        j        z  }nt           }| j                            |          S rM   )r)  r   r   r   rZ  r`  r_  s     rS   r`  z"SliceIndexNode.inferable_item_node  sV    &&4:&z--// '33&y,,U333rT   c                     | j         j        }|r-|j        rdS |t          t          t
          t          t          fv rdS t          	                    |           S rw  )
rZ  r   r  r   r    r   r   r   r   rA  r  s     rS   rA  zSliceIndexNode.may_be_none  sY    IN	 	" uZ&
4 4 4u##D)))rT   c                     | j         d }n| j         j        }| j        d }n| j        j        }| j        j        ||         | _        d S rM   )r   r   r   rZ  )rX   r   r   s      rS   r%  z(SliceIndexNode.calculate_constant_result  sP    :EEJ.E9DD9,D#y8tDrT   c                 6   | j                             |          }| j        d}n| j                            |          }| j        d }n| j                            |          }	 |||         S # t          $ r }|                     |           Y d }~d S d }~ww xY wr   )rZ  r/  r   r   r=  r3  )rX   r.  rZ  r   r   r2  s         rS   r/  z!SliceIndexNode.compile_time_value  s    y++D11:EEJ11$77E9DD9//55D	-d
## 	- 	- 	-))!,,,,,,,,,	-s   $	A. .
B8BBc                     d S rM   rV   r   s     rS   r8  z)SliceIndexNode.analyse_target_declaration'  r   rT   c                 d    |                      |d          }|j        j        rt          |_        |S r  )r<  r   ro   r   r>  s      rS   rD  z#SliceIndexNode.analyse_target_types*  s3    !!#u!559  	'&DIrT   Tc                 P   | j                             |          | _         | j         j        j        s"| j         j        j        s| j         j        j        rpt          | j                  }t          | j        | j	        p|| j
        p||          }t          | j        || j                   }|                    ||| d          S | j	        r| j	                            |          | _	        | j
        r| j
                            |          | _
        |j        d         st          | j	        | j
                   | j         j        }|j        r7|s5| j	        s| j
        s|| _        nt!          j        |j                  | _        n|j        s|j        rt+          |          | _        nt|j        rt.          | _        n`|j        r|| _        nQ|j        rt!          j        |j                  | _        n+| j                             |          | _         t4          | _        |j        r&|| _        | j                             d          | _         | j        t4          u r| j	        r| j	        j        r| j
        r| j
        j        rvt          | j                  }t          | j        t=          j        | j	        p|          t=          j        | j
        p|          |                              |          | _         nt           j!        fd}| j	        rH| j	        j        j"        r || j	        d|          | _	        | j	        #                    |          | _	        | j
        rH| j
        j        j"        r || j
        d	|          | _
        | j
        #                    |          | _
        d
| _$        | S )Nr-  )r[  rZ  Fr'  r  r  c                    ddl m}m}  ||           }t          | j        t          | j        ||                                rt          |          nt                    |	                    |          t          | j        |dt          | j                                                |                                        |          } |||          S )Nr+   EvalWithTempExprNodeResultRefNoderV  is)operand1r   operand2)true_val	false_valtest)	UtilNodesr  r	  CondExprNoder   r]  r  r   r)  r  PrimaryCmpNoder  r<  analyse_result_type)r   default_valuerr   r  r	  node_refnew_exprc_ints          rS   
allow_nonez0SliceIndexNode.analyse_types.<locals>.allow_noneo  s    JJJJJJJJ(=..'H$"+>K>S>S>U>U(iM(:(:(:[i	   '00<<'!)!%!)$(!3!3	  
 $mC((   &%c**   ,+Hh???rT   r  r%  r+   )%rZ  r<  r   r  r=   r   r  r   r  r   r   r\  r  rj   r   rT  r   r  r  r  rX  rz   r  r   r  r   r   r  rI  r   r&   deepcopyr  r^  ro   r  r   )	rX   rr   r  	none_noder[  r   r  r  r  s	           @rS   r<  zSliceIndexNode.analyse_types1  s   I++C00	9># 		$ty~'E 		$Ij 		$ **Idh$(J$;)#'9#9	#,. . .E #485tyIIIJ::W'k" ; $ $ $ : 	711#66DJ9 	5	//44DI~l+ 	:"4:ty999IN	 	'g 	': Edi E%		&/	0CDD		  	'I$; 	'(--DII' 	'$DII 		'!DII 	' #+I,?@@DII	44S99DI&DI$ 	^!DI	334\]]DI9&&J 	%$*"7 	%	%&*i&:	% %TX..	&H-
(?i@@ty'=I>>"	  
  -$$ 
 0E@ @ @ @ @. z >:?. B!+DJS!A!ADJ!Z11%==
y <9>- M *
496F L LDI I//s;;	rT   c                 v   | j                             |          }|r| j        s| j        sddlm} |                    |                    |j        j	                             t          | j                  }t          | j        |||          }t          j        ||                    ||g                    S d S )Nr+   r  r-  )rZ  re  r   r   r  r  r   r  r  r  r  r   r  r   r  r  )rX   rr   r  r  r  
slice_nodes         rS   re  zSliceIndexNode.analyse_as_type  s    I--c22	 	M: Mdi M(((((($$44A   
 %TX..	&H#""	  
 "5z88zlKKM M MtrT   c                 ^    |j         | _         t                                          |          S rM   )r   rO   rs  rX   rr   rR   s     rS   rs  zSliceIndexNode.nogil_check  s$    Y
ww""3'''rT   zSlicing Python objectSliceObjectr  r  Get)r  Setc                    | j         j        j        s| j         j        j        rY|t          t
          t          fv rC|t          u r3|j        d         s&t          | j	        d| j         j        d|d           || _        |j
        r:| j         j        j
        r)| j        s"| j        s| j                             ||          S t                                          ||          S )Nr`   /default encoding required for conversion from '' to 'r  )rZ  r   r  rX  r   r    r   rj   r   r   rT  r   r   r  rO   r  s      rS   r  zSliceIndexNode.coerce_to  s    Y^% 	!)E 	!^\ JJJL((@S1T(dhhY^^^XXX/0 0 0 !DI 	:!8 	:: :di :y**8S999ww  3///rT   c                    | j         j        st          | j        d| j         z             d S | j        j         }|                                 }|                                 }|                                 }|j        r| j        	                    t          j                  }| j         t          u rd}n/| j         t          u rd}n| j         j                                        }| j        d| d| d| d}n*d| d| d| d	| d
| d}n|j        rt| j        	                    t          j                  }|j                            t+          j        dd                     | j        d| d| d}nd| d| d	| d
| d	}n|t          u rT| j                                        }|j                            t+          j        dd                     d| d	| d	| d}n>| j         t.          u r| j                                        }|                                 \  }	}
}}}}}t5          |j        j        d                   }|j                            | j                   d| d	| d	| d	| d	| d	| d	|	dd	|
dd	|dd}n| j                                        }|t:          u r0|j                            t=          j        dd                     d}n;|t>          u r0|j                            t=          j        dd                     d}nd}| d| d	| d	| d}|                     | d| d|!                    || j                              | "                    |           d S )Nz,Slicing is not currently supported for '%s'.	ByteArrayUnicoder  z_FromString(r  r  z_FromStringAndSize(r   - pyunicode_from_unicoder  z__Pyx_PyUnicode_FromUnicode(z%__Pyx_PyUnicode_FromUnicodeAndLength(PyUnicode_Substringz__Pyx_PyUnicode_Substring(r  z__Pyx_PyObject_GetSlice(r  SliceTupleAndListr  __Pyx_PyList_GetSlice__Pyx_PyTuple_GetSlicePySequence_GetSlicer;  r<  r  )#r   ro   r   r   rZ  r  
start_code	stop_coder  r  r   rm   r    r   rp   titler   r  c_const_py_unicode_ptr_typer   r   r   r   r   r   get_slice_configrH  rj   get_slice_utility_coder   r	   r   r   r   r  )rX   r   r  r  r/  r0  base_result	type_namecallhas_c_start
has_c_stopc_startc_stoppy_startpy_stoppy_slicer  cfuncs                     rS   r  z#SliceIndexNode.generate_result_code  sg   y$ 	$(@49LN N NFIN	__&&
NN$$	 7	H)--j.NOOKyN** (		l**%		 IN0022	y V)VVVVVVVy)yyyyPZyy^gyylvyyy' &	H)--j.TUUK--'(@/RRT T Ty SkSSjSSSx{xxzxx]fxxkuxxx,&&)**,,K--'(=OOQ Q QYYYzYYYYYYDDY.(()--//KTXTiTiTkTkQKWfhd.9,GHHJ--d.IJJJDD D")D D-3D D7?D DCJD DNVD DCD D$.CD D4>CD D DDD )--//KI%% 11&23FHZ[[] ] ]/j(( 11&23FHZ[[] ] ]0-GGkGGZGG9GGGD

fTTTT)@)@)R)RTTUUUT"""""rT   c                 2   |                      |           | j        j        r|j                            | j                   |                                 \  }}}}	}
}}|                    | j        d| j	        
                                |
                                ||	|
||||t          |j        j        d                   f
z             n| j        r|                                 nd}|j        j        r#|j        j        }|                     ||           n|                                 d|}|j                            t'          j        dd                     |                    d| j	                                        d|d	|                                d
| j	                                        d|d           |                     |           |                     |           |                    |           |                    |           d S )Nz?__Pyx_PyObject_SetSlice(%s, %s, %s, %s, %s, %s, %s, %d, %d, %d)r  r  r(  IncludeStringHr  	memcpy(&(re  ]), rn  z[0]) * (r  )r  r   ro   r   r   set_slice_utility_coder3  rr  r   rZ  r   rH  rj   r   r/  rT  ri  generate_slice_guard_coder0  r   r   r   r  r  r  r  r  )rX   r   r   r  r   r   r8  r9  r:  r;  r<  r=  r>  start_offsetarray_lengths                  rS   r  z'SliceIndexNode.generate_assignment_code	  s    --d3339  	--d.IJJJTXTiTiTkTkQKWfh!!$(QI''))MMOOVgx)4\BCCUE EF F F F 15
C4??,,,Lx  L"x}..t\BBBB,0NN,<,<,<,<llK--k.EFVXg.h.hiiiJJJ	  """"LLL

	  """"LLL    	++D111%%%""4(((trT   c                    | j         j        j        st          | j        d| j        z             d S |                     |           |j                            | j                   | 	                                \  }}}}}}}	|
                    | j        d| j                                         |||||	||t          |j        j        d                   f	z             |                     |           |                     |           d S )Nz=Deleting slices is only supported for Python types, not '%s'.z;__Pyx_PyObject_DelSlice(%s, %s, %s, %s, %s, %s, %d, %d, %d)r  )rZ  r   ro   r   r   r  r   r   rD  r3  rr  r   rH  rj   r  r  )
rX   r   r  r8  r9  r:  r;  r<  r=  r>  s
             rS   r  z%SliceIndexNode.generate_deletion_code+  s#   y~) 	$(QTXT]]_ _ _F--d333))$*EFFF(,(=(=(?(?	&j'6	7HdhI	##%%'8ZT%0>??MA A	B 	B 	B 	++D111%%%%%rT   c                    d\  }}}| j         rJ| j         j        j         }|r| j                                         }nd| j                                         z  }d\  }}}| j        rJ| j        j        j         }|r| j                                        }nd| j                                        z  }| j        rd| j                                        z  pd}|||||||fS )N)Fr  r  &%sr  )r   r   ro   r  r   r   r  )rX   r8  r:  r<  r9  r;  r=  r>  s           rS   r3  zSliceIndexNode.get_slice_config>  s    );&Wh: 	:"jo99K :*++-- 4:#7#7#9#99&8#
FG9 	8!Y^77J 8))++$)"5"5"7"77:@%$**>*>*@*@"@JFZ&'8- 	-rT   c                    | j         j        j        sd S | j         j        j        }	 t	          |          x}}n# t
          $ r d }Y nw xY wd x}}| j        rT| j                                        }	 t	          |          }|dk     r|d||fz  }n||z  }n|}d }n# t
          $ r Y nw xY w| j        r| j                                        }	 t	          |          }|dk     r|d| j         j        j        |fz  }n||z  }t          |t                    r||z  }n|d|d}d }n# t
          $ r Y nw xY wd }d}	 t	          |          }	t          |t                    }n# t
          $ r d }	Y nw xY w|r"|dk     r|	dk    rt          | j        d           n?|r&|$|"|	|k    rt          | j        d|d|           n|||}d	|d
|d}n||}n|}|r|                    d|d|d           | j        r|                                 |                    d|d|d           | j        r|                                 |                    |                    | j                             |                    d           d S d S )Nr   z%s + %dz - (r  FzAssignment to empty slice.z.Assignment to slice of wrong length, expected r  r;  z)-(if (unlikely((z) != ())) {zPyErr_Format(PyExc_ValueError, "Assignment to slice of wrong length, expected %" CYTHON_FORMAT_SSIZE_T "d, got %" CYTHON_FORMAT_SSIZE_T "d", (Py_ssize_t)(z), (Py_ssize_t)(r  r   )rZ  r   rT  ri  r   r   r   r  r   r~   r   r   r   r   r   r   r   )
rX   r   target_size
slice_sizetotal_lengthr   r   runtime_checkcompile_time_checkint_target_sizes
             rS   rE  z(SliceIndexNode.generate_slice_guard_codeQ  sx   y~& 	FY^(
	 (+J7L:: 	  	  	 LLL	  9 	9##%%D4yy!88#+%.*d1C%C

"d*

!%J    : 	J%%''EE

199#+ )TY^-@%,H H-j#.. C%'JJ0:

EEE!BJ    "	=!+..O ",J!<!<  	# 	# 	#"OOO	#
  	'*q..""dh <=== 	'EMdl*,,dhh jj++!/ 0 0 0|!+/447MM MM&M 	JJJ---UVVVz &##%%%JJJ  KK01 1 1
 z /,,...JJttx00111JJsOOOOO	 	sF   8 AA/)B 
B&%B&
AD# #
D0/D08E E,+E,c                 F    | j         r| j                                         S dS )Nr  )r   r  rW   s    rS   r/  zSliceIndexNode.start_code  s%    : 	:$$&&&3rT   c                     | j         r| j                                         S | j        j        j        r| j        j        j        S dS )Nr%  )r   r  rZ  r   rT  ri  rW   s    rS   r0  zSliceIndexNode.stop_code  sB    9 	$9##%%%Y^$ 	$9>&&##rT   c                     dS )Nz<unused>rV   rW   s    rS   r  z$SliceIndexNode.calculate_result_code  s    zrT   rS  r~  rT  rR  )rZ   r[   r\   r   r   r  r   r`  rA  r%  r/  r8  rD  r<  re  rs  r  r	   loadr4  rD  r  r  r  r  r3  rE  r/  r0  r  r]   r^   s   @rS   r  r    s        211HEE  4 4 4 4* * *	E 	E 	E- - -    ^ ^ ^ ^@  ,( ( ( ( ( *K4/4)He3DF F F 5/4)He3DF F F0 0 0 0 0E# E# E#N INGK       D& & & &&- - -&P P Pd  $ $ $      rT   r  c                   J    e Zd Zg dZdZeZdZd Zd Z	d Z
d ZdZd	 Zd
 ZdS )r  r-  Tr+   c                 n    t          | j        j        | j        j        | j        j                  | _        d S rM   r  r   r   r   r   rW   s    rS   r%  z#SliceNode.calculate_constant_result  2    $J&I%I% '  'rT   c                    | j                             |          }| j                            |          }| j                            |          }	 t	          |||          S # t
          $ r }|                     |           Y d }~d S d }~ww xY wrM   r   r/  r   r   r  r=  r3  rX   r.  r   r   r   r2  s         rS   r/  zSliceNode.compile_time_value      
--d33y++D11y++D11	-d+++ 	- 	- 	-))!,,,,,,,,,	-   A! !
B+BBc                     dS rw  rV   rW   s    rS   rA  zSliceNode.may_be_none  r  rT   c                    | j                             |          }| j                            |          }| j                            |          }|                    |          | _         |                    |          | _        |                    |          | _        | j         j        r&| j        j        r| j        j        rd| _        d| _        | S r  )r   r<  r   r   r   r   r   )rX   rr   r   r   r   s        rS   r<  zSliceNode.analyse_types  s    
((--y&&s++y&&s++--c22
++C00	++C00	:  	!TY%9 	!di>R 	!"DO DLrT   z Constructing Python slice objectc                     | j         S rM   r  rW   s    rS   r  zSliceNode.calculate_result_code  r  rT   c                    | j         rjt          | j        | f          }|                    d|          | _        |                    | j                  }|d S |                    | j                   |                    | 	                                d| j
                                        d| j                                        d| j                                        d|                    | 	                                | j                  	           |                     |           | j         r|                     |           d S d S )Nr  	dedup_keyz = PySlice_New(r  r  )r   r   r   rp  r  rq  r  r   r   r  r   r   r   r   r   r  r  )rX   r   rf  s      rS   r  zSliceNode.generate_result_code  sE   ? 	$&ty4'::I#00I0NND33D4DEED|MM$(###


$$&&&&	##%%%%	##%%%%''tx@@@B	C 	C 	C 	T"""? 	(!!$'''''	( 	(rT   N)rZ   r[   r\   r   r   r!   r   r   r%  r/  rA  r<  r  r  r  rV   rT   rS   r  r    s         )((HHDG' ' '- - -  
 
 
 5K     ( ( ( ( (rT   r  c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	r5  r   c                 n    t          | j        j        | j        j        | j        j                  | _        d S rM   rZ  rW   s    rS   r%  z&SliceIntNode.calculate_constant_result  r[  rT   c                    | j                             |          }| j                            |          }| j                            |          }	 t	          |||          S # t
          $ r }|                     |           Y d }~d S d }~ww xY wrM   r]  r^  s         rS   r/  zSliceIntNode.compile_time_value
  r_  r`  c                     dS rw  rV   rW   s    rS   rA  zSliceIntNode.may_be_none  r  rT   c                 &   | j                             |          | _         | j                            |          | _        | j                            |          | _        | j         j        s| j                             |          | _         | j        j        s| j                            |          | _        | j        j        s| j                            |          | _        | j         j        r&| j        j        r| j        j        rd| _        d| _        | S r  )r   r<  r   r   r  r5  r   r   r   s     rS   r<  zSliceIntNode.analyse_types  s    Z--c22
I++C00	I++C00	z! 	933C88DJy  	7	11#66DIy  	7	11#66DI:  	!TY%9 	!di>R 	!"DO DLrT   c                     d S rM   rV   rW   s    rS   r  z"SliceIntNode.calculate_result_code'  r   rT   c                     | j         | j        | j        fD ]0}t          |t                    r|j                                         1d S rM   )r   r   r   r~   r  rh  r  )rX   r   r  s      rS   r  z!SliceIntNode.generate_result_code*  sJ    DIdi/ 	 	A!Y'' 	 	rT   N)
rZ   r[   r\   r   r%  r/  rA  r<  r  r  rV   rT   rS   r5  r5    su         G' ' '- - -    "      rT   r5  c                   N    e Z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S )CallNodeNc                    | j         }|                              }t          |t                    rt	          j        |j                  S |t          u ri|j        rF|j	                                      }|j
        r%t          j        ||j                  }|t          ur|S t          |dd           }|	|j        p|}|j        r|j        }|j        r~t          | j         dd           rat'          | d          rQfd| j        D             }| j         j                            |          }|r|j        }|j        r|j        }|j        S |j        S |t0          u rv|j        ro|j        rh|j        j        r\|j        j        }|j        r|S |j
        r@|j        j        }	|	dk    rt          j        S |	dk    rt          j        S |	t          j        v r|S | j                                       }|r|j         s|j!        r|S t          S )Nr   r   c                 :    g | ]}|                               S rV   r   rb   rh  rr   s     rS   r   z'CallNode.infer_type.<locals>.<listcomp>K  s%    FFFSS^^C00FFFrT   r   rH  )"r&  r   r~   r  r   r  r  r   r\  r#  r  r   "find_return_type_of_builtin_methodr$  r   r   r  r  rU  r  r   r   best_function_matchr  r   r   r  rp   r  r)  #types_that_construct_their_instancere  is_struct_or_unionr  )
rX   rr   r&  r  method_obj_typeresult_typer   	arg_types
func_entry	func_names
    `        rS   r   zCallNode.infer_type5  sE   ='',,	h,, 	<&x':;;;&&$ +"*,"9"9#">">"2 +")"L_^f^p"q"qK".88**Hgt44E !J3)	 	,!+I! 	+t}gt44 1v9N9N 1FFFFDIFFF	!]0DDS)TT
 1 *I ' 8$-$7	$00(()## +HN +x~7J +&n10 	+&& 0 + ( 3I G++)77"f,,)55"g&QQQ**M11#66	 	)6 	):P 	rT   c                 6    | j                             |          S rM   )r&  rO  r   s     rS   rO  zCallNode.type_dependenciese  s     }..s333rT   c                     dS rw  rV   rW   s    rS   r:  zCallNode.is_simplej  s	    
 urT   c                 
   | j         | j         S | j        j        }|t          u rG| j        j        r;| j        j        }|j        j        rdS |j        j        r|j        t          j
        v rdS t                              |           S rw  )may_return_noner&  r   r   r   r   r  r  rp   r   rv  r   rA  )rX   r  r   s      rS   rA  zCallNode.may_be_noneq  s    +''M&		!!dm&;!M'Ez+ u
* J'"MMMu##D)))rT   c                    ||j         }|t          j        u r|j        r|j        r|j        j        r|j        j        t          j        v ri|j        j        dk    r#t          j	        | _         t          j	        | _
        n-t          j        |j        j                 | _         t          | _
        d| _        d S |j        r-|j        r&|j        j         | _         t          | _
        d| _        d S |j        rx|j        j         j        rg|j        j         }t          j        ||j                  }|t          u | _        |j        r	|| _         d S |j        r|j        | _         d S t          | _         d S t          | _         d S )Nr   F)r   r   r   r   r   r  rp   rv  r   r  r!  builtin_typesr   r  r  r\  r#  r  rt  r$  ro   r  )rX   r&  r  rx  ry  s        rS   set_py_result_typezCallNode.set_py_result_type~  sn    I)))  * * ) * #w'RRR~"g--&4	$.$<!!#1(.2EF	$2!#(D    	'("5 	' !+0DI .D#(D   " 	'x|'8'H 	'&l/O!D_V^VhiiK#..#@D & +'			, +'7			*			&DIIIrT   c           
         | j                                       }|r|j        r|                                 \  }}g }t	          ||j        j                  D ]H\  }}|                    t          |j	        t          |j	        |j                  |                     I|r
||j        z  }t          | j	        |          }|                                                  |          }|S |r|j        rfd| j        D             | _        |j                            d          }	|	s5t'          | j         j	        d| j         j        z             t(          | _        | S t-          | j         j	        |	j                  | _         |	| j         _        | j                             |                                           |                                || _        | S dS dS )z4
        Returns a replacement node or None
        r  keyr   key_value_pairsc                 :    g | ]}|                               S rV   rA  rs  s     rS   r   z8CallNode.analyse_as_type_constructor.<locals>.<listcomp>  '    GGGS#++C00GGGrT   z<init>z'no constructor found for C++  type '%s'N)r&  re  rw  explicit_args_kwdsr  r,  r  r   DictItemNoder   r  rp   r  DictNoder<  r  r  r   r-  r   r2   r   rk  r   rp  r  analyse_c_function_call)
rX   rr   r   r   r  r  rh  memberr   r  s
    `        rS   analyse_as_type_constructorz$CallNode.analyse_as_type_constructor  s    },,S11 	D+ 	0022JD$E"4)?@@ l lV\#'{37RXR]7^7^7^fijjjkkkk .--DHe<<<D%%c**44T3??DK 	d' 	GGGGDIGGGDI*++H55K dm')RUYUbUg)ghhh&	,T]->@PQQDM"-DMM##D$?$?$A$ABBB((---DIK	 	 	 	rT   c                 :    | j         j        }|j        r|j        }|S rM   )r&  r   r  r  rX   r  s     rS   function_typezCallNode.function_type  s'     M&	 	,!+IrT   c                     | j         j        S rM   )r   r	  rW   s    rS   r   zCallNode.is_lvalue  s    y%%rT   c                     |                                  }|j        r|                                  d S |j        s't	          |dd          s|                                  d S d S d S )Nr   F)r  ro   rr  r  r   )rX   rr   r  s      rS   rs  zCallNode.nogil_check  s|    &&((	  	NN# 	GIw,N,N 	NN	 	 	 	rT   zCalling gil-requiring functionrM   )rZ   r[   r\   r  r   rO  r:  rA  r  r  r  r   rs  r  rV   rT   rS   ro  ro  0  s         O. . .`4 4 4
  * * *"' "' "' "'H  <  & & &   3KKKrT   ro  c                        e Zd Zg dZdZdZdZdZdZdZ	dZ
dZd Zd Zed             Zd Zd Zd	 Zd
 Zd Zd Zd Z fdZd Z xZS )r.  )rX   coerced_selfr&  r   r  NFc                     | j                                       }fd| j        D             }	  || S # t          $ r }|                     |           Y d }~d S d }~ww xY w)Nc                 :    g | ]}|                               S rV   r/  rb   rh  r.  s     rS   r   z5SimpleCallNode.compile_time_value.<locals>.<listcomp>  '    BBB&&t,,BBBrT   )r&  r/  r   r=  r3  )rX   r.  r&  r   r2  s    `   rS   r/  z!SimpleCallNode.compile_time_value  s    =33D99BBBB	BBB	-8T?" 	- 	- 	-))!,,,,,,,,,	-s   5 
AAAc                    | j         j        r| j         j        j        r| j         j        }t          j        |          st          j        |          rp|j        }| j         j        j	        }|r|j
        nt          |j                  j        }t          j        ||          r#d | j        D             } || | _        d S d S d S d S d S )Nc                     g | ]	}|j         
S rV   r   rb   rh  s     rS   r   z<SimpleCallNode.calculate_constant_result.<locals>.<listcomp>   s    EEECC/EEErT   )r&  r\  r#  r   r   r%   	isbuiltinismethodrZ   r   rp   __self__r   is_safe_compile_time_methodr   )rX   methodr   object_typeobject_type_namer   s         rS   r%  z(SimpleCallNode.calculate_constant_result  s    =% 
	9$-*;*F 
	9]2F (( 9G,<V,D,D 9$o"m/47B#f;#3#3V_H]H]Hf 67GUU 9EE49EEED+164=D(((
	9 
	9 
	9 
	99 99 9rT   c                     |j         }|                    |j                  }|sJ d|d|j                    t	          ||j        ||j                  } | |||g          }|S )NzGetter not found in scope r1  )rp   r   r   r%  )r,  r  rp   r  r  r   )rQ   r   r#  r   property_scopegetter_entryr&  r   s           rS   for_cpropertyzSimpleCallNode.for_cproperty  s     %11%*==jjj>>>SaSiSijjjjCej<K\]]]s3666rT   c                    | j                                         }|dk    rt          | j                  dk    rt	          | j        j        d           d S | j        d                             |          }|s"t	          | j        d         j        d           d S t          j        |          S |dk    rYt          | j                  dk    rt	          | j        j        d           | j        d         	                    |          }|j
        S d S )Nr  r+   zonly one type allowed.r   zUnknown typetypeof)r&  rC  r   r   r   r   re  r   r  r<  r   )rX   rr   r  r   operands        rS   re  zSimpleCallNode.analyse_as_type  s    }0022949~~""dim%=>>>>>y|33C88 5$)A,*N;;;;;%.t444X49~~""dim%=>>>il0055G<	 rT   c                     | j         d fS rM   r}  rW   s    rS   r  z!SimpleCallNode.explicit_args_kwds  s    y$rT   c                    | j         r| S d| _         |                               x}|S d| j        _        | j                                      | _        | j        }|j        r8|j        r1|j        j        r%|j        | _	        t          | j	                  |_        |                                 }d| _        t                    r|j        rt          |          rvd}t!          | j        | j                  | _        | j                                      | _        | j        j        D ]}|t)          |          z  }t+          |          | _        | j        rw                    t/          |                     t0                              | t5          |          | j        t7          t9          || j        j                                      S |j        rwt!          | j        | j                  | _        | j                                                                    | _        d | _        |                     ||           d| _         n?fd| j        D             | _        | !                               |j"        dk    rd| _         | S )NTr+   Fr}  )function_cnamer  r   c                 :    g | ]}|                               S rV   rA  rs  s     rS   r   z0SimpleCallNode.analyse_types.<locals>.<listcomp>J  r  rT   r   )#analysedr  r&  re  r<  r\  r   
is_cmethodr#  rX   r  r  is_numpy_call_with_exprsrA   rW  rF   r  r   r   r  rD   rH  add_include_filerG   NumPyMethodCallNoderO  rH   rI   r>   ro   r   r  r   r  r   )rX   rr   as_type_constructorr&  r  has_pythran_argsrh  s    `     rS   r<  zSimpleCallNode.analyse_types!  s   = 	K#'#C#CC#H#HHU&&"#33C88=  	0X^ 	08Q 	0 !DI$TY//HL&&((	(-%3 	CH$? 	C/99	C#&tx	BBBDN!^99#>>DN~* K K $Ec$J$JJ  ,01A,B,BD)( 	$  !>x!H!HIII&00.x88. !28T^=P!Q!QRR	 1    " 
	$&tx	BBBDN!^99#>>QQRUVVDNDI##Hi888DLLGGGGDIGGGDI((---(C//#rT   c                 f   | j         j        }|t          u rt          | _        d S |j        r<|j        r5| j        r&| j        j        j        rt          | j        d           | j	        }n| j        r| j        g| j	        z   }n| j	        }|j
        rA| j         j        j                            d          }|t          j        | _        d| _        d S nNt          | j         d          r| j         j        }n,| j         j        r| j         j        r| j         j        j        }nd }|r	 |                    |d |D             dd |D                       }n[# t          j        $ rI}t+          |          }|rt          | j        |           t          j        | _        d| _        Y d }~d S d }~ww xY wd|_        |j
        s|| j         _        |j        | j         _        |                                 }nOd }|                                 }|j        s2t          | j        d	|z             t          j        | _        d| _        d S t1          |j	                  }||j        z
  }	t1          |          }
|j        r|	|
k    rd
| _        d
| _        |rg|j        r_|j	        rW|j        sO|j	        d         }|d         }|j        r| j        rV| j                            d                    t1          |j                   dk    rdnd          d|j         g          | _        n(|                    d|j         |j        j         g          }| j        rS|j!        rtE          | j                  }ntG          | j                  }|$                    |j        |          x}| _%        nO|j        j&        rC|$                    |j        |          }|j        j&        rtO          |tP                    rd|_)        ||d<   d}tU          tW          ||
                    D ]}|j	        |         }|j        }||         $                    ||          }|j        r|                    d          }|,                                r	|dk    rd}nS|j        j-        rG|j.        s@|dk    r| j        n2|/                                rn|dk    rd}|0                    |          }|||<   tU          ||
          D ]}||         }|j        j-        ru|j        tb          u rt          j2        }n|j        3                                }|$t          | j	        |d
z
           j        d           n|$                    ||          x||<   }|,                                r|dk    rd}|rtU          |
d
z
            D ]y}|dk    r| j        ||         }|/                                r-|j        j
        r:|j.        r|j        j-        rN|dk    s|d
k    r| j        ti          |j        dd            nz|| j	        d d <   tO          | j         tj                    r$t          j6        | j         j7                  | _        n|j8        | _        | j         j9        s| j         j:        r#| j         j        }|r|j;        s|j<        rd
| _        | j        j-        rtz          | _>        d
| _        n)|j?        |j@        rd
| _        n| j        jA        rd
| _        | j        r/| j        jB        r#t          jC        | j        jD                  | _        |j8        jE        r/d|F                    | j         j        |j8        jG                  _        |j@        dk    r7t          |          r(|I                    t          jK        dd                     |jL        d         | _M        d S )Nz4Cannot call a static method on an instance variable.z
operator()r  r   c                     g | ]	}|j         
S rV   r  r  s     rS   r   z:SimpleCallNode.analyse_c_function_call.<locals>.<listcomp>t  s    ...#SX...rT   Tc                 6    g | ]}|                                 S rV   )r   r  s     rS   r   z:SimpleCallNode.analyse_c_function_call.<locals>.<listcomp>v  s     (I(I(IS(I(I(IrT   )fail_if_emptyarg_is_lvalue_arrayzCalling non-function type '%s'r+   r   )'NoneType' object has no attribute '%{}s'   .30r  PyExc_AttributeError)r   rH  z@descriptor '%s' requires a '%s' object but received a 'NoneType'rH  FzGcannot pass None into a C function argument that is declared 'not None'z5Python object cannot be passed as a varargs parameterTArgument evaluation order in C function call is undefined and may not be as expectedr   r  r  overflowcheck)Nr&  r   r2   rU  is_static_methodrX   r  r   r   r   r  r,  r-  r   r  r  r   r]  rB  ru  NoMatchFoundrw   r  r  r   optional_arg_counthas_optional_argsr   r  not_nonerI  r  rp   accept_builtin_subtypesCMethodSelfCloneNoder  r  r  r  r~   r   exact_builtin_typerangeminr  ro   r   rV  r8  r   r0   default_coerced_ctyper   r  r  r  r  r   r\  r$  utility_code_definitionr   r!  r   r   r   r	  CFakeReferenceTyper  r1  declare_tuple_typer2  r   r   r   r   rj   r  )rX   rr   r  r   overloaded_entryr   excr  	max_nargsexpected_nargsactual_nargs
formal_argrh  some_args_in_tempsr  formal_type	arg_ctyper{  s                     rS   r  z&SimpleCallNode.analyse_c_function_callQ  s   M&	
"""DIF! 
	i&@ 
	y XTY^= X dh VWWW9DDY 	I;*DD9D! 	$#}17>>|LL'&1	#,  ( T]G,, 	$#}2]' 	$DM,H 	$#}17# 	(<<....."&(I(ID(I(I(I	 =   *   c(( -$(G,,,&1	#,  EJ) ,&+#!&DM**,,IIE**,,I) dh @9 LMMM&1	#,  	''	"Y%AA4yy' 	Nl,J,J%&D"DL  	U% 	). 	A[ 	"*Jq'C" 
H9 	H $	 ; ;CJJTWX]XbTcTcgiTiTi55oqrr4%*ZL !< !2 !2DII //Z%*Z1E$F 0 H HC y 
35 /.ty99CC#DI..C*---
*M*MMd''0 3mmJOS998+ 3
30O0O 3-2C*DG #s9l3344 	 	A"*J$/Kq'##K55C" _++]_ _!!## 2q55)-&% 2ci 266di3--// 
2 1uu-1*,,S11CDGG y,// 	* 	*Aq'Cx# 
B8|++ * :II # > > @ @I$$)AaC.,QS S S S %(MM)S$A$AADGc!!## *A%)" 	 <>**  66di31g++-- X* Y 
38#7 
  1uuQ49+@)  BC  D  D  D	!!! dm[11 	."+DM,DEEDII!-DI=  	!DM$> 	!,J !z6 !*:\ ! 9  	 .DDLL&2i6O2DLLY) 	DL < 	ODI2 	O"5di6MNNDI * 	d_cC""4=#4i6K6VWW\ $++-i88 j$$[%<=UWg%h%hiii ^O<s   -E F%>F  F%c                 *    |                                  S rM   )c_call_coderW   s    rS   r  z$SimpleCallNode.calculate_result_code!  s    !!!rT   c                    |                                  }| j        t          j        u s|j        sdS |j        }g }t          t          || j                            }t          |j                  }||j	        z
  }t          | j                  }|d |         D ]4\  }}	|	
                    |j                  }
|                    |
           5|j        rE|                    t          t          | j        p| j        j        j                                       |j	        r(||k    rd}n
d| j        z  }|                    |           | j        t          |          d          D ])}	|                    |	                                           *| j                                        dd                    |          d}|S )Nr  r  rJ  r;  r  r  )r  r   r   r2   rU  r   r   r  r   r  r  r   r  rw   r   wrapper_callr&  r   is_unbound_cmethodopt_arg_structr  r  r  )rX   r  formal_argsarg_list_coder   r  r  r  r  
actual_argarg_codeoptional_argsr  s                rS   r  zSimpleCallNode.c_call_code$  s   &&((	9
---Y5K-9nCTY//00	''	"Y%AA49~~&*?N?&; 	+ 	+"J
!44Z_EEH  ****# 	h  S):)ddm>Q>d%e%e!f!fggg' 	0-- & %(; ;  ///)C$4$4$5$56 	? 	?J  !;!;!=!=>>>>!]113333TYY}5M5M5M5MNrT   c                 V    |                                  }|j        |j        dk    rdS dS )Nr   FT)r  r   r   r  s     rS   r  z#SimpleCallNode.is_c_result_requiredB  s3    &&((	$,	0IS0P0P5trT   c                    | j         }|j        s|j        r|j                            |j                   d}| j        j        o| j        j        }| j	        r|r|
                                |v r|j                            t          j        dd                     |                    d| j        d         
                                d| j        d         j                                        d|                    | j                  d           |j        j        r5t)          | j        j                  d	k    s| j        j        r/| j        j        r#t/                                          |           d S | j        j        r| j        j        d         nd }| j        | j        ||f}|D ]}||                    |           |                    | j                   | j        sJ |                     |           ||j                            t          j        d
d                     |                    | 
                                d|                                d|                    | 
                                | j                             n|j                            t          j        dd                     |                    | 
                                d|                                d|                                d|                    | 
                                | j                             |                      |           |D ].}|*|!                    |           |"                    |           /d S )N)abslabs__Pyx_abs_longlongCommon
Overflow.cr_  r   z == __PYX_MIN(z))) {                PyErr_SetString(PyExc_OverflowError,                                "Trying to take the absolute value of the most negative integer is not defined."); z; }r+   PyObjectCallNoArgr  z = __Pyx_PyObject_CallNoArg(r  PyObjectCallOneArgz = __Pyx_PyObject_CallOneArg(r  )#r&  r   r\  r   use_entry_utility_coder   r   r  r  r  r  r   r   r   r   r   r  r   r   ro   r   r  r   rO   r  rX   r  r  r   r  r   r   r  r  r  )	rX   r   r&  abs_function_cnamesis_signed_intrh  r   subexprrR   s	           rS   r  z'SimpleCallNode.generate_evaluation_codeH  s   = 	Dx4 	D33HNCCCC	(=TY-= 	8- 	8HOO4E4EI\4\4\--k.EhP\.].]^^^JJJ !IaL//1111 IaL-DDFFFF OODH55557 8 8 8 }( 	C0C,D,Dq,H,H# -I(,(A -IGG,,T222F )-(;Edn!!$$It0(C@ 	7 	7G"00666dh|!!$''';--k.E#%7/9 /9 : : :JJKKMMMM&&((((++DKKMM48DDDFG G G G --k.E$&8/: /: ; ; ;JJKKMMMM&&((((MMOOOO++DKKMM48DDD	FG G G 	T""" 	) 	)G"..t444""4(((	) 	)rT   c                    |                                  }|j        r| j                                        }|j                            t          j        dd                     |                    | 	                                d| j
                                        d|d|                    | 	                                | j                             |                     |           d S |j        r|j        j         }| j        r*t%          | j                  }t%          |j                  |j        z
  }|j                            |j        j        d          | _        |                    | j        dt2          j        d	z   d
t%          | j                  |z
  d           t7          t9          |j        | j                            }|||         D ]X\  }}	|                    | j        d|                    |j                  d
|	                    |j                   d           Yg }
| j         j        r3| j!        r,|
"                    d| 	                                z             n| j         j#        rJ| j!        sJ |
"                    | j         $                    | 	                                                     n|j%        dk    r|j&        }|j%        }||j'        (                    |          }|j'        j)        rq|j                            t          j        dd                     |
"                    d| 	                                 d| d| 	                                 d           n,|
"                    | 	                                 d|            |r|r|
sYtU          | j
        dd           }tW          j,        | j        |j        j-        |r|j        nd | j         j.        d|o|j/                   |j                            t          j        dd                     |
"                    d           n|
"                    d           | j!        s|
rC| 0                                }| 	                                rFd| 	                                z  }| j!        r'| j         j        rtc          td          | j         |          }nd}|j%        dk    rDtg          || j        ||d| j         j        r| 	                                nd |j&        |           nO|
r/|4                    d5                    |
          | j                  }nd}|                    ||d|           | j         j        r)| 	                                r|                     |           | j        r#|j        6                    | j                   d S d S d S )NrC  r  rD  r  z	, NULL); Tr  r   rM  r<  r=  rf  r   rA  r  zmemcmp(&, &rn  z)) == 0z == r   )function_namevoid_returnis_callis_from_pxdr   r   r   r   z%s = r  z && r  )7r  ro   r  r   r   r   r   r   r   r  r&  r   r   r  rU  r  	gil_ownedr  r   r   r  r  op_arg_structr  r  r   pyrex_prefixr   r  opt_arg_cnamerp   r  r   r   r   r   error_conditionr   r   r  	cast_coder1  r   r   write_noexcept_performance_hintr,  r  defined_in_pxdr  r1   r   r   r   r  r  )rX   r   r  r  r   r  r  r   r  r  
exc_checksexc_val	exc_checktyped_exc_valperf_hint_entryr   r  
goto_errors                     rS   r  z#SimpleCallNode.generate_result_code  sE   &&((	  S	A~//11H--k.E 2/4 /4 5 5 5JJKKMMMMM++----HH++DKKMM48DDD	FG G G   &&&&&# H	A00E% D"49~~!$Y^!4!4y7S!S&*n&B&B+5$ 'C 'H 'H#

++++c111DI7779 : : : C		::;;.2>,3N.O D D*J
JJ ///%33JODDDD&00AAAA C D D D D Jy$ > >!!%$++--"78888- >|###!!$)";";DKKMM"J"JKKKK*c11#3%5	&$-$9$C$CG$L$LM ,6 Q(99+:Q,o;? ;? @ @ @"))*uT[[]]*u*u}*u*u_c_j_j_l_l*u*u*uvvvv"))T[[]]*O*O*O*OPPP > >) b.5dmWd.S.SO&F $$.*>FU._o.B.B[_,0I,=t-<-_A_	b b b b
 (99'34H.YY[ [ ["))*FGGGG"))*<===| /z /&&((;;== !DKKMM1C| G	(= G '~ty#FFC,33+D$(ssCCC<P=AY=R,\DKKMMMX\,5,EuN N N N " (%)%7%7J8O8OQUQY%Z%Z

%'
JJSS###zzBCCC9( /T[[]] /((...% A++D,?@@@@@QH	A H	ANA ArT   )rZ   r[   r\   r   rX   r  r  r  r  r   r  r  r/  r%  re  r  re  r  r<  r  r  r  r  r  r  r]   r^   s   @rS   r.  r.    s4        IHHHDLILEHM- - -9 9 9   [     "  . . .`N= N= N=`" " "  <  7) 7) 7) 7) 7)rUA UA UA UA UA UA UArT   r.  c                   "    e Zd ZdgZdZdZd ZdS )r  r  Tc                    |                     | j                   |                     |           | j        j        J | j        j        }|D ]}|                    |           |                    d           |                    d|                                 z             |                    d|                                 d|                                 d| j	        dd
                    d |D                       d		           d S )
Nz.// function evaluation code for numpy functionr  r>  r?  r@  z{}(r  c              3   >   K   | ]}|                                 V  d S rM   )r  )rb   r  s     rS   re   z?NumPyMethodCallNode.generate_evaluation_code.<locals>.<genexpr>  s.      77Qa&&((777777rT   )};)r  r   r  r  r   r   r  r   r  r  r  )rX   r   r   rh  s       rS   r  z,NumPyMethodCallNode.generate_evaluation_code  s   dh!!$'''~)111~" 	/ 	/C((....

CDDD

/$++--?@@@


KKMMMMKKMMMMII77$7777777	9 	: 	: 	: 	: 	:rT   N)rZ   r[   r\   r   r   r  r  rV   rT   rS   r  r    s6         }HGO: : : : :rT   r  c                        e Zd Zg dZdZdZdZdZdZ fdZ	d Z
ed             Zedd            Zed	             Zd
efdZd Zd Zd Zd Zd Z xZS )PyMethodCallNode)r&  r  kwdictkwargs_key_value_pairsTFNc                      t                      j        |fi | |                                 rd| _        | j        j        | _        | j        r&| j        j        r| j        j	        | _
        d | _        d S d S d S r  )rO   rl  can_avoid_attribute_lookupuse_method_vectorcallr&  r#  function_objr  rY  r  r  )rX   r   kwrR   s      rS   rl  zPyMethodCallNode.__init__  s    #####**,, 	2)-D& $ 1D; 	4;6 	*.+*ED'DKKK	 	 	 	rT   c                     | j         rt          | j         t                    sdS | j        }|j        sdS |j        sdS |j        rdS t                              |          sdS dS r@  )	r  r~   r  r&  r\  
is_py_attris_special_lookupr  attribute_is_likely_method)rX   r&  s     rS   r  z+PyMethodCallNode.can_avoid_attribute_lookup  s     ; 	z$+x@@ 	5=$ 	5" 	5% 	5::8DD 	 5trT   c                 >    | j         }|j        r|j        j        rdS dS r@  )r#  r   r   r  )r  r#  s     rS   r  z+PyMethodCallNode.attribute_is_likely_method$  s)    h; 	390 	5trT   c                     t          | t                    sdS | j        rdS | j        rt	          | j                  dk    rdS t	          | j                  s|p| S dS )z~
        Test whether the positional args given are compatible with
        being translated into a PyMethodCallNode.
        Fr+   T)r~   r  r   r   r   r   )r  
has_kwargshas_explicit_kwargss      rS   can_be_used_for_posargsz(PyMethodCallNode.can_be_used_for_posargs+  sw     /955 	5& 	5% 	#o.B*C*Ca*G*G5?'(( 	9 '8j.8trT   c                     d}| j         r| j        r| j        j        j        rd}nX| j        rQ| j        }|j        j        rd}n;|j        r4t          t          t          ft          fd|j        D                       }|S )zo
        Test whether the function passed is suitable to be translated
        into a PyMethodCallNode
        TFc              3   R   K   | ]!}|j         ot          |j                    V  "d S rM   )r   r~   )rb   r  non_method_nodess     rS   re   z<PyMethodCallNode.can_be_used_for_function.<locals>.<genexpr>O  sN       &< &<" NW:jnFV+W+W'W&< &< &< &< &< &<rT   )
r\  r   r   rU  r   cf_assignmentsPyCFunctionNode	ClassNodePy3ClassNoderk   )r&  may_be_a_methodr   r!  s      @rS   can_be_used_for_functionz)PyMethodCallNode.can_be_used_for_function=  s       	<~ ((."5"B ("' 		<NEz& <"'% <$3Y#M "% &< &< &< &<&+&:&< &< &< #< #< rT   returnc                 *   | j         r| j                            |           |                    | d| j                                         d           |                    |t                     |                    | j        j	                  S |                    | d           | j                            |           | j        
                                r| j                                        S |j                            t          d          }| j                            |           |                    |d| j                                        d           | j                            |           | j                            |           |S )Nr<  r=   = NULL;Tr  r  )r  r  r  r   r   r  r   rI  r&  r$  r  r  r  r  r  r  r  )rX   r   self_argr&  s       rS   generate_evaluate_functionz+PyMethodCallNode.generate_evaluate_functionT  ss   % 	E66t<<<JJ(GGt'8'B'B'D'DGGGHHHOOHn555++DM,CDDD

h((()))..t444 ='')) 	*=''))) >//4/PP**4000

(((DM,C,C,E,E,E,EFGGG,,T222  &&&rT   c                    | j         r6| j                            |           | j                            |           d S | j                                        r6| j                            |           | j                            |           d S |                    |t                     |j        	                    |           d S rM   )
r  r  r  r  r&  r  r  r   r  r  rX   r   r&  s      rS   generate_dispose_functionz*PyMethodCallNode.generate_dispose_functionk  s    % 	244T:::((.....]))++ 	2M00666M$$T*****!!(N;;;N''11111rT   c                    | j         s| j        sd S | j        j        r|                     | j                  rdnd}nr| j        j        rd| j        j        rX| j        j        D ]H}|j        }|r=|j        r6|j        j	        r*|j        j	        j
        r|                     |          rd} nId}nd}|                    d           |                    d|d|d           |                    | d| d           |                    d	| d           |                    d
| d           |                    |t                     |                    dt                     |                    |t          d           |                    | d           |                    d           |                    d           d S )Nlikelyunlikelyz#if CYTHON_UNPACK_METHODSr  z(PyMethod_Check(rM  z = PyMethod_GET_SELF(r  zassert(z2PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx__functionz = 0;r   r  )r  unpackr&  r\  r  r   r   r   r#  r   ro   r   r  r   r  )rX   r   r+  space_for_selfarg_var
method_objlikely_methodr  r   s           rS   &generate_runtime_method_unpacking_codez7PyMethodCallNode.generate_runtime_method_unpacking_codev  s   % 	T[ 	F=% 	'(,(G(G(V(VfHH\fMM]" 	't}'= 	'"m4 + +
" U/ EIN uy~Ga 66u== (0 *&M 	

.///


mmmZZZPQQQ

hCCZCCCDDD

)X)))***

V
VVVWWW.111)>:::J8IJJJ

+222333

3

8rT   c                 L   |                     | dt          |           d|                    || j                              |                    |t
                     t          |          D ]\  }}|j        j        t          j
        u o|j                                         }|                    | j        d|rdnd d|j                                         d|j                                         d| dt          j         dt          |          d	z    d|d
d           d S )Nz# = __Pyx_MakeVectorcallBuilderKwds(r  __Pyx_VectorcallBuilder_AddArgr  _Checkr;  r  r   r+   r  r  )r   r   r   r   r  r   r  r  r   r   r   rA  rr  r   r   r   callargs_cname)rX   r   r   r  kwnames_temprM  keyvalue
key_is_strs           rS   generate_keyvalue_argsz'PyMethodCallNode.generate_keyvalue_args  s   

 A ADZ@[@[ A A&&|TX>>A A	
 	
 	
 	n555$%;<< 	 	KAx!*g.BBe8<KcKcKeKeGeJ!!z1Ox  <))++ >++--     (	  ,/t99q=	 
   	 	 	 		 	rT   c                     | j         r| j        rd}d}n!d}d}n| j        rd}d}n| j        rd}d}nd}d	}|j                            t          j        |d
                     |S )N!PyObjectVectorCallMethodKwBuilder-__Pyx_Object_VectorcallMethod_CallFromBuilderPyObjectFastCallMethod__Pyx_PyObject_FastCallMethodPyObjectVectorCallKwBuilder'__Pyx_Object_Vectorcall_CallFromBuilderPyObjectFastCall__Pyx_PyObject_FastCallDict__Pyx_PyObject_FastCallr  )r  r  r  r   r   r   r   )rX   r   rp   r?  s       rS   select_utility_codez$PyMethodCallNode.select_utility_code  s    % 	.* 8:G/7( 	.0D=EE[ 	.%D1EE%D-E))#D*<==	? 	? 	?rT   c                 N   |                     | j                   |                     |           | j        }| j        }|j                            t          d          }|                     ||          }| j	        j
        }| j	        j        J |D ]}|                    |           |r|D ]}|                    |           n|r|                    |           |j                            t          j        d          }	|                    |	 d| j        rdnd d           |                     |||	|           |                     |          }
|                    d	           |rd
                    d |D                       nd}|rdt)          |           dnd}|                    dt*          j         d|rt)          |          dz   ndd| d| d
| d
           d}|r:|j                            t          d          }|                     ||||           n|r|                                }|                    |                                  d|
 d| d
t*          j         d|	 dt)          |          dz   dd|	 d| j        rdn|	 d|rd
nd | d           |                    |t                     ||	fD ]}|j                            |           |D ],}|                    |           |                    |           -|re|D ],}|                    |           |                    |           -|                    |t                     |j                            |           n,|r*|                    |           |                    |           |                     ||           |                    |                    |                                 | j                             |                      |           |                    d           d S )NTr  Fr<  r  1r=  )r+  r5  r6  r  r  c              3   >   K   | ]}|                                 V  d S rM   r   r  s     rS   re   z<PyMethodCallNode.generate_evaluation_code.<locals>.<genexpr>  s*      >>#cmmoo>>>>>>rT   r  z + ((CYTHON_VECTORCALL) ? z : 0)r  
PyObject *re  r+   r6   r  ] = {rA  r;  r   z, (r  z) | (z&*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)r  r   )!r  r   r  r  r  r  r  r   r,  r  r   r   r  r   r  r   r  r8  rK  r  r   r   r<  r@  r  ra  r  r  r  r  r/  r   r  )rX   r   r  r  r+  r&  r   rh  r>  space_for_selfargfunction_caller	args_listextra_keyword_argskeyword_variabletmpkw_nodes                   rS   r  z)PyMethodCallNode.generate_evaluation_code  s.   dh!!$'''!%!<>//4/PP224BB~"~)111 	/ 	/C((....! 	22 8 811$77778 	2++D111 !N889Q^c8dd

'YY43M,VCCSVYYYZZZ33"3	 	4 	
 	
 	
 22488 	

3
 CGRDII>>>>>>>>F	`v~\#>T:U:U\\\\|~

 H.  H  HD1O#d))a--a  H  HSe  H  Hmu  H  H  zC  H  H  H	
 	
 	
 ! 	/#~;;NW[;\\''d4JL\]]]] 	/%}}

{{}}     $ '8  D		!4  !2  4K33:K	 
 (/ttR
 2B  	 	 	 	x888/0 	- 	-CN'',,,, 	! 	!C&&t,,,NN4    ! 	$1 ) )..t444""4((((!!"2NCCCN''(89999 	$))$///d###&&tX666

4**4;;==$(CCDDDT"""

3rT   rR  )rZ   r[   r\   r   r   r  r  r  r  rl  r  r  r  r  r'  rw   r,  r/  r8  r@  rK  r  r]   r^   s   @rS   r  r    s4        MLLHG!F!L      (   \    \"   \,C    .	2 	2 	2! ! !H  (  .W W W W W W WrT   r  c                   8    e Zd ZddgZdZeZdZdZd Z	d Z
d ZdS )InlinedDefNodeCallNoder   r  r+   Nc                     | j         j        }|j        s|j        rdS t	          |j                  t	          | j                  k    rdS |j        rdS dS r@  )r&  def_nodestar_argstarstar_argr   r   num_kwonly_argsr  s     rS   can_be_inlinedz%InlinedDefNodeCallNode.can_be_inlined,  s]    =)	 	!7 	5y~#di..005$ 	5trT   c                    | j                                       | _         fd| j        D             | _        | j        j        }t          | j                  }d}t          |          D ]}|j        |         j        }| j        |                             |          }|	                                r	|dk    rd}nE|j        j
        r9j        s2|                                rn|dk    rd}|                              }|| j        |<   |rvt          |dz
            D ]c}| j        |         }|                                r$|j        j        r1j        r|j        j
        rE|dk    rt          |j        dd            nd| S )Nc                 :    g | ]}|                               S rV   rA  rs  s     rS   r   z8InlinedDefNodeCallNode.analyse_types.<locals>.<listcomp>9  s'    CCCc'',,CCCrT   Fr   Tr+   r  )r  r<  r   r&  r\  r   r  r   r  r  ro   r   rV  r8  r  r   r   )rX   rr   r  r  r  r  r  rh  s    `      rS   r<  z$InlinedDefNodeCallNode.analyse_types6  s   !/==cBBCCCC	CCC	M*	49~~ #|$$ 	 	A#.+0K)A,((c::C!!## 2q55)-&% 2ci 2++-- 
2 1uu-1*,,S11CDIaLL 	 <>**  il++-- X* Y 
38#7 
  1uu)  BC  D  D  D  rT   c                    | j                                         }| j        j        j        s|                    d           |                    d           |                    dt          j         d| d           |                    |                    t          j         d| j	                             |                    d           |                    dt          j         d| d           |                    d	           t          j        }|g}| j        j        }t          | j        |j                  D ]f\  }}|j        j        r.|                    |                    |j                             ?|                    |                                           gd
                    |          }|                    |                                 d| j        j        j        j        d|d|                    |                                 | j	                             | j        j        j        s|                    d           |                     |           d S )Nr  ##if CYTHON_COMPILING_IN_LIMITED_APIrP  z = PyCFunction_GetSelf(r  z == NULL && PyErr_Occurred()r  z = PyCFunction_GET_SELF(r  r  r<  r;  r  r   )r  r   r&  r\  is_cyfunctionr   r   r  r   r   r  r   r   ro   r   r  r  r  r   pyfunc_cnamer   r  )rX   r   	self_coder  r  rh  	proto_args          rS   r  z+InlinedDefNodeCallNode.generate_result_codeo  sL   &0022	}%3 	0 JJsOOOJJ<===JJZV4ZZYZZZ\ \ \JJt))*HHH     JJwJJ[V4[[i[[[] ] ]JJx   /I;M*	!$)Y^<< 	. 	.NCx# .in = =>>>>

----99X&&

&,999''tx@@@	B	C 	C 	C }%3 	JJsOOOT"""""rT   )rZ   r[   r\   r   r   r   r   r&  r  r`  r<  r  rV   rT   rS   rZ  rZ    sb         (HGDHM  7 7 7r%# %# %# %# %#rT   rZ  c                   ,    e Zd Zg ZddZd Zd Zd ZdS )PythonCapiFunctionNodeNc                 F    t                               | |||||           d S )N)rp   r   r   r$  rO  )rX   r   py_namer   r  r$  s         rS   rl  zPythonCapiFunctionNode.__init__  s;    $'(| 	 	E 	E 	E 	E 	ErT   c                     | S rM   rV   r   s     rS   r<  z$PythonCapiFunctionNode.analyse_types  r  rT   c                 V    | j         r!|j                            | j                    d S d S rM   )r$  r   r   r  s     rS   r  z+PythonCapiFunctionNode.generate_result_code  s:     	A--d.?@@@@@	A 	ArT   c                     | j         S rM   ro  rW   s    rS   r  z,PythonCapiFunctionNode.calculate_result_code  r  rT   rM   )rZ   r[   r\   r   rl  r<  r  r  rV   rT   rS   rj  rj    sa        HE E E E  A A A    rT   rj  c                       e Zd ZdZ	 ddZdS )PythonCapiCallNodeFNc                     |j         | _        | j        | _        t          |||||          | _        t          j        | |fi | d S )N)r$  )r  r   r!  rj  r&  r.  rl  )rX   r   r  r  r$  rl  rL  s          rS   rl  zPythonCapiCallNode.__init__  s[    )	 I.-') ) )
 	c44V44444rT   rz  )rZ   r[   r\   r  rl  rV   rT   rS   rq  rq    s4         O /3	5 	5 	5 	5 	5 	5rT   rq  c                   6     e Zd ZddgZdZ fdZd Zd Z xZS )CachedBuiltinMethodCallNoder#  r   Tc                 t    t                                          |j        ||||j        |j                   d S )N)r#  r   r   r  r   )rO   rl  r   r  r   )rX   	call_noder#  r   r   rR   s        rS   rl  z$CachedBuiltinMethodCallNode.__init__  sE    M4%5	 	 	! 	! 	! 	! 	!rT   c                 R    | j         | j         S t                              |           S rM   )r  r   rA  rW   s    rS   rA  z'CachedBuiltinMethodCallNode.may_be_none  s(    +''##D)))rT   c           
         | j         j        j        }| j                                         }d | j        D             }|j                            |                    d          ||| j        |          }|	                    | 
                                d|d|                    | 
                                | j                             |                     |           d S )Nc                 6    g | ]}|                                 S rV   rO  r  s     rS   r   zDCachedBuiltinMethodCallNode.generate_result_code.<locals>.<listcomp>  s     555C555rT   r  r<  r  )r#  r   typeptr_cnamer   r   r   cached_unbound_method_call_coder  r   r   r  r   r   r  )rX   r   
type_cname	obj_cnamer   	call_codes         rS   r  z0CachedBuiltinMethodCallNode.generate_result_code  s    X]0
H&&((	5549555$DD%%b))z4#3T; ;	 	

KKMMMM999##DKKMM48<<<
 	 	 	 	T"""""rT   )	rZ   r[   r\   r   r   rl  rA  r  r]   r^   s   @rS   rt  rt    sf         vHG! ! ! ! !* * *
# # # # # # #rT   rt  c                   L    e Zd ZeZg dZej        Zd Z	d Z
d Zd Zd Zd ZdS )	GeneralCallNode)r&  r  r  c                 
   | j                             |          }| j                            |          }| j                            |          }	  ||i |S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )r&  r/  r  r  r=  r3  )rX   r.  r&  r  r  r2  s         rS   r/  z"GeneralCallNode.compile_time_value  s    =33D99.AA$GG(;;DAA	-8_==== 	- 	- 	-))!,,,,,,,,,	-s   A 
B"A==Bc                    | j         j        r| j         j        j        r| j         j        }t          j        |          st          j        |          rz|j        }| j         j        j	        }|r|j
        nt          |j                  j        }t          j        ||          r-| j        j        }| j        j        } ||i || _        d S d S d S d S d S rM   )r&  r\  r#  r   r   r%   r  r  rZ   r   rp   r  r   r  r  r  )rX   r  r   r  r  r   rL  s          rS   r%  z)GeneralCallNode.calculate_constant_result  s    =% 	C$-*;*F 	C]2F (( 	CG,<V,D,D 	C$o"m/47B#f;#3#3V_H]H]Hf 67GUU C/?D!.>F+164+B6+B+BD(((	C 	C 	C 	C	C 	CC CrT   c                     | j         r| j         j        r| j        j        st	          | j        d          | j        j        | j         fS )Nz0Compile-time keyword arguments must be explicit.)r  rY  r  r   r   r   r   rW   s    rS   r  z"GeneralCallNode.explicit_args_kwds  s[     	Dd&7&G 	D(@	DtxBD D D#($*;;;rT   c                 >   |                      |          x}|S | j                            |          | _        | j        j        j        s| j        j        j        rt          | _        | S t          | j        d          r{|                                 }||| ur|                    |          S | j        j	        j
        r | j                            |          | _        n:|| u rt          | j        d           n n| j                            |          | _        | j        r| j                            |          | _        | j                            |          | _        | j                            |          | _        |                     | j                   d| _        | S )Nr   zRNon-trivial keyword arguments and starred arguments not allowed in cdef functions.r+   )r  r&  r<  r   ro   r  r2   r  map_to_simple_call_noder   r  r   r   r   r  r  r  r   )rX   rr   r  r   s       rS   r<  zGeneralCallNode.analyse_types
  s   #'#C#CC#H#HHU&&33C88}!- 	F}!* &	t}g.. F3355#D(8(8--c222](4 $(M$D$DS$I$IDMMT\\$(EF F F F
  $ @ @ E E 	E $ 1 ? ? D DD#3AA#FF 33C88 	...rT   c                 |   t          | j        t                    s| S | j        j        s| S | j        }t          |dd          }|s| S |j        }|j        r|j	        }|j
        s| S | j        j        | j        }|j        }|j        r
|dd         }t                    t          |          k    r6t          | j        dt          |          t                    fz             dS d |dt                             D             }|t                    d         }d}t!                    }	t#          |          }
d}|j        D ]A}|j        j        }||
v rt          |j        d|z             d	}|
                    |           Bt-          ||j                  D ]Q\  }}|j        j        }|j        |k    r5|                    |           |dz  }|	                    |j                   Q dd
lm}m} g }t          |j                  |k    r|t          |	          d         }fdt9          |j                  D             }d}|D ]}|j        }||vr|s|}|r&|j        r| c S t          | j        d|z              dS ||         \  }}|                    |           |dz  }|j                                        r|	                    |j                    ||j                  }|                                sJ |	                    |           |                    ||f           |rg }g }|d         d         }|	D ]g}||u r n`|                                r|                    |           2 ||          }|                    |           |                    |           h|r|}	|d t?          |          D             z   }|j        D ],}|j        j        }||vrd	}t          |j        d|z             -|rdS tA          | j        ||	          }|ddd         D ]} |||          }|S )z
        Tries to map keyword arguments to declared positional arguments.
        Returns self to try a Python call, None to report an error
        or a SimpleCallNode if the mapping succeeds.
        r   Nr+   zDfunction call got too many positional arguments, expected %d, got %sc                 *    h | ]}|j         	|j         S rV   r  r  s     rS   r   z:GeneralCallNode.map_to_simple_call_node.<locals>.<setcomp>L  s2     
 
 
x
H
 
 
rT   r   Fzargument '%s' passed twiceT)r  
LetRefNodec                 T    i | ]$\  }}|j         j        |t                    z   |f%S rV   )r  r   r   )rb   r  rh  pos_argss      rS   
<dictcomp>z;GeneralCallNode.map_to_simple_call_node.<locals>.<dictcomp>p  sH     I I I"As #h--'= I I IrT   z(C function call is missing argument '%s'ry  c                     g | ]\  }}|S rV   rV   )rb   r  rh  s      rS   r   z;GeneralCallNode.map_to_simple_call_node.<locals>.<listcomp>  s    $F$F$Feac$F$F$FrT   z/C function got unexpected keyword argument '%s'r%  )!r~   r  r  r  rY  r&  r   r   r  r  rU  r   r  r   r   r   r   r  r  r  r   r  r  rp   r   r  r  r  r  r  r:  r  r.  )rX   r&  r   r  rL  declared_argsmatched_argsunmatched_argsmatched_kwargs_countr   seen
has_errorsrh  rp   decl_argr  r  tempskeywordsfirst_missing_keywordr   r  
final_args	new_tempsfirst_temp_arg	arg_valuer   r  s                              @rS   r  z'GeneralCallNode.map_to_simple_call_node*  sj    $.	:: 	K 0 	K='400 	K
 	4)3M) 	K',"%* 	.)!""-Mx==3}----$( 2585G5G58]]5DD E E E 4
 
 -ns8}}n =
 
 
 's8}}~~6 H~~ <  
) 	 	C7=Dt||cg;dBCCC!
HHTNNNN !1GHH 	 	MHc7=D}$$  &&&$)$CI&&&&
 	@???????v%&&)===*3t99::6NI I I I&/0F&G&GI I IH$(!* . .}x''0 504-* 
 ( $
  $$( %46K%L M M M44#D>S  &&&$)$9&&(( .KK	****%:ci00D>>+++++KK%%%LL#t---- G
	!&q"!% 0 0I N22 **,, 0")))4444)z)44!((..."))$//// &%D!$F$Fve}}$F$F$FF ) 	 	C7=D<''!
cgG    	4 dhEEE$$B$K 	4 	4D''d33DDrT   c                    | j         j        rd S | j        r| j                                        }nd}|j                            t          j        dd                     |                    | 	                                d| j
                                        d| j                                        d|d|                    | 	                                | j                  	           |                     |           d S )Nr  rC  r  rD  r  r  )r   r  r  r   r   r   r   r   r   r  r&  r  r   r   r  )rX   r   rL  s      rS   r  z$GeneralCallNode.generate_result_code  s   9%vv 	&0022FFF))+*A.+0 +0 	1 	1 	1

''))))$..0000''tx@@@B	C 	C 	C 	T"""""rT   N)rZ   r[   r\   r   r   r   r.   rr  rs  r/  r%  r  r<  r  r  rV   rT   rS   r  r    s         D>>>H.K- - -C C C< < <  @J J JX# # # # #rT   r  c                   H    e Zd ZdgZdZd Zd Zd Zd Ze	j
        ZdZd Zd	S )
AsTupleNoderh  r+   c                 B    t          | j        j                  | _        d S rM   )r   rh  r   rW   s    rS   r%  z%AsTupleNode.calculate_constant_result  s    $TX%=>>rT   c                     | j                             |          }	 t          |          S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )rh  r/  r   r=  r3  )rX   r.  rh  r2  s       rS   r/  zAsTupleNode.compile_time_value  sm    h))$//	-:: 	- 	- 	-))!,,,,,,,,,	-s   + 
AAAc                     | j                             |                              |          | _         | j         j        t          u r| j                             d          S t          | _        | S Nr  )rh  r<  r   r   r   rI  r   s     rS   r<  zAsTupleNode.analyse_types  sY    8))#..AA#FF8=J&&8--.QRRR	rT   c                     dS rw  rV   rW   s    rS   rA  zAsTupleNode.may_be_none  r  rT   Constructing Python tuplec                 T   | j         j        t          t          fv rdnd}|                    |                                 d|d| j                                         d|                    |                                 | j                             | 	                    |           d S )N__Pyx_PySequence_TuplePySequence_Tupler<  r;  r  )
rh  r   r   r   r   r  r   r   r   r  )rX   r   r?  s      rS   r  z AsTupleNode.generate_result_code  s    ,0HMnj=Y,Y,Y((_q

tx))++++''tx@@@B	C 	C 	C
 	T"""""rT   N)rZ   r[   r\   r   r   r%  r/  r<  rA  r.   rr  rs  r  r  rV   rT   rS   r  r    s{         wHG? ? ?- - -     .K-K# # # # #rT   r  c                   T    e Zd ZdgZdZeZdZd Zd Z	d Z
d Zd Zd	 Zd
Zd Zd ZdS )MergedDictNoder  r+   Tc                     i }| j         }| j        D ]Y}|j        rd |j        D             }n|j                                        }|D ]"\  }}|r||v rt          d|z            |||<   #Z|| _        d S )Nc              3   8   K   | ]\  }}|j         |j         fV  d S rM   r  rb   r  r   s      rS   re   z;MergedDictNode.calculate_constant_result.<locals>.<genexpr>  sM       A A'S% -u/DE A A A A A ArT   $duplicate keyword argument found: %s)reject_duplicatesr  rY  r  r   	iteritemsr   )rX   r  r  r   r  r  r   s          rS   r%  z(MergedDictNode.calculate_constant_result  s     2% 	$ 	$D# 9A A+/+?A A A ,6688# $ $
U$ S$%Kc%QRRR#s$
  &rT   c                 V   i }| j         }| j        D ]}|j        rfd|j        D             }n'|                                                              }	 |D ]"\  }}|r||v rt          d|z            |||<   #k# t          $ r}|                     |           Y d }~d }~ww xY w|S )Nc                 j    g | ]/\  }}|                               |                               f0S rV   r  )rb   r  r   r.  s      rS   r   z5MergedDictNode.compile_time_value.<locals>.<listcomp>  sU     A A A'S% 00668P8PQU8V8VW A A ArT   r  )	r  r  rY  r  r/  r  r   r=  r3  )	rX   r.  r  r  r   r  r  r   r2  s	    `       rS   r/  z!MergedDictNode.compile_time_value  s    2% 	1 	1D# BA A A A+/+?A A A //55??AA1"' ( (JC( WSF]]()ORU)UVVV"'F3KK(  1 1 1--a000000001s   %A==
B&B!!B&c                     dS r  rV   r   s     rS   rO  z MergedDictNode.type_dependencies"      rrT   c                     t           S rM   r   r   s     rS   r   zMergedDictNode.infer_type%  s    rT   c                 8    fd| j         D             | _         | S )Nc                     g | ]=}|                                                                                 d           >S )z1argument after ** must be a mapping, not NoneTyper<  r   rI  rs  s     rS   r   z0MergedDictNode.analyse_types.<locals>.<listcomp>)  s\     
 
 
  c""55c::LLCE E
 
 
rT   )r  r   s    `rS   r<  zMergedDictNode.analyse_types(  s:    
 
 
 
 (	
 
 
 rT   c                     dS rw  rV   rW   s    rS   rA  zMergedDictNode.may_be_none2  r  rT   Constructing Python dictc                    |                     | j                   |                     |           t          | j                  }t          |          }|                    |           |j        t          ur*|	                    d|
                                z             |j        rk|                    |           |	                    |                                 d|
                                d           |                    |           n|                                r|	                    d           |	                    d|
                                z             |	                    |                                 d|
                                d           |                    |           |	                    d           |	                    d           |	                    d           |	                    |                                 d	|
                                d
|                    |                                 |j                             |                     |           |                    |           |                                r|	                    d           |j        t          ur|	                    d           |j                            t+          j        dd                     |	                    |                                 d|
                                d
|                    |                                 | j                             |                     |           |                    |           |	                    d           |                    |           t1                      }|D ]}|j        rw|j        D ]l}|                    |           | j        r|	                    d|                                 d|j        
                                d           |                    d           |	                    d|j        
                                d
|                    | j                             |	                    d           |                    |j        j        d|                                 d|j        
                                d|j        
                                d           |                    |           |                    |           n|                    |           | j        r\|                    d           |                    |j        d|                                 d|
                                d           n|                    d           |	                    d|                                 d|
                                d           |	                    d|
                                z             |	                    |                    |j                             |	                    d           |                    |           |                    |           tA          |          D ]/}|j                            t+          j        |d                     0d S )Nz$if (likely(PyDict_CheckExact(%s))) {r<  r=  zB#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_APIzif (Py_REFCNT(%s) == 1) {z} elser  r  z = PyDict_Copy(r  r   r  r  r  z6 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, if (unlikely(PyDict_Contains(r  rM  RaiseDoubleKeywords+__Pyx_RaiseDoubleKeywordsError("function", PyDict_SetItem(r  MergeKeywordsz__Pyx_MergeKeywords(RaiseMappingExpectedzif (unlikely(PyDict_Update(z	) < 0)) {zVif (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseMappingExpectedError(%s);FunctionArguments.c)!r  r   r  r  r  r  r  r   r   r   r   rY  r  r  r  r  r   r  r  r   r   r   r   r  r  r  r  r  r  r   rr  r   r  )rX   r   r   r   helpersrh  helpers          rS   r  z'MergedDictNode.generate_evaluation_code7  s   dh!!$'''D%&&Dzz%%d+++9I%%JJ=~~''( ) ) )  	 %%d+++JJT[[]]]]DNN4D4D4D4DEFFF..t4444""$$ 
  

_```

69I9IIJJJ

8H8H8H8HIJJJ224888

8$$$

8$$$

3JJ    ''tx@@@B C C C   &&&''---""$$  

39I%%JJz"""--k.E$&8/: /: ; ; ;JJ    ''tx@@@B C C C   &&&''---JJsOOO%% &	& &	&D# %&/ ) )C00666- 	(


 KKMMMMG--////$1 2 2 2  $9:::


G--//// OODH555$7 8 8 8 

3))#'++))++++	++----8/ 0 0 0 ..t444NN4((((#)& --d333) $KK000))$((t~~'7'7'7'759 : : : : KK 6777JJJt~~'7'7'7'7 9 : : :JJ  FHLHXHX Y Z Z ZJJttx88999JJsOOO++D111%%%%Woo 	f 	fF--k.EfNc.d.deeee	f 	frT   c                 D    | j         D ]}|                    |           d S rM   )r  r  rX   r   r   s      rS   r  zMergedDictNode.annotate  s3    % 	  	 DMM$	  	 rT   N)rZ   r[   r\   r   r   r   r   r  r%  r/  rO  r   r<  rA  r  r  r  rV   rT   rS   r  r    s        
 HGD& & &$  (         -K\f \f \f|         rT   r  c                      e Zd ZdZdg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)dZd Zd Zd Zd Zd Zd Zd Zd Zd*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,d%Z)d-d&Z*d' Z+d( Z,dS ).r/  r+   r#  Nr   TFc                     t          | j        t                    r| j        j        r| j        dk    s| j        S | j                                        }|r|d| j        S d S )Nparallelr   )r~   r#  r  r  r$  rC  )rX   cys     rS   rC  z!AttributeNode.as_cython_attribute  sk    tx** 	")	"*,,>!X))++ 	2 bb$..11trT   c           	      $   |t           u rk| j        }|r8|j        r1|j        r*d| _        |j        | _        |                     |           | S |r'|j        r| j        j        t          j	        urddl
m}m}  || j        | j        j                  }| j        j        |_        || _        t                              | ||          }t!          j        dd          }t%          j        t$          j         t%          j        dt$          j         d           t%          j        dt$          j         d           g          }	t+          | j        d|	||g|	          }
 |||
          }|                    |          S t                              | ||          S )
Nr+   r  r  PyMethodNew2Argr  r  rX   __Pyx_PyMethod_New2Arg)r  r  r   r$  )r   r   rU  r  r   analyse_as_python_attributer#  r   r   r   r  r  r	  r!  r   r  r   r   r   r  r  rq  r   r<  )rX   r  rr   r   r  r	  obj_nodeunbound_noder$  r  binding_callcomplete_calls               rS   r  zAttributeNode.coerce_to  s    ~%%JE "8+ "80A "8 ".
00555 85- 8$(-wGX2X2X
 KJJJJJJJ(=FFF(,(=%#'11$#FF(4%'9  '0-"/
8QSWXX"/
8QSWXX0 	  2H":'&1!-      !5 4X| L L$223777!!$#666rT   c                     | j         }|                    d          r|                    d          rd S t          | j        j        |          | _        d S )N__)r$  
startswithendswithr   r#  r   )rX   r  s     rS   r%  z'AttributeNode.calculate_constant_result  sR    ~??4   	T]]4%8%8 	F&tx'?FFrT   c                 H   | j         }|                    d          r/|                    d          rt          | j        d|z             d S | j                            |          }	 t          ||          S # t          $ r }| 	                    |           Y d }~d S d }~ww xY w)Nr  z6Invalid attribute name '%s' in compile-time expression)
r$  r  r  r   r   r#  r/  r   r=  r3  )rX   r.  r  r#  r2  s        rS   r/  z AttributeNode.compile_time_value  s    ~??4   	T]]4%8%8 	$(JTQS S S4h))$//	-3%%% 	- 	- 	-))!,,,,,,,,,	-s   'A7 7
B!BB!c                 6    | j                             |          S rM   )r#  rO  r   s     rS   rO  zAttributeNode.type_dependencies      x))#...rT   c                    |                      |d          }|G|j        j        r/|j        j        j        rt	          j        |j        j                  S |j        j        S |                     |          }||j        j        S | j                            |          }| 	                    ||           |j
        r| j        j        rt          S | j        r| j        j        rt          S | j        S )NFtarget)obj_type)#analyse_as_cimported_attribute_noder   r   rU  r   r  analyse_as_type_attributer#  r   analyse_attributer  r   r  )rX   rr   r   r  s       rS   r   zAttributeNode.infer_type  s    77E7JJz '4:?#? '!*4:?;;;z&--c22:?"8&&s++sX666# 	"	(> 	" "!Z 	"DJ1 	" "!yrT   c                     d| _         d S r  r  r   s     rS   r8  z(AttributeNode.analyse_target_declaration  r\  rT   c                     |                      |d          }|j        j        rt          | j        d| j        z             |                                st          | j        d| j        z             |S )Nr+   r  z"Assignment to const attribute '%s'r  )r<  r   rG  r   r   r$  r   r>  s      rS   rD  z"AttributeNode.analyse_target_types  st    !!#!229 	S$(@4>QRRR~~ 	Q$(CdiOPPPrT   c                 j   | j         st          j        | _         |j        d         | _        |                     ||          }||s|                     |          }||                     ||          }|J |j        s|j	        r|j
        rd|j
        _        |j        r|                    |           |S )Nr  T)r   r   r2   rj   r  r  r  "analyse_as_ordinary_attribute_noder\  r   r   r  wrap_obj_in_nonecheck)rX   rr   r  r   s       rS   r<  zAttributeNode.analyse_types!  s    y 	."-DI!$0B!C77VDD<<11#66D<::3GGD### 	# 	#4: 	#"DJO 	,&&s+++rT   c                 R   | j                             |          }|r|                    | j                  }|r:|j        s3|j        s|j        s|j        s|j        r| 	                    |||          S | 
                    |          rt          | j        d| j        z             | S d S )Nz&cimported module has no attribute '%s')r#  rb  r  r$  r  r  rU  r%  rG  as_name_noder   r   r   )rX   rr   r  module_scoper   s        rS   r  z1AttributeNode.analyse_as_cimported_attribute_node1  s    
 x11#66 		 ,,T^<<E =U@ =$=(-(:=}=(-= ((eV<<<66s;; dh H4> YZZZtrT   c                 P     j         j        rd S  j                                       rwj        sj        sj        rj                             j                  }|rv|j	        sj        rh|j
        j        r\j        r j        sd S |}n1                     |          } fd|j        D             |_                             |d          S nʉj        sj        r j        j        v rYj        j        D ],}|j         j        k    r                     |d          c S -t-           j         j        d           nU j                            d          r j                            d          rd S t-           j         j        d           d S )Nc                 >    g | ]}                     |          S rV   )_create_unbound_cmethod_entry)rb   overloaded_alternativerr   rX   r   s     rS   r   z;AttributeNode.analyse_as_type_attribute.<locals>.<listcomp>V  s=     > > > 6 !>>tE[]`aa> > >rT   Fr  z not a known value of r  )r#  r[  re  r  r  r  r,  r  r$  r  r   rU  re  r  overloaded_alternativesr  r(  r  ru  r   enum_valuesrp   r   r   r  r  )rX   rr   r   
ubcm_entryr   s   ``  @rS   r  z'AttributeNode.analyse_as_type_attributeC  s   
 8% 	Fx'',, 	[% [)= [AR [
..t~>> Le. L$2C L
H_ L+ 
#~ (#'4%*

%)%G%GeUX%Y%Y
> > > > > >:?:W> > >
:  ,,S*U,KKK [!1 [>T[00!%!7 _ _ :77#'#4#4S%#4#N#NNNN 8 dhX\X\(]^^^^^..t44 [9P9PQU9V9V [4$(DNNNTXTX$YZZZtrT   c                 :   |j         r|j        j        |j         }|j        j        s|j        r|j        j        r|j        }n|j        r,t          | j        |j	        d|           t          j        }net          j        |j                  }|j        d d          |_        t          j        d|dd           |j        d<   n|j        d|j        }|j        }t#          j        |j	        ||          }d|_        |j         |_         d|_        |j        |_        |S )Nz not a static member of rX   r   r  r+   )
func_cnamer   r  r  parent_scopeis_cpp_class_scoper  r   r   rp   r   r2   r&   r   r  vtabptr_cnamer   r   r  rU  r  r,  )rX   r   r   rr   r   r  r  s          rS   r  z+AttributeNode._create_unbound_cmethod_entryi  s(     	
 8 @$Ez* 
T$
T),)9)L
T
" Tdh%***dd STTT"- 	%*--"Z]
 * 7fd S S
1 $ 2 2 2EKK@EJE\%*eU;;
"#
 % 0
()
% ;
rT   c                 "   | j                             |          }|r|                    | j                  S | j         j        sL| j                             |          }|r0t          |dd           |j                            | j                  S d S )Nr,  )r#  rb  lookup_typer$  r[  re  r   r,  )rX   rr   r  r  s       rS   re  zAttributeNode.analyse_as_type  s    x11#66 	<++DN;;;x) 	C0055I CWY>>J 224>BBBtrT   c                     | j                             |          }|rB|                    | j                  }|r&|j        r|j        j        s|j        j        r|j        S d S rM   )r#  rb  r  r$  r%  r   r  r  rX   rr   r  r   s       rS   rm  z'AttributeNode.analyse_as_extension_type  sm     x11#66 	& ,,T^<<E & &:/ &5:3M & :%trT   c                     | j                             |          }|r*|                    | j                  }|r|j        r|j        S d S rM   )r#  rb  r  r$  r  r  s       rS   rb  zAttributeNode.analyse_as_module  sT     x11#66 	' ,,T^<<E ' '&trT   c                     t                               | | j        |          }|r|                    |          }n|                    |          }d|j        _        |S )N)rp   r   r+   )r  rO  r$  rD  r  r   r  )rX   rr   r   r  r   s        rS   r  zAttributeNode.as_name_node  s^     !!$T^5!II 	2,,S11DD,,S11D
rT   c                     | j                             |          | _         |                     |           | j        r| j        j        r| j        s	 | j        r|sd| _        t          | _	        n|r'| j         j
        j        rt          | j        d           nh| j        ra| j        j        rU|s>t                              | j        | j         | j                                      |          S t          | j        d           | S )Nr+   z'Assignment to an immutable object fieldz"Assignment to a read-only property)r#  r<  r  r   r  re  r  r   r   r!  r   r  r   r   is_cpropertyr.  r  )rX   rr   r  s      rS   r  z0AttributeNode.analyse_as_ordinary_attribute_node  s
   8))#..s###: 	$*/ 	 	 ? 
	B 3 $2! 	B5 	B$(EFFFFZ 	BDJ3 	B g%33DHdh
SSaabefff$(@AAA rT   c                    |d u}d| _         | j        | _        |N| j        j        j        s| j        j        j        r| j                            |          | _        | j        j        }n|j        s|j        rt          }|j	        s|j
        r|j        }d| _        n3|j        s|j        rd| _        n|j        r|j        rd| _        nd| _        |j        rs|                                r|j                            | j                  }|j        r|s| j        dk    r@d| _        d| _        d| _        | j        j                            | j                  | _        d S |                    | j        || j                   |j                            | j                  }|r	|j        rd }n+t;          | j        d|z             t<          j        | _        d S || _         |rl|j        r |j!        dk    rt;          | j        d           |j"        r|j        | _        d S |j#        r|j$        r|j%        r|j        | _        |j&        | _        d S 	 | '                    |||           d S )	Nr   r  r   TTz/Cannot select attribute of incomplete type '%s'__weakref__z,Illegal use of special attribute __weakref__)(r  r$  r  r#  r   r  r  r   r   r  rT  r  r  r  r  r	  is_fake_referencehas_attributesattributes_knownr,  r  r   is_memslice_transposer   r  	transposer   declare_attributerE  r   r   r2   r   rp   r  r  r  r  r   r  )rX   rr   r  immutable_objr   s        rS   r  zAttributeNode.analyse_attribute  s    ,nx}& <$(-*H <866s;;x}HH! *X%> *)? 	h/ 	)HDGG' 	8+C 	DGG" 	x'A 	DGGDG" *	((**  224>BB. 	Ku 	K~,,592'+/3,$(HM$;$;DH$E$E	 224>3QQQ ( : :4> J J !U_ ! EdhE      '1	DJ - T%*2M2M$($RSSS %  %
DIF' 0E %JZ  %
DI"'+DKF
 
 	((hFFFFFrT   c                    || j         j        }|                    | j                  | _        | j        | _        t
          | _        d| _        |j        s|j        s|j	        sT|j
        sM|j        sF|j        s?|j        s8|j        r|                    |          s|j        r:|                    |          r%|s!| j                             |          | _         d S d S |j        ri| j         j        s| j         j        rQ| j         j        j        r@| j         j        j        j        j        r%|s!| j                             |          | _         d S d S t/          | j        d|d| j        d           d S d S d S )Nr+   zObject of type 'z' has no attribute 'r  )r#  r   mangle_class_private_namer$  r  r   r  ro   r  r  rX  r  r   r  r1  r  	is_structr   rU  r   r\  r   r  r   r   )rX   rr   r  r	  s       rS   r  z)AttributeNode.analyse_as_python_attribute  s   x}H66t~FFn"	# 	2H,= 	2" 2h&< 2)2-5-H2*2 !*2 08/N/Ns/S/S2 !*	2 08/N/Ns/S/S	2
 % @#x::3??DHHH@ @' 	2TX-= 	2AV 	22	227C	2 % @#x::3??DHHH@ @ dhhxx12 2 2 2 2!	2 	2 	2 	2rT   c                    |j         d         sd S d }d}| j        j        j        rF| j        r?| j        s8d                    t          | j                  dk    rdnd          }| j        f}nP| j        j        j	        r?| j
        rd}n5| j        j        j                            | j                  }|r
d}|j        f}|r$| j                            |d	|
          | _        d S d S )Nr;  rV   r  r  r  r  z&Cannot transpose None memoryview slicez5Cannot access '%s' attribute of None memoryview slicer  r  )rj   r#  r   r  needs_none_checkr  r  r   r$  r   r	  r,  r  rp   rI  )rX   rr   r  rH  r   s        rS   r  z#AttributeNode.wrap_obj_in_nonecheck(  s   ~k* 	FHM+ 	00E 	0	0=DDcRVR`NaNaegNgNgUUmoppC>+KKX]- 	0) 0>+77GG 0QC#(:-K 	Kx11#7M>I 2 K KDHHH	K 	KrT   c                 @    | j         r|                                  d S d S rM   )r  rr  r   s     rS   rs  zAttributeNode.nogil_check@  s,    ? 	NN	 	rT   zAccessing Python attributec                 6    | j                             |          S rM   )r#  r   r   s     rS   r   z0AttributeNode.is_cimported_module_without_shadowF  s    x::3???rT   c                     | j         r-|                                 p| j                                         S t                              |           S rM   )r#  r  r:  r  rW   s    rS   r:  zAttributeNode.is_simpleI  sE    8 	,&&((@DH,>,>,@,@@%%d+++rT   c                 H    | j         rdS t                              |           S r  )r#  r  r   rW   s    rS   r   zAttributeNode.is_lvalueO  s%    8 	,4%%d+++rT   c                 v    | j         r| j                                         S t                              |           S rM   )r#  r   r  rW   s    rS   r   zAttributeNode.is_ephemeralU  s4    8 	/8((***((...rT   c                 l    |                                  }| j        r| j        j        r| j        sd|z  }|S r  )calculate_access_coder   r  ra  )rX   r  s     rS   r  z#AttributeNode.calculate_result_code[  sA    ++--: 	&$*4 	&T^ 	&v%FrT   c                    | j         }|                    |j                  }| j        r| j        j        r|j        j        rn| j        j        sb| j        j        r| j        j        S | j        j        r| j        j	        | _
        d|j        j        d|| j        |j        j        d| j
        S | j        r| j
        S d S |j        j        r d| j
                                        d|dS |j        j        rA| j        r:| j        j        r.|j                            |                                d          }|| j        | j
        S )	Nz	((struct z *))->__Pyx_Cr;  r  T)to_object_struct)r#  r  r   r   r  r  is_builtin_cmethodfinal_func_cname
from_fusedr   r  vtabstruct_cnamer  vtabslot_cnamer  r  upperr  r  r   r  )rX   r#  obj_codes      rS   r	  z#AttributeNode.calculate_access_codea  sh    h==**: 	?$*/ 	?x) #$*2O #:. 7:669' 3
 #'*"2DK H---xxH+++T[[: : $ #{"
 FX  	? 	?&*k&7&7&9&9&9&9888DDx' UDJ U4:;Q U8--cjjllt-TT'x$++>>rT   c                    | j         r| j        r0|j                            t	          j        dd                     d}n/|j                            t	          j        dd                     d}|                    |                                 d|d| j        	                                d|
                    | j                  d	|                    |                                 | j                  	           |                     |           d S | j        j        rB| j        r| j        j        D ]#\  }}|d
k    rt'          | j        d            d S $|                    |                                 d| j                                        d           |                    |                                 | j        d           d|                                 z  }|                    |                    || j                             d S | j        rH|                    d|                                 d|                    | j                  d           d S d S | j        j        r| j        r}| j        r|                                 }n| j        rJ |                                 }| j                            |          }|                    | j        | j        | j        |           d S | j        j        r| j        j        j         rd S | j        r-| j        j!        r#|j        "                    | j                   d S d S d S )NPyObjectLookupSpecialr  __Pyx_PyObject_LookupSpecialPyObjectGetAttrStr__Pyx_PyObject_GetAttrStrr<  r;  r  r  r  z=Transposing not supported for slices with indirect dimensionsr=  Tr  z__pyx_memslice_transpose(&%s)zif (unlikely(!zR.memview)) {PyErr_SetString(PyExc_AttributeError,"Memoryview is not initialized");r   r"  )#r  r  r   r   r   r   r   r  r#  r   rt  r$  r   r   r  r   r   r	  r  r   r  r  r  r   r   r  ra  r   r	  r,  r.  r  r  r  r  )rX   r   lookup_func_namer  r  r  undereferenced_resultr#  s           rS   r  z"AttributeNode.generate_result_code  s   ? 6	D% ? 11+,CEWXXZ Z Z#A   11+,@BTUUW W W#> JJKKMMMM$$$H&&((((**4>::::++DKKMM48DDDFG G G   &&&&&Y) %	D) F'+y~  OFGdh )C D D D '
 

8I8I8I8IJKKK//ty)- 0 / / / 4dkkmmC

411!TX>>?????' F



  ;;====$//$(*C*C*C*C	EF F F F FF F Z' 	DD,B 	D~ E(,%%<'''(,(B(B(D(D%!%!K!KLa!b!b%%dh
D<Qfx%yyyyy x} D!@ D D
 5 D 77
CCCCCD D D DrT   c                     | j         rD| j        j        r8| j        r1|                    |                                 | j        d           d S t                              | |           d S )NTr  )r   r   r   r	  ra  r  r   r  r  s     rS   r  z$AttributeNode.generate_disposal_code  si    < 	8DI8 	8T=W 	8""4;;==$)d"KKKKK++D$77777rT   c                 ^   | j                             |           | j        r|j                            t          j        dd                     |                    | j        d| j         	                                d|
                    | j                  d|	                                d           |                    |           |                    |           n| j         j        j        r|                    d| j                                        | j         j        j        d| j                             | j         j                  d|                    |                                           d           |                    |           |                    |           nM|                                 }| j        j        ru| j        rn|                    |           |                    |           |                    || j                   |                    ||                                            nB| j        j        r6d	d
lm} |                     |||                                | j        |           | j        j        s@|                    |d|!                    |                                           d           |"                    |           |                    |           | j                             |           | j                             |           d S )Nr]  r  z__Pyx_PyObject_SetAttrStr(r  r  __Pyx_SET_Cr;  r  r+   r  r<  r=  )#r#  r  r  r   r   r   r   rr  r   r   rt  r$  r  r  r   r  r   r  r	  implementation_suffixr  r  r  ro   r  r  r  r  
put_decrefr   r  r  put_assign_to_memviewslicer  r  )rX   r   r   r  r   r   select_coder  s           rS   r  z&AttributeNode.generate_assignment_code  s   ))$///? %	!--'(<>PQQS S S!!$((H&&((((**4>::::MMOOOO%& & &
 &&t,,,NN4    X]% 	!JJJ!!###333""48=1111djjll++++	- . . .
 &&t,,,NN4    ++--Ky$ I)= I((...$$T***TY777TZZ\\::::- I((((((55#S#**,,	4I I I 9/ ?

#..tzz||<<<<>? ? ?
 --d333NN4   ''---D!!!!!rT   c           	          | j                             |           | j        s$| j        j        j        rd| j        j        j        v r|j                            t          j
        dd                     |                    | j        d| j                                         d|                    | j                  d           nt!          | j        d           | j                             |           | j                             |           d S )N__del__r]  r  r^  r  r  z+Cannot delete C attribute of extension type)r#  r  r  r   r,  is_property_scoper  r   r   r   r   rr  r   r   rt  r$  r   r  r  r  s      rS   r  z$AttributeNode.generate_deletion_code  s   ))$///? 		Ktz/A 		K#,
0@0H#H#H--'(<>PQQS S S!!$((H&&((((**4>::::<= = = =
 $(IJJJ''---D!!!!!rT   c           
          | j         rd\  }}nd\  }}|                    | j        t          ||| j        z  t          | j                                       d S )N)py_attrzpython attribute (%s))c_attrzc attribute (%s)rh  )r  r  r   r7   r   r   r$  )rX   r   rj  rk  s       rS   r  zAttributeNode.annotate    s^    ? 	7<KE446KE4dhudTY6FSQUQ_M`M` a a abbbbbrT   c                 x    | j                                         }|rt          j        |d| j                  S d S )Nr   )r#  rQ  r
   r0  r$  )rX   rt  s     rS   rQ  z/AttributeNode.get_known_standard_library_import   sA    h@@BB 	Y!/;;;0WXXXtrT   rS  rM   rw  rT  rR  )-rZ   r[   r\   r\  r   r   re  r
	  r	  r  r  rC  r  r%  r/  rO  r   r8  rD  r<  r  r  r  re  rm  rb  r  r  r  r  r  rs  r  r   r:  r   r   r  r	  r  r  r  r  r  rQ  rV   rT   rS   r/  r/    sy        LwHEI!J	 	 	(7 (7 (7TG G G
- 
- 
-/ / /  2          $$ $ $L  4  	 	 	  	 	 	  0DG DG DG DGL2 2 2 2:K K K0   /K@ @ @, , ,, , ,/ / /  "? "? "?H7D 7D 7Dr8 8 8 INGK*" *" *" *"X" " " "c c c    rT   r/  c                   T    e Zd ZdgZdZeZdZdZd Z	d Z
d Zd Zd Zd	 Zd
 Zd ZdS )StarredUnpackingNoder  r+   Fc                 @    t                               | ||           d S )Nr  rO  )rX   r   r  s      rS   rl  zStarredUnpackingNode.__init__&   s#    $F33333rT   c                 r    | j         st          | j        d           | j                            |           d S Nz&starred expression is not allowed here)starred_expr_allowed_herer   r   r  r  r   s     rS   r  z)StarredUnpackingNode.analyse_declarations)   s=    - 	F$(DEEE((-----rT   c                 6    | j                             |          S rM   )r  r   r   s     rS   r   zStarredUnpackingNode.infer_type.   s    {%%c***rT   c                     | j         st          | j        d           | j                            |          | _        | j        j        | _        | S r6	  )r7	  r   r   r  r<  r   r   s     rS   r<  z"StarredUnpackingNode.analyse_types1   sI    - 	F$(DEEEk//44K$	rT   c                 :    | j                             |           d S rM   )r  r8  r   s     rS   r8  z/StarredUnpackingNode.analyse_target_declaration8   s    ..s33333rT   c                 f    | j                             |          | _         | j         j        | _        | S rM   )r  rD  r   r   s     rS   rD  z)StarredUnpackingNode.analyse_target_types;   s*    k66s;;K$	rT   c                     dS r  rV   rW   s    rS   r  z*StarredUnpackingNode.calculate_result_code@   r  rT   c                     d S rM   rV   r  s     rS   r  z)StarredUnpackingNode.generate_result_codeC   r   rT   N)rZ   r[   r\   r   r   r   r   r   r7	  rl  r  r   r<  r8  rD  r  r  rV   rT   rS   r3	  r3	     s         zHJDG %4 4 4. . .
+ + +  4 4 4  
      rT   r3	  c            
            e Zd ZddgZdZdZ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dZ fdZ	 	 ddZ ej         ej        ej         ej        dej        d          g                    Zd Zd ZddZd Zd Z  xZ!S )SequenceNoder   r   r+   NFc                 *    fd| j         D             S )Nc                 :    g | ]}|                               S rV   r  r  s     rS   r   z8SequenceNode.compile_time_value_list.<locals>.<listcomp>\   r  rT   r}  r-  s    `rS   compile_time_value_listz$SequenceNode.compile_time_value_list[   s    BBBB	BBBBrT   c                     d| _         g }| j        D ]O}|j        r1| j         rt          |j        d           d| _         |j        }d|_        |                    |           P|| _        d S )NFz,more than 1 starred expression in assignmentT)starred_assignmentr   r   r   r   r  r   rX   r   rh  s      rS   replace_starred_target_nodez(SequenceNode.replace_starred_target_node^   s    "'9 	 	C~ &* S#'#QRRR*.'j!%KK			rT   c                 l    |                                   | j        D ]}|                    |           d S rM   )rF	  r   r8  rX   rr   rh  s      rS   r8  z'SequenceNode.analyse_target_declarationl   sF    ((***9 	0 	0C**3////	0 	0rT   c                    t          | j                  D ]9\  }}|s|                    |          }|                    |          | j        |<   :| j        rU| j                            |          }|j        j        s|                    |          }|                    |          | _        d| _        |j	        s|j
        s|j        r|j        j	        rd| _        | S Nr+   T)r  r   r<  r   r   r   r  rK  r   r  r  r  r  slow)rX   rr   skip_childrenr  rh  r   s         rS   r<  zSequenceNode.analyse_typesq   s    	** 	7 	7FAs  -'',,11#66DIaLL 	A*88==K#* B)<<SAA*;;C@@D 	3#7 	&	+.?+J	 DIrT   c                 t   t          j        |d          }| j        |k    r| S | j        rJ t	          | j                  |j        k    r1t          | j        d|j        t	          | j                  fz             fdt          | j        |j
                  D             }t          | j        ||d          S )NTr#  zHtrying to coerce sequence to ctuple of wrong length, expected %d, got %dc                 B    g | ]\  }}|                     |          S rV   )r  )rb   rh  r   rr   s      rS   r   z1SequenceNode.coerce_to_ctuple.<locals>.<listcomp>   s+    fffYS$dC00fffrT   )r   r   r   )r   r&  r   r   r   r   ri  r   r   r  r2  r  rX   r  rr   coerced_argss     ` rS   coerce_to_ctuplezSequenceNode.coerce_to_ctuple   s    +HTJJJ9  K####ty>>X]**$(fs49~~j/ / 0 0 0ffff#diQYQdBeBefff8TRRRRrT   c           	         |                                   t          d | j        D                       s| S g }g }| j        D ]}|j        rc|rF|                    t          |d         j        |                              |d                     g }|                    |j                   l|                    |           |rD|                    t          |d         j        |                              |d                     t          | j        || j
                  }| j        r8t          | j        d|| j                            |          d| j
        d          }|S )Nc              3   $   K   | ]}|j         V  d S rM   )r   r  s     rS   re   z?SequenceNode._create_merge_node_if_necessary.<locals>.<genexpr>   s$      77c3>777777rT   r   r}  TrL	  r   )inplacer   r   )_flatten_starred_argsrk   r   r   r   r  r   r<  r  MergedSequenceNoder   r   
binop_noder   )rX   rr   r   ru  rh  r   s         rS   _create_merge_node_if_necessaryz,SequenceNode._create_merge_node_if_necessary   st   ""$$$77TY77777 	K9 	# 	#C~ #  KK	&)-f E E E S STWgk S l lmmmFCJ''''c"""" 	fKK	&)-f===KKC_cKddeee!$(D$)<< 	<#tT%5%H%H%M%M49d< < <D rT   c                     g }| j         D ]V}|j        r8|j        j        r,|j        j        s |                    |j        j                    A|                    |           W|| j         d d <   d S rM   )r   r   r  r   r   r   r   rE	  s      rS   rV	  z"SequenceNode._flatten_starred_args   s{    9 	! 	!C~ !#*"D !SZMc !CJO,,,,C    	!!!rT   c                     dS rw  rV   rW   s    rS   rA  zSequenceNode.may_be_none   r  rT   c                 z   | j         rt          | j        d           g | _        g | _        d| _        t          | j                  D ]\  }}|                    |          x}| j        |<   |j	        rN|j
                            t                    st          |j        d           |j
        t          u rt          |_
        t          | j        |          }|                    |j
        |          }||urd| _        | j                            |           | j                            |           t          | _
        | S )Nz#can't assign to multiplied sequenceFz2starred target must have Python object (list) typeT)r   r   r   unpacked_itemscoerced_unpacked_itemsany_coerced_itemsr  r   rD  r   r   r  r   r   rg  r  r   )rX   rr   r  rh  unpacked_itemcoerced_unpacked_items         rS   rD  z!SequenceNode.analyse_target_types   sD    	C$(ABBB &(#!&	** 	F 	FFAs!$!9!9#!>!>>C$)A,~ )x//	:: P#'NP P P8~--(CH&tx55M$1$;$;CHc$J$J!$999)-&&&}555'../DEEEE"	rT   c                 0    |                      |           d S rM   generate_operation_coder  s     rS   r  z!SequenceNode.generate_result_code       $$T*****rT   c                 
   ||                                  }dx}}d }| j        ru|ss| j        }|j        j        r`|                                 }t	          |j        t                    r|j        dk    rd|j        z  }n|j        j        r
d|d|d}nd|d}| j        t          u s| j        t          u r| j
        s| j        r|st          | j                  dk    r| j        t          u r0d}|j                            t!          j        d	d
                     nd}|                    d||t          | j                  d                    d | j        D                       |                    || j                  fz             |                    |t.                     d| _        no| j        j        rLt5          | j                  D ]5\  }}	|                    |d|d|	                                 d           6n| j        t          u rd\  }
}n+| j        t          u rd\  }
}nt7          d| j        z            t          | j                  }|                    |d|
d||d|                    || j                             |                    |t.                     |r^t8          j        }|                    d|z             |dk    r|}n|d|}|                    d|d|d|d|d	           d| _        nd}t=          |          D ]}| j        |         }	|s|	                                s:|                     |	                                 |	!                                           |	"                    |           |                    d |d|d|r	|r|d!|p|p|d|	#                                d"|$                    | j                  d           |r*|                    d#           |                    d#           ||j        j%        r|                    d$t8          j        d%|d|#                                d|                    t8          j        | j                             |                    t8          j        t.                     |&                    |t.                     |                    |dt8          j        d           |                    d#           d S d S d S )&Nr  r   z * %sz * ((z<0) ? 0:r  z * (__Pyx_PyList_PackListPackr  PyTuple_Packz%s = %s(%d, %s); %sr  c              3   >   K   | ]}|                                 V  d S rM   rO  r  s     rS   re   z>SequenceNode.generate_sequence_packing_code.<locals>.<genexpr>   s*      ??c#--//??????rT   TrP  r<  r=  )
PyList_New__Pyx_PyList_SET_ITEM)PyTuple_New__Pyx_PyTuple_SET_ITEMz'sequence packing for unexpected type %sr;  r  z{ Py_ssize_t %s;r+   r~  zfor (z=0; z < r  z++) {r  r  z
) != (0)) r   z{ PyObject* z = PyNumber_InPlaceMultiply()'r  r   r   r  r~   r   r   r  r   r   r   rK	  r   r   r   r   r   r   r   r  r   r   r  r   needs_subexpr_disposalr1  r  r   r   r  r  r  r  r  r  r   r   ro   r(	  )rX   r   r  plainsize_factorc_multr   	pack_namer  rh  create_funcset_item_func	arg_countcounteroffsets                  rS   generate_sequence_packing_codez+SequenceNode.generate_sequence_packing_code   s   >[[]]F!!f 
	8E 
	8*K& 8$++--{:C@@ 8#3a77")K,G"GKK %, 8 8:@&&&&&"IKK8 06vv"7KY*$$	Y(>(> )?$(I )? )? DI""yI%%/	 11+J8JKK    +	JJ,DI		??TY?????''990; ; < < < OOFN333*.D''Y  4	 #DI.. . .3

FFAAAszz||||- . . . ..
 yI%%-R*]]j((-T*]]#$MPTPY$YZZZDIIJJYY''999; < < < OOFN333  !1

-7888>>$FF*1''99=F


GGWWWfffggg    /3++9%% 
0 
0il ?!3!3!5!5 ?OOCJJLL#))++>>>$$T***


!MMFF\@VVVQQ(?QV[qQQMMOOOOOODH----/ 0 0 0 0   

3

3"{'7'C"JJJ'''1F1F1H1H1H1H''(?JJJ    OOF3^DDDOOFN333JJVVVV-D-D-DEFFFJJsOOOOO #"""rT   c                     | j         r#t                                          |           d S | j        D ]}|                    |           | j        r| j                            |           d S d S rM   )ro	  rO   r  r   r  r   r  )rX   r   rh  rR   s      rS   r  z+SequenceNode.generate_subexpr_disposal_code4!  s    & 	>GG22488888
 y 8 811$7777  > 77=====> >rT   c                     | j         r|                     ||           n|                     ||           | j        D ]}|                    |           |                    |           d S rM   )rD	   generate_starred_assignment_code!generate_parallel_assignment_coder]	  rb  r  )rX   r   r   r  r   r   r   s          rS   r  z%SequenceNode.generate_assignment_codeB!  s{    " 	>11#t<<<<223===' 	 	DLLtrT   r  c                 x   | j         D ]}|                    |           |j        t          u p!|j        t          t
          fv p|j        j         }t          | j                   dk    }|r|                     |||           nH|	                    d           | 
                    ||| j         |           |	                    d           | j        D ]}|                    |           t          t          | j                            D ].}| j        |                             | j        |         |           /d S )N   use_loopr  r   )r]	  r`  r   r   r   r   r  r   (generate_special_parallel_unpacking_coder   (generate_generic_parallel_unpacking_coder^	  r  r  r   r  )rX   r   r   r   special_unpacklong_enough_for_a_loop
value_noder  s           rS   r}	  z.SequenceNode.generate_parallel_assignment_codeR!  sw    ' 	  	 DMM$(n4 : X*i)@@:!$!99 	 "%T%8!9!9A!= 	99c$: : < < < < JJsOOO99c4.9O : Q Q QJJsOOO5 	6 	6J//5555s49~~&& 	6 	6AIaL11+A.6 6 6 6	6 	6rT   c           
      .   d}d|                                 z  }|j        t          u rdg}d}|                                r|}ng|j        t          u rdg}d}|                                r|}n=ddg}d}d|                                 z  }d	|                                 z  }	d
|d|	d}|                    d|z             |                    d|                                 z             |                    d|z             |                    dt          | j                  z             |j        	                    t          j        dd                     |                    dt          | j                  t          | j                  fz             |j        	                    t          j        dd                     |                    d           |                    |                    | j                             |                    d           |                    d           t          |          dk    r|                    d|d         z             t          | j                  D ]!\  }
}|d         dk    r|                    |                                 d|
 d           |                    |                    |                                | j                             |                    |                                |                                           |                    |                                 d|
 d           |                    |                                |                                           #t          |          dk    ra|                    d           t          | j                  D ]!\  }
}|d         dk    r|                    |                                 d|
 d           |                    |                    |                                | j                             |                    |                                |                                           |                    |                                 d|
 d           |                    |                                |                                           #|                    d           |                    d            |st          | j                  D ]\  }
}|                    d!|                                |
|                    |                                | j                  fz             |                    |                                |j                   n/|                    d"           |                    d#           |                    d$t          | j                  d%d&                    d' | j        D                       d(           |                    d)t          | j                  z             |                    d*|                    d+| j                  z             |                    d+t.                     |                    d,           |                    d           |                    d           |                    d-           |                    |           |dk    r|                    d           d S ||k    r|                    d           |j        	                    t          j        d.d                     |                    d/|                    | j                  z             |                    d           d S |                    d           |                     ||| j        |0           |                    d           d S )1NrM  zlikely(%s != Py_None)r  r  r  r  __Pyx_PySequence_SIZEzlikely(PyTuple_CheckExact(%s))zPyList_CheckExact(%s)r;  z) || (r  rB  zPyObject* sequence = %s;zPy_ssize_t size = %s(sequence);zif (unlikely(size != %d)) {RaiseTooManyValuesToUnpackr  z1if (size > %d) __Pyx_RaiseTooManyValuesError(%d);RaiseNeedMoreValuesToUnpackz9else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);r   r  r6   z(if (likely(Py%s_CheckExact(sequence))) {r   z% = __Pyx_PyList_GetItemRef(sequence, r  z = PyTuple_GET_ITEM(sequence, r  r+   r  z,%s = __Pyx_PySequence_ITEM(sequence, %d); %sr  zPy_ssize_t i;PyObject** temps[rQ  rL  c                 <    g | ]}d |                                 z  S rJ  r  r  s     rS   r   zISequenceNode.generate_special_parallel_unpacking_code.<locals>.<listcomp>!  s%    PPPD%$++--/PPPrT   rA  zfor (i=0; i < %s; i++) {z7PyObject* item = __Pyx_PySequence_ITEM(sequence, i); %sr   z*(temps[i]) = item;r  RaiseNoneIterErrorz%__Pyx_RaiseNoneNotIterableError(); %sr	  )r   r   r   rA  r   r   r   r   r   r   r   r   r   r   r  r]	  r  r   r  r  r  r  r  r   r  r	  )rX   r   r   r	  sequence_type_test
none_checkr5   get_size_functuple_check
list_checkr  r   s               rS   r	  z5SequenceNode.generate_special_parallel_unpacking_codel!  s{    ,s}}>
8y  $XN3M   0%/"X##%YN4M   0%/"%v.N3M:S]]__LK1CMMOOCJJ3>;;


!K

;!33444

-?@@@ 	

4}DEEE

03ty>>ABBB))#$@BTUU	W 	W 	W

F	NNC	NNJ, , 	- 	- 	-))#$ACUVV	X 	X 	X

NOOO

4??48,,---

3

QRRR~!##JJANSTDUUVVV !455 	= 	=GAta F**

dkkmmWWRSWWWXXX

4224;;==$(KKLLL  

====

dkkmmPP1PPPQQQtzz||<<<<~!##JJz"""$T%899 A A4!!$..JJ$++--[[VW[[[\\\JJt66t{{}}dhOOPPP$$T[[]]DJJLLAAAAJJ$++--TTqTTTUUUOODKKMM4::<<@@@@JJsOOO

7 	$T%899 : :4

IKKMM1++DKKMM48DDMF F G G G ty9999	: JJsOOOJJ'''JJJD'((((PPD<OPPPQQQQS T T T JJ1C8K4L4LLMMMJJP''99; < < <OOFN333JJ,---JJsOOOJJsOOO

8""4((($$JJsOOOOO:--JJz"""--'(<>PQQS S SJJ>QUQYAZAZZ[[[JJsOOOOOJJz"""99c4. : C C CJJsOOOOOrT   Tc           
         |j                             t          j        dd                     |j                             t          j        dd                     |                    d           |rK|                    dt          | j                  dd                    d |D                       d	           |j        	                    t          d
          }|                    |d|                                d|                    || j                             |                    |t                     |                    |           |j        	                    | j        d          }|                    | d| d           |                    d          }|d|d}	|r|                    dt          |          z             |                    d|	z             |                    |           |                    dt                     |                    d           |                    d           nt)          |          D ]o\  }
}|                    d|
|                                |	|                                fz             |                    |           |                    |           p|r|j                             t          j        dd                     |                    | j        d|	t          |          fz             |                    d|z             |                    |t                     |                    d          }|                    |           |                    |           |                    |t                     |                    d|z             |                    d           |                    |                    | j                             |                    |           |j                            |           |r|j                            |           d }|S )Nr	  r  
IterFinishzPy_ssize_t index = -1;r	  rQ  rL  c                 <    g | ]}d |                                 z  S r	  r	  r  s     rS   r   zISequenceNode.generate_generic_parallel_unpacking_code.<locals>.<listcomp>!  s%    KKKD%$++--/KKKrT   rA  Tr  r  r  Fr  r  unpacking_failedr;  r  z$for (index=0; index < %s; index++) {z*PyObject* item = %s; if (unlikely(!item)) r   z*(temps[index]) = item;r   z(index = %d; %s = %s; if (unlikely(!%s)) UnpackItemEndCheckz$__Pyx_IternextUnpackEndCheck(%s, %d)r  unpacking_donezCif (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);)r   r   r   r   r   r   r]	  r  r  r  r   r   r   r   r  r  r  r  r  r  r  r  r  rr  r  r  r   r  )rX   r   r   r]	  r	  	terminateiterator_tempiternext_funcunpacking_error_labelunpack_coder  r   unpacking_done_labels                rS   r	  z5SequenceNode.generate_generic_parallel_unpacking_code!  s   ))#$ACUVV	X 	X 	X))#L2DEE	G 	G 	G

+,,, 	OJJJD'((((KKNKKKLLLLN O O O 44^PT4UU

''tx@@@B	C 	C 	C
 	~666""4(((44T5MZ_4``

 N N<IN N N	
 	
 	

 !%/A B B"/--? 	+JJ=N@S@SSTTTHHAKOPPPMM/000OOFN333JJ0111JJsOOOO$^44 + +4>#	B' '( ( ( 3444$$T**** 	A--'(<>PQQS S S!!$(,RN##V% -% & & & JJ|m3444!!-@@@#~~.>??*+++,---m^<<<

<-/000

XYYY

4??48,,---+,,,##M222 	!N''666 MrT   c                 D   t          | j                  D ]<\  }}|j        r0| j        |         }| j        d |         }| j        |dz   d          } n=J d }|r|D ]}	|	                    |           |                    d           |                     |||dd          }t          |          D ]'\  }}	| j        |         }
|
                    |           (|                    d           |                    |           |	                                }|                    |d|s+|
                                r|j        t          t          fv rdnd	d
|p|                                d|                    || j                             |                    |           |r6|                    |t                     |j                            |           n|                    |           |rp|j                            t1          j        dd                     |j                            t6          j        d          }|                    |d|d           |                    d|t;          |          fz             |                    dt;          |          ||                    | j                  fz             |                    d           |d d d         D ]}	|	                    |           t          t?          |d d d         | j        d d d                             D ]\  }\  }	}|                    d           |                    d|	                                |||dz   fz             |                    d|z             |                    d           |                    d|	                                |||dz   fz             |                    d           |	                    |           |                    |           |                    d           |j                            t          d          }|                    d|||t;          |          |                    || j                  fz             |                     |t                     |j                            |           |!                    |t                     |                    |d|d|d           |                    d           |                    d|z             |j                            |           |                    d           t          | j                  D ]&\  }}|"                    | j        |         |           'd S )Nr+   Fr  T)r	  r	  r   r<  __Pyx_PySequence_ListKeepNewPySequence_Listr;  r  r	  r  r  z = __Pyx_PyList_GET_SIZE(r  zif (unlikely(%s < %d)) {z)__Pyx_RaiseNeedMoreValuesError(%d+%s); %sry  z#if CYTHON_COMPILING_IN_CPYTHONz!%s = PyList_GET_ITEM(%s, %s-%d); z((PyVarObject*)%s)->ob_size--;r  z'%s = __Pyx_PySequence_ITEM(%s, %s-%d); r  z #if !CYTHON_COMPILING_IN_CPYTHONz*%s = PySequence_GetSlice(%s, 0, %s-%d); %sr  r*  zCYTHON_UNUSED_VAR(%s);)#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  )rX   r   r   r  rh  starred_targetunpacked_fixed_items_leftunpacked_fixed_items_rightr	  r   r	  target_listlength_tempcoerced_argsublist_temps                  rS   r|	  z-SequenceNode.generate_starred_assignment_code"  s:   	** 	 	FAs~ !%!4Q!7-1-@!-D)-1-@1-F*	 L$ 
	1 $ $d####JJsOOO IIc4 J 0 0M %%>?? : :4!8;
33D9999JJsOOO%%%$++--

KK%'*-*<*<*>*>'CF8P^`iOjCjCj +*&' ' ,S]]__,,##K:::< 	= 	= 	= 	&&t,,, 	-!!-@@@N''6666&&t,,,% '	!--'(EGYZZ\ \ \.66z7S`e6ffKJJKKKUVVVJJ1[#F`BaBa4bbcccJJB.//**F, , - - - JJsOOO244R48 $ $d####*3C8RSWSWUWSW8X8<8STXTXVXTX8Y5[ 5[ +\ +\ ; ;&&D+

<===

>NN$$k;!BE E F F F 

;kIJJJ

7###

DNN$$k;!HE E F F F

8$$$$$T***44T::::JJ9:::>77SW7XXLJJCk;<V8W8W''dh??GA A B B B OOL.999N''444OOK888JJ\\\<<<XYYYJJwJJ/,>???N''555JJx   	** 	O 	OFAs(()DQ)GNNNN	O 	OrT   c                     | j         D ]}|                    |           | j        r>| j        D ]}|                    |           | j        D ]}|                    |           d S d S rM   )r   r  r]	  r^	  rX   r   rh  s      rS   r  zSequenceNode.annotaten"  s    9 	 	CLL 	#* # #T""""2 # #T""""		# 	## #rT   rR  rw  rT  r~  )"rZ   r[   r\   r   r   r]	  r   rK	  ro	  rB	  rF	  r8  r<  rQ	  rY	  rV	  rA  rD  r  ry	  r  r  r   r  r  r   r  r  r}	  r	  r	  r|	  r  r]   r^   s   @rS   r?	  r?	  G   s        &HNKD"
C C C  0 0 0
   $S S S  0      .+ + +d d d dL> > > > > INGK	 	 	 	 .*-.Bj.B!#J#D**CTJJ$/ /  
6 6 64c c cJG G G GRRO RO ROh# # # # # # #rT   r?	  c                   ^    e Zd Ze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S )r  Fr  c                     | j         s| j        st          S fd| j        D             }t          d |D                       rt          S                     | j        |          j        S )Nc                 :    g | ]}|                               S rV   rr  rs  s     rS   r   z(TupleNode.infer_type.<locals>.<listcomp>"  s%    >>>SS^^C((>>>rT   c              3   N   K   | ] }|j         p|j        p|j        p|j        V  !d S rM   )ro   r   r  rg  )rb   r   s     rS   re   z'TupleNode.infer_type.<locals>.<genexpr>"  sR       & & b4#:bd>QbUYUb & & & & & &rT   )r   r   r   rk   r  r   r   )rX   rr   rz  s    ` rS   r   zTupleNode.infer_type"  s     	49 	>>>>DI>>>	 & &$& & & & & 	%%dh	::??rT   c                    | j         rd| _         | j        rd| _        t          | j                  dk    rd| _        d| _         | S |sEt          | j                  D ]0\  }}|j        rd|_        |                    |          | j        |<   1| j	        s[t          d | j        D                       s=|                    | j        d | j        D                       j        | _        d| _        | S t                              | |d          }|                    |          }|j        s|S t#          d |j        D                       s|S |j	        r+|j	        j         r.t%          |j	        j        t(                    rd|_        d|_         nO|j	        j        j        s0|j	        j        j        s|j	                            |          |_	        d|_        d|_        |S )	NFr   Tc              3   l   K   | ]/}|j         p#|j        j        p|j        j        p|j        j        V  0d S rM   )r   r   ro   r   rg  r  s     rS   re   z*TupleNode.analyse_types.<locals>.<genexpr>"  sX       . . s38+?s38C^sbebjbs . . . . . .rT   c              3   $   K   | ]}|j         V  d S rM   r  r  s     rS   re   z*TupleNode.analyse_types.<locals>.<genexpr>"  s$      9X9Xs#(9X9X9X9X9X9XrT   r+   rT	  c              3   $   K   | ]}|j         V  d S rM   )r   )rb   childs     rS   re   z*TupleNode.analyse_types.<locals>.<genexpr>"  s%      ;;5#;;;;;;rT   )r   is_partly_literalr   r   r   r  r   r7	  r<  r   rk   r  r   r   r?	  rY	  r   r4  r~   r   r   ro   r  r   )rX   rr   rL	  r  rh  r   s         rS   r<  zTupleNode.analyse_types"  s
   ? 	$#DO! 	+%*D"ty>>Q DL"DOK 	6#DI.. 6 63> 948C1"0055	!  	 . .#'9. . . . .	 ..tx9X9Xdi9X9X9XYY^DIDLK))$4)HH33C88+ 	K;;;;;;; 	K 		* +		*4+;SAA		* !DL"DOO#(4 LT=M=R=Y L#'#3#F#Fs#K#K DL%)D"rT   c                     | j         sd S fd| j         D             }t          d |D                       rd S                     | j        |          }|j        S )Nc                 :    g | ]}|                               S rV   )re  rs  s     rS   r   z-TupleNode.analyse_as_type.<locals>.<listcomp>"  s'    DDD3c))#..DDDrT   c              3      K   | ]}|d u V  	d S rM   rV   )rb   rc   s     rS   re   z,TupleNode.analyse_as_type.<locals>.<genexpr>"  s&      --QqDy------rT   )r   rk   r  r   r   )rX   rr   r   r   s    `  rS   re  zTupleNode.analyse_as_type"  sp    y 	4DDDD$)DDD
--*----- 	4&&tx<<zrT   c                    | j         j        r|j        r+| j         j        |j        k    r|                     |          S |t          u s	|t
          u rKfd| j        D             }t          | j        |t          | j	        d          
                    d          S |                                                   |          S |j        r| j	        s|                     |          S t                              | |          S )Nc                 :    g | ]}|                               S rV   )r   rs  s     rS   r   z'TupleNode.coerce_to.<locals>.<listcomp>"  s'    QQQ 6 6s ; ;QQQrT   r+   )r   r   r   r   TrT	  )r   r1  ri  rQ	  r   r   r   r  r   r   r<  r   r  r?	  rO	  s     ` rS   r  zTupleNode.coerce_to"  s   9 	?! Mdin&E&E,,Xs;;;Z''8~+E+EQQQQtyQQQ H%# $ 0    -4-889 ..s33==hLLL 	?(8 	?((3777))$#>>>rT   c                     t          | j        | j        | j                  }t	          | j        t                    rt          | j                  |_        |S N)r   r   )rB  r   r   r   r~   r   r   r   rX   rc   s     rS   as_listzTupleNode.as_list"  sJ    TXDI4;KLLLd*E22 	; $T%9 : :ArT   c                     dS r  rV   rW   s    rS   r:  zTupleNode.is_simple"      trT   c                     dS r  rV   rW   s    rS   rV  zTupleNode.nonlocally_immutable"  r	  rT   c                     | j         S rM   r  rW   s    rS   r  zTupleNode.calculate_result_code"  r  rT   c                 L    t          d | j        D                       | _        d S )Nc                     g | ]	}|j         
S rV   r  r  s     rS   r   z7TupleNode.calculate_constant_result.<locals>.<listcomp>"  s(     &: &: &:(+#&: &: &:rT   )r   r   r   rW   s    rS   r%  z#TupleNode.calculate_constant_result"  s8    $ &: &:/3y&: &: &:  ;  ;rT   c                     |                      |          }	 t          |          S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )rB	  r   r=  r3  rX   r.  ru  r2  s       rS   r/  zTupleNode.compile_time_value"  sk    --d33	-==  	- 	- 	-))!,,,,,,,,,	-s   & 
AAAc                    t          | j                  dk    r&|                    t          j                  | _        d S | j        s| j        rt          | j	        | j        r| j
        nd g| j        z             }|                    d|          }|                    |          }|S|                    | j                   |                     ||| j                    |                    |t"                     | j        r	|| _        d S | j
        j	        j        r|j                            t+          j        dd                     |                    |                                 d|d| j
                                        d	|                    |                                 | j                             |                     |           d S |                    |                                 d
|d| j
                                        d	|                    |                                 | j                             |                     |           d S d| j	        j        _        |                     |           d S )Nr   r   re  )rp	  PySequenceMultiplyr  z = __Pyx_PySequence_Multiply(r  r  z = PyNumber_Multiply(T)r   r   r  r   empty_tupler  r   r	  r   r   r   rp  rq  r  r   ry	  r  r   r  r   r   r   r   r   r  r   r  r   r   r  )rX   r   rf  tuple_targetrw  s        rS   rd	  z!TupleNode.generate_operation_code"  sz   ty>>Q#889KLLDF? 	6d4 	6 'tyt3`43C3C\`2adhdm2mnnI,,W	,JJL99,GGJ%##DH---33JX\XgTg3hhh&&|^DDD +#/   !&- + 11+,@BTUUW W W

KKMMMM<<<1A1H1H1J1J1J1J++DKKMM48DDD    $$T*****

KKMMMM<<<1A1K1K1M1M1M1M++DKKMM48DDD    $$T*****#'DIO //55555rT   NrR  )rZ   r[   r\   r   r   r	  r  r   r<  re  r  r	  r:  rV  r  r%  r/  rd	  rV   rT   rS   r  r  x"  s         D-K@ @ @) ) ) )V  ? ? ?(           ; ; ;- - -"6 "6 "6 "6 "6rT   r  c                   `    e Zd Zg Z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S )rB  FzConstructing Python listc                     dS r  rV   r   s     rS   rO  zListNode.type_dependencies#  r  rT   c                     t           S rM   )r   r   s     rS   r   zListNode.infer_type"#      rT   c                     | j         D ]}|j        rd|_        t                              | |          }|                    |          S r  )r   r   r7	  r?	  rB  r   )rX   rr   rh  r   s       rS   rB  zListNode.analyse_expressions&#  sO    9 	5 	5C~ 504-//c::&&s+++rT   c                    t          d          5 }t          | j                  | _        t                              | |          }d d d            n# 1 swxY w Y   ||_        |j        rd| _        |	                    |          }|S )NTr  )
r   r   r   original_argsr?	  r<  obj_conversion_errorsr  rD  rY	  )rX   rr   errorsr   s       rS   r<  zListNode.analyse_types-#  s    &&& 	9&!%diD--dC88D	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 &," 	(#'D 33C88s   5AAAc                    |j         rT| j        D ]}t          |           g | _        | j                            |          st          | j        d|z             n|j        s|j        r-|j	        t          j        urt          | j                  }| j        rpt          | j        j        t"                    r9| j        j        dk    rt          | j        d|z             n(|| j        j        z  }nt          | j        d|z             |j	        }t          j        ||          | _        t'          t          | j                            D ]I}| j        |         }t          |t*                    r|j        }|                    ||          | j        |<   Jn|j        r5t3          | j        | t          j                                      ||          S | j        rt          | j        d|z             nU|j        rt          | j                  t          |j        j                  k    rt          | j        d|z             nt          | j                  t          |j        j                  k     rt=          | j        d|z  d	           t?          tA          | j        |j        j                            D ]G\  }\  }}t          |t*                    r|j        }|                    |j        |          | j        |<   H|| _        nA|j!        r| "                    ||          S tF          | _        t          | j        d|z             | S )
NzCannot coerce list to type '%s'r   z4Cannot coerce non-positively multiplied list to '%s'z1Cannot coerce dynamically multiplied list to '%s')r  r   z%Cannot coerce multiplied list to '%s'zToo many members for '%s'zToo few members for '%s'r+   )$ro   r	  r   r   r  r   r   rT  r  r  r   c_void_typer   r   r   r~   r   r   r  r  r	  r  rh  r  r  TypecastNoder   r	  r,  r  r   r  r  r1  rQ	  r2   )	rX   r  rr   rs   rG  r  r  rh  r  s	            rS   r  zListNode.coerce_to7#  s;    +	J1 " "S!!!!)+D&9''11 Ndh AH LMMM %	J8? %	J8JR\Rh8h8hty>>L dd.>DD d'71<<dh(^ai(ijjjj$(8(HH$($WZb$bccc *I"-iFFDI3t12233 = =ilc#566 "'C"}}Y<<	!	=
 " 	J$Z=VWWWaabjloppp 	J$(ChNOOOO 	J49~~HN$> ? ???dh ;h FGGGGty>>C(B$C$CCCDH&@8&KQOOO(1#d6H(.Jd2e2e(f(f C C$A}V!#'9:: &!g#&==c#B#BDIaLL DII 	J((3777"DI$(=HIIIrT   c                     | S rM   rV   rW   s    rS   r	  zListNode.as_listf#  r  rT   c                     t          | j        | j        | j                  }t	          | j        t                    rt          | j                  |_        |S r	  )r  r   r   r   r~   r   r   r   r	  s     rS   as_tuplezListNode.as_tuplei#  sJ    dhTYD<LMMMd*D11 	< %d&: ; ;ArT   c                    | j         j        rZ| j        r*|j                            | j         ddd          | _        d S |j                            | j         dd          | _        d S t                              | |           d S )NFT)r  staticreusable)r  r	  )r   rT  rD  r  r  r  r?	  r  r  s     rS   r  zListNode.allocate_temp_resulto#  s    9 	:# A!%!=!=I%u "> "N "N "&!=!=I%% "> "A "A --dD99999rT   c                 \    | j         rt                      d | j        D             | _        d S )Nc                     g | ]	}|j         
S rV   r  r  s     rS   r   z6ListNode.calculate_constant_result.<locals>.<listcomp>#  s(      6  6  6$'C 6  6  6rT   )r   r   r   r   rW   s    rS   r%  z"ListNode.calculate_constant_result}#  s@     	,, 6  6+/9 6  6  6rT   c                 x    |                      |          }| j        r|| j                            |          z  }|S rM   )rB	  r   r/  )rX   r.  ls      rS   r/  zListNode.compile_time_value#  s@    ((.. 	;!44T:::ArT   c                 \   | j         j        r0| j        D ]}t          |           |                     |           d S | j         j        r| j        r|                    d           |                    dt          j	        z             |                    d
                    t          j	        | j                                                             dt          | j                  t          j	        fz  }nd}t          | j                  D ]\  }}|j         j        r|j                            t#          j        dd                     |                    d	|                                 d
||d|                                d|                                 d
           |                    |                                 d
||d|                                d           | j        r,|                    d           |                    d           d S d S | j         j        rst)          | j        | j         j        j                  D ]L\  }}|                    |                                 d|j        d|                                d           Md S t1          d          )Nr  zPy_ssize_t %s;z&for ({i} = 0; {i} < {count}; {i}++) {{)r  countz+ (%d * %s)r  rA  r  rB  re  rC  rn  z[0]));z] = r=  r   r   r<  zList type never specified)r   ro   r	  r   ry	  rT  r   r   r   r  r  r  r   r   r  r   r   r   r   r	  r  r,  r  r   r   )rX   r   rs   rx	  r  rh  r  s          rS   rd	  z ListNode.generate_operation_code#  s   9  $	=1 " "S!!!!//55555Y  	= 

3

+f.EEFFF

CJJ-T5E5L5L5N5N K P P Q Q Q&#di..&:Q)RR#DI.. ' '38$ '$55k6MN^`o6p6pqqqJJJqq&&&

dkkmmmm     
 JJ

	 & ' ' ' '
   

3

3    Y  	="49dio.IJJ # #V

KKMMMMLLLJJLLLL" # # # ## #   ;<<<rT   N)rZ   r[   r\   r	  r   r   rD  r  rO  r   rB  r<  r  r	  r	  r  r%  r/  rd	  rV   rT   rS   rB  rB  #  s         DO,K    , , ,  - - -^    : : :6 6 6  %= %= %= %= %=rT   rB  c                   R    e Zd ZdgZdZeZd Zd Zd Z	d Z
d Zd Zd	 Zd
 Zd ZdS )ComprehensionNodeloopTc                     | j         S rM   r  r   s     rS   r   zComprehensionNode.infer_type#  
    yrT   c                    | | j         _        |                     |           t          | j        t
          j                  rUt          | j        j        t                    sJ | j        j                    | j        j                            d |           d S t          | j        t
          j	                  sJ | j                    d S rM   )
r   r  r  r~   r	  r   _ForInStatNoder  r  ForFromStatNoder   s     rS   r  z&ComprehensionNode.analyse_declarations#  s    !di!566 	Kdi0.AAUU49CUUUUI))$44444di)>??JJJJJJJrT   c                 :    | j                             |           d S rM   )r	  r  r   s     rS   r  z-ComprehensionNode.analyse_scoped_declarations#  s    	&&s+++++rT   c                 R    | j         s| j                            |          | _        | S rM   r  r	  rB  r   s     rS   r<  zComprehensionNode.analyse_types#  s)    # 	;	55c::DIrT   c                 R    | j         r| j                            |          | _        | S rM   r	  r   s     rS   r  z,ComprehensionNode.analyse_scoped_expressions#  s)     	;	55c::DIrT   c                     dS rw  rV   rW   s    rS   rA  zComprehensionNode.may_be_none#  r  rT   c                 0    |                      |           d S rM   rc	  r  s     rS   r  z&ComprehensionNode.generate_result_code#  re	  rT   c           
         | j         t          j        u rd}nC| j         t          j        u rd}n-| j         t          j        u rd}nt          d| j         z            |                    |                                 d|d|                    |                                 | j	                             | 
                    |           | j                            |           d S )NzPyList_New(0)zPySet_New(NULL)zPyDict_New()z"illegal type for comprehension: %sr<  r  )r   r   r   r   r   r   r   r  r   r   r  r	  generate_execution_code)rX   r   create_codes      rS   rd	  z)ComprehensionNode.generate_operation_code#  s    9))))KKY'***+KKY'+++(KK Dty PQQQ

KKMMMM;;;##DKKMM48<<<> 	? 	? 	? 	T"""	))$/////rT   c                 :    | j                             |           d S rM   )r	  r  r  s     rS   r  zComprehensionNode.annotate#      	4     rT   N)rZ   r[   r\   r   r   r)  r   r   r  r  r<  r  rA  r  rd	  r  rV   rT   rS   r	  r	  #  s         (KG$O  K K K, , ,  
  
  + + +0 0 0 ! ! ! ! !rT   r	  c                   >    e Zd ZdgZdZej        Zd Zd Z	d Z
d ZdS )ComprehensionAppendNoder)  Nc                     | j                             |          | _         | j         j        j        s| j                             |          | _         | S rM   )r)  rB  r   ro   r   r   s     rS   rB  z+ComprehensionAppendNode.analyse_expressions#  sD    I11#66	y~) 	:	44S99DIrT   c           
      V   | j         j        t          u r0|j                            t          j        dd                     d}n2| j         j        t          u rd}nt          d| j         j        z            | j	        
                    |           |                    |                    |d| j                                         d| j	                                        d| j                             | j	                            |           | j	                            |           d S )	NListCompAppend
Optimize.c__Pyx_ListComp_Append	PySet_Addz'Invalid type for comprehension node: %sr;  , (PyObject*)r  )r  r   r   r   r   r   r   r   r   r)  r  r   r   r  r   r  r  r.  s      rS   r	  z/ComprehensionAppendNode.generate_execution_code#  s6   ;y((--'(8,GGI I I.HH[))"HH9DK<LLN N N 		**4000

4%%HHK    I' x	  	 	 	
 		((...	T"""""rT   c                 <    | j                             ||           d S rM   )r)  r  r  s      rS   r  z5ComprehensionAppendNode.generate_function_definitions$  s     	//T:::::rT   c                 :    | j                             |           d S rM   )r)  r  r  s     rS   r  z ComprehensionAppendNode.annotate$  r	  rT   )rZ   r[   r\   r   r  r   r  r   rB  r	  r  r  rV   rT   rS   r	  r	  #  sf         (KF D  # # #(; ; ;! ! ! ! !rT   r	  c                   .    e Zd ZddgZd Zd Zd Zd ZdS )DictComprehensionAppendNodekey_expr
value_exprc                 B   | j                             |          | _         | j         j        j        s| j                             |          | _         | j                            |          | _        | j        j        j        s| j                            |          | _        | S rM   )r
  rB  r   ro   r   r
  r   s     rS   rB  z/DictComprehensionAppendNode.analyse_expressions$  s    99#>>}!- 	B M<<SAADM/==cBB#/ 	F"o@@EEDOrT   c                 8   | j                             |           | j                            |           |                    |                    d| j                                        d| j                                         d| j                                        d| j                             | j                             |           | j         	                    |           | j                            |           | j        	                    |           d S )Nr  r	  r  )
r
  r  r
  r   r   r  r  r   r  r  r  s     rS   r	  z3DictComprehensionAppendNode.generate_execution_code"$  s
   ..t44400666

4%%%K    M  """"O""$$$$' x	  	 	 	
 	,,T222  &&&..t444""4(((((rT   c                 r    | j                             ||           | j                            ||           d S rM   )r
  r  r
  r  s      rS   r  z9DictComprehensionAppendNode.generate_function_definitions/$  s8    33C>>>55c4@@@@@rT   c                 n    | j                             |           | j                            |           d S rM   )r
  r  r
  r  s     rS   r  z$DictComprehensionAppendNode.annotate3$  s4    t$$$  &&&&&rT   N)rZ   r[   r\   r   rB  r	  r  r  rV   rT   rS   r
  r
  $  s]        |,K  ) ) )A A A' ' ' ' 'rT   r
  c                   N     e Zd ZdgZdZdZdZeZd	 fd	Z	d Z
d Zd Zd Z xZS )
InlinedGeneratorExpressionNodegenNTc                    |j         j        }d|_        |W|t          t          t
          fv s
J |            ||_        |                    t          ||t          j
                  |            t                      j        |fd|i| d S )NT)r  r   r
  )r\  gbody
is_inlinedr   r   r   inlined_comprehension_typer  rk  r   retval_cnamerO   rl  )rX   r   r
  comprehension_typerL  r
  rR   s         rS   rl  z'InlinedGeneratorExpressionNode.__init__I$  s    ")%)Xy)IIIIK]III/AE,MM'-?ATUU'     	00#000000rT   c                     | j         dvS )N)rk   r4  r  )	orig_funcrW   s    rS   rA  z*InlinedGeneratorExpressionNode.may_be_noneU$  s    ~%===rT   c                     | j         S rM   r  r   s     rS   r   z)InlinedGeneratorExpressionNode.infer_typeX$  r	  rT   c                 D    | j                             |          | _         | S rM   )r
  rB  r   s     rS   r<  z,InlinedGeneratorExpressionNode.analyse_types[$  s    8//44rT   c           
         |                     |                                 d| j                                        d|                    |                                 | j                             |                     |           d S )Nz$ = __Pyx_Generator_GetInlinedResult(r  )r   r  r
  r   r   r  r  s     rS   r  z3InlinedGeneratorExpressionNode.generate_result_code_$  s|    

KKMMMM48??,,,,##DKKMM48<<<> 	? 	? 	? 	T"""""rT   rM   )rZ   r[   r\   r   r
  r  r   r   r   rl  rA  r   r<  r  r]   r^   s   @rS   r
  r
  8$  s         wHIFGD
1 
1 
1 
1 
1 
1> > >    # # # # # # #rT   r
  c                   V    e Zd ZdZdgZdZdZd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )rW	  z
    Merge a sequence of iterables into a set/list/tuple.

    The target collection is determined by self.type, which must be set externally.

    args    [ExprNode]
    r   TzConstructing Python collectionc                    |t           t          fv rZ|rX|d         j        rK|d         j        t           ur7t	          |d         j        |d         j        d|d         j                  |d<   t          	                    | |||           d S )Nr   T)r   r   r   )r   r   )
r   r   r   r   rB  r   r   r   r   rl  )rX   r   r   r   s       rS   rl  zMergedSequenceNode.__init__r$  s    Iz***t*Q8W*Aw|9,,"47;T!W\4]abc]d]pqqqQ$$T:::::rT   c                 z   g }| j         D ]]}|j        r|j        r|j        j        dk    r!|j        s|j        rd |j         D             }n|j        }|                    |           ^| j        t          u rt          |          }n.| j        t          u rt          |          }n| j        t          u sJ || _        d S )Nr   c              3   $   K   | ]}|j         V  d S rM   r  r  s     rS   re   z?MergedSequenceNode.calculate_constant_result.<locals>.<genexpr>$  s%      BB,BBBBBBrT   )r   r   r   r   rZ  r   r   r   r  r   r   r   )rX   r  r   r  s       rS   r%  z,MergedSequenceNode.calculate_constant_resulty$  s    I 
	! 
	!D+ 0@ #3q88" -d&B -BB	BBB,MM%    9  [[FFY*$$6]]FF9	))))%rT   c                    g }| j         D ]{}|j        r&|j        r|j                                      dk    r/|j        s|j        rfd|j         D             }n|                              }|                    |           || j        t          u r=	 t          |          }nZ# t          $ r}| 
                    |           Y d }~n6d }~ww xY w| j        t          u rt          |          }n| j        t          u sJ |S )Nr   c              3   B   K   | ]}|                               V  d S rM   r  r  s     rS   re   z8MergedSequenceNode.compile_time_value.<locals>.<genexpr>$  s1      KK#//55KKKKKKrT   )r   r   r   r/  rZ  r   r   r   r  r=  r3  r   r   r   )rX   r.  r  r   r  r2  s    `    rS   r/  z%MergedSequenceNode.compile_time_value$  s:   I 		! 		!D+ 0@ #66t<<AA" 6d&B 6KKKKKKK//55MM%    9  1V 1 1 1--a000000001Y*$$6]]FF9	))))s   B& &
C0C

Cc                     dS r  rV   r   s     rS   rO  z$MergedSequenceNode.type_dependencies$  r  rT   c                     | j         S rM   r  r   s     rS   r   zMergedSequenceNode.infer_type$  r	  rT   c                     fd| j         D             }t          |          dk    r|d         j        | j        u r|d         S | j        t          t          t
          fv sJ || _         | S )Nc                     g | ]=}|                                                                                 d           >S )z2argument after * must be an iterable, not NoneTyper  rs  s     rS   r   z4MergedSequenceNode.analyse_types.<locals>.<listcomp>$  s\     
 
 
  c""55c::LLDF F
 
 
rT   r+   r   )r   r   r   r   r   r   )rX   rr   r   s    ` rS   r<  z MergedSequenceNode.analyse_types$  s    
 
 
 
 y	
 
 
 t99>>d1gldi777NyXy*=====	rT   c                     dS rw  rV   rW   s    rS   rA  zMergedSequenceNode.may_be_none$  r  rT   c                 v	   |                     | j                   |                     |           | j        t          u }t          | j                  }t          |          }|                    |           |r|j	        s|sj|j
        rc|j        t          u rU|                    |                                 d|                                d           |                    |           n|                    |                                 d|rdn,|                                r|j        t"          t          fv rdndd|                                d|                    |                                 | j                             |                     |           |                    |           |                    |           t-                      }|rd}d	}nd
}d}|D ]}|r|j	        s|j
        s|j
        r|j        s|s|j        r|                    d           |j        D ]}|                    |           |                    |j        |d|                                 d|                                d           |                    |           |                    |           |r|                    d           n|                    d           |                    |           |                    |j        |d|                                 d|                                d           |                    |           |                    |           | j        t4          u r|                    d           |                    dt6          j        d|                                 d           |                    |                                 t"                     |                    |                                 dt6          j        d|                    |                                 | j                             |                     |           |                    d           t=          |          D ](}	|j                             tC          j"        |	            )d S )Nr<  r=  	PySet_Newr	  r	  r;  r  r	  __Pyx_PySet_Updater	  __Pyx_PyList_Extend)r	  r	  r  r  )PySet_Updatez
Builtins.c)
ListExtendr	  r  rP  z = PyList_AsTuple(r  r  r   )#r  r   r  r   r   r  r   r  r  rZ  r   r   r   r  r   r  r  r   r   r  r  r  r  r   r  rr  r   r   r  r(	  r  r   r   r   r   )
rX   r   is_setr   r   r  add_funcextend_funcrh  r  s
             rS   r  z+MergedSequenceNode.generate_evaluation_code$  s   dh!!$'''h&DIDzz%%d+++ 	.t* 	.	.#;	.@D	Y@V@VJJT[[]]]]DNN4D4D4D4DEFFF..t4444JJ% +;?;N;N;P;P +UYU^cqs|b}U}U}77*+ +     ''tx@@@B C C C   &&&''---%% 	0"H.KK.H/K 	" 	"D D/ 43O 1:>:J B$) BKK @AAA9 ) )C00666))#' 4) * * * ..t444NN4(((( ::;;;;8999))$///!!$(    -" # # # ''---OOD!!!!9
""JJsOOOJJJ'''       OODKKMM>:::JJ'''''tx@@@B C C C   &&&JJsOOOWoo 	P 	PF--k.Ev.NOOOO	P 	PrT   c                 D    | j         D ]}|                    |           d S rM   )r   r  r  s      rS   r  zMergedSequenceNode.annotate%  s2    I 	  	 DMM$	  	 rT   N)rZ   r[   r\   r  r   r   r  rl  r%  r/  rO  r   r<  rA  r  r  rV   rT   rS   rW	  rW	  f$  s          xHG2K; ; ;& & &*  .      "  KP KP KPZ         rT   rW	  c                   B    e Zd ZdZdgZeZdZdZd Z	d Z
d Zd Zd	 Zd
S )SetNodez
    Set constructor.
    r   TzConstructing Python setc                     t          t          | j                            D ]A}| j        |         }|                    |          }|                    |          | j        |<   Bt
          | _        d| _        | S r  )r  r   r   r<  r   r   r   r   )rX   rr   r  rh  s       rS   r<  zSetNode.analyse_types%  sm    s49~~&& 	7 	7A)A,C##C((C11#66DIaLL	rT   c                     dS rw  rV   rW   s    rS   rA  zSetNode.may_be_none#%  r  rT   c                 2    d | j         D             | _        d S )Nc                     h | ]	}|j         
S rV   r  r  s     rS   r   z4SetNode.calculate_constant_result.<locals>.<setcomp>'%  s    III 3IIIrT   )r   r   rW   s    rS   r%  z!SetNode.calculate_constant_result&%  s     IItyIIIrT   c                     fd| j         D             }	 t          |          S # t          $ r }|                     |           Y d }~d S d }~ww xY w)Nc                 :    g | ]}|                               S rV   r  r  s     rS   r   z.SetNode.compile_time_value.<locals>.<listcomp>*%  s'    DDD3#((..DDDrT   )r   r  r=  r3  r	  s    `  rS   r/  zSetNode.compile_time_value)%  st    DDDD$)DDD	-v;; 	- 	- 	-))!,,,,,,,,,	-   % 
AA

Ac           	      :   | j         D ]}|                    |           |                     |           |                    |                                 d|                    |                                 | j                             |                     |           | j         D ]r}|                    | j        d|                                 d|	                                d           |
                    |           |                    |           sd S )Nz = PySet_New(0); z
PySet_Add(r  r  )r   r  r  r   r  r   r   r  rr  r   r  r  r	  s      rS   r  z SetNode.generate_evaluation_code0%  s*   9 	/ 	/C((....!!$'''

''tx@@@B	C 	C 	C 	T"""9 	! 	!C!!'+{{}}}}cmmooooFH H H &&t,,,NN4    	! 	!rT   N)rZ   r[   r\   r  r   r   r   rZ  r  r<  rA  r%  r/  r  rV   rT   rS   r.
  r.
  %  s          xHDN+K    J J J- - -! ! ! ! !rT   r.
  c                        e Zd ZdgZdZdZeZdZdZ	g Z
ed             Zd Zd Zd Zd	 Zd
 Zd Z fdZd ZdZd Zd Zd Z xZS )r  r  r+   FTc                 6     | fd|D                       S )Nc                 :    g | ]\  }}t          ||           S r  )r  )rb   krx  r   s      rS   r   z'DictNode.from_pairs.<locals>.<listcomp>T%  s?     )E )E )E6:aSaq111)E )E )ErT   r  rV   )rQ   r   pairss    ` rS   
from_pairszDictNode.from_pairsR%  sO    s3 )E )E )E )E>C)E )E )E F F F 	FrT   c                 L    t          d | j        D                       | _        d S )Nc                     g | ]	}|j         
S rV   r  r  s     rS   r   z6DictNode.calculate_constant_result.<locals>.<listcomp>X%  s.     %G %G %G)-$%G %G %GrT   )r$  r  r   rW   s    rS   r%  z"DictNode.calculate_constant_resultW%  s@    # %G %G151E%G %G %G  H  HrT   c                     fd| j         D             }	 t          |          S # t          $ r }|                     |           Y d }~d S d }~ww xY w)Nc                 x    g | ]6}|j                                       |j                                      f7S rV   )r  r/  r   )rb   r   r.  s     rS   r   z/DictNode.compile_time_value.<locals>.<listcomp>\%  sO     . . . (--d33TZ5R5RSW5X5XY . . .rT   )r  r$  r=  r3  )rX   r.  r<
  r2  s    `  rS   r/  zDictNode.compile_time_value[%  s    . . . .,. . .	-;; 	- 	- 	-))!,,,,,,,,,	-r5
  c                     dS r  rV   r   s     rS   rO  zDictNode.type_dependenciesc%  r  rT   c                     t           S rM   r  r   s     rS   r   zDictNode.infer_typef%  r	  rT   c                     t          d          5 }fd| j        D             | _        d d d            n# 1 swxY w Y   || _        | S )NTr  c                 :    g | ]}|                               S rV   rA  r   s     rS   r   z*DictNode.analyse_types.<locals>.<listcomp>l%  s7     $ $ $ ""3''$ $ $rT   )r   r  r	  )rX   rr   r	  s    ` rS   r<  zDictNode.analyse_typesj%  s    &&& 	&$ $ $ $ 0$ $ $D 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
 &,"s   7;;c                     dS rw  rV   rW   s    rS   rA  zDictNode.may_be_nones%  r  rT   c           	      X   t          j        |d          }|j        r|                                  | j        j        rSt          j        |          st          | j	        d|z             t          | j	        fd| j        D                       S | j                            |          st          | j	        d|z             n|j        r|| _        |j        s1t          | j                  dk    rt          | j	        d|z             nO|j        rHt          | j                  t          |j        j                  k     rt!          | j	        d	|z  d           | j        D ]!}t#          |j        t&                    r|j        j        |_        |j        j        sMt          |j        j	        d
           t-          |j        j	        t/          j        d                    |_        t3          |j        j                  }|j                            |          }|s"t          |j        j	        d|d|d           |j        }t#          |t&                    r|j        }|                    |j                  |_        #n"t;                                          |          S | S )NTr#  z-Cannot interpret struct as non-dict type '%s'c           	          g | ]I}t          |j        |j                                      |j                                                 JS r:
  )r  r   r  r   r   r   s     rS   r   z&DictNode.coerce_to.<locals>.<listcomp>}%  sf     ;6 ;6 ;6  !tx/J/J3/O/O'+z'D'DS'I'IK K K;6 ;6 ;6rT   r  z"Cannot interpret dict as type '%s'r+   z<Exactly one field must be specified to convert to union '%s'z%Not all members given for struct '%s'zInvalid struct field identifierr  r  zstruct 'z' has no field 'r  )r   r&  ro   release_errorsr   rw  r   r  r   r   r  r  r	  r   r,  r  r   r~   r  r  rh  r[  r  r
   r0  rw   r   r  r  rO   )rX   r  rr   r   r  r  r   rR   s     `    rS   r  zDictNode.coerce_tov%  s   +HTJJJ "	4!!!y+ 7 +H55 `$($SV^$^___ ;6 ;6 ;6 ;6 !% 4;6 ;6 ;6 7 7 7 7 9''11 Qdh Dx OPPP( 	4 DI% Y#d.B*C*Cq*H*Hdh ^ai ijjjj# YD,@(A(ACHbDcDc(c(c"IH"TVWXXX, G Gdh(:;; ,#x|DHx1 G$(,(IJJJ*48<~?[\e?f?fgggDHHdhn--C%^77<<F! GdhllxxxY\Y\Y\,]^^^^ $
%e-?@@ .$)IE%*__V[#%F%F

G" 77$$Xs333rT   c                 F    | j         D ]}t          |           g | _         d S rM   )r	  r   )rX   rs   s     rS   rI
  zDictNode.release_errors%  s3    - 	 	C%'"""rT   r  c                    |                     | j                   |                     |           | j        j        }|r|                                  |                    d|                                 t          | j	                  |
                    |                                 | j                  fz             |                     |           d }n| j        j        }t                      }d }d}| j	        D ]@}|                    |           |r| j        r/|                    d|j                                        z             |j        }| j        r|z|j        sd }np|j        |v rd }nd|t          |j                  ur4|/t          |j                  }|                    |j                   nd }n|                    |j                   ||                    d|                                 d|                                d           d}|                    d|                                d	|                    |j                             |                    d
           |                    | j        d|                                 d|j                                        d|j                                        d           | j        r||                    d           | j        r|                    d           n|                    |j        j                  }	|	J d|j        j         d            |	j        }
|j                                        }|j        j        j        rb|j                            t;          j        dd                     |                    d|                                  d|
 d| d| d	           n0|                    |                                  d|
 d| d           |                    |           |                     |           B|r/|j                            t;          j        dd                     d S d S )Nz%%s = __Pyx_PyDict_NewPresized(%d); %sFrB  r  r  rM  Tr  r  r  r  r  r   zstruct member z1 not found, error was not handled during coercionrA  r  zmemcpy(r   rn  r  r<  r=  r  r  )!r  r   r  r   ro   rI
  r   r  r   r  r   r  r,  r  r  exclude_null_valuesr   r   r  r  r[  r  r   rr  r  r   rT  r   r   r   r   r  r  )rX   r   is_dictstruct_scope	keys_seenkey_typeneeds_error_helperr   r  r  	key_cnamevalue_cnames               rS   r  z!DictNode.generate_evaluation_code%  s    	dh!!$''')' 
	+!!!JJ7KKMM,--++DKKMM48DD;F FG G G
   &&&LL9?LEE	"( 5	" 5	"D))$/// 1P+ EJJ{TZ-A-A-C-CCDDDh) / ,"4 5(,II Y)33(,II%T#)__<<'/+/	?? )ci 8 8 8 8 -1		%MM#)444 (


 KKMMMM3==????$< = = = .2*


MMOOOO OODH555$7 8 8 8 

:...%%dhhKKMMMMH&&((((J((****1, - - - ) $i.?JJsOOO+ $JJsOOO%11$(.AA))+}DHN+}+}+})))"L	"j//11:?+ P$55k6MN^`o6p6pqqqJJlllllkll\glllmmmmJJ$++--NN)NNNNNOOO''---OOD!!!! 	W--'(=?TUUW W W W W	W 	WrT   c                 D    | j         D ]}|                    |           d S rM   )r  r  r  s      rS   r  zDictNode.annotate%  s3    ( 	  	 DMM$	  	 rT   c                 $    d | j         D             S )Nc                 $    i | ]\  }}|j         |S rV   r  r  s      rS   r  z+DictNode.as_python_dict.<locals>.<dictcomp>%  s     HHHZS%	5HHHrT   r  rW   s    rS   as_python_dictzDictNode.as_python_dict%  s     IH43GHHHHrT   )rZ   r[   r\   r   r   rL
  r   r   rY  r  r	  re  r=
  r%  r/  rO  r   r<  rA  r  rI
  r  r  r  rW
  r]   r^   s   @rS   r  r  A%  s.        ""HGDOF F [FH H H- - -        % % % % %N( ( (
 -KPW PW PWd     I I I I I I IrT   r  c                   >    e Zd ZddgZdZd Zd Zd Zd Zd Z	d	 Z
dS )
r  r  r   Nc                 @    | j         j        | j        j        f| _        d S rM   )r  r   r   rW   s    rS   r%  z&DictItemNode.calculate_constant_result	&  s"    H$dj&@ BrT   c                     | j                             |          | _         | j                            |          | _        | j                             |          | _         | j                            |          | _        | S rM   )r  r<  r   r   r   s     rS   r<  zDictItemNode.analyse_types&  sc    8))#..Z--c22
8..s33Z22377
rT   c                 n    | j                             |           | j                            |           d S rM   )r  r  r   r  s     rS   r  z%DictItemNode.generate_evaluation_code&  s4    ))$///
++D11111rT   c                 n    | j                             |           | j                            |           d S rM   )r  r  r   r  s     rS   r  z#DictItemNode.generate_disposal_code&  s4    ''---
))$/////rT   c                 n    | j                             |           | j                            |           d S rM   )r  r  r   r  s     rS   r  zDictItemNode.free_temps&  s4    D!!!
d#####rT   c                 8    t          | j        | j        g          S rM   )r  r  r   rW   s    rS   __iter__zDictItemNode.__iter__ &  s    TXtz*+++rT   )rZ   r[   r\   r   rs  r%  r<  r  r  r  r_
  rV   rT   rS   r  r   &  s        
 wHKB B B  2 2 20 0 0$ $ $, , , , ,rT   r  c                   0    e Zd ZdgZdZd Zd Zd Zd ZdS )SortedDictKeysNoderh  Tc                 l    t                               | |j        |           t          j        | _        d S rj  )r   rl  r   r   r   r   )rX   rh  s     rS   rl  zSortedDictKeysNode.__init__*&  s-    $S111%			rT   c                     | j                             |          }|j        t          j        u r|                    d          }|| _         | S r  )rh  r<  r   r   r   rI  rH	  s      rS   r<  z SortedDictKeysNode.analyse_types.&  sK    h$$S))8w(((''35 5CrT   c                     dS rw  rV   rW   s    rS   rA  zSortedDictKeysNode.may_be_none6&  r  rT   c                    | j                                         }| j         j        t          j        u rq|                    |                                 d|d|                    |                                 | j                             | 	                    |           n|j
                            t          j        dd                     |                    t          j        d                    }|                    |                                 d|d|d|                    |                                 | j                             | 	                    |           |                    d|                                 z             |                     |d	|                                 z             |                    |                    |                                 | j                             | 	                    |           |                    d
           |                    | j        d|                                 z             d S )Nz = PyDict_Keys(r  PyObjectCallMethod0r  keysz = __Pyx_PyObject_CallMethod0(r  z"if (unlikely(!PyList_Check(%s))) {zPySequence_List(%s)r   zPyList_Sort(%s))rh  r   r   r   r   r   r  r   r   r  r   r   r   r   rt  r
   r0  r  rr  )rX   r   dict_result
keys_cnames       rS   r  z'SortedDictKeysNode.generate_result_code9&  s    h((**8=G---JJ{{{''tx@@@B C C C   &&&& --k.E%'9/; /; < < <//0LV0T0TUUJJJ{{{JJJ''tx@@@B C C C   &&&JJ;dkkmmKLLL$$T+@4;;==+PQQQJJt..t{{}}dhGGHHH  &&&JJsOOOH'$..*:*::	< 	< 	< 	< 	<rT   N)	rZ   r[   r\   r   r   rl  r<  rA  r  rV   rT   rS   ra
  ra
  $&  s\        wHG& & &    < < < < <rT   ra
  c                       e Zd ZdZeZd ZdS )SortedListNodez0Sorts a newly created Python list in place.
    c                     |                     |                    d| j                                         d| j                             d S )NzPyList_Sort(r  )r   r  rh  r  r   r  s     rS   r  z#SortedListNode.generate_result_codeW&  sD    

4))*M9J9J*M*M*MtxXXYYYYYrT   N)rZ   r[   r\   r  r   r   r  rV   rT   rS   rk
  rk
  R&  s7         DZ Z Z Z ZrT   rk
  c                       e Zd Zd Zd ZdS )ModuleNameMixinc                 :    |                     | j        d          S NT
identifier)rI  rt  r  s     rS   get_py_mod_namezModuleNameMixin.get_py_mod_name\&  s'    '' ( / / 	/rT   c                 :    |                     | j        d          S rp
  )rI  qualnamer  s     rS   get_py_qualified_namez%ModuleNameMixin.get_py_qualified_name`&  s&    ''Md ( , , 	,rT   N)rZ   r[   r\   rs
  rv
  rV   rT   rS   rn
  rn
  [&  s2        / / /, , , , ,rT   rn
  c                   >    e Zd ZdgZeZdZd Zd Zd Z	d Z
dZd Zd	S )
r$  docTc                     d S rM   rV   r   s     rS   r   zClassNode.analyse_annotationss&  r   rT   c                     t           S rM   r/  r   s     rS   r   zClassNode.infer_typev&      rT   c                     | j         r>| j                             |          | _         | j                             |          | _         |                    t	          j        dd                     | S )NCreateClassr  )rx
  r<  r   r   r   r   r   s     rS   r<  zClassNode.analyse_typesz&  sa    8 	8x--c22DHx22377DH[4]DVWWXXXrT   c                     dS r  rV   rW   s    rS   rA  zClassNode.may_be_none&  rD  rT   Constructing Python classc                    | j         }|                    | j                  }| j        rx|                    | j        d|j                                        d|                    t          j	        d                    d| j                                        d           | 
                    |          }|                     |          }|                    |                                 d|j                                        d|j                                        d|d|d|d|                    |                                 | j                             |                     |           d S )Nr  r  r  r  z = __Pyx_CreateClass(r  )class_def_nodert  rp   rx
  rr  r   r$  r   r
   r0  rs
  rv
  r   r  basesr   r  )rX   r   r
  r   py_mod_nameru
  s         rS   r  zClassNode.generate_result_code&  s   ,&&ty118 	+!!$(("'113333**&4Y??A A A AH&&((((	*+ + + **400--d33

$..0000#--////''tx@@@B	C 	C 	C 	T"""""rT   N)rZ   r[   r\   r   r   r   r   r   r   r<  rA  r  r  rV   rT   rS   r$  r$  e&  sy         wHDG         .K# # # # #rT   r$  c                   @    e Zd Zg ZeZdZdZd Zd Z	d Z
dZd Zd Zd	S )
r%  FTc                     t           S rM   r/  r   s     rS   r   zPy3ClassNode.infer_type&  r{
  rT   c                     | S rM   rV   r   s     rS   r<  zPy3ClassNode.analyse_types&  r  rT   c                     dS r  rV   rW   s    rS   rA  zPy3ClassNode.may_be_none&  rD  rT   r
  c                    ddl m} | j        j        }d |j                                        D             }|rt          ||          }t          |t          j	        d                    }|
                    |j                  p |                    |j        t          |          |_        t          |||          }|                    |           | j        j        j                            d|           d S d S )	Nr+   AnnotationWriterc           	          g | ]C}|j         	t          |j        t          |j        |j                   |j         j                  DS r  r  )rV  r  r   r|  rp   stringrb   r   s     rS   r   z4Py3ClassNode.analyse_annotations.<locals>.<listcomp>&  sc     
 
 
 1A
	(%*EEE&-  
 
 
rT   r  __annotations__r  )r  r   r   )AutoDocTransformsr
  r
  r   r  ru  r  r  r
   r0  r  rp   r  r   r   r/   r  bodyr(  insert)rX   rr   r
  position
dict_itemsannotations_dictr  r   s           rS   r   z Py3ClassNode.analyse_annotations&  s   777777&*
 
 ++--
 
 

  	;'*MMM8.*FGX*Y*YZZZC11cS__SXyZb5c5cCI'c?OPPPD%%c***$*11!T:::::	; 	;rT   c                    |j                             t          j        dd                     |                    | j                  }| j        }|j        r|j                                        nd}|j	        r|j	                                        }n| j
        rd}nd}|                    d|                                 |||j                                        |j                                        || j        | j        |                    |                                 | j                  f	z             |                     |           d S )NPy3ClassCreater  r  z((PyObject*)&PyType_Type)z$((PyObject*)&__Pyx_DefaultClassType)z9%s = __Pyx_Py3ClassCreate(%s, %s, %s, %s, %s, %d, %d); %s)r   r   r   r   rt  rp   r
  mkwr   	metaclass
force_typer   r  r
  r$  calculate_metaclassallow_py2_metaclassr   r   r  )rX   r   r   r
  r
  r
  s         rS   r  z!Py3ClassNode.generate_result_code&  sC   ))+*ABRTf*g*ghhh&&ty11,0>0BNn **,,,# 	?&0::<<II_ 	?3II>I

G$..00#--//((''tx@@	KB 	B
	C 
	C 
	C 	T"""""rT   N)rZ   r[   r\   r   r   r   r
  r   r   r<  rA  r  r   r  rV   rT   rS   r%  r%  &  s|         HDJG       .K; ; ;(# # # # #rT   r%  c                   $    e Zd Zg Zd Zd Zd ZdS )PyClassMetaclassNodec                 ,    t           | _        d| _        | S r  )r   r   r   r   s     rS   r<  z"PyClassMetaclassNode.analyse_types&  s    "	rT   c                     dS r  rV   rW   s    rS   rA  z PyClassMetaclassNode.may_be_none&  rD  rT   c           
      V   | j         j        }| j         j        }|r[|j                            t          j        dd                     d|                                d|                                d}nD|j                            t          j        dd                     d|                                z  }|                    |                                 d|d	|	                    |                                 | j
                             |                     |           d S )
NPy3MetaclassGetr  z__Pyx_Py3MetaclassGet(r  r  CalculateMetaclassz"__Pyx_CalculateMetaclass(NULL, %s)r<  r  )r
  r
  r
  r   r   r   r   r  r   r   r   r  )rX   r   r
  r
  r7  s        rS   r  z)PyClassMetaclassNode.generate_result_code&  s6   #)!% 
	 --'(9;MNNP P P P 

DD --'(<>PQQS S S7 D

ttt''tx@@@B	C 	C 	C 	T"""""rT   NrZ   r[   r\   r   r<  rA  r  rV   rT   rS   r
  r
  &  sH        
 H  
  # # # # #rT   r
  c                   &    e Zd ZdgZd Zd Zd ZdS )PyClassNamespaceNoderx
  c                     | j         r2| j                             |                              |          | _         t          | _        d| _        | S r  )rx
  r<  r   r   r   r   r   s     rS   r<  z"PyClassNamespaceNode.analyse_types'  sE    8 	Kx--c22EEcJJDH"	rT   c                     dS r  rV   rW   s    rS   rA  z PyClassNamespaceNode.may_be_none'  rD  rT   c                    |                     | j                  }|                     |          }|                     |          }| j        }d}| j        r| j                                        n|}|j        r|j                                        n|}|j	        r|j	                                        n|}	|
                    |                                 d|	d|j                                        d|d|d|d|d|d|                    |                                 | j                             |                     |           d S )Nz(PyObject *) NULLz = __Pyx_Py3MetaclassPrepare(r  r  )rt  rp   rs
  rv
  r
  rx
  r  r
  r   r
  r   r
  r   r   r  )
rX   r   r   r
  ru
  r
  nulldoc_coder
  r
  s
             rS   r  z)PyClassNamespaceNode.generate_result_code '  sV   &&ty11**400--d33,"(,:48??$$$d0>0BLn **,,,<J<T^N,66888Z^	

		$++----''tx@@@	B
	C 
	C 
	C 	T"""""rT   Nr
  rV   rT   rS   r
  r
  '  sJ         wH    # # # # #rT   r
  c                   0    e Zd ZdZeZg ZdZd Zd Z	d Z
dS )ClassCellInjectorNodeTFc                     | S rM   rV   r   s     rS   rB  z)ClassCellInjectorNode.analyse_expressions>'  r  rT   c                     | j         sJ |                    |                                 d|                    |                                 | j                             |                     |           d S )Nz = PyList_New(0); )	is_activer   r  r   r   r  r  s     rS   r  z*ClassCellInjectorNode.generate_result_codeA'  sz    ~

''tx@@@B	C 	C 	C 	T"""""rT   c                     | j         sJ |j                            t          j        dd                     |                    | j        d|                                 d|d           d S )NCyFunctionClassCellCythonFunction.cz__Pyx_CyFunction_InitClassCell(r  r  )r
  r   r   r   r   rr  r   r  )rX   r   classobj_cnames      rS   generate_injection_codez-ClassCellInjectorNode.generate_injection_codeI'  s    ~))#$9;MNN	P 	P 	PdhhKKMMMM>>>)+ 	, 	, 	, 	, 	,rT   N)rZ   r[   r\   r   r   r   r   r
  rB  r  r
  rV   rT   rS   r
  r
  7'  sU        GDHI  # # #, , , , ,rT   r
  c                   *    e Zd Zg ZdZdZeZd Zd Z	dS )ClassCellNodeTFc                     | S rM   rV   r   s     rS   r<  zClassCellNode.analyse_typesX'  r  rT   c                    | j         s8|                    |                                 dt          j        d           n7|                    |                                 dt          j        d           |                    d|                                 d|                    | j                  d           |                    |                                 t                     d S )Nz  = __Pyx_CyFunction_GetClassObj(r  z =  z->classobj;zif (!zJ) { PyErr_SetString(PyExc_RuntimeError, "super(): empty __class__ cell"); r\  )
is_generatorr   r  r   
self_cnamegenerator_cnamer   r   r  r   r  s     rS   r  z"ClassCellNode.generate_result_code['  s      	8JJ!!!# $ $ $ $ JJv5557 8 8 8


 ))))+	, 	, 	,
 	~66666rT   N)
rZ   r[   r\   r   r   r
  r   r   r<  r  rV   rT   rS   r
  r
  Q'  sF        HGLD  7 7 7 7 7rT   r
  c                       e Zd Zg dZdZdZdZdZdZdZ	dZ
eZdZdZdZed             Zed             Zd Zd Zd	 Zd
Zd Zd Zd Zd ZdS )r#  )defaults_tupledefaults_kwdictr
  FNr+   c                 X     | |j         ||j        j        |p|j        |j                  S )N)r\  pymethdef_cnamebindingspecialized_cpdefs)r   r   r
  r
  )rQ   r   r
  s      rS   from_defnodezPyCFunctionNode.from_defnode'  s<    sH J66t6#6
 
 
 	
rT   c                     | j         j        S rM   )r\  code_objectrW   s    rS   r
  zPyCFunctionNode.code_object'  s    }((rT   c                 >    | j         r|                     |           | S rM   )r
  analyse_default_argsr   s     rS   r<  zPyCFunctionNode.analyse_types'  s%    < 	+%%c***rT   c                 4   g }g }g }g }g }|j         p| j        j        o|j        }| j        j        D ]V}|j        r|s|j        j        rQt          |j        |j                  |_        |j        j	        r%|j        
                    |j	        |          |_        n>d|_        |j	        j        r|                    |           n|                    |           |j        j	        rQ|j        j	                            |          r2|j        r|                    |           n|                    |           |j        rK|j                            |          |_        |                    |j        |j        |j        j        f           X| j        j        | j        j        fD ]V}|rR|j        rK|j                            |          |_        |                    |j        |j        |j        j        f           W| j        j        }	|	rS|	                    |          | j        _        |                    |	j        t/          j        d          |	j        f           |s|rY|                                }
g }|D ],}|j	        }|j        r|j        }|                    |           -|d |D             z  }|
                    | j        |          | _        | j        j	        j        }t?          tA          |j!        "                                                    }d |D             }g | _#        tI          ||z   |          D ]-\  }}|j%        |_&        | j#                            ||f           .tO          |          | _(        | j#        D ] \  }}tR          j*        d|j%        |_+        !|j        | j        _,        |s|r| j        |rMt[          | j        d |D                       }|                    |          .                    |          | _/        |r:ta          | j        d	 |D             
          }|                    |          | _1        n| j2        s|r&tg          | j        || j        j	        j                  }nti          | j                  }|r&tk          | j        || j        j	        j                  }nti          | j                  }tm          j7        | j        g ddtm          j8        | j        tr          t[          | j        ||g                    dt/          j        d                    }|                                }
tl          j:        ;                    ||
          }|<                    |
           |=                    |
          }|j>        }|j>        =                    |j?                  |_>        d|_@        d|_A        || j        _B        |r<ta          | j        d |D             
          }|                    |          | _C        dS dS )zB
        Handle non-literal function's default arguments.
        Tr(  c                     g | ]	}|j         
S rV   r  r  s     rS   r   z8PyCFunctionNode.analyse_default_args.<locals>.<listcomp>'  s    ===Csx===rT   c                 B    g | ]\  }}|                     d           |S rk  )r  )rb   rp   r2  s      rS   r   z8PyCFunctionNode.analyse_default_args.<locals>.<listcomp>'  s-    TTT'$DOOE<R<RTATTTrT   r  Nc                     g | ]	}|j         
S rV   )rq   r  s     rS   r   z8PyCFunctionNode.analyse_default_args.<locals>.<listcomp>'  s'     ?= ?= ?=(+?= ?= ?=rT   r}  c           	      x    g | ]7}t          |j        t          |j        |j                   |j                  8S r
  )r  r   r|  rp   rq   r  s     rS   r   z8PyCFunctionNode.analyse_default_args.<locals>.<listcomp>'  s]     J3 J3 J3
  	 %G 4SWCH M M M"%+/ / /J3 J3 J3rT   r  )r  r   __defaults__)r   r]  r^  r
  
decoratorsrp   Fc           	      X    g | ]'\  }}}t          |t          ||           |          (S r
  )r  r|  )rb   r   rp   r   s       rS   r   z8PyCFunctionNode.analyse_default_args.<locals>.<listcomp>(  s[     C5 C5 C5 %Cu 1#TBBB! ! !C5 C5 C5rT   )Dr  r\  
is_wrapperr  r   rq   r   DefaultLiteralArgNoder   r   r  
is_dynamicro   r   r  kw_onlyrV  r<  rp   r
  r]  r^  return_type_annotationr
   r0  r$  r  rZ  declare_defaults_c_classdefaults_entryr,  r  r   r  r  defaultsr  r   defaults_class_keyr   defaults_pyobjectsr   dynamic_args_cnamer  defaults_structr  r   r
  r  r
  r
  DefaultsTupleNoder  DefaultsKwDictNoder   DefNodeReturnStatNoder   CompilerDirectivesNodefor_internalr  rB  r
  local_scopepy_wrapper_requiredpymethdef_requireddefaults_getterr
  )rX   rr   nonliteral_objectsnonliteral_otherdefault_argsdefault_kwargsannotationsmust_use_constantsrh  rV  r  rE  r  defaults_class_scopearg_entriesr   r
  r
  r
  directives_noder
  s                        rS   r
  z$PyCFunctionNode.analyse_default_args'  s      !1gdm6N6fSVSf=% 	O 	OC{ 1) 
9{- 	9&;CGS[&Q&Q;+ O*-+*?*?#*N*NCK)-8/ 9.55c::::,33C888;# 1(8(O(OPS(T(T 1{ 1&--c2222$++C000~ O!$!=!=c!B!B""CGSXs~7L#MNNNM*DM,FG 	O 	OC Os~ O!$!=!=c!B!B""CGSXs~7L#MNNN]9
 	43=3K3KC3P3PDM0
0LX0V0V * 1 3 4 4 4  	F!1 	F++--LE) $ $? '!JEU####==+;====E"."G"GRW"X"XD#'#6#;#A  !&:&B&H&H&J&J!K!KLLKTT[TTTKDM!"47G"GUU 3 3
U).&$$c5\2222&)*<&=&=D#"m < <
U---u{{%<!!,@,EDM) .	@> .	@"* d%.tx ?= ?=/;?= ?= ?= &> &> &>N*8*F*Fs*K*K*^*^_b*c*cD'! N&.tx J3 J3
 $2J3 J3 J3 '4 '4 '4O ,;+H+H+M+MD(,  @ 8%6,0C0H0N&P &PNN &.dh%7%7N! 9&8.$2E2J2P'R 'ROO '/tx&8&8O"'-H24-n' HNO+LN N NO O O  $'5nEE#G #G #G  #//11"'">"K"KO]i"j"j44\BBB"1"E"El"S"S"1"6'6';'O'O#/(1 (1$6;35:20?- 	H' C5 C5 )4	C5 C5 C5  6  6  6
 %5$B$B3$G$GD!!!	H 	HrT   c                     dS rw  rV   rW   s    rS   rA  zPyCFunctionNode.may_be_none(  r  rT   zConstructing Python functionc                     dS )Nr  rV   rW   s    rS   closure_result_codez#PyCFunctionNode.closure_result_code (  s    vrT   c                 l    | j         r|                     |           d S |                     |           d S rM   )r
  generate_cyfunction_codegenerate_pycfunction_coder  s     rS   r  z$PyCFunctionNode.generate_result_code#(  s@    < 	1))$/////**400000rT   c                 H   |                      |          }|                    |                                 d| j        d|                                 d|d|                    |                                 | j                  	           |                     |           d S )Nz = PyCFunction_NewEx(&r  r  )rs
  r   r  r
  r
  r   r   r  )rX   r   r
  s      rS   r
  z)PyCFunctionNode.generate_pycfunction_code)(  s    **400

$$$((****''tx@@@B	C 	C 	C 	T"""""rT   c                 L	   | j         r| j         d         }n| j        }| j         s| j        r0|j                            t          j        dd                     d}n/|j                            t          j        dd                     d}g }|j        r|                    d           n|j	        r|                    d           |j
        j        j        r!|j        j        s|                    d	           |j        r|                    d
           |rd                    |          }nd}|                    t$          j                  }| j                            |           |                    |                                 d|d| j        d|d|                     |          d|                                 d|                     |          d|d| j                                        d|                    |                                 | j                             |                     |           |j         rc|j!        s
J d            |j!        d         }|                    d|j"                                        d|                                 d           | j#        r|                    d|                                 d|                    | j$        j%        j&                  d|'                    | j                             d| j$        j%        j(        d|                                 d}| j#        D ]&\  }}	|)                    ||d|	j*                   '| j+        rE|                    d|                                 d| j+                                        d           | j         s| j,        rE|                    d|                                 d| j,                                        d           |j-        r=|                    d|                                 d|j-        j        j.        d           | j/        rI|                    d|                                 d| j/                                        d           d S d S d S )Nr   FusedFunctionr
  __pyx_FusedFunction_NewCythonFunction__Pyx_CyFunction_New__Pyx_CYFUNCTION_STATICMETHOD__Pyx_CYFUNCTION_CLASSMETHOD__Pyx_CYFUNCTION_CCLASS__Pyx_CYFUNCTION_COROUTINEr  r  r<  z(&r  r  zpyclass_stack is emptyry  zPyList_Append(r  z#if (!__Pyx_CyFunction_InitDefaults()) !__Pyx_CyFunction_Defaults(struct r  r  r  z"__Pyx_CyFunction_SetDefaultsTuple(z#__Pyx_CyFunction_SetDefaultsKwDict(z#__Pyx_CyFunction_SetDefaultsGetter(z$__Pyx_CyFunction_SetAnnotationsDict()0r
  r\  is_specializationr   r   r   r   is_staticmethodr   is_classmethodr
  r  r  r   is_anonymousis_coroutiner  r  r   rF  r
  r  r   r  r
  rv
  r
  rs
  r   r   r   r  requires_classobjpyclass_stack
class_cellr
  r
  r   rz  r   objstruct_cnamer  r   r
  r
  r
  rf  r
  )
rX   r   r\  r  flagsrF  
class_noder
  rh  r   s
             rS   r
  z(PyCFunctionNode.generate_cyfunction_code5(  s8   " 	%.q1HH}H" 	1d&< 	1--'9KLLN N N3KK--'(8:LMMO O O0K# 	9LL89999$ 	9LL7888,= 	4hnFa 	4LL2333  	7LL5666 	JJu%%EEE11&2FGG--d333

$$$**40000((****$$T**** **,,,,''tx@@@
B	C 	C 	C 	T"""% 	'%??'????+B/JJJJ)002222NN$$$$&' ' '
 = 
	,JJJKKMMMM--d.A.F.TUUUUOODH---/0 0 0 0 #(888$++----IH"m , ,
U,,THHekk;+, , , , ,  	AJJJt2<<>>>>@ A A A& 	G # F


KKMMMM4#7#A#A#C#C#C#CE F F F' Q


KKMMMM8#;#A#N#N#NP Q Q Q$ G


KKMMMM4#8#B#B#D#D#D#DF G G G G G	G 	GG GrT   )rZ   r[   r\   r   r
  r\  r
  r
  r
  r
  r
  r   r   r   r
  r  re  r
  rc  r
  r<  r
  rA  r  r
  r  r
  r
  rV   rT   rS   r#  r#  k'  s        IHHHGHHNNODG
 
 [
 ) ) X)  
AH AH AHF   1K  1 1 1
# 
# 
#UG UG UG UG UGrT   r#  c                       e Zd ZdZdZd ZdS )InnerFunctionNodeTc                 2    | j         rdt          j        z  S dS )Nz((PyObject*)%s)r  )needs_closure_coder   cur_scope_cnamerW   s    rS   r
  z%InnerFunctionNode.closure_result_code(  s     " 	>$v'===vrT   N)rZ   r[   r\   r
  r  r
  rV   rT   rS   r  r  (  s0         G    rT   r  c                   d    e Zd ZdZdZdZdZdZdZdZ	dZ
dZd Zed             Zed             ZdS )DefFuncLikeNodez\
    Adapter for CFuncDefNode to give it the same attributes as DefNode in CodeObjects.
    Fr   Nc                     |j         j        | _        |j         j        | _        |j        | _        |j        | _        || _        d S rM   )r   rp   r,  r
  r   r   _cfuncdef_node)rX   cfuncdef_nodes     rS   rl  zDefFuncLikeNode.__init__(  s?    !',	(.4!&	 $+rT   c                     | j         j        S rM   )r  node_positionsrW   s    rS   r  zDefFuncLikeNode.node_positions(  s    "11rT   c                     | j         j        S rM   )r  node_positions_to_offsetrW   s    rS   r  z(DefFuncLikeNode.node_positions_to_offset(  s    ";;rT   )rZ   r[   r\   r  r
  r  is_asyncgenis_generator_expressionnum_posonly_argsr_  r]  r^  rl  rc  r  r  rV   rT   rS   r  r  (  s          LLK#OHL, , , 2 2 X2 < < X< < <rT   r  c                   R    e Zd ZdgZdZdZd Zed             Zd Z	d
dZ
d Zd	 ZdS )CodeObjectNodevarnamesFNc                     t                               | |j        |           t          |j                  }d |j        j        D             }d ||z   D             | _        d S )N)r\  c                      g | ]}|j         	|S rV   r  r  s     rS   r   z+CodeObjectNode.__init__.<locals>.<listcomp>(  s    RRRcRcRRRrT   c                 D    g | ]}t          |j        |j                   S r{  )r|  r   rp   r  s     rS   r   z+CodeObjectNode.__init__.<locals>.<listcomp>(  s9     
 
 
 !999
 
 
rT   )r   rl  r   r   r   r
  r  r   )rX   r\  r   
local_varss       rS   rl  zCodeObjectNode.__init__(  sp    $x@@@HM""RRX%9%ERRR

 
j(
 
 
rT   c                 2     | t          |                    S rM   )r  )rQ   r  s     rS   	for_cfunczCodeObjectNode.for_cfunc(  s    s?=11222rT   c                     dS rw  rV   rW   s    rS   rA  zCodeObjectNode.may_be_none(  r  rT   c                 R    | j         |                    |           | _         | j         S rM   r  get_py_codeobj_constr  s     rS   r  z$CodeObjectNode.calculate_result_code(  s*    ##88>>DrT   c                 L    | j         |                    |           | _         d S d S rM   r)  r  s     rS   r  z#CodeObjectNode.generate_result_code(  s/    ##88>>D $#rT   c                    | j         }| j        d         }|                    |j        d          }|j        d                                         }t
          j                            |          r|j        d                                         }t          j
        t          j        |                                                    }|                    |          }|j        r`t          j        t!          |j        |                              d          d          }|                    |          }	t'          |          }
nd}	d}
ddg}|j        r|                    d	           |j        r|                    d
           |j        r|                    d           n9|j        r|                    d           n|j        r|                    d           |j        rd}nt'          |j                  }|j        }|j        }t'          | j                  }dd                    |          z  pd}|                     d           |                     d||z
   d| d| d| d| d| d|
 d           | j        D ]}|!                    |           d | j        D             pdg}|                     dd                    |          z             | j        D ],}|"                    |           |#                    |           -|                     | j$         d| d| d|	 d| j$         d| d           |                     d           d S )Nr+   Trq
  r   z	iso8859-1r  CO_OPTIMIZEDCO_NEWLOCALS
CO_VARARGSCO_VARKEYWORDSCO_ASYNC_GENERATORCO_COROUTINECO_GENERATORz(unsigned int)(%s)|r  r  z5const __Pyx_PyCode_New_function_description descr = {r  rA  c                 6    g | ]}|                                 S rV   rO  )rb   rR  s     rS   r   z3CodeObjectNode.generate_codeobj.<locals>.<listcomp>)  s     ===CMMOO===rT   z"PyObject* const varnames[] = {%s};z% = __Pyx_PyCode_New(descr, varnames, z", tuple_dedup_map); if (unlikely(!z)) goto r=  r   )%r\  r   rI  rp   get_filenametable_entryr'   r  isabsr  r
   r0  r(   Pathas_posixr  r4  r$   rY  rJ  r   r]  r   r^  r  r  r
  r  r   r  r_  r   r  r   r  r  r  r  )rX   r   r  r  first_linenofunc_name_result	file_pathfile_path_result
line_tableline_table_resultline_table_lengthr  argcountr  kwonly_argcountnlocalsrR  r   s                     rS   generate_codeobjzCodeObjectNode.generate_codeobj(  s   }x{33DI$3OOHQK7799	7==## 	63355I"0i1H1H1Q1Q1S1STT	33I>> 	"'56FtGZ\h6i6i6p6pq|6}6}  @K  L  LJ $ 5 5j A A #J & !  0= 	'LL&&& 	+LL)*** 	)LL-.... 	)LL(((( 	)LL(((' 	& HH49~~H0.dm$$$sxx6=# 	

3

/)     	 
     !  
	
 
	
 
	
 = 	/ 	/C((....==t}===F#

7$))H:M:MMNNN= 	! 	!C&&t,,,NN4    

 F F  F F  	F F
 !F F "-F F 8CF F F
	
 
	
 
	
 	

3rT   rM   )rZ   r[   r\   r   r   r  rl  re  r&  rA  r  r  rD  rV   rT   rS   r  r  (  s         |HGK
 
 
 3 3 [3         
? ? ?R R R R RrT   r  c                   B     e Zd Zg ZdZdZ fdZd Zd Zd Z	d Z
 xZS )r
  TFc                     t                                          |           || _        |j        | _        | j        j        | _        d| _        d S rw  )rO   rl  rh  r   r   	evaluatedrm  s      rS   rl  zDefaultLiteralArgNode.__init__9)  sC    "2HM	rT   c                     | S rM   rV   r   s     rS   r<  z#DefaultLiteralArgNode.analyse_types@)  r  rT   c                     d S rM   rV   r  s     rS   r  z*DefaultLiteralArgNode.generate_result_codeC)  r   rT   c                 Z    | j         s#| j                            |           d| _         d S d S r  )rG  rh  r  r  s     rS   r  z.DefaultLiteralArgNode.generate_evaluation_codeF)  s7    ~ 	"H--d333!DNNN	" 	"rT   c                 d    | j                             | j                                                  S rM   )r   r   rh  r  rW   s    rS   r  zDefaultLiteralArgNode.resultK)  s$    y""48??#4#4555rT   )rZ   r[   r\   r   r   r   rl  r<  r  r  r  r]   r^   s   @rS   r
  r
  0)  s        
 HJG        " " "
6 6 6 6 6 6 6rT   r
  c                   4     e Zd Zg Z fdZd Zd Zd Z xZS )DefaultNonLiteralArgNodec                 f    t                                          |           || _        || _        d S rM   )rO   rl  rh  r
  )rX   r   rh  r
  rR   s       rS   rl  z!DefaultNonLiteralArgNode.__init__T)  s0    .rT   c                 6    | j         j        | _        d| _        | S rw  )rh  r   r   r   s     rS   r<  z&DefaultNonLiteralArgNode.analyse_typesY)  s    HM	rT   c                     d S rM   rV   r  s     rS   r  z-DefaultNonLiteralArgNode.generate_result_code^)  r   rT   c                     d| j         j        dt          j        d| j                             | j        j                  j        S )Nr  r  r	  )r
  rp   r   r
  r-  rh  r
  r   rW   s    rS   r  zDefaultNonLiteralArgNode.resulta)  sI      %%%v'8'8'8 ''(CDDJJL 	LrT   )	rZ   r[   r\   r   rl  r<  r  r  r]   r^   s   @rS   rM  rM  O)  ss         H/ / / / /
  
  L L L L L L LrT   rM  c                   *     e Zd Z fdZd fd	Z xZS )r
  c                     g }|D ]<}|j         j        st          |||          }n|j         }|                    |           =t	                                          ||           d S )Nr}  )rq   r   rM  r   rO   rl  )rX   r   r
  r
  r   rh  rR   s         rS   rl  zDefaultsTupleNode.__init__j)  sv     	 	C;) ".sCIIkKK4(((((rT   Fc                 n    t                                          ||                              |          S rM   )rO   r<  r   )rX   rr   rL	  rR   s      rS   r<  zDefaultsTupleNode.analyse_typest)  s+    ww$$S-88KKCPPPrT   rR  rZ   r[   r\   rl  r<  r]   r^   s   @rS   r
  r
  g)  s`        ) ) ) ) )Q Q Q Q Q Q Q Q Q QrT   r
  c                        e Zd Z fdZ xZS )r
  c                 0   g }|D ]l}t          |j        |j                  }|j        j        st          |||          }n|j        }|                    t          |j        ||                     mt                      	                    ||           d S )Nr  r  r  )
r|  r   rp   rq   r   rM  r   r  rO   rl  )rX   r   r
  r
  r  rh  rp   rR   s          rS   rl  zDefaultsKwDictNode.__init__{)  s     	E 	EC'sx@@@D;) ".sCIIkLLcg4sCCCDDDDe44444rT   )rZ   r[   r\   rl  r]   r^   s   @rS   r
  r
  x)  s8        	5 	5 	5 	5 	5 	5 	5 	5 	5rT   r
  c                   T     e Zd ZdgZ ej        d          Zd Z fdZ fdZ	 xZ
S )
LambdaNoder\  z<lambda>c                 R   t          | d          rd S |                    d          x| _        | j        _        d| j        _        d| j        _        d| j        _        | j                            |           | j        j        j	        | _	        |
                    | j                   d S )Nlambda_namelambdaT)r  next_idr[  r\  no_assignment_synthesisr
  re  r  r   r
  add_lambda_defr   s     rS   r  zLambdaNode.analyse_declarations)  s    4'' 	F7:{{87L7LL4=404-+/(&*#**3///#}2B4=)))))rT   c                     | j                             |          | _         t                                          |          S rM   )r\  rB  rO   r<  r  s     rS   r<  zLambdaNode.analyse_types)  s2    99#>>ww$$S)))rT   c                 ~    | j                             |           t                                          |           d S rM   )r\  r	  rO   r  rX   r   rR   s     rS   r  zLambdaNode.generate_result_code)  s7    --d333$$T*****rT   )rZ   r[   r\   r   r
   r0  rp   r  r<  r  r]   r^   s   @rS   rY  rY  )  s{         ,K'>'
33D
* 
* 
** * * * *+ + + + + + + + +rT   rY  c                   ~     e Zd Z ej        d          ZdZej        dgz   Zej	        dgz   Z	 fdZ
 fdZd Z xZS )GeneratorExpressionNodegenexprFcall_parametersc                 P     t                      j        |g|R i | g | _        d S rM   )rO   rl  rf  )rX   r   r   r  rR   s       rS   rl  z GeneratorExpressionNode.__init__)  s8    ,t,,,t,,,!rT   c                 &   t          | d          rd S |                    d          | _        t                                          |           d| j        _        d| j        _        d| j        _        t          j
        | j        j        _        t          | j        t          j                  rCt          | j        j        t$                    sJ | j        j                            d |           d S t          | j        t          j                  sJ d S )Ngenexpr_namere  F)r  r]  ri  rO   r  r\  r
  r
  re  r4   pyfunction_noargsr   r  r~   r	  r   r	  r  r  r  r	  r  s     rS   r  z,GeneratorExpressionNode.analyse_declarations)  s    4(( 	FKK	22$$S)))+0(,1)&+#(1(C%di!566 	@di0.AAAAAI))$44444di)>???????rT   c                    |                                  gd | j        D             z   }d                    |          }|                    |                                 d| j        j        j        d|d|                    |                                 | j	                             | 
                    |           d S )Nc                 6    g | ]}|                                 S rV   r	  )rb   cps     rS   r   z@GeneratorExpressionNode.generate_result_code.<locals>.<listcomp>)  s     FFF""))++FFFrT   r  r<  r;  r  )r
  rf  r  r   r  r\  r   rf  r   r   r  )rX   r   args_to_calls      rS   r  z,GeneratorExpressionNode.generate_result_code)  s    11334FF0DFFFGyy..

#000''tx@@@	B	C 	C 	C 	T"""""rT   )rZ   r[   r\   r
   r0  rp   r
  rY  r   r   rl  r  r  r]   r^   s   @rS   rd  rd  )  s         (>'	22DG(,=+>>K"&7%88H" " " " "@ @ @ @ @&
# 
# 
# 
# 
# 
# 
#rT   rd  c                   J    e Zd ZdgZeZdZdZdZdZ	dZ
d Zd Zd Zd Zd	 Zd
S )YieldExprNoderh  r   Fyieldc                    | j         r| j        r$| j        rt          | j        d| j        z             d| _        | j        E| j                            |          | _        | j        j	        j
        s|                     |           | S )Nz'%s' not supported herer+   )	label_numis_yield_fromin_async_genr   r   expr_keywordr   rh  r<  r   ro   coerce_yield_argumentr   s     rS   r<  zYieldExprNode.analyse_types)  s    ~ 	K$"4 	K9J 	K$(58IIJJJ8x--c22DH8=, 0**3///rT   c                 D    | j                             |          | _         d S rM   rh  r   r   s     rS   rw  z#YieldExprNode.coerce_yield_argument)  s    8..s33rT   c                    | j         r| j                             |           | j                             |           |                    t          j        d| j                             t                    d           | j                             |           | j         	                    |           n%|
                    t          j        t                     |                     |           d S Nr<  r=  )rh  r  r  r   r   r
  r  r   r  r  put_init_to_py_nonegenerate_yield_coder  s     rS   r  z&YieldExprNode.generate_evaluation_code)  s    8 
	JH--d333H))$///JJ'''H&&~666689 9 9 H224888H%%%%$$V%8.III  &&&&&rT   c           	      F   |                     | j                            dd                    \  }}|                    |           g }|j        j                                         |j                                        D ]\  }}}|j        j                            |          }|	                    |||f           |j
        r3|j                            t          j        dd                     d|z  }n|                    ||           |                    t"          j        d|d|d           |j        j        d	         }	|j        j        d
         }
|	s|
r&|                    t"          j        | j                   |                    t"          j        t.                     |                                 |j        j        #|                    dt"          j        z             n"|                    dt"          j        z             |                    d| j        rdndd| j        rdndd           |                    dt"          j        |fz             | j        r*| j        s#|                    dt"          j        z             n"|                    dt"          j        z             |                    |           |	s|
r|                    | j                   |D ]\  }}}t"          j        d|}|j
        rd|z  }|                    |d|d           |j        r/|                    d|z             |                     ||           t|j!        r|                    |d|d           | "                    |t"          j#                   | j$        r{| %                    |           |&                    | '                                dt"          j#        d           |(                    | '                                t.                     dS dS )z
        Generate the code to return the argument in 'Naming.retval_cname'
        and to continue at the yield label.
        r[  r  r  r  z__PYX_STD_MOVE_IF_SUPPORTED(%s)r  r<  r=  profile	linetrace)r   Nz"__Pyx_Coroutine_SwapException(%s);z+__Pyx_Coroutine_ResetAndClearException(%s);z/* return from zasync r  zgenerator, awaitrq  zing value */z%s->resume_label = %d;z,return __Pyx__PyAsyncGenValueWrapperNew(%s);z
return %s;r  z.memview = NULL; z.data = NULL;r  ))new_yield_labelrv  replace	use_labelr  closure_tempsresettemps_in_user  r   r  r   r   r   r   r  r   r   r  rj   put_trace_yieldr
  r   r   put_finish_refcount_contextcurrent_exceptr
  ru  is_awaitr  put_trace_resumero   r  r   !generate_sent_value_handling_codesent_value_cnamer  r  r  r  r  )rX   r   rs  resume_labelsavedr   r   r  
save_cnamer  r  s              rS   r}  z!YieldExprNode.generate_yield_code*  sS   
 #'"6"6%%c3//#1 #1	<|$$$$**,,,'+~'B'B'D'D 		U 		U#E45CCDIIJLL%T2333  / 11+,=?OPPR R R9EA!!%...JJ)?)?)?UUUSTTTT"-i8$/<	 	Di 	D  !4$( CCC&-~>>>((***>(4JJ;f>TTUUUU JJDvG]]^^^


)1HHr11}1GG'113 	4 	4 	4 	

+"I// / 	0 	0 	0 	;T] 	;JJEH[[\\\\JJ|f&99:::|$$$ 	,i 	,!!$(+++', 		\ 		\#E:t%+%;%;%;ZZHJ  L>K
JJUUUJJJ7888 \

9z1222  ----( \

:::zzzZ[[[..tV5LMMM 	;%%d+++HHDKKMMMM63J3J3JKLLLOODKKMM>:::::	; 	;rT   c                 b    |                     |                    || j                             d S rM   )r   r   r   rX   r   rS
  s      rS   r  z/YieldExprNode.generate_sent_value_handling_codeL*  s,    

4**;AABBBBBrT   N)rZ   r[   r\   r   r   r   rs  rt  r  ru  rv  r<  rw  r  r}  r  rV   rT   rS   rp  rp  )  s         wHDIMHLL  4 4 4' ' 'C; C; C;JC C C C CrT   rp  c                   (    e Zd Zd ZddZd Zd ZdS )_YieldDelegationExprNodec                     t                      rM   )NotImplementedErrorr  s     rS   yield_from_funcz(_YieldDelegationExprNode.yield_from_funcQ*  s    !###rT   NFc                 R   || j                             |           |j                            t          j        d          }|                    |d|                     |          dt          j	        d|| j         
                                n|dt          j        d
           |5| j                             |           | j                             |           n|r|                    |t                     |                    d|z             |                    t          j        t                     |j                            |           |                     |           |                    d	|z             |                    t          j        t                     | j        r|                     |           n%|                    t          j        t                     |                    d
           |                     |           |                    d           d S )NFr  r<  r;  r  r  r  zif (likely(%s == PYGEN_NEXT)) {z(} else if (likely(%s == PYGEN_RETURN)) {r  r   )rh  r  r  r  r   PySendResult_typer   r  r   r
  r   r
  r  r  r  r   r  r  r}  r  fetch_iteration_resultpropagate_exception)rX   r   rE  rF  result_temps        rS   r  z1_YieldDelegationExprNode.generate_evaluation_codeT*  s   H--d333n22:3O\a2bb

KK  &&&&"""$0$8DH   lJJ! 	" 	" 	" H++D111H%%%% 	@!!,???

4{BCCC+^<<<##K000  &&&

=KLLL+^<<< 	G''----!!&"5~FFF

:  &&&

3rT   c                     |                     t          j        t                     |                    |                    | j                             d S rM   )r  r   r
  r   r   r   r   r  s     rS   r  z,_YieldDelegationExprNode.propagate_exceptions*  sA    ,n===

4??48,,-----rT   c                     |                     |                                 dt          j        dt          j        d           d S )Nr<  r  r*  )r   r  r   r
  r  s     rS   r  z/_YieldDelegationExprNode.fetch_iteration_resultx*  sN    

KKMMMM
 	 	 	 	 	rT   rw  )rZ   r[   r\   r  r  r  r  rV   rT   rS   r  r  P*  sU        $ $ $   >. . .
    rT   r  c                   "    e Zd ZdZdZd Zd ZdS )YieldFromExprNodeTz
yield fromc                     | j         j        j        st          | j        d           | j                             |          | _         d S )Nz-yielding from non-Python object not supported)rh  r   r  r   r   r   r   s     rS   rw  z'YieldFromExprNode.coerce_yield_argument*  s@    x}& 	M$(KLLL8..s33rT   c                 `    |j                             t          j        dd                     dS )NGeneratorYieldFromr4  __Pyx_Generator_Yield_Fromr   r   r   r   r  s     rS   r  z!YieldFromExprNode.yield_from_func*  .    ))+*ABVXe*f*fggg++rT   N)rZ   r[   r\   rt  rv  rw  r  rV   rT   rS   r  r  *  s<        ML4 4 4, , , , ,rT   r  c                   "    e Zd ZdZdZd Zd ZdS )AwaitExprNodeTr  c                 V    | j         !| j                             |          | _         d S d S rM   ry  r   s     rS   rw  z#AwaitExprNode.coerce_yield_argument*  s-    8x22377DHHH  rT   c                 `    |j                             t          j        dd                     dS )NCoroutineYieldFromr4  __Pyx_Coroutine_Yield_Fromr  r  s     rS   r  zAwaitExprNode.yield_from_func*  r  rT   N)rZ   r[   r\   r  rv  rw  r  rV   rT   rS   r  r  *  s>         HL8 8 8
, , , , ,rT   r  c                   *     e Zd Zd Z fdZd Z xZS )AwaitIterNextExprNodec                     |                     d           |                     d           |                     d           |                     d           |                     d           d S )Nz8PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();zif (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {r  r  r   )r   r  s     rS   _generate_breakz%AwaitIterNextExprNode._generate_break*  sn    

MNNN

 b 	c 	c 	c 	

#$$$

8

3rT   c                 t    |                      |           t                                          |           d S rM   )r  rO   r  rb  s     rS   r  z)AwaitIterNextExprNode.propagate_exception*  s5    T"""##D)))))rT   c                    |j         s
J d            |                    d|z             |                     |           |                    |                    | j                             |                    d           d S )Nz1AwaitIterNextExprNode outside of 'async for' loopr  r   )break_labelr   r  r   r   r  s      rS   r  z7AwaitIterNextExprNode.generate_sent_value_handling_code*  sy    TT!TTTT

)K7888T"""

4??48,,---

3rT   )rZ   r[   r\   r  r  r  r]   r^   s   @rS   r  r  *  sV        
  * * * * *      rT   r  c                   ,    e Zd ZeZdZd ZdZd Zd Z	dS )GlobalsExprNoder+   c                 D    |                     t          j                   | S rM   )r   r   globals_utility_coder   s     rS   r<  zGlobalsExprNode.analyse_types*  s    W9:::rT   zConstructing globals dictc                     dS rw  rV   rW   s    rS   rA  zGlobalsExprNode.may_be_none*  r  rT   c                     |                     |                                 d|                    |                                 | j                             |                     |           d S )Nz = __Pyx_Globals(); )r   r  r   r   r  r  s     rS   r  z$GlobalsExprNode.generate_result_code*  sh    

KKMMMM##DKKMM48<<<> 	? 	? 	? 	T"""""rT   N)
rZ   r[   r\   r   r   r   r<  r  rA  r  rV   rT   rS   r  r  *  sR        DG   .K  # # # # #rT   r  c                       e Zd Zd ZdS )LocalsDictItemNodec                 L   | j                             |          | _         | j                            |          | _        | j                             |          | _         | j        j                            |          r | j                            |          | _        nd | _        | S rM   )r  r<  r   r   r   r  r   s     rS   r<  z LocalsDictItemNode.analyse_types*  s    8))#..Z--c22
8..s33:?11#66 	66s;;DJJDJrT   N)rZ   r[   r\   r<  rV   rT   rS   r  r  *  s#            rT   r  c                   $     e Zd Zd Z fdZ xZS )FuncLocalsExprNodec                     t          d |j                                        D                       }fd|D             }t                              | |d           d S )Nc                 *    g | ]}|j         	|j         S rV   r  r
  s     rS   r   z/FuncLocalsExprNode.__init__.<locals>.<listcomp>*  s8     H H H EJHJH H HrT   c                 r    g | ]3}t          t          |           t          |d                    4S )r  T)rp   r+  r  )r  r|  r  )rb   rR  r   s     rS   r   z/FuncLocalsExprNode.__init__.<locals>.<listcomp>*  s_     ( ( (  $)#S9993ST:::< < < ( ( (rT   T)r  rL
  )r  r  ru  r  rl  )rX   r   rr   r$  r  s    `   rS   rl  zFuncLocalsExprNode.__init__*  s     H H$'K$6$6$8$8H H H I I
( ( ( ( '( ( ( 	$U.2 	 	4 	4 	4 	4 	4rT   c                 v    t                                          |          }d |j        D             |_        |S )Nc                      g | ]}|j         	|S rM   r  )rb   r  s     rS   r   z4FuncLocalsExprNode.analyse_types.<locals>.<listcomp>*  s)      :  :  :q$%G$7 "#$7$7$7rT   )rO   r<  r  )rX   rr   r   rR   s      rS   r<  z FuncLocalsExprNode.analyse_types*  sB    ww$$S)) :  :D,@  :  :  :rT   rU  r^   s   @rS   r  r  *  sG        4 4 4        rT   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )PyClassLocalsExprNodec                 J    t                               | |           || _        d S rM   )r  rl  pyclass_dict)rX   r   r  s      rS   rl  zPyClassLocalsExprNode.__init__*  s&    c***(rT   c                 6    | j         j        | _        d| _        | S rw  )r  r   r   r   s     rS   r<  z#PyClassLocalsExprNode.analyse_types*  s    %*	rT   c                     dS rw  rV   rW   s    rS   rA  z!PyClassLocalsExprNode.may_be_none*  r  rT   c                 4    | j                                         S rM   )r  r  rW   s    rS   r  zPyClassLocalsExprNode.result*  s     '')))rT   c                     d S rM   rV   r  s     rS   r  z*PyClassLocalsExprNode.generate_result_code+  r   rT   N)rZ   r[   r\   rl  r<  rA  r  r  rV   rT   rS   r  r  *  s_        ) ) )  
  * * *    rT   r  c                     |j         rt          |           S |j        rt          | |j                  S t          | |          S rM   )r  r  r  r  r$  r  )r   
scope_noderr   s      rS   LocalsExprNoder  +  sH    
 $s###
 ;$S*/:::c3'''rT   )not~r  r   c                   ~    e Zd Zdg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dZdS )UnopNoder  TFc                 ^    t           | j                 } || j        j                  | _        d S rM   )compile_time_unary_operatorsr   r  r   rX   r  s     rS   r%  z"UnopNode.calculate_constant_result*+  s+    +DM:#tDL$@AArT   c                 $   t                               | j                  }|st          | j        d| j        z             | j                            |          }	  ||          S # t          $ r }|                     |           Y d }~d S d }~ww xY w)Nz3Unary '%s' not supported in compile-time expression)	r  ri   r   r   r   r  r/  r=  r3  )rX   r.  r  r  r2  s        rS   r/  zUnopNode.compile_time_value.+  s    +//>> 	%$(Em$% % % ,11$77	-4==  	- 	- 	-))!,,,,,,,,,	-s   
A% %
B/B

Bc                     | j                             |          }|j        s|j        r|                    | j                  }||S |                     ||          S rM   )r  r   r  r  find_cpp_operation_typer   infer_unop_type)rX   rr   operand_typecpp_types       rS   r   zUnopNode.infer_type:+  sb    |..s33$ 	 (; 	 #;;DMJJH###C666rT   c                 0    |j         r|j        st          S |S rM   )ro   r  r   rX   rr   r  s      rS   r  zUnopNode.infer_unop_typeB+  s#    # 	 L,H 	 !!rT   c                     | j         j        r&| j         j        j        r| j         j        t          urdS t                              |           S rw  )r  r   r  r   r   rA  rW   s    rS   rA  zUnopNode.may_be_noneH+  sG    < 	!2!B 	| 	11u##D)))rT   c                    | j                             |          | _         |                     |          r9t          t	          | j        | j         j                            | _        d| _        n||                                 r)| 	                    |           t          | _        d| _        n?|                                 r|                     |           n|                     |           | S r  )r  r<  is_pythran_operationrI   r@   r   r   r   is_py_operationcoerce_operand_to_pyobjectr   is_cpp_operationanalyse_cpp_operationanalyse_c_operationr   s     rS   r<  zUnopNode.analyse_typesN+  s    |11#66$$S)) 
	*#$8HY$Z$Z[[DIDLL!!## 	*++C000&DIDLL""$$ 	*&&s++++$$S)))rT   c                 4    | j                                         S rM   r  r=  rW   s    rS   r=  zUnopNode.check_const]+      |'')))rT   c                 F    | j         j        j        p| j         j        j        S rM   )r  r   ro   r1  rW   s    rS   r  zUnopNode.is_py_operation`+  s    | ,K0A0KKrT   c                 X    t          |          }| j        j        }|o|j        p|j        S rM   )rA   r  r   r  r=   )rX   rr   
np_pythranop_types       rS   r  zUnopNode.is_pythran_operationc+  s/    #C((
,#Lw0KG4KLrT   c                 Z    |                                  r|                                  d S d S rM   r  rr  r   s     rS   rs  zUnopNode.nogil_checkh+  6    !! 	NN	 	rT   c                 (    | j         j        }|j        S rM   )r  r   r  r  s     rS   r  zUnopNode.is_cpp_operationl+  s    |   rT   c                 D    | j                             |          | _         d S rM   )r  r   r   s     rS   r  z#UnopNode.coerce_operand_to_pyobjectp+  s    |66s;;rT   c           
         | j         j        r|                    d           |                    d|                                 z             |                    d|                                 d|                                 d| j        | j                                        d           d S | j        j         j        r|                     |           d S | j	        r| 
                                r| j        dk    r|t          || j        |                                 d| j        d	| j                                        d
| j         j        r|                                 nd | j        | j                   d S |                    |                                 d| j        d	| j                                        d
           d S d S )Nz// Pythran unaryopr  r>  r?  r@  rA  r   r<  r[  r=  )r   r=   r   r  r   r  r  ro   generate_py_operation_coder   r  r   r   r   r   r  r  s     rS   r  zUnopNode.generate_result_codes+  s   9$ 	bJJ+,,,JJ3dkkmmCDDDJJJ++----	/ 0 0 0 0 0
 \* 		b++D11111\ 	b$$&& b4+?3+F+F'dh%)[[]]]]DMMM4<CVCVCXCXCXCXY%)Y%:DDKKMMM($*?A A A A A
 

DKKMMMM4===$,J]J]J_J_J_J_`aaaaa	b 	brT   c                 B   |                      |          }|                    |                                 d|d| j                                        d|                    |                                 | j                             |                     |           d S )Nr<  r;  r  )py_operation_functionr   r  r  r   r   r   r  r.  s      rS   r  z#UnopNode.generate_py_operation_code+  s    --d33

&&((((''tx@@@	B	C 	C 	C 	T"""""rT   c                     | j         j        j        s+t          | j        d| j        d| j         j        d           t          j        | _        d S )NzInvalid operand type for '' (r  )r  r   r  r   r   r   r   r2   rW   s    rS   
type_errorzUnopNode.type_error+  sS    | ) 	4$(( 1 1 13 4 4 4)			rT   c                 :   | j         j        g}| j        r&| j        s|                    t
          j                   |                    | j        | j	        |          }|r|s| 
                                 d S |rl|j        j        | _        |j        j        | _        | j        dk    r>d| _        t          |           r(|                    t!          j        dd                     nd| _        d| _        | j        r8| j        s1| j         j                            | j	        t
          j                  }n$| j         j                            | j	                  }|r=|;t'          | j        d| j	        dt                     | 
                                 d S || _        d S )	Nr   Tr  r  r  )r  r  z' operator not defined for )r  r   is_inc_dec_op	is_prefixr   r   r  r	  r   r   r  r   r   r   r   r   r   r   r  r   )rX   rr   overload_checkoperand_typesr   r  s         rS   r  zUnopNode.analyse_cpp_operation+  s   *+ 	8dn 	8  !6777--dh}UU 	% 	OOF 		&#(:#=D #(:#=D #s**#1$77 n(()@AY[k)l)lmmm#%D #%D  	Pdn 	P|(@@J,A A  HH |(@@OOH 	h.$((tt% & & &OOF			rT   Nr~  )rZ   r[   r\   r   infixr  r%  r/  r   r  rA  r<  r=  r  r  rs  r  r  r  r  r  r  rV   rT   rS   r  r  +  s(        {HEMB B B
- 
- 
-7 7 7     * * *  * * *L L LM M M
  ! ! !< < <b b b(# # #* * *     rT   r  c                   >    e Zd ZdZej        Zd Zd Zd Z	d Z
d ZdS )NotNode!c                 *    | j         j         | _        d S rM   )r  r   rW   s    rS   r%  z!NotNode.calculate_constant_result+  s    #'<#??rT   c                     | j                             |          }	 | S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )r  r/  r=  r3  )rX   r.  r  r2  s       rS   r/  zNotNode.compile_time_value+  si    ,11$77	-; 	- 	- 	-))!,,,,,,,,,	-s    
A	AA	c                     t           j        S rM   )r   r)  r  s      rS   r  zNotNode.infer_unop_type+  s    %%rT   c                     | j                             |          | _         | j         j        }|j        r|                     |           n| j                             |          | _         | S rM   )r  r<  r   r  r  rG  r  s      rS   r<  zNotNode.analyse_types+  sa    |11#66|($ 	?&&s++++<99#>>DLrT   c                 :    d| j                                         z  S )Nz(!%s)r  r  rW   s    rS   r  zNotNode.calculate_result_code+      ,,....rT   N)rZ   r[   r\   r   r   r)  r   r%  r/  r  r<  r  rV   rT   rS   r  r  +  sq         H!D@ @ @- - -& & &  / / / / /rT   r  c                   $    e Zd ZdZd Zd Zd ZdS )UnaryPlusNoder   c                 b    t          j        | j        j        t           j                  | _        d S rM   )r   r  r  r   r  r   s     rS   r  z!UnaryPlusNode.analyse_c_operation+  s'    2Lz46 6			rT   c                     dS )NPyNumber_PositiverV   r  s     rS   r  z#UnaryPlusNode.py_operation_function+      ""rT   c                     |                                  rd| j                                        z  S | j                                        S )Nz(+%s))r  r  r  rW   s    rS   r  z#UnaryPlusNode.calculate_result_code+  sC      "" 	)T\002222<&&(((rT   N)rZ   r[   r\   r   r  r  r  rV   rT   rS   r  r  +  sH         H6 6 6# # #) ) ) ) )rT   r  c                   *    e Zd ZdZd Zd Zd Zd ZdS )UnaryMinusNoder  c                    | j         j        j        r/t          j        | j         j        t          j                  | _        n7| j         j        j        rt          j        | _        n|                                  | j        j        r	d| _	        d S d S rw  )
r  r   r  r   r  r  r(  r  r  r  r   s     rS   r  z"UnaryMinusNode.analyse_c_operation+  s    <' 	"6!:#8: :DII\& 	"-DIIOO9 	DJJJ	 	rT   c                     dS )NPyNumber_NegativerV   r  s     rS   r  z$UnaryMinusNode.py_operation_function+  r  rT   c                     | j         rd| j                                        z  S | j        j                            d          d| j                                        dS )N(-%s)r  r;  r  )r  r  r  r   unary_oprW   s    rS   r  z$UnaryMinusNode.calculate_result_code+  s^    : 	WT\002222#|099#>>>>@S@S@U@U@U@UVVrT   c                 F    | j                                         }|rd|z  S d S )Nr  )r  r#  )rX   r   s     rS   r#  z)UnaryMinusNode.get_constant_c_result_code,  s1    7799 	#U?"	# 	#rT   N)rZ   r[   r\   r   r  r  r  r#  rV   rT   rS   r  r  +  sZ         H	 	 	# # #W W W# # # # #rT   r  c                        e Zd Zd Zd Zd ZdS )	TildeNodec                     | j         j        j        r0t          j        | j         j        t          j                  | _        d S | j         j        j        rt          j        | _        d S |                                  d S rM   )r  r   r  r   r  r  r(  r  r   s     rS   r  zTildeNode.analyse_c_operation,  sk    <# 	"6!:#8: :DIII\& 	"-DIIIOOrT   c                     dS )NPyNumber_InvertrV   r  s     rS   r  zTildeNode.py_operation_function,  s      rT   c                 :    d| j                                         z  S )Nz(~%s)r  rW   s    rS   r  zTildeNode.calculate_result_code,  r	  rT   N)rZ   r[   r\   r  r  r  rV   rT   rS   r  r  
,  sA          ! ! !/ / / / /rT   r  c                       e Zd Zd ZdS )	CUnopNodec                     dS rw  rV   rW   s    rS   r  zCUnopNode.is_py_operation,  r  rT   N)rZ   r[   r\   r  rV   rT   rS   r!  r!  ,  s#            rT   r!  c                   $    e Zd ZdZd Zd Zd ZdS )DereferenceNoder   c                 6    |j         r|j        S t          j        S rM   )r  r  r   r2   r  s      rS   r  zDereferenceNode.infer_unop_type',  s     	)))((rT   c                     | j         j        j        rI|j        r*t	          j        | j         j        j                  | _        d S | j         j        j        | _        d S |                                  d S rM   )r  r   r  is_cppr   r  r  r  r   s     rS   r  z#DereferenceNode.analyse_c_operation-,  sc    <# 	z 8&5dl6G6QRR			 L-7			OOrT   c                 :    d| j                                         z  S r  r  rW   s    rS   r  z%DereferenceNode.calculate_result_code6,  r	  rT   N)rZ   r[   r\   r   r  r  r  rV   rT   rS   r$  r$  ",  sH         H) ) )  / / / / /rT   r$  c                   $    e Zd ZdZd Zd Zd ZdS )DecrementIncrementNodeTc           
         | j         j        j        sf| j        r,t	          | j        d| j        d| j         j        d           n3t	          | j        d| j        d| j        d| j         j        d           t          j        | _        d S )NzNo match for 'operatorz' (operand type is 'r  zNo 'operatorz(int)' declared for postfix ')	r  r   r  r  r   r   r   r   r2   rW   s    rS   r  z!DecrementIncrementNode.type_error>,  s    | ) 	G~ Gdhh]]]DL$5$5$5!7 8 8 8 8 dhh]]]DMMM4<3D3D3D!F G G G)			rT   c                     | j         j        j        r0t          j        | j         j        t          j                  | _        d S | j         j        j        r| j         j        | _        d S |                                  d S rM   )r  r   r  r   r  r  r  r  r   s     rS   r  z*DecrementIncrementNode.analyse_c_operationH,  sm    <' 	"6!:#8: :DIII\% 	)DIIIOOrT   c                     | j         r$d| j        | j                                        dS d| j                                        | j        dS )Nr;  r  )r  r   r  r  rW   s    rS   r  z,DecrementIncrementNode.calculate_result_codeQ,  s`    > 	E 	E#}}dl.A.A.C.C.C.CDD	E  $|22444dmmmDDrT   N)rZ   r[   r\   r  r  r  r  rV   rT   rS   r*  r*  :,  sK        M* * *  E E E E ErT   r*  c                       fdS )Nc                 $    t          | fd|S )Nr  r   )r*  )r   r  r  r   s     rS   <lambda>z%inc_dec_constructor.<locals>.<lambda>X,  s!    5cjYYajjeijj rT   rV   r0  s   ``rS   inc_dec_constructorr2  W,  s    jjjjjjrT   c                   6    e Zd ZdZd Zd Zd Zd Zd Zd Z	dS )	AmpersandNoder  c                 *    t          j        |          S rM   )r   
c_ptr_typer  s      rS   r  zAmpersandNode.infer_unop_typea,  s    $\222rT   c                 P   | j                             |          | _         | j         j        }|j        r|                     |d           |j        sW|j        sP| j                                         s7|j        r| 	                    d           n| 	                    d|z             | S |j
        rP| 	                    d| j         j        rd| j         j        z  n| j         j        rd| j         j        z  ndz             | S |j        r| j        st          j        |          | _        | S )	NF)r  z'Cannot take address of memoryview slicez&Taking address of non-lvalue (type %s)z Cannot take address of Python %szvariable '%s'zobject attribute '%s'r  )r  r<  r   r  r  rU  r	  r   r   r   ro   r   rp   r\  r$  r   r6  )rX   rr   argtypes      rS   r<  zAmpersandNode.analyse_typesd,  sH   |11#66,# 	B&&s5&AAA$ 	(< 	@[@[@]@] 	) O

DEEEE

CgMNNNK 	JJ97;|7K $,"333DHLD] '$,*@@@    K# 	749 	7"-g66DIrT   c                 4    | j                                         S rM   )r  r|  rW   s    rS   r=  zAmpersandNode.check_consty,  s    |,,...rT   c                 `    t          | j        |           t          j        | _        d| _        d S Nr  r   r   r   r2   r   r  rX   messs     rS   r   zAmpersandNode.error|,  ,    dh)	$rT   c                 :    d| j                                         z  S )Nz(&%s)r  rW   s    rS   r  z#AmpersandNode.calculate_result_code,  r	  rT   c           
      :   | j         j        j        r| j        dk    r~t	          || j        |                                 d| j        d| j                                         d| j        j        r|                                 nd | j	        | j
                   d S d S d S )Nr   r<  r[  r=  )r  r   r  r   r   r   r  r   ro   r   r  r  s     rS   r  z"AmpersandNode.generate_result_code,  s    L* 	=t/Cs/J/J#D$(!%t|?R?R?T?T?T?TU!%!6@D$d&;= = = = =	= 	=/J/JrT   N)
rZ   r[   r\   r   r  r<  r=  r   r  r  rV   rT   rS   r4  r4  [,  su         H3 3 3  */ / /% % %
/ / /= = = = =rT   r4  )r   r  r  c                 v   t          |t                    rM|dk    rGt          |j        t          t	          j        |j                             |j        |j                  S t          |t                    r+|j
        |cxk    rdv rn nt          | d|fdz  z  d           t          |         | ||          S )Nr  )r   r   r  r  z+-zAPython has no increment/decrement operator: %s%sx == %s(%sx) == x      )r   r  )r~   r]  r   rw   r   r  r   r  r  r  r   r   unop_node_classes)r   r   r  s      rS   	unop_noderF  ,  s     '7## oCW[#u7J7=7Y7Y6Y2Z2Z ' 07;KM M M 	M	GX	&	& o7+;x+O+O+O+O4+O+O+O+O+OX]e\ghi\ijlmnnnX&s   rT   c                   p    e Zd ZdgZdxZxZZd Zd Zd Z	d Z
d Zd Zd	 Zd
 Zd ZddZd Zd Zd ZdS )r	  r  Nc                     dS r  rV   r   s     rS   rO  zTypecastNode.type_dependencies,  r  rT   c                     | j         =| j                            |          }| j                            ||          \  }| _         | j         S rM   )r   r  r  
declarator)rX   rr   r  r  s       rS   r   zTypecastNode.infer_type,  sD    9..s33I?229cBBLAtyyrT   c                 	   | j         =| j                            |          }| j                            ||          \  }| _         | j                                        r|                                  | j         j        r&t          | j	        d           t          j        | _         | j                            |          | _        | j         t          j        u r| j                            |          S | j         j        }| j        j         j        }|rH|sF| j                                        r-| j         j        s!| j         j        st          | j	        d           |r(|s%| j         t&          u r&| j        j         j        rt+          | j        |          S | j        j                             |          r3t.          | _        | j                            | j         |          | _        n6| j        j         j        rB| j        j         j        j        s+| j        j         j        j        st          | j	        d           n+t;          | j	        d| j        j         d| j         d           | j                            |          | _        n|r|s| j                             |          r'| j                            | j         |          | _        nR| j         j        r9| j         j        j        s&| j         j        j        st          | j	        d           nt;          | j	        d| j         d| j        j         d           n|rl|rj| j         r#tC          | j        | j         |d	          | _        ntE          | j        tF                    r%| j                            | j         |          | _        ns| j         j$        r1| j        j         j$        r | j                            |          | _        n6| j        j         j%        r%| j                            | j         |          | _        | j         j        r`| j         j        j        rO| j         j        j&        r>| j        j         }|j        r|j        }|j        r|j&        st;          | j	        d
d           | S )NzCannot cast to a function typez>Casting temporary Python object to non-numeric non-Python typez>Python objects cannot be cast from pointers of primitive typeszNo conversion from z to z, python object pointer used.z<Python objects cannot be cast to pointers of primitive typesT)notnonezQCasting a GIL-requiring function into a nogil function circumvents GIL validationr+   )'r   r  r  rJ  r  r   r%  rU  r   r   r   r2   r<  r)  rG  ro   r   r  r  r   r  r  r  r   r!  r  r  r  r	  r   rK  create_from_py_utility_code	typecheckr   r~   r  r  rg  r   )rX   rr   r  r  to_pyfrom_pyr  s          rS   r<  zTypecastNode.analyse_types,  sg   9..s33I?229cBBLAty<++-- 	-**,,,9! 	.$(02 2 2"-DI|11#669
...<11#666	%,#/ 	b5 	bT\%>%>%@%@ 	b9' b	0F bdh `aaa !	B !	ByJ&&4<+<+C&+DL#>>>"99#>> B$2!#|55diEE<$+ 7 L-7? j4<CTC^Ch jdh(hiii DHH)))4999'6 7 7 7#|<<SAA 	BU 	By44S99 3#|55diEE! 3	+3 dty7J7T d$($bcccIIIt|000#2 3 3 3 3 		B 		B~ F-dlDIsTXYYYDL.99 F#|55diEEY! 	Bdl&7&B 	B<88==DLL\' 	B<11$)SAADL9 	p	 3 @ 	pTYEXE^ 	pl'G~ ,!+# pGM pkmnp p prT   c                 4    | j                                         S rM   )r  r:  rW   s    rS   r:  zTypecastNode.is_simple,  s    |%%'''rT   c                 4    | j                                         S rM   )r  r   rW   s    rS   r   zTypecastNode.is_ephemeral,  s    |((***rT   c                 B    | j         p| j                                        S rM   )r   r  rV  rW   s    rS   rV  z!TypecastNode.nonlocally_immutable,  s    |Bt|@@BBBrT   c                 n    | j         r)| j         j        r| j        r|                                  d S d S d S d S rM   )r   ro   r   rr  r   s     rS   rs  zTypecastNode.nogil_check-  sU    9 	. 	4< 	NN	 	 	 	 	 	rT   c                 4    | j                                         S rM   r  rW   s    rS   r=  zTypecastNode.check_const-  r  rT   c                 N    |                      | j        j                  | _        d S rM   )r  r  r   rW   s    rS   r%  z&TypecastNode.calculate_constant_result-  s#    #99$,:VWWrT   c                 6   || j                                         }| j        j        r| j                                         }| j         j        j        ry| j        j                            | j         j                            |                    }| j        j                            | j         j                            |                    }n!| j        j                            |          }d}| j        j        d|d|dS | j                            |          S Nr  r;  r  r  )	r  r  r   r  	real_typer   	real_code	imag_coder  )rX   operand_result	real_part	imag_parts       rS   r  z"TypecastNode.calculate_result_code-  s   !!\0022N9 	7!\0022N| +   I/99L%//??A A	 I/99L%//??A A		 !I/99.II		I(((IIII 
 9&&~666rT   c                 p    | j                                         }|r| j                            |          S d S rM   )r  r#  r   r   )rX   r\  s     rS   r#  z'TypecastNode.get_constant_c_result_code-  s=    @@BB 	79&&~666	7 	7rT   c                     | j         j        r!| j        s| j                            |          S t
                              | |          S rM   )r   ro   r   r  r  r   r  s     rS   r  zTypecastNode.result_as$-  sD    9  	2 	2<))$///%%dD111rT   c                    | j         r|                    |                                 d| j                                        d           |                    |                                 |                                            d S d S )Nz = (PyObject *)r=  )r   r   r  r  r  r  r  s     rS   r  z!TypecastNode.generate_result_code+-  s    < 	9JJKKMMMML''))))+, , , OODKKMM4::<<88888	9 	9rT   rM   )rZ   r[   r\   r   r  rJ  r   rO  r   r<  r:  r   rV  rs  r=  r%  r  r#  r  r  rV   rT   rS   r	  r	  ,  s         {H$((I(
T    > > >@( ( (+ + +C C C  * * *X X X7 7 7 7(7 7 7
2 2 29 9 9 9 9rT   r	  zStart may not be givenz'Stop must be provided to indicate shapezVStrides may only be given to indicate contiguity. Consider slicing it after conversionz2Can only create cython.array from pointer or arrayz7Pointer base type does not match cython.array base typec                   l    e Zd ZdZddgZdZdZdZdZe	j
        Zd Zd Zd	 Zd
 Zd Zed             ZdS )r  an  
    Used when a pointer of base_type is cast to a memoryviewslice with that
    base type. i.e.

        <int[:M:1, :N]> p

    creates a fortran-contiguous cython.array.

    We leave the type set to object so coercions to object are more efficient
    and less work. Acquiring a memoryviewslice from this will be just as
    efficient. ExprNode.coerce_to() will do the additional typecheck on
    self.compile_time_type

    This also handles <int[:, :]> my_c_array


    operand             ExprNode                 the thing we're casting
    base_type_node      MemoryViewSliceTypeNode  the cast expression node
    r  shapesNTcc                 	   ddl m} | j                            |          | _        | j        r| j        }n| j        j                            |          }| j        j        }t          | _	        g | _
        t          |          }| j        j	        }| j        j	        j        s2| j        j	        j        s!t          | j        j        t                      | S g }|j        r0|j        r(|                    |j                   |j        }|j        (n)|j        r|j        }nt          | j        d|z             | S |                    |          s(|j        s!t          | j        j        t,                     | S | j        j	        j        rAt          |          |k    r.t          | j        j        d|t          |          fz             | S t/          |          D ]\  }}	|	j        j        s#t          |	j        j        t4                     | c S |	j        j        r]|r=||         }
t9          | j        t;          |
          |
t<          j                  |	_        nt          |	j        t@                     | c S |	j                            |          |	_        |	j        !                    | j"        |          }|j#        s|$                    |           | j
                            |           |d|dz
  fv }|	j%        j        s|r|	j%                            |          |	_%        |	j%        j	        j&        s;|	j%        j#        r/|	j%        j	        j'        st          |	j%        j        d           | c S |	j%        (                    |          dk    r#t          |	j%        j        tR                     | c S |dk    rd| _*        |	j%        j        s%|s#t          |	j%        j        tR                     | c S | j        j+        s| j        $                    |          | _        d	gt          |          z  }| j*        dk    rd
|d<   nd
|d<   t=          j,        ||          | _-        | j-        .                    | j                   | /                    |          | _	        |0                    |           |1                    |2                    |j3        j4                             | S )Nr+   r  zunexpected base type %s foundz/Expected %d dimensions, array has %d dimensionsrX  r   zExpected an integer literalfortran)r  follow)r  contigry  )5r  r  r  r<  array_dtypebase_type_noder  r  r2   r   rc  r   r  rT  r   r   ERR_NOT_POINTERr   ri  r  r  r  ERR_BASE_TYPEr  r   r  	ERR_STARTr   r]  rw   r   r  ERR_NOT_STOPr  
shape_typer   r8  r   r  r  r/  	ERR_STEPSmoder   r  r  validate_memslice_dtypeget_cython_array_typeuse_cython_array_utility_coder   get_typeinfo_to_format_coder  r  )rX   rr   r  ri  r  r  r  array_dimension_sizesaxis_noaxisdimsizeshapefirst_or_lasts                rS   r<  zCythonArrayNode.analyse_typesZ-  s         |11#66 	J*KK-<DDSIIK"'	4yy L%	| ' 	0A0J 	$,"O444K !# 	$ 0%,,Y^<<<%/	 $ 0  	!+II$(;iGHHHK!!+.. 	)2C 	$,"M222K\' 	C0E,F,F$,N,N$,"C-137L3M3M,NOP P P K
 't__ )	 )	MGT:% djni000y   (  3G<G 'G8?-7-B!D !D !DDII $(L111KKK	//44DII''==E# *$$S)))Ku%%%#4!8}4M9$   I33C88		-  $)2F  	/ $)-)FGGGKKK9//4499$)-333KKKa<< )DIY& } dimY///|# 	<<66s;;DL$%D		19	!!*DGG+DH';KNN2248<<<..s33	00555223;3\]]	
 	
 	
 rT   c                 |    | j         rt          d          |j                            | j        d          | _         d S )Nztemp allocated multiple timesT)r  r  r  r  r   r  s     rS   r  z$CythonArrayNode.allocate_temp_result-  s;    > 	@>???55diFFrT   c                 ,    |                      |          S rM   )rs  r   s     rS   r   zCythonArrayNode.infer_type-  s    ))#...rT   c                     |j         j        }|                                 |j                            d          j        S )Narray)r  cython_scopeload_cythonscope	viewscoper-  r   )rX   rr   r  s      rS   rs  z%CythonArrayNode.get_cython_array_type-  s8    {/%%'''%,,W55::rT   c                     ddl m}  fd j        D             } j        j        }j                            t          d          }j                            t          d          }j                            t          d          }d|	                                z  }|
                    |          }	 j        j        j        r                    d j                                        z                                 d                                                    j        j                                                 d                               |d	|	d
                    | j                                                 |t                     dt)          |          z  }
                    |d|
dd                    |          d
                    | j                                                 |t                                         d                               |d|d
                    | j                                                 d                               |d|d                               d                                                                d|d|d|d j        d j                                        d
                                                      j                                                             fd} ||            ||           j                            |           d S )Nr+   r  c                 h    g | ].}j                             |                                          /S rV   )ro  r   r  )rb   rz  rX   s     rS   r   z8CythonArrayNode.generate_result_code.<locals>.<listcomp>-  sA     0 0 0 /++ELLNN;; 0 0 0rT   Tr   z
if (!%s) {zQPyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer");r   z = __pyx_format_from_typeinfo(&r  z __PYX_BUILD_PY_SSIZE_T z = Py_BuildValue("(" z ")", r  rd  z = PyBytes_AsString(r  z = PyBytes_AS_STRING(r  r  z = __pyx_array_new(, "z", (char *) c                 r                         | t                     j                            |            d S rM   )r  r   r  r  )r  r   s    rS   disposez5CythonArrayNode.generate_result_code.<locals>.dispose
.  s5    !!$777N''-----rT   )r  r  rc  r  r  r  r  r   r0   r  get_type_information_cnamer  r   r  r   r  r   r   r   r  r   r  rq  r  r  )rX   r   r  rc  r  shapes_tempformat_tempformat_ptr_tempitemsize	type_infobuildvalue_fmtr  s   ``          rS   r  z$CythonArrayNode.generate_result_code-  s   0 0 0 0#';0 0 0"(n22>4HHn22>4HH.66MM%">">"@"@@55dEBB	<# 	JJ|dl&9&9&;&;;<<<JJ S T T TJJtt|'788999JJsOOO

KKII##K:::
 	 	 	
 	^4443c&kkA

KKNNIIf##K:::	
 	 	 	 	^444 	

8999

OO[[[##OTX>>>
 	 	 	 	

7

OO[[[
 	 	 	 	

8

KKMMMMKK???DIIIt|?R?R?T?T?T?T##DKKMM48<<<
 	 	 	
 	T"""	. 	. 	. 	. 	. 	##O44444rT   c                 r   |j         }|j        }t          |          }g }|j        r4|                    t          ||||                     |j        }|j        4t          |dd          |d         _        t          j
        |||          }t          ||||          }|                    |          }|S )z@
        Given a C array type, return a CythonArrayNode
        r-  rM  T)r   r  ry  )r  rj  )rj  r  ri  )r   r   r  rT  r   r  r  r]  r   r   MemoryViewSliceTypeNoder  r<  )	rQ   src_noderr   r   r  r  r  memslicenoder  s	            rS   r  zCythonArrayNode.from_carray.  s    
 lM	SMM	  	,KK	#YY,57 7 7 8 8 8!+I   	,  3TBBBR4StDMO O O \)1yJ J J%%c**rT   )rZ   r[   r\   r  r   rc  r   rq  ri  r   r^  ro  r<  r  r   rs  r  re  r  rV   rT   rS   r  r  <-  s         ( 8$HFGDK-Jh h hTG G G/ / /; ; ;
>5 >5 >5@   [  rT   r  c                   (    e Zd Zej        Zd Zd ZdS )
SizeofNodec                     dS r  rV   rW   s    rS   r=  zSizeofNode.check_const/.  rD  rT   c                     d S rM   rV   r  s     rS   r  zSizeofNode.generate_result_code2.  r   rT   N)rZ   r[   r\   r   r  r   r=  r  rV   rT   rS   r  r  *.  s<         #D      rT   r  c                   (    e Zd Zg ZdZd Zd Zd ZdS )r*  Nc                     	 | j
        ?| j                             |          }| j                            ||          \  }}	|	| _
        |                                  | S rM   )r  module_pathr-  r  r  r   r/  rp   SizeofVarNoder<  r+  r  rJ  
check_type)
rX   rr   r  r#  r  r  r   r  r  r+  s
             rS   r<  zSizeofTypeNode.analyse_types?.  s]    		 = ..s33I/11)SAAKAx$DMrT   c                     | j         }|sd S |j        r|j        st          | j        d           d S |j        rt          | j        d           d S |                                st          | j        d|z             d S d S )Nz Cannot take sizeof Python objectzCannot take sizeof voidz'Cannot take sizeof incomplete type '%s')r+  ro   r  r   r   r  is_complete)rX   r+  s     rS   r  zSizeofTypeNode.check_typeS.  s    = 	F 	R(B 	R$(>????? 	R$(566666%%'' 	R$(EPQQQQQ	R 	RrT   c                     | j         j        r| j                             dd          }n| j                                         }d|z  S )Nr  r+   )deref(sizeof(%s)))r+  r  r   r  )rX   r  s     rS   r  z$SizeofTypeNode.calculate_result_code^.  sK    =* 	> }55b5BBHH};;==H((rT   )rZ   r[   r\   r   r+  r<  r  r  rV   rT   rS   r*  r*  6.  sP         HH  (	R 	R 	R) ) ) ) )rT   r*  c                   &    e Zd ZdgZd Zd Zd ZdS )r  r  c                    | j                             |          }|r|| _        | j        j        rP	 | j                            |j                  | _        n*# t          $ r t          | j         j        d           Y nw xY wt          | _
        |                                  n| j                             |          | _         | S )NzLType cannot be specialized since it is not a fused argument to this function)r  re  r+  rg  ri  rh  r,   r   r   r*  rR   r  r<  )rX   rr   operand_as_types      rS   r<  zSizeofVarNode.analyse_typeso.  s     ,66s;; 	;+DM}% jj$(M$<$<S=R$S$SDMM' j j j$,*hj j j j jj ,DNOO<55c::DLs   $A $A=<A=c                 :    d| j                                         z  S )Nr  r  rW   s    rS   r  z#SizeofVarNode.calculate_result_code.  s     3 3 5 555rT   c                     d S rM   rV   r  s     rS   r  z"SizeofVarNode.generate_result_code.  r   rT   N)rZ   r[   r\   r   r<  r  r  rV   rT   rS   r  r  h.  sJ        
 {H  $6 6 6    rT   r  c                   H    e Zd ZdgZdZdZdZd ZdZd Z	d Z
d Zd	 Zd
 ZdS )
TypeidNoder  Nr+   c                     |}|j         s|j        }|j         |                    d| j                  }|                    d          }t          j        t          j        |j        d                    S )Nzlibcpp.typeinfor  T)rG  )	r  r  find_moduler   r-  r   r  r  r   )rX   rr   
env_moduletypeinfo_moduletypeinfo_entrys        rS   get_type_info_typezTypeidNode.get_type_info_type.  sx    
, 	0#/J , 	0$001BDHMM(//<<,Z-PQ_Qdos-t-t-tuuurT   ztypeid operatorc                    | j         st          j        | _         |                     |           |                     |          }|s|                     d           | S | j        | S || _         | j                            |          }|r|| _        d| _	        d | _        n| j        
                    |          | _        d| _	        d | _        | j        j         j        r|                     d           | S | j        j         j        r|                     d           | S | j        j                                         s$|                     d| j        j         z             | S |                    t          j        dd                     | S )	NzKThe 'libcpp.typeinfo' module must be cimported to use the typeid() operatorTFz$Cannot use typeid on a Python objectzCannot use typeid on voidz)Cannot use typeid on incomplete type '%s'r  r  )r   r   r2   r  r  r   r  rk  r+  r%  r<  ro   r  r  r   r   r   )rX   rr   r  as_types       rS   r<  zTypeidNode.analyse_types.  s{   y 	."-DIs++C00	 	JJdeeeK<K	,::3?? 	#DMDLDLL L66s;;DM DLDL}!- 

ABBB#+ 

6777]'3355 

FI[[\\\[45MO_``aaarT   c                 `    t          | j        |           t          j        | _        d| _        d S r;  r<  r=  s     rS   r   zTypeidNode.error.  r?  rT   c                     dS r  rV   rW   s    rS   r=  zTypeidNode.check_const.  rD  rT   c                     | j         S rM   r  rW   s    rS   r  z TypeidNode.calculate_result_code.  r  rT   c                     | j         r| j                                        }n| j                                        }t	          || j        | j        d|dd d | j                   d S )Nz
 = typeid(r  )r%  r+  r  r  r   r   r  r  )rX   r   r  s      rS   r  zTypeidNode.generate_result_code.  sr    < 	.};;==HH}++--Hdh"&...(((;$-	/ 	/ 	/ 	/ 	/rT   )rZ   r[   r\   r   r+  r  r   r  cpp_messager<  r   r=  r  r  rV   rT   rS   r  r  .  s         {HHKGv v v $K  @% % %
    / / / / /rT   r  c                   :    e Zd ZdZeZdgZd Zd Zd Z	d Z
d ZdS )
TypeofNodeNr  c                 $   | j                             |          | _         t          j        t	          | j         j                            }t          | j        |          }|                    |          }|                    |          | _	        | S )Nr  )
r  r<  r
   r0  rw   r   r  r   r   r  )rX   rr   r   r  s       rS   r<  zTypeofNode.analyse_types.  sw    |11#66,S1B-C-CDDdhe444'',,11#66rT   c                 X    | j                             |          | _         | j         j        S rM   )r  r<  r   r   s     rS   re  zTypeofNode.analyse_as_type.  s$    |11#66|  rT   c                     dS rw  rV   rW   s    rS   rA  zTypeofNode.may_be_none.  r  rT   c                 :    | j                             |           d S rM   )r  r  r  s     rS   r  z#TypeofNode.generate_evaluation_code.  s    --d33333rT   c                 4    | j                                         S rM   )r  r  rW   s    rS   r  z TypeofNode.calculate_result_code.  s    |11333rT   )rZ   r[   r\   r  r   r   r   r<  re  rA  r  r  rV   rT   rS   r  r  .  sr         GD{H  ! ! !  4 4 44 4 4 4 4rT   r  c                 Z    	 | j         }n# t          $ r
 |j        }Y nw xY w || |          S rM   )
__matmul__r   __rmatmul__)r  br  s      rS   matmul_operatorr  .  sF    	!<DD 	! 	! 	!=DDD	!tAqzzs   
 rK  <===r  >=rO  r
  is_notr   r  ///<<%r   r4  **c                 
    | |v S rM   rV   xseqs     rS   r1  r1  /  s
    c rT   c                 
    | |vS rM   rV   r  s     rS   r1  r1  /  s
    Qc\ rT   )>>r  ^@innot_inc                     t                               | j                  }|st          | j        d| j        z             |S )Nz4Binary '%s' not supported in compile-time expression)compile_time_binary_operatorsri   r   r   r   )r   r  s     rS   get_compile_time_binopr  /  sI    (,,T];;D !dhB- 	! 	! 	! KrT   c                        e Zd Zddg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 fdZd Zd Z xZS )	BinopNoder  r  Fc                 t    t           | j                 } || j        j        | j        j                  | _        d S rM   )r  r   r  r   r  r  s     rS   r%  z#BinopNode.calculate_constant_result6/  s8    ,T];#tM)M) +  +rT   c                     t          |           }| j                            |          }| j                            |          }	  |||          S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )r  r  r/  r  r=  r3  )rX   r.  r  r  r  r2  s         rS   r/  zBinopNode.compile_time_value</  s    %d++=33D99=33D99	-4(+++ 	- 	- 	-))!,,,,,,,,,	-s   A 
A;A66A;c                     |                      | j                            |          | j                            |          |          S rM   )ry  r  r   r  r   s     rS   r   zBinopNode.infer_typeE/  sD     8 8 = = $ 8 8 = =sD D 	DrT   c                     | j                             |          | _         | j                            |          | _        |                     |          S rM   )r  r<  r  r  r   s     rS   r<  zBinopNode.analyse_typesI/  sD    33C8833C88%%c***rT   c                 h   |                      |          rF|                     | j        j        | j        j        |          | _        | j        j        sJ d| _        n|                                 r|                     |           |                     | j        j        | j        j        |          | _        d| _        | j        j	        s*| j        t          c}| _        |                     ||          S n?|                                 r|                     |           n|                     |           | S r  )r  ry  r  r   r  r=   r   r  coerce_operands_to_pyobjectsro   r   r  r  r  r  )rX   rr   original_types      rS   r  zBinopNode.analyse_operationN/  s1   $$S)) 	*(();)-);SB BDI9,,,,DLL!!## 	*--c222(();)-);SB BDIDL9( :+/9n(ty~~mS999:
 ""$$ 	*&&s++++$$S)))rT   c                 V    |                      | j        j        | j        j                  S rM   )is_py_operation_typesr  r   r  rW   s    rS   r  zBinopNode.is_py_operationf/  s"    ))$-*<dm>PQQQrT   c                 :    |j         p|j         p|j        p|j        S rM   )ro   r1  rX   type1type2s      rS   r  zBinopNode.is_py_operation_typesi/  s!     [E$5[[EO[rT   c                 X    |                      | j        j        | j        j        |          S rM   )is_pythran_operation_typesr  r   r  r   s     rS   r  zBinopNode.is_pythran_operationl/  s%    ..t}/A4=CUWZ[[[rT   c                     t          |          o;t          |          ot          |          ot          |          pt          |          S rM   )rA   r<   r=   )rX   r  r  rr   s       rS   r  z$BinopNode.is_pythran_operation_typeso/  sQ    c"" B3E::i?bch?i?iB&&@/%*@*@	BrT   c                 F    | j         j        j        p| j        j        j        S rM   r  r   r  r  rW   s    rS   r  zBinopNode.is_cpp_operationu/  s"    "/ /}!.	0rT   c                    |                     | j        | j        | j        g          }|s|                                  d S |j        }|j        | _        |j        | _        | j        dk    r>d| _        t          |           r(|
                    t          j        dd                     |j        r|j        }t          |j                  dk    r1| j                            |j        d         j        |          | _        n`| j                            |j        d         j        |          | _        | j                            |j        d         j        |          | _        |j        | _        d S )Nr   r+   r  r  r   )r  r   r  r  r  r   r   r   r   r   r   r   r   r  r  r   r   r  r  )rX   rr   r   r  s       rS   r  zBinopNode.analyse_cpp_operationy/  sH   ##DMDM4=3QRR 	OOFJ	(8(83&& DL-d33 j$$[%<=UWg%h%hiii 	,!+Iy~!## M33IN14E4JCPPDMM M33IN14E4JCPPDM M33IN14E4JCPPDM)			rT   c                 ,   |                      |||          r#t          t          | j        ||                    S |                     ||          r|j        rt          j        }n|j        rt          j	        }|j        rt          j        }n|j        rt          j	        }|j
        s|j
        r2||u r|t          ur| j        dv r|S |                     ||          }||S t          S |j        s|j        rt          j        S |                     ||          S )Nz**%+|&^)r  rI   r?   r   r  r  r   r   r  r   r  r   infer_builtin_types_operationr   r  r   r2   compute_c_result_type)rX   r  r  rr   ry  s        rS   ry  zBinopNode.result_type/  s3   **5%== 	P1$-NNOOO%%eU33 	< -*' -, -*' -,$ '(= 'E>>e9&<&<R[A[A[ L"@@NN*&&!!^ 	<u~ 	<((--eU;;;rT   c                     d S rM   rV   r  s      rS   r  z'BinopNode.infer_builtin_types_operation/  rD  rT   c                 Z    |                                  r|                                  d S d S rM   r  r   s     rS   rs  zBinopNode.nogil_check/  r  rT   c                     | j                             |          | _         | j                            |          | _        d S rM   )r  r   r  r   s     rS   r  z&BinopNode.coerce_operands_to_pyobjects/  s4    88==88==rT   c                 f    | j                                         o| j                                        S rM   r  r=  r  rW   s    rS   r=  zBinopNode.check_const/  )    }((**Jt}/H/H/J/JJrT   c                     t                                                      p1| j                                        p| j                                        S rM   )rO   r   r  r  )rX   rR   s    rS   r   zBinopNode.is_ephemeral/  sJ    $$&& M**,,M040J0J0L0L	NrT   c                    | j         j        }| j        j        }| j        j        r>|                    d           |                    d|                                 z             | j        dk    rv|                    d|                                 d|                                 d| j                                         d| j                                        d	           d S |                    d|                                 d|                                 d	| j                                         d
| j        d
| j                                        d           d S |j        s|j        r| 	                    |          }| j        dk    rdnd}|j        r| j         
                                n| j                                         }|j        r| j        
                                n| j                                        }|                    |                                 d|d|d||d|                    |                                 | j                  
           |                     |           d S | j        r|                                 rz| j        dk    rot#          || j        |                                 d|                                 d| j        j        r|                                 nd | j        | j                   d S |                    |                                 d|                                 d           d S d S )Nz// Pythran binopr  r  r>  r?  z$){pythonic::numpy::functor::power{}(r  r  r@  r[  rA  z	, Py_Noner  r<  r;  r  r   r=  )r  r   r  r=   r   r  r   r  ro   r  r   r   r   r  r   r  r   r   r  r   r  )rX   r   r  r  r&  
extra_args
op1_result
op2_results           rS   r  zBinopNode.generate_result_code/  s`   ""9$ '	WJJ)***JJ3dkkmmCDDD}$$


KKMMMMKKMMMMM002222M002222	4 5 5 5 5 5 


KKMMMMKKMMMMM002222MMMM0022224 5 5 5 5 5  	W%"3 	W11$77H(,(=(=2J6;6Gc00222T]MaMaMcMcJ6;6Gc00222T]MaMaMcMcJJJKKMMMMHHJJJJJ++DKKMM48DDDFG G G   &&&&&\ 		W $$&& W4+?3+F+F'dh6:kkmmmmTE_E_EaEaEaEa(b9=9N(XTX(,(<d>SU U U U U
 

8R8R8T8T8T8TUVVVVV		W 		WrT   c           
          | j         j        j        sI| j        j        j        s8t	          | j        d| j        d| j         j        d| j        j        d           t          j        | _        d S )NzInvalid operand types for 'r  r  r  )	r  r   r  r  r   r   r   r   r2   rW   s    rS   r  zBinopNode.type_error/  ss    "+ 	)=%.	)$(( 2 2 2M&&&( ) ) ) )			rT   )rZ   r[   r\   r   rU	  r%  r/  r   r<  r  r  r  r  r  r  r  ry  r  rs  r  r=  r   r  r  r]   r^   s   @rS   r  r  &/  sr        J'HG+ + +- - -D D D+ + +
  0R R R\ \ \\ \ \B B B0 0 0* * *.< < <2    > > >K K KN N N N N*W *W *WX* * * * * * *rT   r  c                   &    e Zd Zd Zd Zd Zd ZdS )
CBinopNodec                     t                               | |          }|                                rt          j        |_        |S rM   )r  r<  r  r   r2   r   r>  s      rS   r<  zCBinopNode.analyse_types/  s:    &&tS11!! 	."-DIrT   c                     dS r  rV   r  s     rS   r  z CBinopNode.py_operation_function/  r  rT   c                     d| j                                         d| j        d| j                                        dS Nr;  r[  r  )r  r  r   r  rW   s    rS   r  z CBinopNode.calculate_result_code/  sE     M  """"MMMM  """"$ 	$rT   c                     d }|j         s|j        r|                    | j        |          }|)|j         s|j        r|                    | j        |          }|S rM   )r  r  r  r   )rX   r  r  r  s       rS   r  z CBinopNode.compute_c_result_type0  se     	K 	K44T]EJJH!3u|44T]EJJHrT   N)rZ   r[   r\   r<  r  r  r  rV   rT   rS   r  r  /  sP            $ $ $    rT   r  c                       fd}|S )Nc                 "    t          | fdi|S )Nr   )r  )r   r  r   s     rS   make_binop_nodez,c_binop_constructor.<locals>.make_binop_node0  s    #===H===rT   rV   )r   r  s   ` rS   c_binop_constructorr  0  s"    > > > > >rT   c                        e Zd ZdZdZdZd Zd Zd Z fdZ	d Z
d	 Z fd
Zd Zd Zd ZddddddddddddddZddddd Z xZS )!NumBinopNodeTFNc                 Z   | j         j        }| j        j        }|                     ||          | _        | j        s|                                  d S | j        j        rd| _        | j        j        r|j        d         r| j	        | j
        v r| j	        dv rK| j                                         r2| j                                        s| j        | j         c| _         | _        d| _        |j        d         | _        | j                            | j
        | j	                 || j                                                  | _        d| _        | j        r|j        rS|j        rN| j                             | j        |          | _         | j                            | j        |          | _        d S d S d S )NFr  )r   r   Tzoverflowcheck.fold)	const_rhs)r  r   r  r  r  r  r  r  rj   r   overflow_op_namesr   overflow_checkoverflow_foldoverflow_check_binopr  r   r  r  rX   rr   r  r  s       rS   r  z NumBinopNode.analyse_c_operation0  s   ""..ue<<	y 	OOF9 	DJI 	 N?3	 MT%;;;++99;; , M==?? , 04}dm,t}"&D!$0D!ED	66&t}5 M==?? 7 A ADI  DLz 	De. 	D53C 	D M33DIsCCDM M33DIsCCDMMM	D 	D 	D 	DrT   c                     |                      ||          rZt          j        ||          }|t          j        u r| j        dvrt          j        }nt          j        |t          j                  }|S d S )Nz|^&)c_types_okayr   r  r)  r   r  rX   r  r  widest_types       rS   r  z"NumBinopNode.compute_c_result_type20  su    UE** 	$8FFKj444=--","7K(<!68 84rT   c                 d    |j         rt          j        ||          S t          j        ||          S rM   )r  r    result_type_of_builtin_operationr  s      rS   r  z*NumBinopNode.infer_builtin_types_operation@0  s4      	M>ueLLL>ueLLLrT   c                     | j         r| j         j        rdS | j        j         }| j        j         }|r|j        r|r	|j        rdS t	                                                      S rw  )r   r  r  r  rO   rA  rX   r  r  rR   s      rS   rA  zNumBinopNode.may_be_noneF0  sr    9 	2 	5"" 	U* 	u 	9N 	 5ww""$$$rT   c                     | j                                         }| j                                        }|r|rd|d| j        d|dS d S r   )r  r#  r  r   )rX   value1value2s      rS   r#  z'NumBinopNode.get_constant_c_result_codeS0  s\    99;;99;; 	f 	 	#)664===&&&AA4rT   c                 :    |j         s|j        o|j         p|j        S rM   )r  r(  r  s      rS   r  zNumBinopNode.c_types_okay[0  s&     1EM 4!2U]	4rT   c                 .   | j         rO| | _        |j                            t          j        d          | _        |                    d| j        z             t                      	                    |           | j         r|                    d| j        z             |                    d           |                    |
                    | j                             |                    d           |j                            | j                   d S d S )NFr  r  ru  z8PyErr_SetString(PyExc_OverflowError, "value too large");r   )r  overflow_bit_noder  r  r   r  overflow_bitr   rO   r  r   r   r  rb  s     rS   r  z%NumBinopNode.generate_evaluation_code`0  s     	6%)D" $ < <Z=R_d < e eDJJy4#44555((... 	;JJ,t/@@AAAJJQRRRJJttx00111JJsOOON''(9:::::	; 	;rT   c                    | j         K| j        d| j                                        d| j                                        d| j         j        dS | j        j        s| j        rt          | j                  r3| j        
                                | j        
                                }}n2| j                                        | j                                        }}d|d| j        d|dS | j                            | j                  }|%t          | j        d| j        d| j                   |d| j                                        d| j                                        dS )Nr;  r  r  r  r[  zbinary operator z not supported for )r  r  r  r  r  r  r   r  r  r=   r  r   	binary_opr   r   )rX   result1result2r  s       rS   r  z"NumBinopNode.calculate_result_codem0  so   !-			$$&&&&$$&&&&&333	5 5
 Y# 	(tz 	(ty)) R#'=#?#?#A#A4=C_C_CaCa#'=#7#7#9#94=;O;O;Q;Q#*77DMMM777CC9&&t}55D|dhhT]]]\`\e\e fggg$$&&&&$$&&&&( (rT   c                 V    |j         p"|j         pt                              | ||          S rM   )rD  r  r  r  s      rS   r  z"NumBinopNode.is_py_operation_types0  s5    % D%D//eUCC	ErT   c                 d    | j         | j                 }| j        r|                    dd          }|S )N	PyNumber_PyNumber_InPlace)py_functionsr   rU	  r  )rX   r   r  s      rS   r  z"NumBinopNode.py_operation_function0  s8    )$-8< 	S)11+?QRRMrT   PyNumber_OrPyNumber_XorPyNumber_AndPyNumber_LshiftPyNumber_RshiftPyNumber_AddPyNumber_SubtractPyNumber_Multiply__Pyx_PyNumber_MatrixMultiply__Pyx_PyNumber_DividePyNumber_FloorDividePyNumber_RemainderPyNumber_Power)r4  r  r  r  r  r   r  r   r  r  r  r  r  r  r  mullshift)r   r  r   r  )rZ   r[   r\   r  r  r  r  r  r  rA  r#  r  r  r  r  r  r&  r
  r]   r^   s   @rS   r  r  0  s,        END D D6  M M M% % % % %  4 4 4
; ; ; ; ;( ( (,E E E
   """%%"''3+*($ L" 	 rT   r  c                       e Zd Zd ZdS )IntBinopNodec                 :    |j         s|j        o|j         p|j        S rM   )r  r(  r  s      rS   r  zIntBinopNode.c_types_okay0  s$    - 0.	0rT   N)rZ   r[   r\   r  rV   rT   rS   r7  r7  0  s#        0 0 0 0 0rT   r7  c                        e Zd Zd Zd Zd ZdS )BitwiseOrNodec                 <    | j         j        s| j        j        rdgS d S r  )r  r  r  r   s     rS   r  z(BitwiseOrNode.analyse_pytyping_modifiers0  s.    =  	'DM$9 	'%&&	' 	'rT   c                 .   |                     d          5  |                    |          }ddd           n# 1 swxY w Y   |sdS |                                s:|j        r|                                s|j        S t          |j        d|            |S )z=Analyse annotations in form `[...] | None` and `None | [...]`FNz)'[...] | None' cannot be applied to type )new_c_type_contextre  can_be_optionalr  rC  r   r   )rX   rr   operand_nodettypes       rS   _analyse_bitwise_or_nonez&BitwiseOrNode._analyse_bitwise_or_none0  s    ##E** 	6 	6 0055E	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	4$$&& 	] $ ]\-M-M-O-O ],,l&([TY([([\\\s   8<<c                     | j         j        r|                     || j                  S | j        j        r|                     || j                   S d S rM   )r  r  rA  r  r   s     rS   re  zBitwiseOrNode.analyse_as_type0  sS    =  	E00dmDDD]" 	E00dmDDDtrT   N)rZ   r[   r\   r  rA  re  rV   rT   rS   r:  r:  0  sA        ' ' '      rT   r:  c                   4     e Zd Zd Z fdZd Z fdZ xZS )AddNodec                 v    |j         r|j         s|j        r	|j        rdS t                              | ||          S r  )r  r  r  r  r  s      rS   r  zAddNode.is_py_operation_types0  sJ    ? 	Ju 	J%2H 	JUMc 	J155dE5IIIrT   c                     t           t          t          f}||v r@||v r<|t          |                    |          |                    |                             S t                                          ||          S rM   )r   r    r   re  r[  rO   r  )rX   r  r  string_typesrR   s       rS   r  z%AddNode.infer_builtin_types_operation0  s|     #NLAL  Ul%:%:L$6$6u$=$=$0$6$6u$=$=!? !? @ @ww44UEBBBrT   c                     |j         s|j        r|j        s|j        r|S |j         s|j        r|j        s|j        r|S t                              | ||          S rM   )r  rT  r  r(  r  r  r  s      rS   r  zAddNode.compute_c_result_type0  su    L 	$EN 	$ 	$ 	$Ll 	$en 	$5< 	$5= 	$L55eU$ $ $rT   c                    | j         j        | j        j        }}d }|t          u s	|t          u r|t          u r|t          u rd}n9t	          | j         t
                    st	          | j        t
                    rd}nd}|rO| j        s| j                                         r-|j        	                    t          j        dd                     d}|r^| j        s| j                                         r|dz  }| j                                         s| j                                        r|dz  }|S t                                          |          S )NTFUnicodeConcatInPlacer  __Pyx_PyUnicode_ConcatInPlaceSafe)r  r   r  r   r~   r  rU	  r  r   r   r   r   rA  rO   r  )rX   r   r  r  r  is_unicode_concatrR   s         rS   r  zAddNode.py_operation_function0  sh   })4=+=uL  E\$9$9$$,)>)>$(!!DM+=>> **T]\nBoBo *$(!! %*!  0< ]4=#?#?#A#A ]$55#/0FHZ[[] ] ]/ 	| "t};;== "	!}((** dm.G.G.I.I Kww,,T222rT   )rZ   r[   r\   r  r  r  r  r]   r^   s   @rS   rD  rD  0  sw        J J JC C C C C$ $ $3 3 3 3 3 3 3 3 3rT   rD  c                       e Zd Zd ZdS )SubNodec                     |j         s|j        r|j        s|j        r|S |j         s|j        r|j         s|j        rt          j        S t                              | ||          S rM   )r  rT  r  r(  r   c_ptrdiff_t_typer  r  r  s      rS   r  zSubNode.compute_c_result_type
1  sy    L 	$EN 	$ 	$ 	$Ll 	$en 	$5< 	$5> 	$..55eU$ $ $rT   N)rZ   r[   r\   r  rV   rT   rS   rP  rP  1  s#        $ $ $ $ $rT   rP  c                   h     e Zd ZdZd Zed             Zd Zd Z fdZ	 fdZ
 fdZ fd	Z xZS )
MulNodeFc                 :   | j                             |          | _         | j                            |          | _        |                                 | _        | j        r| j         }| j        }|j        r|j        |                     |||          S |j        r|j        |                     |||          S |j        t          v r|
                    |          | _        n(|j        t          v r|
                    |          | _         |                     |          S rM   )r  r<  r  calculate_is_sequence_mulis_sequence_mulr   r   analyse_sequence_mulr   r#   r5  r  rX   rr   r  r  s       rS   r<  zMulNode.analyse_types1  s   33C8833C88#==??  
	>}H}H/ >H4H4P00hIII1 >h6J6R00hIII"888 ( 8 8 = ="888 ( 8 8 = =%%c***rT   c                 4    | j         o| t          v o| t          uS rM   )r  r#   r"   r  s    rS   is_builtin_seqmul_typezMulNode.is_builtin_seqmul_type,1  s!    #f0F(Ff4WfKffrT   c                     | j         j        }| j        j        }|t          j        u s|j        r||}}|t          j        u s|j        r'|j        s|j        rdS |                     |          rdS dS r  )	r  r   r  r   r  r  r  r1  r[  r  s      rS   rV  z!MulNode.calculate_is_sequence_mul01  s    ""G$$$$ %5EG$$$$ %/ t**511 turT   c                     |j         J |                    |          }|                    |          |_         |                    |          S rM   )r   r   r5  r<  )rX   rr   r  mults       rS   rX  zMulNode.analyse_sequence_mul=1  sL    &&&$$S))..s33  %%%rT   c                    | j         rc| j        j        j        r | j                            |          | _        n0| j        j        j        r| j                            |          | _        d S t                                          |           d S rM   )rW  r  r   r1  r   r  rO   r  r  s     rS   r  z$MulNode.coerce_operands_to_pyobjectsC1  s     	}!+ F $ @ @ E E#- F $ @ @ E EF,,S11111rT   c                 V    | j         p!t                                          ||          S rM   )rW  rO   r  r  s      rS   r  zMulNode.is_py_operation_typesM1  s%    #Ruww'D'DUE'R'RRrT   c                     | j         rB|j                            t          j        dd                     | j        j        j        rdndS t                      	                    |          S )Nr	  r  __Pyx_PySequence_Multiply__Pyx_PySequence_Multiply_Left)
rW  r   r   r   r   r  r   ro   rO   r  rb  s     rS   r  zMulNode.py_operation_functionP1  sq     	w--'(<>PQQS S S26-2D2Pv..Vvvww,,T222rT   c                     |j         r5|j         r.|                     |          r|S |                     |          r|S |j        r|S |j        r|S t                                          ||          S rM   )r  r[  r  rO   r  r  s      rS   r  z%MulNode.infer_builtin_types_operationW1  s       	U%: 	**511 **511  < 	L< 	Lww44UEBBBrT   )rZ   r[   r\   rW  r<  r  r[  rV  rX  r  r  r  r  r]   r^   s   @rS   rT  rT  1  s        O+ + +( g g \g  & & &2 2 2 2 2S S S S S3 3 3 3 3C C C C C C C C CrT   rT  c                   *     e Zd Zd Zd Z fdZ xZS )MatMultNodec                     dS r  rV   r  s      rS   r  z!MatMultNode.is_py_operation_typesk1  rD  rT   c                     d S rM   rV   r  s      rS   r  z)MatMultNode.infer_builtin_types_operationn1  r	  rT   c                     |j                             t          j        dd                     t	                                          |           d S )NMatrixMultiplyr  )r   r   r   r   rO   r  rb  s     rS   r  z$MatMultNode.generate_evaluation_coder1  sG    ))+*ABRTf*g*ghhh((.....rT   )rZ   r[   r\   r  r  r  r]   r^   s   @rS   rf  rf  h1  sV            / / / / / / / / /rT   rf  c                   t     e Zd ZdZdZdZdZdZd Zd Z	d Z
d Zd Z fdZd	 Zd
 Zd Zd Zd Zd Z xZS )DivNodeNFc                     t           | j                 }| j        dk    r>| j        7t          |t                    r"t          |t                    rt           d         }|S )Nr  r  )r  r   truedivisionr~   r   rX   op1op2r  s       rS   !find_compile_time_binary_operatorz)DivNode.find_compile_time_binary_operator1  sU    ,T];=CD$5$=#s## ;
3(<(< ;4T:rT   c                     | j         j        }| j        j        }|                     ||          } |||          | _        d S rM   )r  r   r  rr  ro  s       rS   r%  z!DivNode.calculate_constant_result1  sC    m+m+55c3??#tC~~rT   c                 
   | j                             |          }| j                            |          }|                     ||          }	  |||          S # t          $ r }|                     |           Y d }~d S d }~ww xY wrM   )r  r/  r  rr  r=  r3  )rX   r.  r  r  r  r2  s         rS   r/  zDivNode.compile_time_value1  s    =33D99=33D9955hII	-4(+++ 	- 	- 	-))!,,,,,,,,,	-s   A 
B"A==Bc                 X    | j         s|j        d         r	d| _        d S | j        | _        d S )N	cdivisionF)rv  rj   ctruedivisionrn  r   s     rS   _check_truedivisionzDivNode._check_truedivision1  s9    > 	3S^K8 	3!&D!%!2DrT   c                     |                      |           |                     | j                            |          | j                            |          |          S rM   )rx  ry  r  r   r  r   s     rS   r   zDivNode.infer_type1  sV      %%%M$$S))M$$S))30 0 	0rT   c                 2   t                                          ||          }|q| j        dk    rf| j        s| j        rA|t
          j        u rt          j        S |j	        rt          j
        t          j        |          S n|t
          j        u s|j	        rd }|S Nr  )rO   r  r   rn  rw  r   r  r   r  r  r  )rX   r  r  ry  rR   s       rS   r  z%DivNode.infer_builtin_types_operation1  s    gg;;E5II"t}';';  #D$6 #'"222%33 ' a%9*:RT_```a 000K4F0"rT   c                    |                      |           t                              | |          }|                                 rd| _        | j        j        s| j        d u o7|j        d          o)| j        	                                 p| j        j
        dk    | _        | j        s|j        d         r>| j                            |          | _        | j                            |          | _        |S )NTrv  r   cdivision_warnings)rx  r  r  r  rv  r   ro   rj   r  r   r   zerodivision_checkr  rK  r5  s      rS   r  zDivNode.analyse_operation1  s      %%%//c::   "" 	"!DNy$ 	D$& 9s~k/J+J 9::<<< 8]2a7 # & D#.9M*N D $ > >s C C $ > >s C CrT   c                    | j         dk    rY| j        rR|j        sK|j        sD|j        s=|j        s6t	          j        |t          j                  }t	          j        ||          }|S t                              | ||          S r{  )	r   rw  r  r*  r   r  r  r  r  r  s       rS   r  zDivNode.compute_c_result_type1  s    =CD$6u?QZ_Zl> #%. #(<UJD\]](<UKPP""11$uEEErT   c                 "    | j         j        rdS dS )N"integer division or modulo by zerozfloat divisionr/  rW   s    rS   zero_division_messagezDivNode.zero_division_message1      9 	$77##rT   c                    | j         j        s| j         j        s| j        H|j        j        d         p0| j         j        p$| j         j        s| j         j        o| j         j	         | _        | j        sE|j        
                    t          j        dd                              | j                              t                              | |           |                     |           d S )Nrv  DivIntCMath.c)r   ro   r  rv  r   rj   r*  r  r(  r  r   r   r   ri  r  r  generate_div_warning_coder  s     rS   r  z DivNode.generate_evaluation_code1  s    y$ 		XTY-A 		X~%$/< ^y)^-B1B\DIL\H\ 
 > X 11+Hi@@KKDIVVX X X--dD999&&t,,,,,rT   c           	         | j         }| j        j        sd| j        r| j        s8| j                            d          d| j                                        d}nd| j                                        z  }|                    d|z             |r|	                                 |                    d| 
                                z             |r|                                 |                    |                    | j                             |                    d           | j        j        r| j        j        r|| j        dk    rp|j                            t'          j        d	d
                     | j        j        j        dk    rd| j                                        z  }nA| j        j                                        }d|d| j                                        d|d}|                    d| j                                        d|d| j                                        d           |r|	                                 |                    d           |r|                                 |                    |                    | j                             |                    d           |j        j        d         r| j        dk    r|j                            t'          j        dd                     |                    d| j                                        d| j                                        d           dt0          j        t0          j        dz  }|rd}|                    d |z             |	                                 |                    |                    | j        d!"                     |                    |d#|d$           |                                 n1|}|                    |                    | j        d!"                     |                    d%|z             |                    |j                   |                    d           d S d S d S d S )&Nzeror;  r  z%s == 0ru  z/PyErr_SetString(PyExc_ZeroDivisionError, "%s");r   r  UnaryNegOverflowsr  r6   zunlikely(%s == -1)z(!(((z)-1) > 0)) && unlikely(z == (z)-1)zelse if (sizeof(z) == sizeof(long) && z-  && unlikely(__Pyx_UNARY_NEG_WOULD_OVERFLOW(rM  zLPyErr_SetString(PyExc_OverflowError, "value too large to perform division");r}  r  CDivisionWarningr  rL  z	 < 0) ^ (z	 < 0))) {z1__Pyx_cdivision_warning(%(FILENAME)s, %(LINENO)s))FILENAMELINENOr  zint %s;T)r  r<  r=  zif (unlikely(%s)) )r  r   ro   r~  r  r  r  r  r   r   r  r   r   r   r  r  r   r   r   r   r   r  r  rj   r   filename_cnamelineno_cnameset_error_infor  r  r  )rX   r   in_nogil	zero_testminus1_checktype_of_op2warning_coder  s           rS   r  z!DivNode.generate_div_warning_code1  s{   (y$ ;	 & !$z C,0I,>,>v,F,F,F,FH\H\H^H^H^H^ _II )DM,@,@,B,B BI

09<=== *'')))

LtOiOiOkOkklll 300222

4??4844555

39# $	(8 $T]c=Q=Q$55k6MNaco6p6pqqq})0A55';dm>R>R>T>T'T&*m&8&O&O&Q&Q'KK)=)=)?)?)?)?(NJJJ#y??AAAA+||#}335555	 7 8 8 8
   .++---JJmnnn 744666JJttx88999JJsOOO*+?@  T]VYEYEY 11+,>	JJL L L


 $ 4 4 6 6 6 6 $ 4 4 6 6 6 68 9 9 9  S & 5%2V V  
  	I"*KJJy;6777'')))JJt2248$2GGHHHJJ[[[,,,GHHH002222".KJJt2248$2GGHHH-;<<<d.///

3w;	  ;	 F   EYEYrT   c           
         | j         j        s|                                 rt                              |           S | j                                        }| j                                        }| j         j        r| j	        dk    r	d| d| dS | j
        s| j        rn| j
        r^| j         | j        j         k    r| j                             |          }| j         | j        j         k    r| j                             |          }d| d| dS | j                                        }d| j                                          d| d| dt          |          dd	S )	Nr  zfloor(z / r  r;  
__Pyx_div_r  r  )r   r  r  r  r  r  r  r  r*  r   rn  rv  r   r   specialization_namerH  rX   rp  rq  b_is_constants       rS   r  zDivNode.calculate_result_code!2  sn   9 	<4#8#8#:#: 	<55d;;;m""$$m""$$9 	i$-4"7"7*C**C**** 		i$. 		i  39 222)--c22C9 222)--c22C%s%%s%%%% M==??Mh	 = = ? ?hh#hhhhPTUbPcPchhhhhrT   )rZ   r[   r\   rv  rn  rw  r}  r~  rr  r%  r/  rx  r   r  r  r  r  r  r  r  r]   r^   s   @rS   rl  rl  w1  s        ILM  . . .- - -3 3 30 0 0      *F F F$ $ $- - -=  =  = ~i i i i i i irT   rl  s'   %(?:%|(?:\([^)]+\))?[-+#,0-9 ]*([a-z]))>      E   F   G   X   a   b   c   d   e   f   g   i   o   u   xc                   F     e Zd Zd Z fdZd Zd Zd Zd Z fdZ	 xZ
S )ModNodec                 V    |j         p"|j         pt                              | ||          S rM   )r  r  r  r  s      rS   r  zModNode.is_py_operation_typesG2  s3     J?J55dE5II	KrT   c                     |t           t          t          fv r)|j        s |j        r| j                                        s|S t                                          ||          S rM   )	r   r   r    r  ro   r  rA  rO   r  r  s      rS   r  z%ModNode.infer_builtin_types_operationL2  s^    \:~>>>$ E,= T]E^E^E`E` ww44UEBBBrT   c                 "    | j         j        rdS dS )Nr  zfloat divmod()r/  rW   s    rS   r  zModNode.zero_division_messageS2  r  rT   c                    t                               | |          }| j        j        sb| j        |j        d         p| j        j         | _        | j        s5| j        j        s)| j        j        st          | j
        d| j        z             |S )Nrv  z(mod operator not supported for type '%s')rl  r  r   ro   rv  rj   r  r  r*  r   r   r5  s      rS   r  zModNode.analyse_operationY2  s    **455 y$ 	X~%!$!<!TDIDT@T> X$)*: X49CU Xdh JTY VWWWrT   c                    | j         j        s| j        s| j         j        rF|j                            t          j        dd                              | j                              nQ|j                            t          j        dd                              | j         | j         j	                             t                              | |           |                     |           d S )NModIntr  ModFloat)math_h_modifier)r   ro   rv  r  r   r   r   r   ri  r  r  r  r  r  s     rS   r  z ModNode.generate_evaluation_codee2  s    y$ 	OT^ 	Oy O 11+Hi@@KKDIVVX X X X  11+J	BBMM	493L N N NO O O 	--dD999&&t,,,,,rT   c           
      d   | j                                         }| j                                        }| j        r+| j        j        rd| j        j         d| d| dS d| d| dS | j                                        }d| j                                         d| d| dt          |          dd	S )Nfmodr;  r  r  z % 
__Pyx_mod_r  )
r  r  r  rv  r   r*  r  r   r  rH  r  s       rS   r  zModNode.calculate_result_coder2  s    m""$$m""$$> 	iy! *Gdi7GG#GGGGGG)3))3)))) M==??Mh	 = = ? ?hh#hhhhPTUbPcPchhhhhrT   c                 @   | j         j        | j        j        }}|t          u r\| j                                         s?|j        r|                    |          s#|t          u rt          | j        t                    sdS dS t                                          |          S )N__Pyx_PyUnicode_FormatSafePyUnicode_Format)r  r   r  r   rA  r  r  r   r~   r  rO   r  )rX   r   r  r  rR   s       rS   r  zModNode.py_operation_function2  s    })4=+=uL  }((** *+*050@0@0G0G*^++Jt}N`4a4a+33))ww,,T222rT   )rZ   r[   r\   r  r  r  r  r  r  r  r]   r^   s   @rS   r  r  D2  s        K K K
C C C C C$ $ $
 
 
- - -i i i
3 
3 
3 
3 
3 
3 
3 
3 
3rT   r  c                   f     e Zd ZdZdZd Z fdZ fdZd Zd Z	 fdZ
d	 Z fd
Z fdZ xZS )PowNodeNFc                 <    | j         d S |j        d         | _         d S )Ncpow)is_cpowrj   r   s     rS   _check_cpowzPowNode._check_cpow2  s!    <#F~f-rT   c                 p    |                      |           t                                          |          S rM   )r  rO   r   r  s     rS   r   zPowNode.infer_type2  s/    ww!!#&&&rT   c                 p    |                      |           t                                          |          S rM   )r  rO   r<  r  s     rS   r<  zPowNode.analyse_types2  s/    ww$$S)))rT   c                     d S rM   rV   r  s      rS   r  z%PowNode.infer_builtin_types_operation2  r	  rT   c                    t                               | |           | j        j        r| j        j        j        rk| j                            | j        |          | _        | j                            | j        |          | _        | j        	                    d          | _
        d S t          | j        d           d| _
        d S | j        j        rd| j        j        z   | _
        d S | j        j        rd| j                                                            dd          z  | _
        |                    t%          j        dd	                              | j
        | j                                        | j        j        rd
pd                     d S | j        j        s1t          | j        d| j        j        d| j        j                   d S d S )Nr  z complex int powers not supportedr  powz__Pyx_pow_%sr[  r  IntPowr  r+   r   )r|  r   r  z+got unexpected types for C power operator: r  )r  r  r   r  rY  r*  r  r  r  r  pow_funcr   r   r  r  r  r  r   r   r   ri  r  r  r   s     rS   r  zPowNode.analyse_c_operation2  s   ((s3339 	Fy"+ * $ 7 7	3 G G $ 7 7	3 G G $	 3 3D 9 9dh BCCC )Y 	F!DI$==DMMMY 		F*TY-M-M-O-O-W-WX[]`-a-aaDM  ')<<GG"m99;;9+16Q H 8 89 9 9 9 9
 # 	F$((!]///1C1CE F F F F F	F 	FrT   c                    ddl m} d }| j                                        o| j        j        dk    p|j        o
|j        dk    }|j        pY| j                                        o@t          | j        j        |          o&t          | j        j                  | j        j        k    }d}| j
        rkt                                          ||          }| j                                        s/t          | j        j        t                    o| j        j        dk     }n|s|rt                                          ||          }| j                                        s|j        o|j        }|rd| _        nYt          | j        j        t                    o| j        j        dk     }n)|                     ||          rt          j        }d| _        |rt          j        |t          j                  }|S )Nr   )RealFT)numbersr  r  r   r   r  r  r  r~   r   r  rO   r  type_was_inferredr  r   r  r  r  )	rX   r  r  r  c_result_typeop1_is_definitely_positivetype2_is_intneeds_wideningrR   s	           rS   r  zPowNode.compute_c_result_type2  s         M--// 3-2&
 L.U\Q.	 	# | 
M--// Pt}4d;;P-..$-2OO 	
 < 	*!GG99%GGM=4466 t}<cBBht}GdghGh  ( 	*< 	*!GG99%GGM=4466 !&!>%,! 2-1D* t}<cBBht}GdghGh  ue,, 	* '8M%)D" 	d&:=*JbccMrT   c                 f      fd} j         d | j                  d | j                  dS )Nc                     j         | j         k    r|                                 S j                             |                                           S rM   )r   r  r   )r  rX   s    rS   r1   z/PowNode.calculate_result_code.<locals>.typecast2  sB    yGL((~~'''y**7>>+;+;<<<rT   r;  r  r  )r  r  r  )rX   r1   s   ` rS   r  zPowNode.calculate_result_code2  s[    	= 	= 	= 	= 	= MMMHT]####HT]####% 	%rT   c                 R   | j         j        rz| j        j        dk    rjt	          | j        j        t
                    rK| j        j         t          u r8|j        	                    t          j        dd                     | j        rdS dS t                                          |          S )Nr6   PyNumberPow2r	  __Pyx_PyNumber_InPlacePowerOf2__Pyx_PyNumber_PowerOf2)r   ro   r  r   r~   r   r  r   r   r   r   r   rU	  rO   r  rb  s     rS   r  zPowNode.py_operation_function2  s    I! 	1-224=8#>> 3"n44--k.EnVb.c.cddd| 17700ww,,T222rT   c                   	 || j         k    r| S | j        | j        r|j        s|j        r| j         t
          j        u r	d	fd		d}n|j        rd 	d}nd 	 	| j                  \  }} 	| j                  \  }}|rg|ret          | j
        d|z             d| _        || _        || _        |                     |          }|j         |k    r|                    ||          }|S t                                          ||          S )	NTc                     | j         j        s| j         j        rd| fS |r.t          | t                    r | j        d          | j        fS dS )NTF)recurserU  )r   r*  r  r~   r  rh  )r  r  check_typess     rS   r  z&PowNode.coerce_to.<locals>.check_types3  se    |, -0C -#W}, T:g7J#K#K T*{7;FFFSS&;rT   za non-complex C numeric typec                 &    | j         j        rd| fS dS )NTrU  r/  r  s    rS   r  z&PowNode.coerce_to.<locals>.check_types3  s     |* +#W},  +{rT   zan integer C numeric typec                     dS )NrU  rV   r  s    rS   r  z&PowNode.coerce_to.<locals>.check_types3  s    &;rT   zTreating '**' as if 'cython.cpow(True)' since it is directly assigned to a %s. This is likely to be fragile and we recommend setting 'cython.cpow' explicitly.r~  )r   r  r  r*  r  r   r  r  r  r   r   r<  r  rO   )rX   r  rr   
msg_detail	check_op1rp  	check_op2rq  r  r  rR   s            @rS   r  zPowNode.coerce_to2  sn   ty  KL T%; " !&.o ! yJ888' ' ' ' ' ' <

 
'+ + + 9

' ' '([77NIs([77NIs Y  #0 3=#= > > >  $ # #++C00;(**#--h<<Fww  3///rT   )rZ   r[   r\   r  r  r  r   r<  r  r  r  r  r  r  r]   r^   s   @rS   r  r  2  s         G. . .
' ' ' ' '* * * * *  F F F.( ( ( ( (T
% 
% 
%
3 
3 
3 
3 
3*0 *0 *0 *0 *0 *0 *0 *0 *0rT   r  c                       e Zd ZdZddg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S )BoolBinopNodeag  
    Short-circuiting boolean operation.

    Note that this node provides the same code generation method as
    BoolBinopResultNode to simplify expression nesting.

    operator  string                              "and"/"or"
    operand1  BoolBinopNode/BoolBinopResultNode   left operand
    operand2  BoolBinopNode/BoolBinopResultNode   right operand
    r  r  TNc                     | j                             |          }| j                            |          }t          j        ||          S rM   )r  r   r  r   independent_spanning_typer  s       rS   r   zBoolBinopNode.infer_type;3  s?    ((--((--3E5AAArT   c                     | j         dk    r| j                                        S | j                                        p| j                                        S )Nor)r   r  rA  r  rW   s    rS   rA  zBoolBinopNode.may_be_none@3  sJ    =D  =,,...=,,..M$-2K2K2M2MMrT   c                 t    | j         j        }| j        j        }| j        dk    r|o|| _        d S |p|| _        d S Nand)r  r   r  r   )rX   r  r  s      rS   r%  z'BoolBinopNode.calculate_constant_resultF3  sI    =0=0=E!!#+#8D   #+#7xD   rT   c                     | j                             |          }| j                            |          }| j        dk    r|o|S |p|S r  )r  r/  r  r   )rX   r.  r  r  s       rS   r/  z BoolBinopNode.compile_time_valueN3  sO    =33D99=33D99=E!!(('x'rT   c                 f    | j                                         p| j                                        S rM   )r  r   r  rW   s    rS   r   zBoolBinopNode.is_ephemeralV3  s)    }))++Kt}/I/I/K/KKrT   c                 "   | j                             |          }| j                            |          }t          j        |j        |j                  | _        |                     ||          | _         |                     ||          | _        | S rM   )r  r<  r  r   r  r   _wrap_operandrY  s       rS   r<  zBoolBinopNode.analyse_typesY3  s~     =..s33=..s338M8=* *	**8S99**8S99rT   c                 j    t          |t          t          f          st          || j        |          }|S rM   )r~   r  BoolBinopResultNoder   )rX   r  rr   s      rS   r  zBoolBinopNode._wrap_operande3  s3    'M3F#GHH 	C)'49cBBGrT   c                     |                      | j        |          | _        |                      | j        |          | _        dS )z
        Must get called by transforms that want to create a correct BoolBinopNode
        after the type analysis phase.
        N)r  r  r  r   s     rS   wrap_operandszBoolBinopNode.wrap_operandsj3  s:    
 **4=#>>**4=#>>rT   c                 B    |                      t          j        |          S rM   r  r   r)  r   s     rS   rG  zBoolBinopNode.coerce_to_booleanr3      ~~j4c:::rT   c                     | j                             ||          }| j                            ||          }t                              | || j        ||          S )N)r   r   r  r  )r  r  r  r  rO  r   )rX   r  rr   r  r  s        rS   r  zBoolBinopNode.coerce_tou3  s\    =**8S99=**8S99&&x] ' 2 2 	2rT   c           	      j   |                     | j                   ||f}| j        dk    r|                    d          x}	}n|                    d          x}	}| j                            |||||||	           |\  }}|                    |	           | j                            |||||||           d S )Nr  next_andnext_or)r  r   r   r  r  generate_bool_evaluation_coder  r  )
rX   r   final_result_tempfinal_result_type	and_labelor_label	end_labelfall_throughouter_labelsmy_labels
             rS   r  z+BoolBinopNode.generate_bool_evaluation_code}3  s    dh!8,=E!!#'>>*#=#==Hyy"&..";";;Hx33#%6	8YX`	b 	b 	b +	8x   33#%6	8YXd	f 	f 	f 	f 	frT   c           	      $   |                      |           | j        j        rt          j        n| j        }d x}}|                    d          }|                     ||                                 |||||           |                    |           d S )Nbool_binop_done)	r  r   ro   r   r   r  r  r  r  )rX   r   ry  r  r  r  s         rS   r  z&BoolBinopNode.generate_evaluation_code3  s    !!$'''3793HWj//di##9NN#455	**4YX`bkmvwwwy!!!!!rT   Truth-testing Python objectc                 f    | j                                         o| j                                        S rM   r  rW   s    rS   r=  zBoolBinopNode.check_const3  r  rT   c                     d S rM   rV   r  s     rS   r  z,BoolBinopNode.generate_subexpr_disposal_code3  r   rT   c                     d S rM   rV   r  s     rS   r  z BoolBinopNode.free_subexpr_temps3  r   rT   c           
      P   | j         j        rt|j                            t          j        d          }|                    |d| j                                        d|	                    || j
                             n| j                                        }|| j         j        fS NFr  rG  r  )r   ro   r  r  r   r)  r   r  r   r  r   r  rX   r   test_results      rS   generate_operand1_testz$BoolBinopNode.generate_operand1_test3  s    9  		1.66&5 7 : :KJJKKM++----**;AAACD D D D -..00KTY233rT   )rZ   r[   r\   r  r   r   r   r  r  r   rA  r%  r/  r   r<  r  r  rG  r  r  r  r  r=  r  r  r
  rV   rT   rS   r  r  *3  sD       	 	 J'HGHHHB B B
N N N8 8 8( ( (L L L
 
 
  
? ? ?; ; ;2 2 2f f f"" " " 0KK K K    4 4 4 4 4rT   r  c                   Z     e Zd ZdZddgZdZdZdZ fdZd Z	d Z
d	 Zd
 Zd Zd Z xZS )r  a  
    Intermediate result of a short-circuiting and/or expression.
    Tests the result for 'truthiness' and takes care of coercing the final result
    of the overall expression to the target type.

    Note that this node provides the same code generation method as
    BoolBinopNode to simplify expression nesting.

    arg     ExprNode    the argument to test
    value   ExprNode    the coerced result value node
    rh  r   TNc           	          |                     |          }t          |          }t                                          |j        ||t          |                              ||                     d S )N)rh  r   r   )rK  	ProxyNoderO   rl  r   r  r  )rX   rh  ry  rr   rR   s       rS   rl  zBoolBinopResultNode.__init__3  sn    ""3''nnG;C..**;<< 	 	> 	> 	> 	> 	>rT   c                 B    |                      t          j        |          S rM   r  r   s     rS   rG  z%BoolBinopResultNode.coerce_to_boolean3  r  rT   c                     | j         j         }|t          j        u r|                    |          }t	          |||          S rM   )rh  r   r)  rG  r  )rX   r  rr   rh  s       rS   r  zBoolBinopResultNode.coerce_to3  s>    hlz---'',,C"3#666rT   c                     d S rM   rV   r   s     rS   rs  zBoolBinopResultNode.nogil_check3  r  rT   c           
      d   | j         j        j        rt|j                            t
          j        d          }|                    |d| j                                         d|	                    || j
                             n| j                                         }|| j         j        j        fS r  )rh  r   ro   r  r  r   r)  r   r   r  r   r  r  s      rS   generate_operand_testz)BoolBinopResultNode.generate_operand_test3  s    8=$ 		,.66&5 7 : :KJJKKH&&((((**;AAACD D D D (//++KTX]677rT   c                    |                     | j                   | j                            |           |s|r|                     |          \  }}	|	r|r|r| j                            |           |rdnd}
|                    d|
|d           |	r|j                            |           |	r|r|s| j                            |           |r||k    r|	                    |           |rN|r1|                    d           |	s| j                            |           ||k    r|	                    |           |r|s|s|r|                    d           | j
                            |           | j
                            |           |                    |d| j
                            |          d           | j
                            |           | j                            |           | j
                            |           ||k    r|	                    |           |s|r|                    d           | j                            |           d S )	Nr  r  r  z) {r  r<  r=  r   )r  r   rh  r  r  r  r   r  r  r  r   r  r  r  r  )rX   r   r  r  r  r  r  r  r	  	uses_tempsenses              rS   r  z1BoolBinopResultNode.generate_bool_evaluation_code3  s   dh 	))$/// 	- 	-%)%?%?%E%E"K 6i 6H 6 //555#+CCEJJJ{{{;<<< 9++K888 6Y 68 6//555 (H44h''' - >JJz***$ >77===,,MM),,, 	) 	) 'H '

:&&&J//555J++D111JJ%6%6%6
8L8LM^8_8_8_8_`aaaJ44T:::H++D111J!!$'''L((i((( 	 	JJsOOOD!!!!!rT   c                     | S rM   rV   r   s     rS   r<  z!BoolBinopResultNode.analyse_types4  r  rT   )rZ   r[   r\   r  r   r   rh  r   rl  rG  r  rs  r  r  r<  r]   r^   s   @rS   r  r  3  s        
 
 wHG
CE> > > > >; ; ;7 7 7  8 8 85" 5" 5"n      rT   r  c                        e Zd ZdZdZdZg dZd Zd Zd Z	d Z
d Zd	 Z fd
Z fdZd Zd Zd Zd Zd Zd Z xZS )r  NT)r  r  r  c                 l    | j                             |          | j                            |          z   S rM   )r  rO  r  r   s     rS   rO  zCondExprNode.type_dependencies04  s.    }..s33dn6V6VWZ6[6[[[rT   c                     t          j        | j                            |          | j                            |                    S rM   )r   r  r  r   r  r   s     rS   r   zCondExprNode.infer_type34  s=    3M$$S))N%%c**, , 	,rT   c                 f    | j         j        r| j        j        | _        d S | j        j        | _        d S rM   )r  r   r  r  rW   s    rS   r%  z&CondExprNode.calculate_constant_result84  s6    9$ 	B#'=#@D   #'>#AD   rT   c                 f    | j                                         p| j                                        S rM   )r  r   r  rW   s    rS   r   zCondExprNode.is_ephemeral>4  s)    }))++Lt~/J/J/L/LLrT   c                     | j                             |          | _         | j                            |          | _        | j                            |          | _        |                     |          S rM   )r  rL  r  r<  r  r  r   s     rS   r<  zCondExprNode.analyse_typesA4  s[    I==cBB	33C8855c::'',,,rT   c                    | j         j        }| j        j        }t          j        ||          | _        | j        j        r#t          j        | j        j                  | _        | j        j        rt          | _
        nr| j        j        rf| j                                         rt          | j         j        d           | j                                        rt          | j        j        d           |j        s|j        s| j        j        r`|| j        k    r%| j                             | j        |          | _         || j        k    r%| j                            | j        |          | _        | j        j        r|                                  | S )NzPUnsafe C derivative of temporary Python reference used in conditional expression)r  r   r  r   r  r	  r  r  ro   r   r!  r  r   r   r   r  r  r  )rX   rr   true_val_typefalse_val_types       rS   r  z CondExprNode.analyse_result_typeG4  sf   *,8WW	9! 	O"5di6MNNDI9  	~ .DY 	~}))++ }dm'){|||~**,, ~dn(*|}}}$ 	J(B 	JdiF[ 	J	)) $ 7 7	3 G G**!%!9!9$)S!I!I9 	OOrT   c                    | j         j        j        s| j                             |          | _         | j        j        j        s| j                            |          | _        d | _        |                     |          }|j        j        sB|| u r)t          t          |                              |          }n|                    |          }|S rM   )	r  r   r  r5  r  r!  r  rO   r  )rX   rr   outrR   s      rS   r5  zCondExprNode.coerce_to_index`4  s    }!( 	? M99#>>DM~") 	A!^;;C@@DN &&s++x 	/d{{L#..>>sCC ))#..
rT   c                    | j         j        |k    r | j                             ||          | _         | j        j        |k    r | j                            ||          | _        d | _        |                     |          }|j        |k    rD|| u r*t          t          |                              ||          }n|                    ||          }|S rM   )r  r   r  r  r!  r  rO   r  )rX   r  rr   r!  rR   s       rS   r  zCondExprNode.coerce_toq4  s    =)) M33HcBBDM>(**!^55hDDDN &&s++8xd{{L#..883GG mmHc22
rT   c                     | j         j        j        sA| j        j        j        s0t	          | j        d| j         j        d| j        j        d           t          j        | _        d S )Nz.Incompatible types in conditional expression (r  r  )r  r   r  r  r   r   r   r2   rW   s    rS   r  zCondExprNode.type_error4  sg    "+ 	;t~/B/K 	;$((###T^%8%8%8: ; ; ;)			rT   c                     | j                                         o1| j                                        o| j                                        S rM   )r  r=  r  r  rW   s    rS   r=  zCondExprNode.check_const4  sD    	%%'' -))++-**,,	.rT   c                    |                     | j                   |                     |           | j                            |           |                    d| j                                        z             |                     || j                   |                    d           |                     || j	                   |                    d           | j        
                    |           | j                            |           d S )NrB  r  r   )r  r   r  r  r  r   r  eval_and_getr  r  r  r  r  s     rS   r  z%CondExprNode.generate_evaluation_code4  s     	dh!!$'''	**4000

;!1!1!3!33444$...

:$///

3	((...	T"""""rT   c                    |                     |           | j        j        r|                    |           n|                    |           |                    |                                 d|                    |                                           d           |	                    |           |
                    |           d S r{  )r  r   r   r  r  r   r  r  r  r  r  )rX   r   r)  s      rS   r&  zCondExprNode.eval_and_get4  s    %%d+++9' 	,++D1111%%d+++

tzz||0L0L0L0LMNNN**4000rT   c                     d S rM   rV   r  s     rS   r  z+CondExprNode.generate_subexpr_disposal_code4  r   rT   c                     d S rM   rV   r  s     rS   r  zCondExprNode.free_subexpr_temps4  r   rT   )rZ   r[   r\   r  r  r   r   rO  r   r%  r   r<  r  r5  r  r  r=  r  r&  r  r  r]   r^   s   @rS   r  r  #4  s*        HIG000H\ \ \, , ,
B B BM M M- - -  2    "    "* * *. . .
# # #          rT   r  Py_LTPy_LEPy_EQPy_NEPy_GTPy_GE)	rK  r  r  r  z<>rO  r  r  r  c                   x    e Zd ZdZdZg 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dZd Zd ZdS )CmpNodeNc                     t           S rM   r/  r   s     rS   r   zCmpNode.infer_type4  r{
  rT   c                    t           | j                 }| j        j        }t	          |t
                    r7t	          |t
                    r"t          |          t          |          k    rd S | j        dv rt	          | j        t          t          t          f          r^| j        j
        s| j        dk    | _        d S t	          | j        t                    r%| j        s| j                                        | _        n8t	          | j        t                    r| j        j        s| j        dk    | _        d S  |||          | _        d S )Nr  r  r  )r  r   r  r   r~   any_string_typer   rB  r  r.
  r   cascader	  r  r  )rX   operand1_resultr  operand2_results       rS   "calculate_cascaded_constant_resultz*CmpNode.calculate_cascaded_constant_result4  s(   ,T];-788 	?O<<	_%%o)>)>>>F=,,,$-(Iw)GHH 
}) =+/=H+DD(Fx88 = =$(M$:$:$<$<DMDM844 }4 +/=H+DD(F#tO_EErT   c                    t          |           }| j                            |          }	  |||          }n.# t          $ r!}|                     |           d }Y d }~nd }~ww xY w|r!| j        }|r|o|                    ||          }|S rM   )r  r  r/  r=  r3  r6  cascaded_compile_time_value)rX   r  r.  r  r  r  r2  r6  s           rS   r;  z#CmpNode.cascaded_compile_time_value4  s    %d++=33D99	T(H--FF 	 	 	))!,,,FFFFFF	  	XlG XWG$G$GRV$W$Ws   8 
A#AA#c                 F    | j         j        j        p| j        j        j        S rM   r  rW   s    rS   is_cpp_comparisonzCmpNode.is_cpp_comparison4  s    }!.Q$-2D2QQrT   c                 &   |j         }|j         }d}d}|j        r|                                rd}|j        r|                                rd}|j        r|r|S n8|j        r|r|S n,|r*|r(t          j        ||fv rt          j        S t          j        S d S r@  )	r   r[  r=  r  r   r   r   r  r  )	rX   rr   r  r  r  r  r  type1_can_be_inttype2_can_be_ints	            rS   find_common_int_typezCmpNode.find_common_int_type4  s      % 	$(*M*M*O*O 	$#% 	$(*M*M*O*O 	$#< 	3 \ 	3  	3 3'E5>99%44%22trT   c                    | j         }|j        }|j        }d }|j        s|j        r|dvr9|j        s|j        r+|j        s|j        rt	          | j        d           t          }n|j        r3|                    t          j
                  rt          j
        nt          }n|j        r3|                    t          j
                  rt          j
        nt          }n[t          j        ||          }nE|j        r|j        rt          j        ||          }n!||j        s|                     ||||          }|4|j        s|j        r	t          }n||k    r|}n|j        s|j        r|j        s|j        r&|                    ||          rt          }nt          }n|j        s|j        r&|                    ||          rt          }nt          }nt          j        |          rt          j        |          rt          }nm|                     |||           t          }nN|                    |          r|}n6|                    |          r|}n|                     |||           t          }|j        r1t)          |t*                    st)          |t*                    rt,          }||j        r|}nt          j        ||          }| j        r"| j                            || j        ||          }|S )Nr  r  zcomplex types are unordered)r  r   r  r  r   r   r2   ro   r  r   r  r   r   r  rA  r1  r  r  r  invalid_types_errorr~   r  r   r  spanning_typer6  find_common_typer   )	rX   rr   r  r  common_typer  r  r  new_common_types	            rS   rF  zCmpNode.find_common_type
5  sA   =  	Uu/ 	U,&&) '-2-= ') '-2-= ' dh =>>>"," O:?:J:J7K_:`:`"t'"6"6ft" O:?:J:J7K_:`:`"t'"6"6ft","@"N"N 	U%"2 	U(<UEJJOO (? "77R8TTO" -%/ -"0%"'" -e&7 -# 1u 188DD 9*4*8% 
1 
188DD 9*4*8#3E:: 1~?]^c?d?d 1&4OO ,,Xr8DDD&0OO&&u-- -"'&&u-- -"' ((2x@@@",$ 	)*Xy*I*I 	)*4Xy*I*I	) )O /":)KK
 %2;PPK< 	c,77T]HVabbKrT   c           
      X    t          | j        d|d|j        d|j        d           d S )NInvalid types for 'r  r  r  )r   r   r   )rX   r  r  r  s       rS   rD  zCmpNode.invalid_types_errorW5  s@    dhhrr8===(---1 	2 	2 	2 	2 	2rT   c                     |                                   oQ|                                  o<|                                 p(| j        o| j                                        p| j        dv S Nr4  )is_ptr_containsis_c_string_containshas_python_operandsr6  is_python_comparisonr   rW   s    rS   rP  zCmpNode.is_python_comparison[5  sq    ((*** 7--///7))++ 6\Idl&G&G&I&I6M%55		8rT   c                     | j         }|j        |k    r|                    ||          | _         | j        r| j                            ||           d S d S rM   )r  r   r  r6  coerce_operands_to)rX   r  rr   r  s       rS   rR  zCmpNode.coerce_operands_tob5  s_    ==H$$$..x==DM< 	;L++Hc:::::	; 	;rT   c                     |                                  r<| j        d u r3| j        dvr*|                                  r|                                  p| j        o| j                                        S )N)r
  r  r  r  )rO  special_bool_cmp_functionr   rN  rM  r6  is_python_resultrW   s    rS   rU  zCmpNode.is_python_resulti5  s    ))++ ,/47,&FF, ..000, ))+++	B
 @!>!>!@!@	CrT   c                     | j         dv oX| j        j        j        r$| j        j        j        p| j        j        t          u p#| j        j        j        o| j        j        t          u S rL  )	r   r  r   r  r  r  r   rD  r   rW   s    rS   rN  zCmpNode.is_c_string_containsq5  sd    } 00 :#* Xm(2Vdm6HJ6V9#3 8]'<7		:rT   c                 \    | j         dv r"| j        j        }|j        s|j        o|j         S d S rL  )r   r  r   r  rT  r  )rX   container_types     rS   rM  zCmpNode.is_ptr_containsx5  sC    =,,,!]/N")D^-D 1&001 -,rT   Fc                    | j         dv r|j        | j        j        }}|s|j        r|j        r|t          j        u s|t          j        u r#t          j        dd          | _        d| _	        dS |t          j
        u s|t          j
        u r#t          j        dd          | _        d| _	        dS |rKdd	lm}  || j         d
k    rdnd| t          j        || j                  }|r|\  | _	        | _        | _        }dS nk| j         dv ra| j        j        t          j        u rB| j                            d          | _        t          j        dd          | _        d| _	        dS | j        j        t          j        u rB| j                            d          | _        t          j        dd          | _        d| _	        dS | j        j        t          j        u rB| j                            d          | _        t          j        dd          | _        d| _	        dS | j        j        j        s| j                            |          | _        t          j        dd          | _        d| _	        dS dS )NrC  UnicodeEqualsr  __Pyx_PyUnicode_EqualsTBytesEquals__Pyx_PyBytes_Equalsr+   )optimise_numeric_binopr  EqNer4  r  PyDictContainsr  __Pyx_PyDict_ContainsTFPySetContains__Pyx_PySet_ContainsTFPyUnicodeContains__Pyx_PyUnicode_ContainsTFPySequenceContains__Pyx_PySequence_ContainsTFF)r   r   r  r  r   r   r   r   special_bool_cmp_utility_coderT  r   Optimizer^  r   r)  special_bool_extra_argsr   rI  r   ro   r   )	rX   rr   r  result_is_boolr  r  r^  r  r  s	            rS   "find_special_bool_compare_functionz*CmpNode.find_special_bool_compare_function~5  s   =L((#=$-*<5E $%"7 $E<Q $G000EW=Q4Q4Q9D9PQ`bq9r9rD65MD24g000EW=O4O4O9D9PQ^`o9p9pD65KD24# $@@@@@@33 $ 5 54".  F  $ %7;5#t]...}!W%666 $ ? ?@c d d5@5LM]_q5r5r21J.t#w'777 $ ? ?@c d d5@5L_^p5q5q21I.t#w';;; $ ? ?@c d d5@5LM`bq5r5r21M.t})5 J$(M$D$DS$I$IDM5@5LMacu5v5v21N.turT   c                 V   | j         j        rF|j        }d|z  }| j        r0|j                            t          j        dd                     d}nd}n|j        }d}d}| j        r	|j         j        r|	                                }	n|
                                }	|j         j        r|	                                }
n|
                                }
d                    d | j        D                       }| j        r|j                            | j                   |                    |d	|d
| j        d
|	d|
d| j        r|nt          |         d| ||| j                             d S |j         j        r|dvr|dvs
J |            | j         j        s| j         t"          j        u sJ |                    |d| j         j        rdndd
|	                                d|	                                dt          |         d| ||| j                             d S |j         j        rl|                    |d	|d
|dk    rdpd|j                             d          d
|
                                d|
                                d           d S |j         }|j         }|j        s|j        r|                    |          st.          }n|j        rt#          j        ||          }n|}|                    |          }|                    |          }|d	|d
|d|                     |          d|d
}|                                 r>| j        dk    r3t=          || j        || j         j        r|nd | j        | j                    d S |                    |           d S )Nz__Pyx_XGOTREF(%s); PyBoolOrNullFromLongr  __Pyx_PyBoolOrNull_FromLong__Pyx_PyBool_FromLongr  r  c                 6    g | ]}|                                 S rV   r	  )rb   	extra_args     rS   r   z3CmpNode.generate_operation_code.<locals>.<listcomp>5  s1     8 8 8'0	  ""8 8 8rT   r<  r;  z)); )r
  r  r4  z = PyObject_RichCompareBoolr  r  r  eqr  r[  r  r   )!r   ro   r   rT  r   r   r   r   r  r   r  r  rk  ri  r   richcmp_constantsr   r   r)  r  r  r  r  r   r  r  r  
c_operatorr=  r   r   r   r  )rX   r   r  r  r  r  error_clausegot_refcoerce_resultr   r!  special_bool_extra_args_resultr  r  rG  code1code2	statements                     rS   rd	  zCmpNode.generate_operation_code5  s   9  	2L+k9G- 8 11+,BDVWWY Y Y = 71LGM) H	&}( ,",,.."//++}( ,",,.."//++-1YY 8 8484P8 8 8 . .* 1 V 11$2TUUUJJKK!MM222GGWWW6:6Rm22XijlXmmmG Ldh7779: : : : : ]& 0	&25E+E+E----r---9(ODI9O,O,O,O,OJJKK)/;BBV;;&&((((&&((((%b)))G Ldh7779 : : : : : ]% $	&JJd
"s(b(&&t,,,,!!!!!!!!# $ $ $ $ $ MEME' $5+B $!MM%00$,! $(<UEJJ#&&{33E&&{33E####I %%'' 	&D,@C,G,G'H#'9#8BKKd()+ + + + + 

9%%%%%rT   c                 &    |dk    rdS |dk    rdS |S )Nr
  r  r  r  rV   )rX   r  s     rS   rw  zCmpNode.c_operator6  s#    ::48^^4IrT   rM   rR  )rZ   r[   r\   rT  ri  rk  r   r9  r;  r=  rA  rF  rD  rP  rR  rU  rN  rM  rm  rd	  rw  rV   rT   rS   r1  r1  4  s&        !%$(!   F F F0  R R R  6K K K KZ2 2 28 8 8; ; ;C C C: : :1 1 12 2 2 2hX& X& X&t    rT   r1  c                       e Zd Zg 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S )r  )r  r  coerced_operand2r6  rk  NFc                 6   | j                             |          }| j                            |          }t          |          st          |          rAt	          |          r2t	          |          r#t          t          | j        ||                    S t          S rM   )	r  r   r  r=   r;   rI   r?   r   r   r  s       rS   r   zPrimaryCmpNode.infer_type)6  s    ((--((--5!! 	T_U%;%; 	T(// T4Me4T4T T"#5dmUE#R#RSSS rT   c                     dS r  rV   r   s     rS   rO  z PrimaryCmpNode.type_dependencies46  r  rT   c                 V    | j         rJ |                     | j        j                   d S rM   )r6  r9  r  r   rW   s    rS   r%  z(PrimaryCmpNode.calculate_constant_result76  s/    <//0MNNNNNrT   c                 b    | j                             |          }|                     ||          S rM   )r  r/  r;  )rX   r.  r  s      rS   r/  z!PrimaryCmpNode.compile_time_value;6  s-    =33D99//$???rT   c                 F    | j         }|r| j        |_        |j         }|d S d S rM   )r6  r   )rX   cdrs     rS   unify_cascade_typez!PrimaryCmpNode.unify_cascade_type?6  s?    l 	yCH+C  	 	 	 	 	rT   c                 	   | j                             |          | _         | j                            |          | _        |                                 r3|                     |           | j        rt          | j        d           | S | j         j        }| j        j        }t          |          st          |          rOt          |          r@t          |          r1t          t          | j        ||                    | _        d| _        | S |                     |          r| S | j        r| j                            |          | _        | j        dv r|                                 r&d| _        d }| j        rt          | j        d           | S | j        j        t"          u r)|                    t'          j        dd                     n| j         j        t*          j        u r*| j                             t*          j        |          | _         | j        j        t2          ur%| j                            t2          |          | _        |                    t'          j        dd                     | j                            d          | _        n)|                                 r/| j        rt          | j        d	           t*          j        | _        | S |                     || j                   r:| j         j        j        s| j                             |          | _         d }d| _        nt@          }d
| _        n|                     || j                   r:| j         j        j        s| j                             |          | _         d }d| _        n-| !                    || j        | j                   }|j        | _        |M|j"        sF| j         j        |k    r | j                             ||          | _         | #                    ||           | j        ri| j        $                    |          | _        | j        %                    |           | j        &                    | j        |          }|| j        ur|| _'        | (                                rt*          j         | _        nt*          j        | _        | )                                 | j        s| j        s| j*        rd| _+        | S )Nz5Cascading comparison not yet supported for cpp types.Fr4  z?Cascading comparison not yet supported for 'int_val in string'.PyUCS4InUnicoder  BytesContainsz+argument of type 'NoneType' is not iterablez?Cascading comparison not supported for 'val in sliced pointer'.Tr+   ),r  r<  r  r=  analyse_cpp_comparisonr6  r   r   r   r=   r;   rI   r?   r   is_pycmp"analyse_memoryviewslice_comparisonrN  r   r   r   r   r   r  r  r   r   rI  rM  r)  rm  ro   r   r   rF  r  rR  rK   coerce_cascaded_operands_to_tempoptimise_comparisonr  rU  r  rT  r   )rX   rr   r  r  rG  r  s         rS   r<  zPrimaryCmpNode.analyse_typesE6  s   33C8833C88!!## 	'',,,| Ydh WXXXK""5!! 	_U%;%; 	(// 4Me4T4T '(:4=%QV(W(WXX	 %22377 	K< 	;<55c::DL=,,,((** % %"<  $($efffK=%55(()@ARTc)d)deeee})Z-DDD(,(?(?
@VX[(\(\});;(,(?(?
C(P(P(()@Ra)b)bccc $ ? ?A!C !C%%'' %< g$($efff&2	88dmLL %})5 J$(M$D$DS$I$IDM" %, $44S$-HH 	4=%1 F $ @ @ E EK!DMM//T]DMRRK'3DM";+?"}![00 $ 7 7S I I##K555< 	1 M::3??DML99#>>>|77sKKHt},,(0%  "" 	/"1DII".DI!!!= 	DL 	D,J 	DLrT   c           
      h   | j         j        }| j        j        }d| _        |                    | j        | j         | j        g          }|>t          | j        d| j        d|d|d           t          j	        | _        d| _
        d S |j        }|j        r|j        }|j        | _        |j        | _        | j        dk    r>d| _        t!          |           r(|                    t%          j        d	d
                     t)          |j                  dk    r1| j                            |j        d         j        |          | _        n`| j                             |j        d         j        |          | _         | j                            |j        d         j        |          | _        |j        | _        d S )NFrJ  r  r  r  r  r   Tr  r  r+   r   )r  r   r  r  r  r   r   r   r   r2   r  r  r  r   r   r   r   r   r   r   r   r   r  r  )rX   rr   r  r  r   r  s         rS   r  z%PrimaryCmpNode.analyse_cpp_comparison6  s   ""##DMDM4=3QRR=$((uuu. / / /"-DI(DFJ	 	,!+I(8(83&&DL-d33 j$$[%<=UWg%h%hiiiy~!## M33IN14E4JCPPDMM M33IN14E4JCPPDM M33IN14E4JCPPDM)			rT   c                     | j         j        p| j        j        }| j         j        j        p| j        j        j        }d}|r,|r*| j        |v r!d| _        t          j        | _        d| _	        dS dS )N)r  r  r
  r  FT)
r  r  r  r   r   r   r  r   r)  is_memslice_nonecheck)rX   rr   	have_none
have_sliceopss        rS   r  z1PrimaryCmpNode.analyse_memoryviewslice_comparison6  sy    M)BT]-B	m(; <m(; 	* 	) 	(<(<!DM".DI)-D&4urT   c                 \   | j         r|                     || j        d          rnd| _         t          j        | _        d| _        | j        r2| j                            | j	        |d          }|| j	        ur|| _
        |                                  | S t                              | |          S )NT)rl  Fr+   )r  rm  r  r   r)  r   r   r6  r  r  r  r  r   rG  )rX   rr   r  s      rS   rG  z PrimaryCmpNode.coerce_to_boolean6  s    = 	66t 7 = =  %&2	 < 9#|??s4  @  A  AHt}4408-'')))))$444rT   c                 F    | j         j        j        p| j        j        j        S rM   )r  r   ro   r  rW   s    rS   rO  z"PrimaryCmpNode.has_python_operands6  s"    ". .}!-	/rT   c                     | j         r|                                  dS | j                                        o| j                                        S rw  )r6  rx  r  r=  r  rW   s    rS   r=  zPrimaryCmpNode.check_const6  sI    < 	ONN5=,,..N4=3L3L3N3NNrT   c                 
   | j         | j        }}|j        j        rZ| j        dk    rd}nd}d||j                            d          d|                                d|                                dS |                                 rU|j        t          u rd}nd	}| j        d
k    rd}nd}d||d|                                d|                                dS t          | j                  r)|
                                |
                                }}nF|                                |                                }}| j        r|j        j        rd|z  }nd|z  }d|d|                     | j                  d|dS )Nr  r  r  r;  r  r  z))__Pyx_UnicodeContainsUCS4__Pyx_BytesContainsr  ((PyObject *) %s.memview)r[  r  )r  r  r   r  r   r  r  rN  r   r=   r  r  r   rw  )rX   r  r  negationr  r   r!  s          rS   r  z$PrimaryCmpNode.calculate_result_code6  s   !]DM(=# &	}$$''----!!!!!!!!	# #
 &&(( 	},,4.}((!!!!!!!!	# # ty)) H#+#:#:#<#<h>U>U>W>W#+??#4#4hoo6G6G- H}7 H"="G"="G .... rT   c                    | j                             |           | j                            |           | j        D ]}|                    |           | j        r|                     |           |                     ||                                 | j         | j        | j                   | j	        rC| j	                            ||                                 | j
        p| j        | j
        d u           | j                             |           | j                             |           | j                            |           | j                            |           d S d S )Nneeds_evaluation)r  r  r  rk  r   r  rd	  r  r   r6  r  r  r  )rX   r   rs  s      rS   r  z'PrimaryCmpNode.generate_evaluation_code7  sa   ..t444..t4445 	5 	5I..t4444< 	+%%d+++((t{{}}t}dm= = =| H55$++--)>)O$-%)%:$%F 6 H H H M00666M$$T***M00666M$$T*****	+ 	+rT   c                 n    | j                             |           | j                            |           d S rM   )r  r  r  r  s     rS   r  z-PrimaryCmpNode.generate_subexpr_disposal_code7  s6     	,,T222,,T22222rT   c                 n    | j                             |           | j                            |           d S rM   )r  r  r  r  s     rS   r  z!PrimaryCmpNode.free_subexpr_temps 7  s6     	  &&&  &&&&&rT   c                     | j                             |           | j                            |           | j        r| j                            |           d S d S rM   )r  r  r  r6  r  s     rS   r  zPrimaryCmpNode.annotate&7  s^    t$$$t$$$< 	(L!!$'''''	( 	(rT   )rZ   r[   r\   r   r6  r  r  r   rO  r%  r/  r  r<  r  r  rG  rO  r=  r  r  r  r  r  rV   rT   rS   r  r  6  s6       . . .K G!	 	 	  O O O@ @ @  R R Rh* * *6  5 5 5$/ / /O O O( ( (T+ + +$3 3 3' ' '( ( ( ( (rT   r  c                   h    e Zd Zg dZdZdZeZd Zd Z	d Z
d Zd Zd Zdd
Zd Zd ZddZd ZdS )CascadedCmpNode)r  r  r6  rk  Nc                     t           S rM   r/  r   s     rS   r   zCascadedCmpNode.infer_type>7  r{
  rT   c                     dS r  rV   r   s     rS   rO  z!CascadedCmpNode.type_dependenciesB7  r  rT   c                 :    | j         t          uo| j         t          uS rM   r'  rW   s    rS   r   z#CascadedCmpNode.has_constant_resultE7  r*  rT   c                     | j                             |          | _         | j        r| j                            |          | _        | S rM   )r  r<  r6  r   s     rS   r<  zCascadedCmpNode.analyse_typesI7  s?    33C88< 	;<55c::DLrT   c                 $    | j         j        j        S rM   )r  r   ro   rW   s    rS   rO  z#CascadedCmpNode.has_python_operandsO7  s    }!--rT   c                     dS rw  rV   rW   s    rS   r=  z!CascadedCmpNode.is_cpp_comparisonR7  rz  rT   Fc                    |                      |||          r9d| _        t          j        | _        |j        j        s|                    |          }| j        r1| j                            | j	        ||          }|| j	        ur|| _
        |S rw  )rm  r  r   r)  r   ro   r   r6  r  r  r  )rX   r  rr   rl  r  s        rS   r  z#CascadedCmpNode.optimise_comparisonV7  s    223.QQ 	<!DM".DI=, <#66s;;< 	1|77sN[[Ht},,(0%rT   c                     | j                             |          | _         | j         j        t          u r(| j        dv r| j                             d          | _         | j        r| j                            |           d S d S )Nr4  r  )r  r   r   r   r   rI  r6  r  r   s     rS   r  z,CascadedCmpNode.coerce_operands_to_pyobjectsb7  s~    88===**t}@P/P/P M;;<_``DM< 	;L55c:::::	; 	;rT   c                     | j         r;| j                            |          | _        | j                             |           d S d S rM   )r6  r  rK  r  r   s     rS   r  z0CascadedCmpNode.coerce_cascaded_operands_to_tempi7  sI    < 	? M::3??DML99#>>>>>	? 	?rT   c                    | j         j        r4|                    d|z             |                    || j                    n|                    d|z             |r|                    |           | j                            |           | j        D ]}|                    |           |                     |||| j        | j                   | j	        r1| j	                            ||| j
        p| j        | j
        d u           |r*|                    |           |                    |           | j                            |           | j                            |           |                    d           d S )Nz if (__Pyx_PyObject_IsTrue(%s)) {rB  r  r   )r   ro   r   r(	  r  r  rk  rd	  r   r6  r  r  r  )rX   r   r  r  r  rs  s         rS   r  z(CascadedCmpNode.generate_evaluation_codeo7  s   9  	-JJ9FBCCCOOFDI....JJ{V+,,, 	4--d333..t4445 	5 	5I..t4444$$T6dmT]	4 	4 	4< 	DL11fd3Dt}!%!6d!B 2 D D D  	&++D111%%%,,T222  &&&

3rT   c                     | j                             |           | j        r| j                            |           d S d S rM   )r  r  r6  r  s     rS   r  zCascadedCmpNode.annotate7  sH    t$$$< 	(L!!$'''''	( 	(rT   rR  )rZ   r[   r\   r   r6  r  r(  r   r   rO  r   r<  rO  r=  r  r  r  r  r  rV   rT   rS   r  r  -7  s        . . .K G,O    : : :  . . .  
 
 
 
; ; ;? ? ?   2( ( ( ( (rT   r  )r  r  r4  r  r  r  r  r   r  r   r  r  r  r  r  Fc                 2    t          |         | f||||d|S )N)r   r  r  rU	  )binop_node_classes)r   r   r  r  rU	  rL  s         rS   rX	  rX	  7  s>     h'    rT   c                   :     e Zd ZdgZeZ fdZd Zd Zd Z	 xZ
S )r  rh  c                     t                                          |j                   || _        t          rt          | d| j                   d S d S )Nz
 Coercing )rO   rl  r   rh  r   rG  rX   rh  rR   s     rS   rl  zCoercionNode.__init__7  sW    !!! 	7dddDHH566666	7 	7rT   c                     d S rM   rV   rW   s    rS   r%  z&CoercionNode.calculate_constant_result7  r  rT   c                    | j                             |           | j         j        | j        k    rO| j        \  }}}|                    |||dz
  ft	          ddd| j         j        d| j        d                     d S d S )Nr+   coercere  z] to [])rj  tagrk  )rh  r  r   r   r7   )rX   r   filelinecols        rS   r  zCoercionNode.annotate7  s    $8=DI%%"hOD$MM4s1u-~HHTX]]]TXT]T]T]3^0` 0` 0` a a a a a &%rT   c                     | S rM   rV   r   s     rS   r<  zCoercionNode.analyse_types7  r  rT   )rZ   r[   r\   r   r)  r   rl  r%  r  r<  r]   r^   s   @rS   r  r  7  sv        
 wH$O7 7 7 7 7  a a a      rT   r  c                       e Zd ZdZd Zd ZdS )r  zc
    Coerce an object to a memoryview slice. This holds a new reference in
    a managed temp.
    c                     |j         sJ |j        j         rJ t                              | |           || _        d| _        d| _        || _        | j                            |           d S rJ	  )r   r   r  rl  r   r  rh  rM  rX   rh  r  rr   s       rS   rl  z!CoerceToMemViewSliceNode.__init__7  sq    ****8....dC(((	#	--c22222rT   c                     |                     | j                            | j                                        |                                 | j        |                     d S rM   )r   r   from_py_call_coderh  r   r  r   r  s     rS   r  z-CoerceToMemViewSliceNode.generate_result_code7  sZ    

49..H  KKMMH	
 
 	 	 	 	 	rT   N)rZ   r[   r\   r  rl  r  rV   rT   rS   r  r  7  s<         
3 3 3    rT   r  c                   &    e Zd Zd Zd Zd Zd ZdS )rF  c                 J    t                               | |           || _        d S rM   )r  rl  r   )rX   rh  new_types      rS   rl  zCastNode.__init__7  s#    dC(((			rT   c                 4    | j                                         S rM   rw  rW   s    rS   rA  zCastNode.may_be_none7  rx  rT   c                 @    | j                             | j                  S rM   )rh  r  r   rW   s    rS   r  zCastNode.calculate_result_code7  s    x!!$),,,rT   c                     d S rM   rV   r  s     rS   r  zCastNode.generate_result_code7  r   rT   N)rZ   r[   r\   rl  rA  r  r  rV   rT   rS   rF  rF  7  sP          & & &- - -    rT   rF  c                       e Zd ZdZddZej        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S )r   TFc                     |j         s|j        sJ d|j        d|            t                              | |           || _        |                                | _        || _        d S )NzPyTypeTest for z against non extension type )r  r  r   r  rl  r  r!  rL  )rX   rh  r  rr   rL  s        rS   rl  zPyTypeTestNode.__init__8  s     ) 	UX-E 	U 	U 	UAD88T	U 	U 	UdC(((	IIKKrT   zPython type testc                     | S rM   rV   r   s     rS   r<  zPyTypeTestNode.analyse_types8  r  rT   c                 F    | j         rdS | j                                        S rw  )rL  rh  rA  rW   s    rS   rA  zPyTypeTestNode.may_be_none8  s%    < 	5x##%%%rT   c                 4    | j                                         S rM   rz  rW   s    rS   r:  zPyTypeTestNode.is_simple8  r{  rT   c                 4    | j                                         S rM   r}  rW   s    rS   r  zPyTypeTestNode.result_in_temp8  r~  rT   c                 4    | j                                         S rM   )rh  r   rW   s    rS   r   zPyTypeTestNode.is_ephemeral!8  s    x$$&&&rT   c                 4    | j                                         S rM   r  rW   s    rS   rV  z#PyTypeTestNode.nonlocally_immutable$8  r  rT   c                 D    | j                             |          | _         | S rM   )rh  r8  r   s     rS   r8  zPyTypeTestNode.coerce_to_temp'8  s    8**3//rT   c                 4   | j         | j        j         k    s| j                                        s| S | j                                         s| S | j                                        r.| j        r'| j                            d| j         j        z            S | j        S )Nz!Cannot convert NoneType to %.200s)r   rh  r  typeobj_is_availablerA  rL  rI  rp   rW   s    rS   	reanalysezPyTypeTestNode.reanalyse+8  s    9%%TX-D-D-F-F%Ky--// 	K8!! 	ddl 	d8--.QTXT]Tb.bcccxrT   c                     d S rM   rV   rW   s    rS   r%  z(PyTypeTestNode.calculate_constant_result48  r  rT   c                 4    | j                                         S rM   r  rW   s    rS   r  z$PyTypeTestNode.calculate_result_code88  r  rT   c                    | j                                         r%| j         }| j         j        rr| j                             |j        j        | j                                        || j	                  }|j
                            t          j        dd                     nj| j                             |j        j        | j                                        |          }|j
                            t          j        dd                     |                    d|d|                    | j                             d S t#          | j        d           d S )N)exactRaiseUnexpectedTypeErrorr  ExtTypeTestzif (!(r   zICannot test type of extern C class without type object name specification)r   r  rL  r  type_test_coder  r,  rh  r   r  r   r   r   r   r   r   r   r   )rX   r   r  	type_tests       rS   r  z#PyTypeTestNode.generate_result_code;8  sy   9))++ 	:!\)Jy( P I44N(H&&((1	 5  	  11+2I.0B3D 3D E E E E !I44N(H&&(( 	
  11+M;MNNP P PJJJ		4??484446 7 7 7 7 7 $( 9 : : : : :rT   c                 :    | j                             |           d S rM   r  r  s     rS   r  z,PyTypeTestNode.generate_post_assignment_codeU8  r  rT   c                     d S rM   rV   r  s     rS   r  z#PyTypeTestNode.allocate_temp_resultX8  r   rT   c                     d S rM   rV   r  s     rS   r  z"PyTypeTestNode.release_temp_result[8  r   rT   c                 :    | j                             |           d S rM   r  r  s     rS   r  zPyTypeTestNode.free_temps^8  r  rT   c                 :    | j                             |           d S rM   )rh  r  r  s     rS   r  z!PyTypeTestNode.free_subexpr_tempsa8  s    ##D)))))rT   NrR  )rZ   r[   r\   r  rl  r.   rr  rs  r  r<  rA  r:  r  r   rV  r8  r  r%  r  r  r  r  r  r  r  rV   rT   rS   r   r   7  s.       
     .K$K  & & &
$ $ $) ) )' ' '/ / /      ! ! !: : :45 5 5    " " "* * * * *rT   r   c                        e Zd ZdZdZ	 d fd	ZdZd Zd Zd Z	e
	 dd
            Ze
	 dd            Zd Zd Z xZS )rG  TNrV   c                     t                                          |j        |           |j        | _        |                                | _        || _        || _        t          |pd          | _	        d S r  )
rO   rl  r   r   r  r!  exception_type_cnameexception_messager   exception_format_args)rX   rh  r  r  r  rR   s        rS   rl  zNoneCheckNode.__init__m8  sd    #&&&H	IIKK$8!!2%*+@+FB%G%G"""rT   c                     | S rM   rV   r   s     rS   r<  zNoneCheckNode.analyse_typesx8  s	     rT   c                     dS rw  rV   rW   s    rS   rA  zNoneCheckNode.may_be_none}8  r  rT   c                     | j         j        r| j                                        S | j         j        rd| j                                        z  S t          d          )Nr  zunsupported type)r   ro   rh  r   r   r  r=  rW   s    rS   	conditionzNoneCheckNode.condition8  sV    9  	08%%'''Y) 	0.1B1BBB.///rT   rE  Fc                 Z     | ||||          }||_         |                    |           d S rM   )r  put_nonecheck)rQ   rh  r   r  r  r  r  r   s           rS   generatezNoneCheckNode.generate8  s>     s3,.?AVWW 04     rT   c                 f    |                                 r|                     ||||||           d S d S rM   )rA  r  )rQ   rh  r   r  r  r  r  s          rS   generate_if_neededz NoneCheckNode.generate_if_needed8  sI     ?? 	vLLd$57KMbdtuuuuu	v 	vrT   c                    |                     d|                                 z             | j        r|                                 t          j        | j        rs|                     d| j        dt	          j        | j        	                    d                    dd
                    fd| j        D                       d           nB|                     d	| j        d | j        	                    d                    d
           | j        r|                                 |                     |                    | j                             |                     d           d S )Nzif (unlikely(%s == Py_None)) {zPyErr_Format(r  UTF-8z", r  c                 l    g | ]0}d  t          |                              d                    z  1S )z"%s"r  )rw   rY  )rb   rh  escapes     rS   r   z/NoneCheckNode.put_nonecheck.<locals>.<listcomp>8  sP     D D D # #VVCHHOOG,D,D%E%EE D D DrT   r  zPyErr_SetString(z");r   )r   r  r  r   r
   escape_byte_stringr  r  r  rY  r  r   r   r   )rX   r   r  s     @rS   r  zNoneCheckNode.put_nonecheck8  s   

,t~~/?/??	A 	A 	A   	"!!!2% 
	AJJJ)))1*11'::< < < <		 D D D D'+'AD D D E E E E	F G G G G JJJ)))t-44W==>>>>@ A A A   	+((***

4??48,,---

3rT   c                 0    |                      |           d S rM   )r  r  s     rS   r  z"NoneCheckNode.generate_result_code8  s    4     rT   )rV   )rE  rV   F)rZ   r[   r\   r  r   rl  rs  r<  rA  r  re  r  r  r  r  r]   r^   s   @rS   rG  rG  e8  s        
 LD (*H H H H H H K  
  0 0 0 di! ! ! [! nsv v v [v
  4! ! ! ! ! ! !rT   rG  c                   F    e Zd ZeZeZdZefdZdZd Z	d Z
d Zd Zd Zd	S )
r  r+   c                    |j                             |          st          |j        d|j         z             n!|j         j        r|                    |          }t                              | |           |t          u r}|j         j	        s|j         j
        rt          |          | _         nB|j         j        s|j         j        rt          | _         n|j         j        rt          j        | _         | j         | _        d S |j         j	        s|j         j
        rN|t$          t&          fvr.|j        d         s!t          |j        d|j         d|d           |x| _         | _        d S || _        d S )Nz$Cannot convert '%s' to Python objectr`   r#  r$  r  )r   r  r   r   r  rK  r  rl  r   r  rX  rz   r  rD  r   r   r  target_typer   r    rj   )rX   rh  rr   r   s       rS   rl  zCoerceToPyTypeNode.__init__8  sy   x11#66 	,#'ACHLMMMMX  	, &&s++CdC(((>!!x! 1SX%; 1,S11		* 1ch.F 1(		$ 1#0	#yDX 		$38#9 		$Z888N+>? 9cggXXXttt%& & & ,0/DI(((  $DrT   zConverting to Python objectc                     dS rw  rV   rW   s    rS   rA  zCoerceToPyTypeNode.may_be_none8  rz  rT   c                     | j         j        }|t          j        k    s|j        r%|j        dk    r| j                             |          S t          | |          S )NrH  )rh  r   r   r)  ro   rp   r8  r+  )rX   rr   r+  s      rS   rG  z$CoerceToPyTypeNode.coerce_to_boolean8  sW    8=
...% /*2-6*A*A8**3///&tS111rT   c                 6    | j                             |          S rM   )rh  r5  r   s     rS   r5  z"CoerceToPyTypeNode.coerce_to_index8  s    x'',,,rT   c                     | S rM   rV   r   s     rS   r<  z CoerceToPyTypeNode.analyse_types8  r  rT   c                 T   |                     | j        j                            | j                                        |                                 | j                  d|                    |                                 | j                             |                     |           d S )Nr  )	r   rh  r   to_py_call_coder  r  r   r   r  r  s     rS   r  z'CoerceToPyTypeNode.generate_result_code8  s    

HM))!! " " " " ##DKKMM48<<<> 	? 	? 	? 	T"""""rT   N)rZ   r[   r\   r   r   r  r   rl  r  rA  rG  r5  r<  r  rV   rT   rS   r  r  8  s         D KG&4 $ $ $ $: 0K  2 2 2- - -  # # # # #rT   r  c                       e Zd ZdZd Zd ZdS )r  r+   c                     |                     |          }t                              | |           t          j        | _        d S rM   )rK  r  rl  r   r   r   rX   rh  rr   s      rS   rl  zCoerceIntToBytesNode.__init__8  s9    ""3''dC(((&			rT   c           
      b   | j         }|                                }|j        t          j        t          j        t          j        fvr|j        j        r|                    d|d|d           n|                    d|z             |                    d|	                    | j
                  z             |                    d           d }|j        t          j        urC|j                            t          j        d          }|                    |d	|d
           |}|                    |                                 d|d|                    |                                 | j
                             ||j                            |           |                     |           d S )Nzif ((z
 < 0) || (z
 > 255)) {zif (%s > 255) {zOPyErr_SetString(PyExc_OverflowError, "value too large to pack into a byte"); %sr   Fr  z	 = (char)r=  z = PyBytes_FromStringAndSize(&z, 1); )rh  r  r   r   r   r  rv  r  r   r   r   r  r  r   r  r  )rX   r   rh  
arg_resultr  s        rS   r  z)CoerceIntToBytesNode.generate_result_code9  s   hZZ\\
8J2&3&35 5 5 x ;


JJ


, - - - - 

,z9:::JJ D??48446 7 7 7 JJsOOO8:111>//
0FSX/YYDJJ444<===J

KKMMMMJJ##DKKMM48<<<> 	? 	? 	? N''---T"""""rT   N)rZ   r[   r\   r   rl  r  rV   rT   rS   r  r  8  s9         G' ' '
# # # # #rT   r  c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )r  Nc                    t                               | |           || _        d| _        |                    |          st          |j        d|z             | j        j        s| j        j        rh| j	        j
        r7| j	        j        r+| j	        j        j        rt          |j        d|z  d           | j        j        rt          |j        dd           d S d S d S )Nr+   z$Cannot convert Python object to '%s'z=Obtaining '%s' from externally modifiable global Python valuer|   a  Py_UNICODE* has been removed in Python 3.12. This conversion to a Py_UNICODE* will no longer compile in the latest Python versions. Use Python C API functions like PyUnicode_AsWideCharString if you need to obtain a wchar_t* on Windows (and free the string manually after use).)r  rl  r   r   rM  r   r   r  r  rh  r   r   r  r   )rX   ry  rh  rr   s       rS   rl  zCoerceFromPyTypeNode.__init__'9  s   dC(((	66s;; 	H#'8;FH H H9 	!$)"< 	!x !DHN !tx~7Q !WZee! ! ! ! y) !i  ! ! ! ! ! !	! 	!
! !rT   c                     | S rM   rV   r   s     rS   r<  z"CoerceFromPyTypeNode.analyse_types;9  r  rT   c                 f    | j         j        o%| j         j         o| j                                        S rM   )r   r  rT  rh  r   rW   s    rS   r   z!CoerceFromPyTypeNode.is_ephemeral?9  s-    	 ;);%;XAVAVAXAXXrT   c           
      "   d }| j         j        rw| j        j         t          u rd| j         j                            d          rEd| j         j        t          d          d          z   }t                              | j        |d           |	                    | j         
                    | j                                        |                                 | j        ||| j                             | j         j        r|                     |           d S d S )N__Pyx_PyObject_As__Pyx_PyBytes__Pyx_PyObjectzexpected bytes, NoneType found)from_py_functionspecial_none_cvalue)r   r  rh  r   r  r  r   rG  r  r   r  r   r  r   r  ro   r  )rX   r   r  s      rS   r  z)CoerceFromPyTypeNode.generate_result_codeB9  s   9 	c48=J#>#>y)445HII c#2TY5OPSTdPePePfPf5g#g 004Aabbb

49..H  $++--4- $ 8 / 
 
 	 	 	
 9  	'  &&&&&	' 	'rT   c                 0    t          | j        d           d S )Nz0Coercion from Python not allowed without the GILr,  r   s     rS   rs  z CoerceFromPyTypeNode.nogil_checkR9  s    dhJKKKKKrT   )	rZ   r[   r\   r  rl  r<  r   r  rs  rV   rT   rS   r  r   9  so        
 ! ! !(  Y Y Y' ' ' L L L L LrT   r  c                       e Zd Zej        Zej        dej        dej	        dej
        dej        dej        dej        diZd Zd Zd	Zd
 Zd Zd Zd ZdS )r+  r  r  __Pyx_PySet_GET_SIZE__Pyx_PyBytes_GET_SIZE__Pyx_PyByteArray_GET_SIZE__Pyx_PyUnicode_IS_TRUEc                 f    t                               | |           |j        j        r	d| _        d S d S r  )r  rl  r   ro   r   r  s      rS   rl  zCoerceToBooleanNode.__init__g9  s:    dC(((8 	DLLL	 	rT   c                     | j         j        j        r:| j                            | j         j                  |                                  d S d S d S rM   )rh  r   ro   _special_builtinsri   rr  r   s     rS   rs  zCoerceToBooleanNode.nogil_checkl9  sQ    8=$ 	)?)C)CDHM)R)R)ZNN	 	)Z)ZrT   r  c                 n    | j         r|                                  dS | j                                        S rw  )r   rx  rh  r=  rW   s    rS   r=  zCoerceToBooleanNode.check_constr9  s5    < 	NN5x##%%%rT   c                 :    d| j                                         z  S )Nz	(%s != 0)r  rW   s    rS   r  z)CoerceToBooleanNode.calculate_result_codex9  s    TX__....rT   c           
      &   | j         sd S | j                            | j        j                  }|| j                                        rd| j                                        z  gng }|                    d|d| j                                        d           |                    | 	                                dd
                    |          d           |                    |                    d| 	                                z  | j                             d S |                    | 	                                d| j                                        d	|                    | 	                                | j                             d S )
Nz(%s != Py_None)r;  z) != 0)r<  z&&r=  z(((!CYTHON_ASSUME_SAFE_MACROS) && %s < 0)rG  r  )r   r  ri   rh  r   rA  r   r   r   r  r  r   r   r  )rX   r   	test_funccheckss       rS   r  z(CoerceToBooleanNode.generate_result_code{9  s   | 	F*..tx}==	 CG8CWCWCYCYa'$(*<*<*>*>>??_aFMMMYYY8J8J8L8L8L8LMNNNJJT[[]]]]DIIf4E4E4E4EFGGGJJt)):T[[]]JDHV V W W W W W JJKKMMMMH&&((((**4;;==$(CCCEF F F F FrT   c                     | S rM   rV   r   s     rS   r<  z!CoerceToBooleanNode.analyse_types9  r  rT   N)rZ   r[   r\   r   r)  r   r   r   r   r   frozenset_typer   r    r   r  rl  rs  r  r=  r  r  r<  rV   rT   rS   r+  r+  V9  s         !D 	!8!9!7!7!9!=!:  
   0K& & &/ / /F F F"    rT   r+  c                   &    e Zd Zd Zd Zd Zd ZdS )r  c                     |j         j        r|                    |          }|| _         t                              | |           |                    |           d S rM   )r   r  rK  r  rl  r  r  s       rS   rl  zCoerceToComplexNode.__init__9  sY    8 	,&&s++C	dC(((0055555rT   c                 ^   | j         j        j        rm| j         j                            | j                                                   }| j         j                            | j                                                   }n| j                                         }d}| j        j        d|d|dS rX  )rh  r   r  rZ  r  r[  r  )rX   r]  r^  s      rS   r  z)CoerceToComplexNode.calculate_result_code9  s    8=# 	//0A0ABBI//0A0ABBII))II	$$$				 	rT   c                     d S rM   rV   r  s     rS   r  z(CoerceToComplexNode.generate_result_code9  r   rT   c                     | S rM   rV   r   s     rS   r<  z!CoerceToComplexNode.analyse_types9  r  rT   N)rZ   r[   r\   rl  r  r  r<  rV   rT   rS   r  r  9  sP        6 6 6
 
 
      rT   r  c           
         ddl m} t          j        t          j        t          j        dt          j        d           t          j        dt          j        d           gddd          }t          | j	        d|t          j        d	d
          |  || j	                  g          }|                    |          }|j        |k    r|                    ||          }|S )Nr+   )HasNoGilNoder   r  ry  T)r   r   r   __Pyx_SoftComplexToDoubleSoftComplexToDoublez	Complex.c)r$  r   )r  r&  r   r  r  r  r  r)  rq  r   r   r   r<  r   r  )rh  r  rr   r&  
cfunc_typer7  s         rS   r  r  9  s    ''''''% 

!':+G
N
N

!*j.Dd
K
K	N  J #"./DkRR\\#'**+  D c""DyH~~h,,KrT   c                   0    e Zd Zd ZdZd Zd Zd Zd ZdS )r7  c                     t                               | |           | j        j                                        | _        | j        j        | _        d| _        | j        j        rt          | _	        d S d S r  )
r  rl  rh  r   as_argument_typer   r   ro   r   r!  r  s      rS   rl  zCoerceToTempNode.__init__9  sh    dC(((HM2244	#x79  	/ .D	/ 	/rT   z#Creating temporary Python referencec                     | S rM   rV   r   s     rS   r<  zCoerceToTempNode.analyse_types9  r  rT   c                 4    | j                                         S rM   rw  rW   s    rS   rA  zCoerceToTempNode.may_be_none9  rx  rT   c                     | j                             |          | _         | j                                         r| j         S | j         j        | _        | j        | _        | S rM   )rh  rG  r:  r   r!  r   s     rS   rG  z"CoerceToTempNode.coerce_to_boolean9  sP    8--c228 	8OHM	 IrT   c                    |                     |                                 d| j                            |                                           d           | j        r| j        j        s<|                    |                                 |                                            d S |	                    |                                 | j        | j
                    d S d S )Nr<  r=  r  )r   r  rh  r  r  r  r   r   r  r  r  r  s     rS   r  z%CoerceToTempNode.generate_result_code9  s     	

KKMMMM48--djjll;;;;= 	> 	> 	> 	P9/ Ptzz||<<<<<//ty9=9N5N 0 P P P P P		P 	PrT   N)	rZ   r[   r\   rl  r  r<  rA  rG  r  rV   rT   rS   r7  r7  9  sk        
/ / / 8K  & & &  
P 
P 
P 
P 
PrT   r7  c                   b     e Zd ZdZdZ f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 )r  z
    A node that should not be replaced by transforms or other means,
    and hence can be useful to wrap the argument to a clone node

    MyNode    -> ProxyNode -> ArgNode
    CloneNode -^
    Nc                     t                                          |           |j        | _        |                                  d S rM   )rO   rl  r   update_type_and_entryr  s     rS   rl  zProxyNode.__init__9  s>    "2""$$$$$rT   c                 l    | j                             |          | _         |                                  | S rM   )rh  rB  r3  r   s     rS   r<  zProxyNode.analyse_types9  s0    8//44""$$$rT   c                 6    | j                             |          S rM   rr  r   s     rS   r   zProxyNode.infer_type:  rs  rT   c                     t          | j        dd           }|r|| _        | j        j        | _        t          | j        dd           }|r	|| _        d S d S Nr   r   )r   rh  r   r!  r   )rX   r   	arg_entrys      rS   r3  zProxyNode.update_type_and_entry:  sa    tx.. 	6DI $ 5DDHgt44	 	#"DJJJ	# 	#rT   c                 :    | j                             |           d S rM   )rh  r  r  s     rS   r  zProxyNode.generate_result_code:  s    %%d+++++rT   c                 4    | j                                         S rM   r  rW   s    rS   r  zProxyNode.result:  r  rT   c                 4    | j                                         S rM   rz  rW   s    rS   r:  zProxyNode.is_simple:  r{  rT   c                 4    | j                                         S rM   rw  rW   s    rS   rA  zProxyNode.may_be_none:  rx  rT   c                 :    | j                             |           d S rM   )rh  r  r  s     rS   r  z"ProxyNode.generate_evaluation_code:  s    ))$/////rT   c                 :    | j                             |           d S rM   )rh  r  r  s     rS   r  z ProxyNode.generate_disposal_code:  s    ''-----rT   c                 :    | j                             |           d S rM   r  r  s     rS   r  zProxyNode.free_temps!:  r  rT   )rZ   r[   r\   r  rs  rl  r<  r   r3  r  r  r:  rA  r  r  r  r]   r^   s   @rS   r  r  9  s          K% % % % %
  
( ( (# # #, , ,! ! !$ $ $& & &0 0 0. . ." " " " " " "rT   r  c                   n     e Zd Zg ZdZd Zd Zd Zd Zd Z	d Z
 fdZd	 Zd
 Zd Zd Zd Zd Z xZS )r  Nc                     t                               | |           |j        | _        t          |dd           }|r|| _        |j        | _        t          |dd           }|r	|| _        d S d S r7  )r  rl  r   r   r   r!  r   )rX   rh  r   r8  s       rS   rl  zCloneNode.__init__/:  s|    dC((("2sFD)) 	1DI # 0DC$//	 	#"DJJJ	# 	#rT   c                 4    | j                                         S rM   r  rW   s    rS   r  zCloneNode.result::  r  rT   c                 4    | j                                         S rM   rw  rW   s    rS   rA  zCloneNode.may_be_none=:  rx  rT   c                 6    | j                             |          S rM   )rh  rO  r   s     rS   rO  zCloneNode.type_dependencies@:  r  rT   c                 6    | j                             |          S rM   rr  r   s     rS   r   zCloneNode.infer_typeC:  rs  rT   c                     | j         j        | _        | j         j        | _        d| _        t	          | j         dd           }|r|| _        | S )Nr+   r   )rh  r   r!  r   r   r   )rX   rr   r8  s      rS   r<  zCloneNode.analyse_typesF:  sH    HM	 H1DHgt44	 	#"DJrT   c                     | j         j        r| j                             ||          S t                                          ||          S rM   )rh  r   r  rO   )rX   	dest_typerr   rR   s      rS   r  zCloneNode.coerce_toO:  sB    8 	68%%i555ww  C000rT   c                     dS r  rV   rW   s    rS   r:  zCloneNode.is_simpleT:  rD  rT   c                     d S rM   rV   r  s     rS   r  z"CloneNode.generate_evaluation_codeW:  r   rT   c                     d S rM   rV   r  s     rS   r  zCloneNode.generate_result_codeZ:  r   rT   c                     d S rM   rV   r  s     rS   r  z CloneNode.generate_disposal_code]:  r   rT   c                     | j         r<|                    |                                 |                                            d S d S rM   )r   r  r  r  r  s     rS   r  z'CloneNode.generate_post_assignment_code`:  sB     < 	9OODKKMM4::<<88888	9 	9rT   c                     d S rM   rV   r  s     rS   r  zCloneNode.free_tempsf:  r   rT   )rZ   r[   r\   r   rs  rl  r  rA  rO  r   r<  r  r:  r  r  r  r  r  r]   r^   s   @rS   r  r  $:  s         HK	# 	# 	#! ! !& & &/ / /( ( (  1 1 1 1 1
        9 9 9      rT   r  c                   P     e Zd ZdZdZed             Zd Zd Zd Z	d fd	Z
 xZS )	CppOptionalTempCoercionz
    Used only in CoerceCppTemps - handles cases the temp is actually a OptionalCppClassType (and thus needs dereferencing when on the rhs)
    Fc                     | j         j        S rM   ro  rW   s    rS   r   zCppOptionalTempCoercion.typep:  rp  rT   c                 :    d| j                                         z  S r  r  rW   s    rS   r  z-CppOptionalTempCoercion.calculate_result_codet:  s    ****rT   c                     d S rM   rV   r  s     rS   r  z,CppOptionalTempCoercion.generate_result_codew:  r   rT   c                 0    t          | j        d           d S )NziUsing C++ classes in boolean binary operators with the 'cpp_locals' directive is not currently supported.r,  )rX   r   r  s      rS   r  z5CppOptionalTempCoercion.generate_bool_evaluation_codez:  s/     	dh I 	J 	J 	J 	J 	JrT   c                 J    t                                          |d          S )NFr  )rO   r  )rX   r  r  rR   s      rS   r  z-CppOptionalTempCoercion._make_move_result_rhs:  s"     ww,,Ve,DDDrT   rR  )rZ   r[   r\   r  r   rc  r   r  r  r  r  r]   r^   s   @rS   rP  rP  j:  s          G  X+ + +  J J JE E E E E E E E E ErT   rP  c                       e Zd Zd ZdS )r  c                     |j         r| j                            |          r| S t                              | ||          S rM   )r  r   r  r  r  r  s      rS   r  zCMethodSelfCloneNode.coerce_to:  sA    # 		(<(<X(F(F 	K""43777rT   N)rZ   r[   r\   r  rV   rT   rS   r  r  :  s#        8 8 8 8 8rT   r  c                   2    e Zd ZeZdZg Zd Zd Zd Z	d Z
dS )ModuleRefNodeFc                     | S rM   rV   r   s     rS   r<  zModuleRefNode.analyse_types:  r  rT   c                     dS rw  rV   rW   s    rS   rA  zModuleRefNode.may_be_none:  r  rT   c                     t           j        S rM   )r   r`  rW   s    rS   r  z#ModuleRefNode.calculate_result_code:  s    ""rT   c                     d S rM   rV   r  s     rS   r  z"ModuleRefNode.generate_result_code:  r   rT   N)rZ   r[   r\   r   r   r   r   r<  rA  r  r  rV   rT   rS   rY  rY  :  sa         DGH    # # #    rT   rY  c                   .    e Zd ZdgZeZdZd Zd Zd Z	dS )DocstringRefNoder
  Tc                 f    t                               | |           |j        j        sJ || _        d S rM   )r   rl  r   ro   r
  )rX   r   r
  s      rS   rl  zDocstringRefNode.__init__:  s4    $$$$y$$$$			rT   c                     | S rM   rV   r   s     rS   r<  zDocstringRefNode.analyse_types:  r  rT   c                 b   |                     |                                 d| j                                        d|                    t	          j        d                    d|                    |                                 | j                             |                     |           d S )Nz = __Pyx_GetAttr(r  r  r  )	r   r  r
  rt  r
   r0  r   r   r  r  s     rS   r  z%DocstringRefNode.generate_result_code:  s    

KKMMMM49++----"">#?	#J#JKKKK##DKKMM48<<<> 	? 	? 	? 	T"""""rT   N)
rZ   r[   r\   r   r   r   r   rl  r<  r  rV   rT   rS   r_  r_  :  sT         xHDG  
  # # # # #rT   r_  c                   8    e Zd Zg ZdZddZd Zd Zd ZddZ	dS )	AnnotationNodeFNc                     t                               | |           |Hddlm} t	          j         |d                              |                    }t          ||          }|| _        || _	        dS )z6string is expected to already be a UnicodeNode or NoneNr+   r
  rV  )descriptionr  )
r   rl  r
  r
  r
   r0  writer  r
  r)  )rX   r   r)  r
  r
  string_values         rS   rl  zAnnotationNode.__init__:  s    $$$$>;;;;;;)7  \:::@@FFH HL L999F			rT   c                     | S rM   rV   r   s     rS   r<  zAnnotationNode.analyse_types:  r  rT   c                 8    |                      |          d         S r  )r  r   s     rS   re  zAnnotationNode.analyse_as_type:  s    ++C0033rT   c                    t          |t                    r|j        }|j        rB|                    |j                  s&t          |j        d| j        j	        z  d           dS dS |j
        r|j        j        r|                    |j        j                  s&t          |j        d| j        j	        z  d           dS |j        j        r^|j                            |          }|r>|                    |j                  s&t!          |j        d| j        j	        z             dS dS dS |j                            |          }|r-|j        r(t          |j        d| j        j	        z  d           dS dS dS t          |j        d           dS )zZMethod checks for cases when user should be warned that annotation contains unknown types.z5Unknown type declaration '%s' in annotation, ignoringr+   r|   z+Unknown type declaration '%s' in annotationz0Unknown type declaration in annotation, ignoringN)r~   r  rZ  r   r-  rp   r   r   r
  r   r\  r#  r  rb  r  r$  r   pxd_file_loaded)rX   rr   rV  r  s       rS   _warn_on_unknown_annotationz*AnnotationNode._warn_on_unknown_annotation:  s#   j.11 	)#J 	X::jo.. n
ORVR]Rcckln n n n n nn n $ 	X)? 	X::jn122 r
ORVR]Rcckln n n n n n0 
r)~??DD _(@(@AU(V(V _*.IDKL]]_ _ _ _ __ _ _ _  *~??DD rL$@ rJNSVZVaVggopr r r r r rr r r r JN$VWWWWWrT   c                 l   | j         rg d fS | j        }dx}}|j        ret          |j        dd           |j        D ]*\  }}|j        s|j        dv rd}|s|}|j        dv rd}|}+|r|rt          |j        dd           n0t          |t                    rt          |j        d	d           g d fS |
                    |
          5  |                    |          }|&|                     ||           g |fcd d d            S |j        rt          |j        dd           |r%|s#|j        s|j        st          |j        d           |j        r|                    |           |j        st          |t$                    r|                    |          ng }	d d d            n# 1 swxY w Y   |	|fS )NFzSDicts should no longer be used as type annotations. Use 'cython.int' etc. directly.r+   r|   )r   s   typeT)r  s   ctypez9Duplicate type declarations found in signature annotationzTTuples cannot be declared as simple tuples of types. Use 'tuple[type1, type2, ...]'.)r#  zWStrings should no longer be used for type declarations. Use 'cython.int' etc. directly.zOPython type declaration in signature annotation does not refer to a Python type)untypedr)  rY  r   r   r  r[  r   r~   r  r=  re  rm  ro   r  r  r  r]  r:  r  )
rX   rr   assigned_valuerV  explicit_pytypeexplicit_ctyperp   r   r+  r  s
             rS   r  z&AnnotationNode.analyse_type_annotation:  s   < 	t8OY
+00.% 	JNiqrt t t t)9 	' 	'e- :!222&*O) +%*
Z#666%)N!&J n> n
(cklmmmm
I.. 	JNjrsu u u ut8O##n#EE 	O 	O!11#66H00jAAA8|	O 	O 	O 	O 	O 	O 	O 	O + !
q! ! ! !  k~ kx?S kW_Wo k
ik k k" >88=== GQF]  Oaklv  yF  bG  bG  O
==cBBB  MOI'	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O* (""s   	1F'BF''F+.F+rM   )
rZ   r[   r\   r   ro  rl  r<  re  rm  r  rV   rT   rS   rd  rd  :  sz         H
 G
 
 
 
  4 4 4X X X:/# /# /# /# /# /#rT   rd  c                        e Zd ZdZdgZddgZdZdZdZ fdZ	e
d             Ze
d             Zd	 Zd
 Zd Z fdZd Zd Z xZS )AssignmentExpressionNodez
    Also known as a named expression or the walrus operator

    Arguments
    lhs - NameNode - not stored directly as an attribute of the node
    rhs - ExprNode

    Attributes
    rhs        - ExprNode
    assignment - SingleAssignmentNode
    r   r  FNc                      t                      j        |fi | t          |          | _        t	          | j                  }t          |||d          | _        d S )NT)r  r   r  )rO   rl  r  r   r  r/   r  )rX   r   r  r   r  assign_expr_rhsrR   s         rS   rl  z!AssignmentExpressionNode.__init__C;  sd    %%%%%S>>#DH--.SoN N NrT   c                     | j         j        S rM   )r   r   rW   s    rS   r   zAssignmentExpressionNode.typeJ;  rp  rT   c                 $    | j         j        j        S rM   )r  r  rp   rW   s    rS   target_namez$AssignmentExpressionNode.target_nameN;  s    "''rT   c                 6    | j                             |          S rM   )r   r   r   s     rS   r   z#AssignmentExpressionNode.infer_typeR;  rs  rT   c                 :    | j                             |           d S rM   )r  r  r   s     rS   r  z-AssignmentExpressionNode.analyse_declarationsU;  s    ,,S11111rT   c                    | j                             |          | _         | j         j                                        s^| j         j        j        s*| j         j                            |          | j         _        n#t          j        | j                   | j        _         | j                            |          | _        | j        j	        r0t          | j        j         t                    rd| j        j         _        | S rw  )r   r<  rh  r  r   r8  r&   r  r   r   r~   r  r   r   s     rS   r<  z&AssignmentExpressionNode.analyse_typesX;  s     8))#..x|**,, 	:8<* :  $x|::3?? '+i&9&9#
 /77<<9' 	0Jt7JI,V,V 	0
 +0DO'rT   c                 @   || j         j        j        k    r| j        j        }t	          |t
                    r|j        }|                    ||          }||ur|| j        _        | j                                         t	          | j         j        t                    r_t	          | j         j        t                    s@| j         j        j        | j         _        | j         j        j        j        | j         j        _        | S t                                          ||          S rM   )r  r   r   rh  r~   r7  r  r3  r  r  rO   )rX   r  rr   old_rhs_argrhs_argrR   s        rS   r  z"AssignmentExpressionNode.coerce_to};  s    t*/// (,K+'788 .)o!++Hc::Gk))&..000t2LAA L *4?+>	 J JL*./*=*ADO'/3/B/F/KDO',ww  3///rT   c                 4    | j                                         S rM   )r   r  rW   s    rS   r  z.AssignmentExpressionNode.calculate_result_code;  r  rT   c                 :    | j                             |           d S rM   )r  r	  r  s     rS   r  z-AssignmentExpressionNode.generate_result_code;  s    //55555rT   )rZ   r[   r\   r  r   r   r   r  
clone_noderl  rc  r   ry  r   r  r<  r  r  r  r]   r^   s   @rS   rt  rt  /;  s       
 
 wH,'KGJJN N N N N   X ( ( X(( ( (2 2 2# # #J0 0 0 0 0(! ! !6 6 6 6 6 6 6rT   rt  c                   2    e Zd ZdgZdZej        Zd Zd Z	dS )#FirstArgumentForCriticalSectionNode	name_nodeNc                 >   t          | j        j                  dk     rt          | j        d           d S t          | j        | j        j        d                                                   | _        | j                            |           | j        j	        | _	        d S )Nr+   zbcritical_section directive can only be applied to a function with one or more positional argumentsr   r  )
r   	func_noder   r   r   r  declared_namer  r  r   r   s     rS   r  z8FirstArgumentForCriticalSectionNode.analyse_declarations;  s    t~"##a''$(  A  B  B  BF!$(1DQ1G1U1U1W1WXXX++C000N'			rT   c                 H    | j         r| j                             |          S | S rM   )r  rB  r   s     rS   rB  z7FirstArgumentForCriticalSectionNode.analyse_expressions;  s'    > 	;>55c:::rT   )
rZ   r[   r\   r   r  r   r   r   r  rB  rV   rT   rS   r  r  ;  sH         }HI$D( ( (    rT   r  rV   rz  rR  (0  cythondeclarer  r&   r%   r   os.pathr'   r(   r)   r*   Errorsr   r   r   r   r   r   r,   r-   Coder   r	   	LineTabler$   r  r
   r   r   r.   r/   r   r0   r   r1   r2   r3   r4   r   r   r   r   r   r   r   r   r    r!   r5   r#   r"   r   r   Annotater7   r8   	Debuggingr9   
DebugFlagsr   r   Pythranr:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   ru   rw   r5  rK   r)  r(  rm   rl   rn   c_py_unicode_ptr_typer2  cy_pymutex_typecy_pythread_type_lock_typerh   r   rz   r   r   r   r   r   r   r   r   r   rg  r  r  r  r  r  r'  r  r   r]  r  r/  r  r  r|  r~  r  r  rn  rs  r  r  r  r  r-  r8  r>  rM  rX  rg  rk  rt  r  r  r  r  r\  r6  r3  r2  r  r  r  r  r  r5  ro  r.  r  r  rZ  rj  rq  rt  r  r  r  r/  r3	  r?	  r  rB  r	  r	  r
  r
  rW	  r.
  r  r  ra
  rk
  rn
  r$  r%  r
  r
  r
  r
  r#  r  r  r  r
  rM  r
  r
  rY  rd  rp  r  r  r  r  r  r  r  r  r  not_invnegr   r  r  r  r  r  r  r!  r$  r*  r2  r4  rE  rF  r	  rm  rn  rp  rk  rl  r  r  r*  r  r  r  matmulr  r   ltleru  negegtis_r  r  and_truedivfloordivr5  modr4  or_r  rshiftr  xorr  r  r  r  r  r  r7  r:  rD  rP  rT  rf  rl  compilefindall_find_formatting_types	frozenset_safe_bytes_formatsr  r  r  r  r  rv  r1  r  r  r  rX	  r  r  rF  r   rG  r  r  r  r+  r  r  r7  r  r  rP  r  rY  r_  rd  rt  r  rV   rT   rS   <module>r     s%       VV VV vv VV "F06KQ6$f/5vDJFY_Y_ f %+F 8>v OUf  	 -3F	 >DV	 PVv	
 #F
 06v
 BH v '-f 5;F QWPV $*6 =CF TZSY %f 28 JP '-f @Fv v %+F 06v @Fv KQ& W]V\       				 



( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 2 1 1 1 1 1 1 1 ' ' ' ' ' '                   - - - - - - - -                                                  
                   $ $ $ $ $ $       ( ( ( ( ( ( ; ; ; ; ; ; ; ;V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V $ # # # # ##,
  
  
  
  
  
  
  
   
 : i:-.0g:346m:./1h:457n d124n78B.0q%|4I ,/1r&5I!;<)*J,QR4) .  "+ + +* * *   :( ( (6  .D D D     "  :U U U U Ut U U Up0" 0" 0" 0" 0" 0" 0" 0"r
 
 
 
 
X 
 
 
    .   .0 0 0 0 0{ 0 0 0*    ;   8 8 8 8 8 8 8 8v8 8 8 8 8y 8 8 8D    y   
? 
? 
? 
? 
?y 
? 
? 
?T/ T/ T/ T/ T/i T/ T/ T/l0' 0' 0' 0' 0'	 0' 0' 0'f  BU  U  U  U  U 	 U  U  U p    )   D    ;   
/' /' /' /' /'~ /' /' /'p!A !A !A !A !A. !A !A !AH} } } } }~ } } }@# # # # #H # # #FS& S& S& S& S& S& S& S&lX2 X2 X2 X2 X2X X2 X2 X2va( a( a( a( a(> a( a( a(HO( O( O( O( O(h O( O( O(d+J +J +J +J +J~ +J +J +J\# # # # # # # #L# # # # #N # # #<9 9 9 9 9x 9 9 9x    >   .. . . . .x . . .`E E E E E E E E    x   8e" e" e" e" e"H e" e" e"PZ# Z# Z# Z# Z# Z# Z# Z#F    >   :    >   <       <S& S& S& S& S&! S& S& S&lF) F) F) F) F)' F) F) F)Rk k k k k/ k k k\O O O O O- O O Od    X   .    n   44 4 4 4 4~ 4 4 4nT T T T TX T T TnA( A( A( A( A( A( A( A(F4 4 4 4 49 4 4 4nd3 d3 d3 d3 d3x d3 d3 d3NA A A A AX A A AD: : : : :( : : :8g g g g gx g g gT	u# u# u# u# u#X u# u# u#p    X   $5 5 5 5 5 5 5 5*# # # # #( # # #@g# g# g# g# g#h g# g# g#T'# '# '# '# '#( '# '# '#Te  e  e  e  e X e  e  e Pq	 q	 q	 q	 q	H q	 q	 q	t0 0 0 0 08 0 0 0fn# n# n# n# n#8 n# n# n#bX6 X6 X6 X6 X6 X6 X6 X6v[= [= [= [= [=| [= [= [=|9! 9! 9! 9! 9! 9! 9! 9!x'! '! '! '! '!d '! '! '!R' ' ' ' '"9 ' ' 'D+# +# +# +# +#X +# +# +#\h  h  h  h  h  h  h  h V-! -! -! -! -!h -! -! -!`|I |I |I |I |Ix |I |I |I~!, !, !, !, !,8 !, !, !,H+< +< +< +< +< +< +< +<\Z Z Z Z Z& Z Z Z, , , , , , , ,7# 7# 7# 7# 7#/ 7# 7# 7#tG# G# G# G# G#8 G# G# G#T!# !# !# !# !#8 !# !# !#H'# '# '# '# '#8_ '# '# '#T, , , , ,H , , ,47 7 7 7 7H 7 7 74_G _G _G _G _Gh _G _G _GD		 	 	 	 	 	 	 	< < < < < < < <<v v v v vX v v vr6 6 6 6 6H 6 6 6>L L L L Lx L L L0Q Q Q Q Q	 Q Q Q"5 5 5 5 5 5 5 5 +  +  +  +  +"  +  +  +F0# 0# 0# 0# 0#j 0# 0# 0#fpC pC pC pC pCH pC pC pCf. . . . .} . . .b, , , , ,0 , , , , , , , ,, , , ,&    M   6# # # # #n # # #(	 	 	 	 	 	 	 	       $    N   (( ( ( =				    Z Z Z Z Zx Z Z Zz/ / / / /h / / /D) ) ) ) )H ) ) )&# # # # #X # # #</ / / / / / / /&       
/ / / / /i / / /0E E E E EY E E E:k k k.= .= .= .= .=I .= .= .=d 

  
 
 
R9 R9 R9 R9 R98 R9 R9 R9j %	84	FIl l l l lh l l l\	 	 	 	 	 	 	 	/) /) /) /) /)Z /) /) /)d    J   @I/ I/ I/ I/ I/ I/ I/ I/V4 4 4 4 4 4 4 4LoOO       !!(+! 	(+! 	(+	!
 	(+! ! 	(,! ho! ! ! 	! 	(
! 	(/! ! !  !!" 	(,#!$ /			
!
!))/! ! ! 4  G* G* G* G* G* G* G* G*T       6  
S S S S S9 S S Sl0 0 0 0 0< 0 0 0    L   <73 73 73 73 73l 73 73 73t
$ 
$ 
$ 
$ 
$l 
$ 
$ 
$QC QC QC QC QCl QC QC QCh/ / / / /, / / /|i |i |i |i |il |i |i |i~ $
 
    i ! ! !   E3 E3 E3 E3 E3g E3 E3 E3P[0 [0 [0 [0 [0l [0 [0 [0|C4 C4 C4 C4 C4H C4 C4 C4Lp p p p p( p p pfG G G G G8 G G GV 





  X X X X X X X Xt
V( V( V( V( V(Xw V( V( V(r^( ^( ^( ^( ^(dG ^( ^( ^(D   &	 	 	 	.    8   :    |   2    |   "c* c* c* c* c*\ c* c* c*LK! K! K! K! K!% K! K! K!\B# B# B# B# B# B# B# B#J%# %# %# %# %#- %# %# %#P3L 3L 3L 3L 3L< 3L 3L 3Ll7 7 7 7 7, 7 7 7t    ,   8  .(P (P (P (P (P| (P (P (PV4" 4" 4" 4" 4" 4" 4" 4"lC C C C C C C CLE E E E El E E E8	8 	8 	8 	8 	89 	8 	8 	8    H   &# # # # #x # # #.p# p# p# p# p#X p# p# p#fg6 g6 g6 g6 g6x g6 g6 g6T    (     s   %c- -	c98c9