
    Ng:                        d dl mZ d dlZ ej        d]i 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mZ d dl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dlmZ ddlmZ ddlmZ ddlmZ ddlmZ 	 d d lmZ n# e$ r	 d d!l m!Z Y nw xY wd"d#d#d$d%d&Z"d'd(d)d*d+Z#d,d-iZ$g d.Z% ej        e& e&d/                    Z'd0d1ij(        Z) G d2 d3e          Z*d4 Z+dZ,	 d5 Z-e-Z, G d6 d7e          Z. G d8 d9e.          Z/ddi fd:Z0 G d; d<e/          Z1 G d= d>e.          Z2 G d? d@e          Z3 G dA dBe          Z4 G dC dDe          Z5 ej        eeeeE            ej6        dF7                    dG          ej8                  j9        Z: ej6        dH;                    dI                    j9        Z< ej6        dJ          j=        Z> ej6        dK          j?        Z@ G dL dMe          ZA G dN dOe          ZB G dP dQe          ZCdR ZD G dS dTe          ZE G dU dVe          ZF G dW dXe          ZG G dY dZe          ZH G d[ d\e          ZIdS )^    )absolute_importNosreoperatortextwrapTemplateNamingOptionsStringEncodingUtilsSourceDescriptorStringIOTree
DebugFlags
basestringdefaultdictclosingpartialr   )r   )r   contextmanager)r      )r	   )r
   )r   )r      )r   )r   )r   )r   )str)zPY_MAJOR_VERSION < 3r   )PY_MAJOR_VERSION >= 3r   )r   range)r   input)bytesunicoder   xrange	raw_inputz&PyInt_Typez&PyLong_Typez&PyFloat_Typez&PyWrapperDescr_Type)py_intpy_longpy_floatwrapper_descriptorPyTypeObjectPyHeapTypeObject) _IncompleteInputErrorPythonFinalizationErrorBaseExceptionGroupExceptionGroupaiteranextEncodingWarning
breakpoint
__loader____spec__BlockingIOErrorBrokenPipeErrorChildProcessErrorConnectionAbortedErrorConnectionErrorConnectionRefusedErrorConnectionResetErrorFileExistsErrorFileNotFoundErrorInterruptedErrorIsADirectoryErrorModuleNotFoundErrorNotADirectoryErrorPermissionErrorProcessLookupErrorRecursionErrorResourceWarningTimeoutError__build_class__asciiWindowsError_)	__cinit____dealloc____richcmp____next__	__await__	__aiter__	__anext____getreadbuffer____getwritebuffer____getsegcount____getcharbuffer____getbuffer____releasebuffer__inlineCYTHON_INLINEc                   B    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S )IncludeCodez]
    An include file and/or verbatim C code to be included in the
    generated sources.
    r   r   r   NTFc                    | j         | _        t          |           xj         dz  c_         i | _        |rU|d         dk    r,|d         dk    r d                    |          | j        d<   d}nd                    |          | j        d<   |r|| j        | j        <   |r| j        | _        d S |r| j        | _        d S | j        | _        d S )	Nr   r   <>z#include {0}Fz#include "{0}")	counterordertypepiecesformatINITIALlocationLATEEARLY)selfincludeverbatimlateinitials        P/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Compiler/Code.py__init__zIncludeCode.__init__   s    \
T

a 	CqzS  WR[C%7%7!0!7!7!@!@A!2!9!9'!B!BA 	/&.DK
# 	' LDMMM 	' IDMMM JDMMM    c                     ||v rH||         }t          | j        |j                  |_        |j                            | j                   dS | ||<   dS )z
        Insert `self` in dict `d` with key `key`. If that key already
        exists, update the attributes of the existing value with `self`.
        N)minra   r^   update)rd   dkeyothers       ri   dict_updatezIncludeCode.dict_update   sV    
 !88cFE ??ENL,,,,,AcFFFrk   c                     | j         S N)r\   rd   s    ri   sortkeyzIncludeCode.sortkey   s
    zrk   c                 6    | j                             d          S )z
        Return the main piece of C code, corresponding to the include
        file. If there was no include file, return None.
        r   )r^   getru   s    ri   	mainpiecezIncludeCode.mainpiece   s    
 {q!!!rk   c                 t    t          | j                  D ]"}|                    | j        |                    #d S rt   )sortedr^   putln)rd   codeks      ri   writezIncludeCode.write   s@    $$ 	' 	'AJJt{1~&&&&	' 	'rk   )NNTF)__name__
__module____qualname____doc__r`   rc   rb   r[   rj   rr   rv   ry   r    rk   ri   rV   rV   |   s         & GEDG' ' ' ',
 
 
  " " "' ' ' ' 'rk   rV   c                      t           j                            t           j                            t           j                            t                                        } t           j                            | d          S )NUtility)r   pathdirnameabspath__file__join)
Cython_dirs    ri   get_utility_dirr      sI     1J1J!K!KLLJ7<<
I...rk   c                     t           j                            t                      |           }t	          t          j        |d                    5 }|                                cddd           S # 1 swxY w Y   dS )zh
    Read all lines of the file at the provided path from a path relative
    to get_utility_dir().
    UTF-8)encodingN)r   r   r   r   r   r   open_source_file	readlines)r   filenamefs      ri   read_utilities_from_utility_dirr      s    
 w||O--t44H	'7CCC	D	D {{}}                 s   A11A58A5c                       e Zd ZdZdZi Zedd            Zed             Zed             Z	ei fd            Z
ed             Z ej        d	          j        fd
Zd Zd ZddZdS )UtilityCodeBasea(  
    Support for loading utility code from a file.

    Code sections in the file can be specified as follows:

        ##### MyUtility.proto #####

        [proto declarations]

        ##### MyUtility.init #####

        [code run at module initialization]

        ##### MyUtility #####
        #@requires: MyOtherUtility
        #@substitute: naming

        [definitions]

        ##### MyUtility #####
        #@substitute: tempita

        [requires tempita substitution
         - context can't be specified here though so only
           tempita utility that requires no external context
           will benefit from this tag
         - only necessary when @required from non-tempita code]

    for prototypes and implementation respectively.  For non-python or
    -cython files backslashes should be used instead.  5 to 30 comment
    characters may be used on either side.

    If the @cname decorator is not used and this is a CythonUtilityCode,
    one should pass in the 'name' keyword argument to be used for name
    mangling of such entries.
    FNc                 0   |d S d                     |          }|rrd|v rnd|d         v rd	 t          |                              t          t                              }n.# t
          t          f$ r}t          d|||fz            d }~ww xY wd|z  |z   }|dk    r||d<   n|dk    r||d<   n|d	         }|||<   |rW|d	         }|                                D ]<\  }	}
|	                    |	t                                                    |
           ;d S d S )
N

substitutenamingz@Error parsing templated utility code of type '%s' at line %d: %sprotor   implr   r   )r   r   r   varsr	   KeyError
ValueErrorRuntimeErroritems
setdefaultsetrn   )clsutilityr]   linesbegin_linenotagsr}   eall_tagsnamevaluess              ri   _add_utilityzUtilityCodeBase._add_utility  sl   ?Fyy 	,LD((Xl9K-K-K,~~00f>>j) , , ,"#e,i+ $+ , , ,,
 l"T)7??GAJJV^^GAJJqzH!HTN 	@qzH $

 @ @f##D#%%0077????	@ 	@@ @s   4A   B1BBc                 t   | j                             |          }|r|S t          j                            |          \  }}|dv r;d}t          t          j        d          j        d          }t          j
        j        }nPd}t          t          j        d          j        d          }t          t          j        d          j        d          }t          j        d	d
|iz            j        }t          j        d          j        }	t          |          }
t          d           }g }t          t                    }d x}}d}t!          |
          D ]"\  }} ||          }|r|                    d          r||                     |||||           |dz   }|d d = |                                 |                    d          } |	|          }|r|                                \  }}nd}||         }||                    d                                       |                    d                     |                    d           |                     | ||                               $|t/          d          |                     |||||           t1          |          }|| j         |<   |S )N)z.pyxz.pyz.pxdz.pxi#z^\s*#(?!\s*cython\s*:).* /z^\s*//.*|/\*[^*]*\*/z	\s+(\\?)$z\1zd^%(C)s{5,30}\s*(?P<name>(?:\w|\.)+)\s*%(C)s{5,30}|^%(C)s+@(?P<tag>\w+)\s*:\s*(?P<value>(?:\w|[.:])+)Cz,(.+)[.](proto(?:[.]\S+)?|impl|init|cleanup)$c                      d d i gS rt   r   r   rk   ri   <lambda>z:UtilityCodeBase.load_utilities_from_file.<locals>.<lambda>B  s    tR(8 rk   r   r   r   r   tagvaluezEmpty utility code file)_utility_cacherx   r   r   splitextr   r   compilesubr   _unicoderstripmatchread_utilities_hookr   r   	enumerategroupr   cleargroupsaddappendr   dict)r   r   	utilitiesrE   extcommentstrip_commentsr   match_special
match_type	all_linesr   r   r   r]   r   linenolinemr   mtypes                        ri   load_utilities_from_filez(UtilityCodeBase.load_utilities_from_file+  s   &**400	 	!!$''3111G$RZ0K%L%L%PRTUUN#,3FFG$RZ0G%H%H%LbQQNRZ5595AAF
C'N  " 	 Z OPPV
'--	 8 899	3$%i00 	; 	;LFDd##A ;776?? %$$WdE<NNN#)A:LaaaJJLLL776??D&Jt,,E &%*\\^^
dd%'oGG(,,QWWW-=-=>>>LL$$$$VVNN4$8$899::::?6777 	$|TBBBOO	#,4 rk   c                    
 d|v r|                     dd          \  }sJ                                }||         \  }}}|rd|v r2d|d         v r(t           t                    st          j        |fi |S |                                
|                                D ]\  }}	||v r
|dk    r=
r 
fdt          |	          D             }	n[ fdt          |	          D             }	n>|dk    r|	ddhz
  }	|	s]n-|	sd	}	n(t          |	          dk    rt          |	          d
         }	|	||<   |||d<   |||d<   d|vr||d<   d|vrr|d<     di |S )z
        Load utility code from a file specified by from_file (relative to
        Cython/Utility) and name util_code_name.
        z::r   r   tempitarequiresc                 .    g | ]} j         |fi S r   )load).0depr   	from_fileorig_kwargss     ri   
<listcomp>z(UtilityCodeBase.load.<locals>.<listcomp>  s?     "= "= "=&) #+#(3	"I"I["I"I "= "= "=rk   c                 <    g | ]}                     |          S r   )load_cached)r   r   r   r   s     ri   r   z(UtilityCodeBase.load.<locals>.<listcomp>  s7     "= "= "=&) #&//#y"A"A "= "= "=rk   r   Nr   r   r   r   filer   )
rsplitr   
issubclassTempitaUtilityCoder   copyr   r{   lenlist)r   util_code_namer   kwargsr   r   r   r   r   r   r   s   ` `       @ri   r   zUtilityCodeBase.loadi  s'    >!!(6(=(=dA(F(F%I~00;;	%n5tT 	&t##	T,5G(G(G!#'9:: X-2>9WWPVWWW ++--K $

 & &f6>>:%%" ="= "= "= "= "= "=-3F^^"= "= "="= "= "= "= "=-3F^^"= "= "=\)) $x&;;F! ! ! -!FF[[A%%!&\\!_F%t#F7O!F6N+F6NI&F6Ns}}V}}rk   c                 x    ||| f}	 ||         S # t           $ r Y nw xY w|                     ||          x}||<   |S )z`
        Calls .load(), but using a per-type cache based on utility name and file name.
        )r   r   )r   utility_code_namer   _UtilityCodeBase__cacherp   r}   s         ri   r   zUtilityCodeBase.load_cached  sa    
 !)S1	3< 	 	 	D	!hh'8)DDDws|s    
c                      | j         ||fi |}|j        |j        }}|                    |          |                    |          fS )zR
        Load a utility code as a string. Returns (proto, implementation)
        )r   r   r   format_code)r   r   r   r   utilr   r   s          ri   load_as_stringzUtilityCodeBase.load_as_string  sS    
 sx	<<V<<j$)t&&(8(8(>(>>>rk   z\n\n+c                 L    |r! |d|                                           dz   }|S )z3
        Format a code section for output.
        r   z

strip)rd   code_stringreplace_empty_liness      ri   r   zUtilityCodeBase.format_code  s6      	R--dK4E4E4G4GHH6QKrk   c                 B    dt          |           j        d| j        dS )NrX   (z)>)r]   r   r   ru   s    ri   __repr__zUtilityCodeBase.__repr__  s$     !$ZZ000$)))<<rk   c                     d S rt   r   )rd   r   s     ri   get_treezUtilityCodeBase.get_tree  s    trk   c                     | S rt   r   )rd   memodicts     ri   __deepcopy__zUtilityCodeBase.__deepcopy__  s    rk   rt   )r   r   r   r   is_cython_utilityr   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   rk   ri   r   r      s       # #J N@ @ @ [@8 ; ; [;z 3 3 [3j ?A 
 
 
 [
 ? ? [? <F2:h;O;O;S    = = =       rk   r   c                   P    e Zd ZdZ	 	 ddZd Zd Zd ZddZd	 Z	d
 Z
d Zd ZdS )UtilityCodeaF  
    Stores utility code to add during code generation.

    See GlobalState.put_utility_code.

    hashes/equals by instance

    proto           C prototypes
    impl            implementation code
    init            code to call on module initialization
    requires        utility code dependencies
    proto_block     the place in the resulting file where the prototype should
                    end up
    name            name of the utility code (or None)
    file            filename of the utility code file this utility was loaded
                    from (or None)
    Nutility_code_protoc	                     || _         || _        || _        || _        || _        i | _        g | _        || _        || _        || _	        d S rt   )
r   r   initcleanupr   _cachespecialize_listproto_blockr   r   )	rd   r   r   r  r  r   r  r   r   s	            ri   rj   zUtilityCode.__init__  sP     
		 !&				rk   c                 8    t          | j        | j        f          S rt   )hashr   r   ru   s    ri   __hash__zUtilityCode.__hash__  s    TZ+,,,rk   c                 J   | |u rdS t          |           t          |          }}||ur"t          ||          st          | |          sdS t          | dd           }t          |dd           }t          | dd           }t          |dd           }||| j        f|||j        fk    S )NTFr  r   )r]   
isinstancegetattrr   )rd   rq   	self_type
other_type	self_init
other_init
self_protoother_protos           ri   __eq__zUtilityCode.__eq__  s    5==4 $T

DKK:	J&&
5)0L0L&PZ[_akPlPl&5D&$//	UFD11
T7D11
eWd33:ty1j+uz5ZZZrk   c                     |dS ||z  S zY
        Format a string in this utility code with context. If None, do nothing.
        Nr   rd   scontexts      ri   none_or_subzUtilityCode.none_or_sub  s     947{rk   c           
         | j         }|<|                                d<   |                                d<   |dd         d}t          t	                                                              }	 | j        |         S # t          $ r | j        d }nfd| j        D             }t          | 
                    | j                  | 
                    | j                  | 
                    | j                  | 
                    | j                  || j        |          x}| j        |<   | j                            |           |cY S w xY w)Nr]   	type_name[]c                 :    g | ]}|                               S r   )
specialize)r   rdatas     ri   r   z*UtilityCode.specialize.<locals>.<listcomp>  s%    FFF1ALL..FFFrk   )r   empty_declaration_codespecialization_nametupler{   r   r  r   r   r   r  r   r   r  r  r  r  r   )rd   
pyrex_typer!  r   rp   r   r  s     `    ri   r  zUtilityCode.specialize  sg   y!%<<>>DL * > > @ @D#ttT+%6%6%67DF4::<<(())	;s## 	 	 	}$FFFFFFF#.  T22  D11  D11  t44 $ $ AC   ''***HHH#	s   6B CEEc                 v    d|vrd|vrd|fS i fd}t          j        d||          }d|vrd|vsJ d|fS )zHReplace 'PYIDENT("xyz")' by a constant Python identifier cname.
        zPYIDENT(z
PYUNICODE(Fc                     |                                  }	 |         }nL# t          $ r? |\  }}                    t          j        |          |dk              j        x}|<   Y nw xY w|S )NIDENT
identifier)r   r   get_py_string_constr   EncodedStringcname)matchobjrp   r-  str_typer   outputreplacementss        ri   externalisez8UtilityCode.inject_string_constants.<locals>.externalise%  s    //##Cb$S) b b b!$$,2,F,F&4T::xSZGZ -G -\ -\\abS)))b Ls     AA)(A)zPY(IDENT|UNICODE)\("([^"]+)"\)Tr   r   )rd   r   r0  r2  r1  s     ` @ri   inject_string_constantsz#UtilityCode.inject_string_constants  s     T!!l$&>&>$;	 	 	 	 	 	 v7dKK%%,d*B*B*B*BTzrk   c                 ^    d|vrd|fS fd}t          j        d||          }d|vsJ d|fS )zVReplace 'UNBOUND_METHOD(type, "name")' by a constant Python identifier cname.
        zCALL_UNBOUND_METHOD(Fc                    |                                  \  }}}}|r'd |dd                              d          D             ng }t          |          dk     sJ dt          |          z                                  ||||          S )Nc                 6    g | ]}|                                 S r   r   )r   args     ri   r   zKUtilityCode.inject_unbound_methods.<locals>.externalise.<locals>.<listcomp>;  s     ???CCIIKK???rk   r   ,   z8CALL_UNBOUND_METHOD() does not support %d call arguments)r   splitr   cached_unbound_method_call_code)r.  
type_cnamemethod_name	obj_cnameargsr0  s        ri   r2  z7UtilityCode.inject_unbound_methods.<locals>.externalise9  s    7?7H7H4JYCGO??48>>#+>+>????RDt99q==="\_bcg_h_h"h===99)ZQ\^bcccrk   zJCALL_UNBOUND_METHOD\(([a-zA-Z_]+),\s*"([^"]+)",\s*([^),]+)((?:,[^),]+)*)\)Tr3  )rd   r   r0  r2  s     ` ri   inject_unbound_methodsz"UtilityCode.inject_unbound_methods3  st     "--$;	d 	d 	d 	d 	d v
 & & &T1111Tzrk   c                 P    d|vr|S d }t          j        d||          }d|vsJ |S )z<Replace CSTRING('''xyz''') by a C compatible string
        zCSTRING(c                     |                      d                              dd          }d                    d |                                D                       S )Nr   "r   c              3      K   | ]@}|                     d           r|                     d          rd|z  nd|dd         z  V  AdS )\z\\z"%s\n"
z"%s"
NrY   )endswithr   r   s     ri   	<genexpr>zCUtilityCode.wrap_c_strings.<locals>.split_string.<locals>.<genexpr>R  su       2 2 +/--*=*=pvAVAVpd""\dgklomologp\p2 2 2 2 2 2rk   )r   replacer   
splitlines)r.  contents     ri   split_stringz0UtilityCode.wrap_c_strings.<locals>.split_stringP  sa    nnQ''//V<<G77 2 2#..002 2 2 2 2 2rk   z)CSTRING\(\s*"""([^"]*(?:"[^"]+)*)"""\s*\)r3  )rd   r   rM  s      ri   wrap_c_stringszUtilityCode.wrap_c_stringsJ  sP     T!!K	2 	2 	2 vBLRVWW%%%%rk   c                    | j         r| j         D ]}|                    |           | j        r`|| j                 }|                    d| j        z             |                    |                     | j                  d| j        z             | j        r|                     | 	                    | j                            }| 
                    ||          \  }}|                     ||          \  }}|d         }|                    d| j        z             |s!|s|                    |d| j        z             n|                    |           | j        r|d         }|                    d| j        z             t          | j        t                    r.|                    |                     | j                             n|                     ||j                   |                    |                    |j                             |                                 | j        rt&          j        r|d         }|                    d	| j        z             t          | j        t                    r8|                    |                     | j                  d
| j        z             d S |                     ||j                   d S d S d S )Nz/* %s.proto */z%s_protoutility_code_defz/* %s */z%s_implinit_globalsz/* %s.init */cleanup_globalsz/* %s.cleanup */z
%s_cleanup)r   use_utility_coder   r  r|   r   put_or_includer   r   rN  r4  rA  putr  r  r   
module_poserror_goto_if_PyErrr  r
   generate_cleanup_code)rd   r0  
dependencywriterr   is_specialised1is_specialised2s          ri   put_codezUtilityCode.put_codeZ  s   = 	4"m 4 4
''
3333: 	FD,-FLL)DI5666!!  ,,j49.DF F F9 
	!##D$7$7	$B$BCCD$($@$@v$N$N!OT$($?$?f$M$M!OT./FLLdi/000# ! !%%dI	,ABBBB

4   9 
	N+FLL494555$)Z00 5

4++DI667777		&&"3444 LL33F4EFFGGGLLNNN< 	8G9 	8-.FLL+di7888$,
33 8%%$$T\22 49,. . . . . VV%677777	8 	8 	8 	8rk   )NNNNNr   NNrt   )r   r   r   r   rj   r	  r  r  r  r4  rA  rN  r]  r   rk   ri   r   r     s         $ QUCG   - - -[ [ [     :  *  .   '8 '8 '8 '8 '8rk   r   c                     | sdS |r|d|}|r||d<   	 ||          }n(# t           $ r ddlm}  || |          x}|| <   Y nw xY w|                    |          S )z+Run tempita on string s with given context.N:__namer   r   )r   )r   Tempitar   r   )r  r  r   r   __cachetemplater   s          ri   sub_tempitard    s     t &$$% ! 71: 7 7 7&&&&&& ( 6 6 6671:::7 w'''s    "AAc                   D     e Zd Zd fd	Zeddi fd            Zd Z xZS )r   Nc                     |i }t          ||||          }t          ||||          }t          ||||          } t          t          |           j        ||f|||d| d S )N)r  r   r   )rd  superr   rj   )	rd   r   r   r   r  r   r  r   	__class__s	           ri   rj   zTempitaUtilityCode.__init__  s    ?GE7D$774$554$550 $''04	D"D	D 	D<B	D 	D 	D 	D 	Drk   c                    |r.t          t          |                                                    nd }t          |          J | |||f}	 ||         S # t          $ r Y nw xY w|                     |||          x}||<   |S )N)r  )r$  r{   r   r  r   r   )r   r   r   r  _TempitaUtilityCode__cachecontext_keyrp   r}   s           ri   r   zTempitaUtilityCode.load_cached  s    8?IeF7==??33444TK  ,,,I0+>	3< 	 	 	D	!hh'8)WhUUUws|s   A 
A A c                 B    |dS t          ||| j        | j                  S r  )rd  r   r   r  s      ri   r  zTempitaUtilityCode.none_or_sub  s&     941gty$)<<<rk   )NNNNNN)r   r   r   rj   r   r   r  __classcell__)rh  s   @ri   r   r     sz        D D D D D D 6:DRT 	 	 	 [	= = = = = = =rk   r   c                   &    e Zd ZdZdZ dZd Zd ZdS )LazyUtilityCodez
    Utility code that calls a callback with the root code writer when
    available. Useful when you only have 'env' but not 'code'.
    z<lazy>Nc                     || _         d S rt   )callback)rd   rq  s     ri   rj   zLazyUtilityCode.__init__  s     rk   c                 d    |                      |j                  }|                    |           d S rt   )rq  
rootwriterrS  )rd   globalstater   s      ri   r]  zLazyUtilityCode.put_code  s0    -- 677$$W-----rk   )r   r   r   r   r   rj   r]  r   rk   ri   ro  ro    sH          HH! ! !. . . . .rk   ro  c                       e Zd Z e            dfdZd ZddZddZddZd	 Z	d
 Z
d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S ) FunctionStateNc                    || _         || _        || _        d | _        d| _        t                      | _        |                                 | _        | 	                                 d | _
        d | _        g | _        d| _        d | _        d | _        d| _        d| _        g | _        i | _        i | _        t                      | _        d| _        d | _        g | _        d| _        d| _        d| _        d| _        d S )Nr   FT)names_takenownerscopeerror_labellabel_counterr   labels_used	new_labelreturn_labelnew_error_labelcontinue_labelbreak_labelyield_labelsin_try_finallyexc_varscurrent_except	can_trace	gil_ownedtemps_allocated
temps_freetemps_used_typezombie_tempstemp_counterclosure_tempscollect_temps_stackshould_declare_error_indicatoruses_error_indicatorerror_without_exceptionneeds_refnanny)rd   ry  rx  rz  s       ri   rj   zFunctionState.__init__  s    &

55 NN,,""!!EE! $&  /4+$)!',$#rk   c           	          | j         ra|                                 }|rMd| j        j        dd                    d t          |          D                       }t          |          d S d S )Nz&TEMPGUARD: Temps left over at end of 'z': , c                 &    g | ]\  }}}|d |dS )z [r  r   )r   r   ctype	is_pytemps       ri   r   z/FunctionState.validate_exit.<locals>.<listcomp>  sG     eE eE eE.eY "&uuu-eE eE eErk   )r  temps_in_userz  r   r   r{   r   )rd   	leftoversmsgs      ri   validate_exitzFunctionState.validate_exit   s     	())++I ( (IMZ^ZcZc eE eE282C2CeE eE eE [F [F [F 
 #3'''	( 	(( (rk   c                 ^    | j         }|dz   | _         dt          j        |fz  }||d|z   z  }|S )Nr   %s%drE   )r|  r	   label_prefix)rd   r   nlabels       ri   r~  zFunctionState.new_label  sA    U&-q11S4ZErk   yieldc                     |                      d|z            }t          | j                  dz   |f}| j                            |           |S )Nzresume_from_%sr   )r~  r   r  r   )rd   	expr_typer  num_and_labels       ri   new_yield_labelzFunctionState.new_yield_label  sP    /);<<T.//!3U;  ///rk   r   c                 N    | j         }|                     |dz             | _         |S )Nerror)r{  r~  )rd   prefixold_err_lbls      ri   r  zFunctionState.new_error_label  s)    &>>&7*:;;rk   c                     | j         | j        fS rt   r  r  ru   s    ri   get_loop_labelszFunctionState.get_loop_labels!  s     	rk   c                 $    |\  | _         | _        d S rt   r  rd   labelss     ri   set_loop_labelszFunctionState.set_loop_labels&  s    #						rk   c                     |                                  }|                     |                     |dz             |                     |dz             f           |S )Ncontinuebreak)r  r  r~  )rd   r  
old_labelss      ri   new_loop_labelszFunctionState.new_loop_labels*  s`    ))++
^^FZ/00^^FW,--/	0 	0 	0 rk   c                 6    | j         | j        | j        | j        fS rt   r  r  r  r{  ru   s    ri   get_all_labelszFunctionState.get_all_labels1  s$    	 	rk   c                 <    |\  | _         | _        | _        | _        d S rt   r  r  s     ri   set_all_labelszFunctionState.set_all_labels8  s)     $										rk   c                    |                                  }g }t          |g d          D ]E\  }}|r)|                    |                     |                     0|                    |           F|                     |           |S )N)r  r  returnr  )r  zipr   r~  r  )rd   r  
new_labels	old_labelr   s        ri   all_new_labelszFunctionState.all_new_labels>  s    ((**

":/W/W/WXX 	- 	-OIt -!!$.."6"67777!!),,,,J'''rk   c                 :    | j                             |           d S rt   )r}  r   rd   lbls     ri   	use_labelzFunctionState.use_labelI  s    S!!!!!rk   c                     || j         v S rt   )r}  r  s     ri   
label_usedzFunctionState.label_usedL  s    d&&&rk   FTc           	         |j         r|j        s|j        }n|j        r|j        s|j        }nv|j        rddlm} |                    |          }nS|j	        rL|j        sE| j
        j        d         r3| j
                            t                              dd                     |j        sd}| j                            ||f          }|r@|>|d         r6|d                                         }|d                             |           nl	 | xj        dz  c_        d
t*          j        | j        fz  }|| j        vrn1| j                            ||||f           |s| j                            |           ||f| j        |<   t:          j        r(| j                             d|d|d|rdndd           | j!        r"| j!        d                             ||f           |S )a
  
        Allocates a temporary (which may create a new one or get a previously
        allocated and released one of the same type). Type is simply registered
        and handed back, but will usually be a PyrexType.

        If type.needs_refcounting, manage_ref comes into play. If manage_ref is set to
        True, the temp will be decref-ed on return statements and in exception
        handling clauses. Otherwise the caller has to deal with any reference
        counting of the variable.

        If not type.needs_refcounting, then manage_ref will be ignored, but it
        still has to be passed. It is recommended to pass False by convention
        if it is known that type will never be a reference counted type.

        static=True marks the temporary declaration with "static".
        This is only used when allocating backing store for a module-level
        C array literals.

        if reusable=False, the temp will not be reused after release.

        A C string referring to the variable is returned.
        r   )
PyrexTypes
cpp_localsOptionalLocalszCppSupport.cppFNr   Tr  /* z allocated ()r   	 - zombiez */rY   )"is_cv_qualifiedis_referencecv_base_typeis_fake_referenceref_base_typeis_cfunctionr   r  
c_ptr_typeis_cpp_classrz  
directivesrS  r   r   needs_refcountingr  rx   popremover  r	   codewriter_temp_prefixrx  r  r   r  r   r  r   debug_temp_code_commentsry  r|   r  )rd   r]   
manage_refstaticreusabler  freelistresults           ri   allocate_tempzFunctionState.allocate_tempQ  sF   .  	e(9 	e$DD 	et'= 	e%DD 	e$$$$$$((..DD 	et'= 	e$*BWXdBe 	eJ''(?(?@PRb(c(cddd% 	 J?&&j'9:: 
	.,!,a[__&&FQKv&&&&9!!Q&!!6#@$BS"TT!11159  ''z6(JKKK .!%%f---(,j'9V$. 	lJFFFDDDPXJi""^iJiJijkkk# 	=$R(,,fd^<<<rk   c                    | j         |         \  }}| j                            ||f          }|g t                      f}|| j        ||f<   ||d         v rt	          d|z            || j        vr|d                             |           |d                             |           t          j	        r.| j
                            d|d|| j        v rdndd	           dS dS )
zv
        Releases a temporary so that it can be reused by other code needing
        a temp of the same type.
        Nr   zTemp %s freed twice!r   r  z
 released r  r   */)r  r  rx   r   r   r  r   r   r   r  ry  r|   )rd   r   r]   r  r  s        ri   release_tempzFunctionState.release_temp  s   
  /5j?&&j'9::CEE{H2:DOT:./8A;5<===t(((QKt$$$. 	IJTT->%>%>kkBFFH I I I I I	I 	Irk   c                     g }| j         D ]N\  }}}}| j                            ||f          }|
||d         vr|                    |||o|j        f           O|S )zxReturn a list of (cname,type,manage_ref) tuples of temp names and their type
        that are currently in use.
        Nr   )r  r  rx   r   r  )rd   usedr   r]   r  r  r  s          ri   r  zFunctionState.temps_in_use  s{     .2.B 	Q 	Q*D$
F**D*+=>>H4x{#:#:T4)N8NOPPPrk   c                 >    d |                                  D             S )zReturn a list of (cname,type) tuples of temp names and their type
        that are currently in use. This includes only temps
        with a reference counted type which owns its reference.
        c                 0    g | ]\  }}}||j         ||fS r   )r  )r   r   r]   r  s       ri   r   z9FunctionState.temps_holding_reference.<locals>.<listcomp>  sB     : : :*D$
:"&"8:t : : :rk   )r  ru   s    ri   temps_holding_referencez%FunctionState.temps_holding_reference  s/    
: :.2.?.?.A.A: : : 	:rk   c                 $    d | j         D             S )zRReturn a list of (cname, type) tuples of refcount-managed Python objects.
        c                 $    g | ]\  }}}}|	||fS r   r   )r   r-  r]   r  r  s        ri   r   z3FunctionState.all_managed_temps.<locals>.<listcomp>  s9       3E4V   rk   )r  ru   s    ri   all_managed_tempszFunctionState.all_managed_temps  s&     7;7K   	rk   c                 b    t          d | j                                        D                       S )zReturn a list of (cname, type) tuples of refcount-managed Python
        objects that are not currently in use.  This is used by
        try-except and try-finally blocks to clean up temps in the
        error case.
        c                 <    g | ]\  \  }}}|
|d          D ]}||fS r   r   )r   r]   r  r  r-  s        ri   r   z8FunctionState.all_free_managed_temps.<locals>.<listcomp>  sY     
 
 
,"zH:
 "!
 
  DM
 
 
 
rk   )r{   r  r   ru   s    ri   all_free_managed_tempsz$FunctionState.all_free_managed_temps  s@      
 
040E0E0G0G
 
 
   	rk   c                 R    | j                             t                                 dS )zJ
        Useful to find out which temps were used in a code block
        N)r  r   r   ru   s    ri   start_collecting_tempsz$FunctionState.start_collecting_temps  s%     	 ''.....rk   c                 4    | j                                         S rt   )r  r  ru   s    ri   stop_collecting_tempsz#FunctionState.stop_collecting_temps  s    '++---rk   c                 .    t          |          | _        d S rt   )ClosureTempAllocatorr  rd   rz  s     ri   init_closure_tempsz FunctionState.init_closure_temps  s    1%88rk   rt   )r  r   )FT)r   r   r   r   rj   r  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rk   ri   rv  rv    s        +.#%%t ($ ($ ($ ($X
( 
( 
(         
  
$ $ $     $ $ $	 	 	" " "' ' '
8 8 8 8tI I I&	 	 	: : :  
 
 
/ / /. . .9 9 9 9 9rk   rv  c                       e Zd ZdZddZdS )NumConstzGlobal info about a Python number constant held by GlobalState.

    cname       string
    value       string
    py_type     string     int, long, float
    value_code  string     evaluation code if different from value
    Nc                 B    || _         || _        || _        |p|| _        d S rt   )r-  r   py_type
value_code)rd   r-  r   r  r  s        ri   rj   zNumConst.__init__  s'    

$-rk   rt   r   r   r   r   rj   r   rk   ri   r  r    s2         . . . . . .rk   r  c                       e Zd ZdZd ZdS )PyObjectConstz>Global info about a generic constant held by GlobalState.
    c                 "    || _         || _        d S rt   )r-  r]   rd   r-  r]   s      ri   rj   zPyObjectConst.__init__  s    
			rk   Nr   r   rk   ri   r  r    s-         
    rk   r  )possible_unicode_identifierpossible_bytes_identifierreplace_identifierfind_alphanumss   (?![0-9])\w+$rC   z(?![0-9])\w+$ASCIIz[^a-zA-Z0-9_]+z([a-zA-Z0-9]+)c                   *    e Zd ZdZd Zd Z	 	 ddZdS )StringConstz?Global info about a C string constant held by GlobalState.
    c                 p    || _         || _        t          j        |          | _        d | _        g | _        d S rt   )r-  textr   escape_byte_stringescaped_value
py_stringspy_versions)rd   r-  r  byte_strings       ri   rj   zStringConst.__init__  s8    
	+>{KKrk   c                 j    |sddg| _         d S || j         vr| j                             |           d S d S )Nr   r:  )r  r   )rd   versions     ri   add_py_versionzStringConst.add_py_version  sO     	- !1vDD,,,##G,,,,, -,rk   NFc                    | j         }| j        }t          |p|          }|d u o| }|d }n?|                                }|dv rd }d }n"d                    t          |                    }||||f}	|	 ||	         S # t          $ r Y nw xY wi | _         |rd}
nS|Ot          |t                    rt          t          |                    }
nt          t          |                    }
nd}
|
rt          j        d         }nt          j        }|rd|z  }nd}||rdp|rdpd	|d
| j        t          t          j                  d          }t#          ||||||
          }|| j         |	<   |S )N)utf8zutf-8rC   usasciizus-asciir   TFr   z_%sr  ubrE   )r  r  boollowerr   r  r   r  r   r  r  r	   interned_prefixespy_const_prefixr-  r   const_prefixPyStringConst)rd   r   r*  is_strpy3str_cstringr  r  
is_unicodeencoding_keyrp   internr  encoding_prefixpystring_cname	py_strings                  ri   r+  zStringConst.get_py_string_const  s   _
yj*F++%4f*
LL  ~~''HLLL#!ww~h'?'?@@z<@!!#&    !DO 	FF$&& A7==>>9$??@@F 	,-e4FF+F 	!#l2OO O F^;!3;;OOJs6.//0011	3 "Hj&.&R R	(s   4A< <
B	B	NFN)r   r   r   r   rj   r  r+  r   rk   ri   r  r    sX           - - - 8<9=9 9 9 9 9 9rk   r  c                   $    e Zd ZdZ	 	 ddZd ZdS )r   zDGlobal info about a Python string constant held by GlobalState.
    FNc                 Z    || _         || _        || _        || _        || _        || _        d S rt   )r-  r"  r   r!  r#  r%  )rd   r-  r   r#  r!  r"  r%  s          ri   rj   zPyStringConst.__init__M  s1    
, $rk   c                 "    | j         |j         k     S rt   )r-  rd   rq   s     ri   __lt__zPyStringConst.__lt__V  s    zEK''rk   )FNF)r   r   r   r   rj   r.  r   rk   ri   r   r   C  sJ          <A-2   ( ( ( ( (rk   r   c                      e Zd Zi Zg dZg dZd*dZd Zd Zd Z	d Z
d	 Zd
 Zd*dZd+dZd Zd,dZd*dZd Z	 	 d-dZd Zd Zd*dZd.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$ Z$d% Z%d& Z&d' Z'd( Z(d) Z)dS )0GlobalState) h_codefilename_tableutility_code_proto_before_typesnumeric_typedefscomplex_type_declarationstype_declarationsr   module_declarationstypeinfobefore_global_var
global_varstring_declsdeclslate_includesmodule_statemodule_state_clearmodule_state_traversemodule_state_definesmodule_codepystring_tablecached_builtinscached_constantsinit_constantsrQ  init_modulerR  cleanup_modulemain_methodutility_code_pragmasrP  utility_code_pragmas_endend)r1  r3  r6  r   rL  Nc                 j   i | _         g | _        i | _        t                      | _        i | _        d| _        || _        || _        i | _	        || _
        i | _        i | _        i | _        i | _        i | _        g | _        i | _        t                      | _        |                    |            || _        d S )NF)r2  filename_listinput_file_contentsr   utility_codesdeclared_cnamesin_utility_code_generationcode_configcommon_utility_include_dirpartsmodule_nodeconst_cnames_usedstring_const_indexdedup_const_indexpyunicode_ptr_const_indexnum_const_indexpy_constantscached_cmethodsinitialised_constantsset_global_staters  )rd   rZ  rV  rS  rT  s        ri   rj   zGlobalState.__init__  s     #%  UU!*/'&*D'
& "$"$!#)+&!!%(UU"%%% rk   c                 l   | j         }t          | j                  D ]A\  }}|                                x}| j        |<   |dk    r|                    d|z             Bt          j        s	| j        d= n6| j        d         }|                                 |                    d           | j        d         }|                                 |                    d           |                    d           |	                                 |
                    t          j        d                     | j        d	         }|                                 |                    d           |                    d
           | j        d         }|                                 |                    d           |                    d           t          j        s	| j        d= nK| j        d         }|                                 |                    d           |                    d           | j        d         }|                    d           |                    d           | j        d         }| j        j        r|                    d           |                    d           |                    d           d S )Nr   z/* #### Code section: %s ### */rD  z=static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {rE  r   z>static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {__Pyx_InitCachedConstantsrQ  z6static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {rF  z8static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) {rR  z:static CYTHON_SMALL_CODE void __Pyx_CleanupGlobals(void) {r   z)/* --- Runtime support code (head) --- */rP  z
#line 1 "cython_utility"
z"/* --- Runtime support code --- */)rs  r   code_layoutinsertion_pointrU  r|   r
   cache_builtinsenter_cfunc_scopeput_declare_refcount_contextput_setup_refcount_contextr   r,  rX  rS  emit_linenumsr   )rd   rs  ipartwr}   s         ri   initialize_main_c_codez"GlobalState.initialize_main_c_code  s   _
 !122 	B 	BGAt#-#=#=#?#??A
4 1uu9D@AAA% 	U
,--
,-A!!!GGSTTTJ)*			PQQQ	&&(((	$$^%AB]%^%^___J~&			HIIIJ'(			JKKK, 	R
,--
,-A!!!GGBKKKGGPQQQz./

2

>???z,-) 	7JJ5666

2

788888rk   c                 `    | j         }| j        D ]}|                                | j        |<   d S rt   )rs  h_code_layoutrc  rU  )rd   rs  rj  s      ri   initialize_main_h_codez"GlobalState.initialize_main_h_code  s@    _
& 	< 	<D)99;;DJt	< 	<rk   c                    |                                   | j        d         }t                              dd          }|                    |                    |j                             |                    d           | j        d         }t                              dd          }|                    |                    |j                             |                    d           | j        d         }t                              d	d          }|                    |                    |j                             |                    d           d S )
NrP  TypeConversionszTypeConversion.cr   rJ  UtilityCodePragmasModuleSetupCode.crK  UtilityCodePragmasEnd)	close_global_declsrU  r   r   rU  r   r   r|   r   )rd   r}   r   s      ri   finalize_main_c_codez GlobalState.finalize_main_c_code  s   !!!
 z,-!--.?ASTT!!$),,---

2
 z01&&';=PQQ

4##DI..///

2z45&&'>@STT

4##DI..///

2rk   c                     | j         |         S rt   )rU  )rd   rp   s     ri   __getitem__zGlobalState.__getitem__  s    z#rk   c                 $   |                                   t          j        r| j        d         }|                    d           |                    |j                  r/|                    |j                   |                    d           |                    d           |                                 | j        d         }|	                                 |                    d           |                    |j                  rC|                    |j                   |	                                 |                    d           |                    d           |                                 dD ]}| j        |         }|                    d           |                    |j                  r/|                    |j                   |                    d           |                    d           |                                 t          j
        r6| j        d         }|                    d           |                                 t          j
        r8| j        d         }|                    d           |                                 d S d S )	NrD  z	return 0;z
return -1;}rE  )rQ  rF  rR  rH  )generate_const_declarationsr
   rd  rU  r|   r  r{  	put_labelexit_cfunc_scopeput_finish_refcount_contextrX  )rd   rk  rj  s      ri   ru  zGlobalState.close_global_decls  sL    	((***! 	!
,-AGGK   ||AM** &AM***%%%GGCLLL   J)*	%%'''	<<&& 	"KK&&&))+++GGL!!!		6 	! 	!D
4 AGGK   ||AM** &AM***%%%GGCLLL    ( 	!
,-AGGCLLL   ( 	!
+,AGGCLLL     	! 	!rk   c                 L    | d                              d|j        z             d S )Nr:  zstatic PyObject *%s;)r|   r-  rd   entrys     ri   put_pyobject_declzGlobalState.put_pyobject_decl;  s)    \  !7%+!EFFFFFrk   c                 j    |%|| j         v rd S | j                             |           | j        d         S )NrE  )r^  r   rU  rd   targets     ri   get_cached_constants_writerz'GlobalState.get_cached_constants_writer@  s@    333t&**6222z,--rk   Fc                     |rdpd}	 | j         ||f         }n&# t          $ r |                     ||          }Y nw xY w|S )Nlongintr[  r   new_num_const)rd   	str_valuelongnessr  cs        ri   get_int_constzGlobalState.get_int_constH  sc    %v.	7$i%9:AA 	7 	7 	7""9g66AAA	7s     ;;c                 v    	 | j         |df         }n'# t          $ r |                     |d|          }Y nw xY w|S )Nfloatr  )rd   r  r  r  s       ri   get_float_constzGlobalState.get_float_constP  s[    	C$i%9:AA 	C 	C 	C""9gzBBAAA	Cs    !66r   c                    || j                             |          }||S |                     ||          }|A|t          j        k    r1|j        r*| j        d         }|                    d|j        z             |
|| j         |<   |S )NrR  zPy_CLEAR(%s);)	rY  rx   new_py_constr
   rX  r  rU  r|   r-  )rd   r]   r  cleanup_level	dedup_keyconstcleanup_writers          ri   get_py_constzGlobalState.get_py_constW  s     *..y99E !!$//%!W%BBB * C "Z(9:N  5;!>??? 05D"9-rk   c                     |j         r|                                }n|                                }	 | j        |         }n&# t          $ r |                     ||          }Y nw xY w|                    |           |S rt   )r#  
utf8encode
byteencoderX  r   new_string_constr  )rd   r  
py_versionr  r  s        ri   get_string_constzGlobalState.get_string_consti  s    ? 	,//++KK//++K	9'4AA 	9 	9 	9%%dK88AAA	9	$$$s   A    A#"A#c                     |j         sJ 	 | j        |         }n.# t          $ r! |                                 x}| j        |<   Y nw xY w|S rt   )r#  rZ  r   new_const_cname)rd   r  r  s      ri   get_pyunicode_ptr_constz#GlobalState.get_pyunicode_ptr_constv  sm    	N.t4AA 	N 	N 	N7;7K7K7M7MMA.t444	Ns    (AAc                 (   d }|r[|Y|                                 |                                k    r/|                     |d          }|                     |d          }n|                     |          }|                    |j        |||          }|S )Nr:  )r  r   )r  r  r  r+  r   )rd   r  r*  r!  unicode_valuer"  c_stringr(  s           ri   r+  zGlobalState.get_py_string_const  s      	3m/ ++--1B1BBB!22=Q2OON,,Ta,@@HH,,T22H00M:v~? ?	rk   c                 0    |                      |d          S NTr)  r+  rd   r  s     ri   get_interned_identifierz#GlobalState.get_interned_identifier      '''>>>rk   c                 f    |                      |          }t          |||          }|| j        |<   |S rt   )new_string_const_cnamer  rX  )rd   r  r  r-  r  s        ri   r  zGlobalState.new_string_const  s8    ++K88t[11/0,rk   c                 n    |                      ||          }t          ||||          }|| j        ||f<   |S rt   )new_num_const_cnamer  r[  )rd   r   r  r  r-  r  s         ri   r  zGlobalState.new_num_const  sA    ((88UE7J7712eW-.rk   c                     |                      |          }t          ||          }| j                            |           |S rt   )r  r  r\  r   )rd   r]   r  r-  r  s        ri   r  zGlobalState.new_py_const  s@    $$V,,%&&  ###rk   c                 Z    |                     dd          }|                     |          S )Nr	  ignore)r   )decoder  )rd   bytes_valuer   s      ri   r  z"GlobalState.new_string_const_cname  s.    ""7H55##%#000rk   c                     | j         }|                    dd          x}}||v r+||         dz   x}||<   |                    d|          }||v +d||<   |S )Nr   )sepr[   r   rE   )rW  r_   )rd   
format_strr  r-  r   r[   s         ri   unique_const_cnamezGlobalState.unique_const_cname  sy    %"))b")===tmm$(K!O3Gd5k%%#w%??E tmm Urk   c                 V   |dk    r|dz  }d}t           j        |         }|                    dd                              dd                              dd          }t          |          d	k    r2|                     |d
z   |d d         z   dz   |dd          z             }n||}|S )Nr  Lr  .rE   +-neg_*   zlarge{counter}_   _xxx_i)r	   r  rJ  r   r  )rd   r   r  r  r-  s        ri   r  zGlobalState.new_num_const_cname  s    fSLEG)'2c3''//S99AA#vNNu::??++**U3B3Z7'AE#$$KOQ QEE %fee,Erk   c                     t          d|          d d                             d          }|                     |dz             }|rt          j        |         }nt          j        }||S )NrE       z{sep}{counter})r  r   r  r	   r  r  )rd   r  r   name_suffixs       ri   r  zGlobalState.new_const_cname  so    "3..ss399#>>--e6F.FGG 	)-f5FF(F--rk   c                     ||f}	 | j         |         }n5# t          $ r( |                     d|d|          x}| j         |<   Y nw xY w|S )NumethodrE   )r]  r   r  )rd   r=  r>  rp   r-  s        ri   get_cached_unbound_methodz%GlobalState.get_cached_unbound_method  s    ;'	@(-EE 	@ 	@ 	@040D0Djjj++>1@ 1@ @ED(---	@ s    /AAc                     dt          |          z  }|                     t                              |d                     |                     ||          }|g|z   }d|d|dd                    |          dS )NzCallUnboundCMethod%dObjectHandling.c__Pyx_z(&r  r  )r   rS  r   r   r  r   )rd   r?  r=  r>  
arg_cnamesr   cache_cnamer@  s           ri   r<  z+GlobalState.cached_unbound_method_call_code  s    2S__Dk556GI[\\]]]44ZMM{Z'KKIIdOOOO
 	
rk   c                 X   |j         r|j        r|                     |j        |          r|                     |           | j        d         }d }|j        t          v rut          |j                 \  }}|                    d|z             | 	                    |j
        t          j        |          |j                   |                    d           | 	                    |j
        t          j        |j                  |j                   |r|                    d           d S d S d S d S d S )NrD  #if %s#else#endif)
is_builtinis_constshould_declarer-  r  rU  r   non_portable_builtins_mapr|   put_cached_builtin_initposr   r,  )rd   r  rk  	conditionreplacements        ri   add_cached_builtin_declz#GlobalState.add_cached_builtin_decl  sJ    	& 	&""5;66 &&&u---J01 	:!:::-Fuz-R*I{GGHy011100	>#?#L#L% % % GGG$$$,,I~;EJGGK! ! !  &GGH%%%%%!	& 	& 	& 	&& && &rk   c                    | j         d         }|                     |          j        }|                     t                              dd                     |                    |d|d|d|                    |                     d S )NrD  GetBuiltinNamer  z = __Pyx_GetBuiltinName(z); if (!) )rU  r  r-  rS  r   r   r|   
error_goto)rd   r  r   r-  rk  interned_cnames         ri   r  z#GlobalState.put_cached_builtin_init  s    J()55d;;A##$46HII	K 	K 	K	EENNEELL	 	  	  	  	  	 rk   c                     |                                   |                                  |                                  |                                  d S rt   )generate_cached_methods_declsgenerate_string_constantsgenerate_num_constantsgenerate_object_constant_declsru   s    ri   r{  z'GlobalState.generate_const_declarations  sP    **,,,&&(((##%%%++-----rk   c           	         d | j         D             }|                                 |D ]\  }}}| j        d                             d|j                            |          z             | j        d                             d|dt          j        d|           |j        j        s| j        d         	                    d	|z  |j        d
d           |j        j
        r|dz  }| j        d                             d|z             d S )Nc                 F    g | ]}t          |j                  |j        |fS r   r   r-  r   r  s     ri   r   z>GlobalState.generate_object_constant_decls.<locals>.<listcomp>  s9     . . . qw<<!, . . .rk   r>  z%s;rA  #define  ->r?  zclear_module_state->%sTF)clear_before_decrefnannyz	->memviewr@  $Py_VISIT(traverse_module_state->%s);)r\  sortrU  r|   r]   declaration_coder	   modulestateglobal_cnamer  put_xdecref_clearis_memoryviewslice)rd   constsrE   r-  r  s        ri   r  z*GlobalState.generate_object_constant_decls  sV   . .,. . .! 	@ 	@KAuaJ~&,,UQV5L5LU5S5S-STTTJ-.444',uuf.L.L.LeeTV V V6+  J+,>>(50$(	 ?    v( %$J./556>@ @ @ @+	@ 	@rk   c                 <   | j         sd S | j        d         }| j        d         }g }t          | j                                                   D ]\  \  }}}|                    |           |                     t          j        |                    j        }|	                    d|z             |	                    |d|d           |	                    |d|d           t          j        r*| j        d         }|D ]}|	                    d|z             d S d S )	Nr<  rF  z2static __Pyx_CachedCFunction %s = {0, 0, 0, 0, 0};z.type = (PyObject*)&;z.method_name = &rR  zPy_CLEAR(%s.method);)r]  rU  r{   r   r   r  r   r,  r-  r|   r
   rX  )	rd   declr  cnamesr=  r>  r-  method_name_cnamer  s	            ri   r  z)GlobalState.generate_cached_methods_decls  sj   # 	Fz'"z*+06t7K7Q7Q7S7S0T0T 
	+ 
	+,%ZuMM%    $ < <^=YZe=f=f g g mJJK    JJzzz# $ $ $ JJ(((* + + + + ( 	>j!23G > >4u<====	> 	>> >rk   c                 	   d | j                                         D             }|                                 g }| j        d         }|D ]\  }}}d}|j        r7d|j        vs	d|j        vr%d}|                    dd|j        v rdpd	z             |                    d
|dt          j        |j                  dd           |r|                    d           |j	        K|j	                                        D ]1}|
                    |j        t          |j                  |f           2t          | j                                                  D ]\  }}t          j        |          \  }	}
|	r|                    d           |                    d|d|
d           |	rF|                    d           |                    d|d|	d           |                    d           | j        d         }|r|                     t$                              dd                     |                                 | j        d         }|                    d           |                    d           |                    dt(          j        z             |D ]}|\  }}}|j        r|j        r	|j        dv rd}nd|j                                        z  }| j        d                             d|j        z             | j        d                              d!|j        d"t(          j        d#|j                   | j        d$                             d%|j        z             | j        d&                             d'|j        z             |j        rg|                    d(           |                    d)|j        |j        j        |j        j        dd*d+|j        fz             |                    d           |                    d)|j        ||||j        |j        |j        fz             |j        r|                    d           |                    d,           |                    d-           |                    d.t(          j        z             |                    d/           |                    d0|                    | j                  z             d S d S )1Nc                 F    g | ]}t          |j                  |j        |fS r   r  r  s     ri   r   z9GlobalState.generate_string_constants.<locals>.<listcomp>6  s)    YYY1S\\17A.YYYrk   r;  Fr   r:  Tz#if PY_MAJOR_VERSION %s 3rX   z>=zstatic const char z[] = "z";)safer  z#ifdef Py_UNICODE_WIDEzstatic Py_UNICODE z[] = { z };r  rF  InitStringszStringTools.crC  r   z6static int __Pyx_CreateStringTabAndInitStrings(void) {z__Pyx_StringTabEntry %s[] = {)r	  USASCIIzUS-ASCIIUTF8r   0z"%s"r>  PyObject *%s;rA  r  r  r  r?  !Py_CLEAR(clear_module_state->%s);r@  r  z#if PY_MAJOR_VERSION >= 3z&{&%s, %s, sizeof(%s), %s, %d, %d, %d},r   r   z{0, 0, 0, 0, 0, 0, 0}z};zreturn __Pyx_InitStrings(%s);rz  z2if (__Pyx_CreateStringTabAndInitStrings() < 0) %s;)rX  r   r  rU  r  r|   r   split_string_literalr  r  r   r-  r   r{   rZ  r   encode_pyunicode_stringrS  r   r   r	   stringtab_cnamer!  r   r  r  r"  r%  r#  r  rV  )rd   c_constsr  decls_writerrE   r-  r  conditionalr(  utf16_arrayutf32_arrayrF  rk  py_string_argsc_cnamer   s                   ri   r  z%GlobalState.generate_string_constants5  s   YY8O8V8V8X8XYYY
z.1# 	R 	RKAuaK} ;!1="8"8AQ]<R<R"""#>!-'0S8D$: ; ; ;~:1?KKKK M      -""8,,,|'!"!4!4!6!6 R RI%%qwIO0D0Di&PQQQQt=CCEEFF 		- 		-HAu'5'Ma'P'P$K =""#;<<<UUUKKKXYYY -""7+++"""P[P[P[#\]]]""8,,,$45 7	@!!+"9"9-"Y"YZZZOO
+,AGGBKKKGGLMMM GG3f6LLMMM", && &&(6%I ' Cy/A C!* /@ @ @"HH%	(:(@(@(B(BBH
>*009?1RSSS
12888OOO222OO:% & & & 
/0667ZO8$ % % %
2399:`O;$ % % %+ 	%GG7888GGD!!06!06Q!(H     GGG$$$@O($$D     + &GGH%%%GG+,,,GGDMMMGG3f6LLMMMGGCLLL  D"--do>>?@ @ @ @ @k7	@ 7	@rk   c                 
   d | j                                         D             }|                                 | j        d         }|D ]:\  }}}}}}|j        }| j        d                             d|z             | j        d                             d|dt          j        d|           | j        d	                             d
|z             | j        d                             d|z             |dk    rd}	nK|dk    rd}	nBt          j	        |          rd}	n+t          |                    d                    dk    rd}	nd}	|                    |d|	|z  d|                    || j                             <d S )Nc                 ~    g | ]:}|j         |j        d          dk    t          |j                  |j        |j        |f;S )r   r  )r  r   r   r  r  s     ri   r   z6GlobalState.generate_num_constants.<locals>.<listcomp>  sO     : : : 9agajC/QWqwVWX : : :rk   rF  r>  r   rA  r  r  r  r?  r  r@  r  r  zPyFloat_FromDouble(%s)r  z%PyLong_FromString((char *)"%s", 0, 0)z$PyInt_FromString((char *)"%s", 0, 0)r     zPyInt_FromLong(%sL)zPyInt_FromLong(%s) = z; )r[  r   r  rU  r-  r|   r	   r  r   long_literalr   lstriperror_goto_if_nullrV  )
rd   r  rF  r  rE   r   r  r  r-  functions
             ri   r  z"GlobalState.generate_num_constants  s   : :/6688: : :$4539 	L 	L/GQ5*aGEJ~&,,_u-DEEEJ-.444v555uu6> ? ? ?J+,223e;= = =J./556>@ @ @'!!3F""B#E** 0AU\\#&&''!++0/  x*,,,11%III"K L L L L'	L 	Lrk   c                     || j         v rM| j         |         }t          |j                  t          |j                  k    sJ |j        |j        k    sJ dS || j         |<   dS )NFT)rQ  r   r]   r  )rd   r-  r  rq   s       ri   r  zGlobalState.should_declare  sj    D((((/Euz??c%*oo5555:++++5*/D '4rk   c                     |                                 }	 | j        |         }nH# t          $ r; t          | j                  }| j                            |           || j        |<   Y nw xY w|S rt   )get_filenametable_entryr2  r   r   rN  r   )rd   source_descr  indexs       ri   lookup_filenamezGlobalState.lookup_filename  s    3355	/'.EE 	/ 	/ 	/*++E%%k222).D&&&	/ s   $ AA)(A)c                 j   	 | j         |         S # t          $ r Y nw xY w|                    dd          }	 d |D             }t          |d          r|                                 n*# t          |d          r|                                 w w xY w|s|                    d           || j         |<   |S )Nr	  r  )r   error_handlingc                     g | ]A}d |                                                     dd                              dd          z   BS )z * r  z.*[inserted by cython to avoid comment closer]/z/*z-/[inserted by cython to avoid comment start]*)r   rJ  rH  s     ri   r   z7GlobalState.commented_file_contents.<locals>.<listcomp>  sd     * * *
  $++--//L gK  * * *rk   closer   )rO  r   	get_lineshasattrr  r   )rd   r  source_fileFs       ri   commented_file_contentsz#GlobalState.commented_file_contents  s    	+K88 	 	 	D	!++W;C , E E		$* *
 )* * *A {G,, $!!### {G,, $!!####$!((3---01 -s    
A( ('Bc                     |r:|| j         vr3| j                             |           |                    |            dS dS dS )a  
        Adds code to the C file. utility_code should
        a) implement __eq__/__hash__ for the purpose of knowing whether the same
           code has already been included
        b) implement put_code, which takes a globalstate instance

        See UtilityCode.
        N)rP  r   r]  )rd   utility_codes     ri   rS  zGlobalState.use_utility_code  sZ      	(L0BBB""<000!!$'''''	( 	(BBrk   c                     |d S |j         r|                     |j                    |j        r|                     |j                   d S d S rt   )r$  rS  utility_code_definitionr  s     ri   use_entry_utility_codez"GlobalState.use_entry_utility_code  sc    =F 	6!!%"4555( 	A!!%"?@@@@@	A 	Ark   rt   Fr   NNr)  r  )r   r   )*r   r   r   r  rb  rn  rj   rl  ro  rv  rx  ru  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"  rS  r'  r   rk   ri   r0  r0  Z  s       : J! ! !KH  M! ! ! !2/9 /9 /9b< < <
  .  (! (! (!TG G G
. . . .        $      488<   ? ? ?        1 1 1
    . . . .  

 

 

& & &&	  	  	 . . .@ @ @8> > >0X@ X@ X@tL L LB      2( ( (A A A A Ark   r0  c                 p    | j         t          j                  fd}fd}t          ||          S )Nc                 $     | j                   S rt   )	funcstate)rd   attribute_ofs    ri   rx   z!funccontext_property.<locals>.get  s    |DN+++rk   c                 4    t          | j        |           d S rt   )setattrr,  )rd   r   r   s     ri   r   z!funccontext_property.<locals>.set  s    e,,,,,rk   )r   r   
attrgetterproperty)funcrx   r   r-  r   s      @@ri   funccontext_propertyr3    s]    =D&t,,L, , , , ,- - - - -Crk   c                       e Zd ZddZdS )CCodeConfigTc                 0    || _         || _        || _        d S rt   )emit_code_commentsrh  c_line_in_traceback)rd   rh  r7  r8  s       ri   rj   zCCodeConfig.__init__  s     "4*#6   rk   N)TTT)r   r   r   rj   r   rk   ri   r5  r5    s(        
7 7 7 7 7 7rk   r5  c                   
   e Zd ZdZ ej        d           dd            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ed             Zed             Zed             Zed             Zed             Zed             ZddZddZd Zd Zd Zd Zd Z d  Z!d! Z"d" Z#d# Z$d$ Z%dd%Z&d& Z'd' Z(d( Z)dd*Z*d+ Z+d, Z,	 	 dd-Z-d. Z.d/ Z/d0 Z0dd1Z1dd2Z2dd3Z3d4 Z4d5 Z5d6 Z6d7 Z7d8 Z8d9 Z9d: Z:d; Z;d< Z<d= Z=d> Z>d? Z?d@ Z@	 	 ddAZAdB ZBdC ZCdD ZDdE ZEeFfdFZGdG ZHdH ZIdI ZJdJ ZKdK ZLdL ZMddMZNddNZOddOZPddPZQddQZRddRZSdS ZTdT ZUdU ZVdV ZWdW ZXdX ZYdY ZZdZ Z[d[ Z\d\ Z]d] Z^d^ Z_d_ Z`d` Zada Zbdb ZcdddZdde Zedf ZfddgZgddiZhddjZidk Zjdl ZkddmZlddnZmddoZnddpZodq Zpdr ZqddsZrddtZsdduZtdv Zudw Zvdx Zwdy Zxdz Zyd{ Zzdd|Z{dd}Z|dd~Z}ddZ~d ZddZddZd ZddZd Zd Zd ZdS )CCodeWritera  
    Utility class to output C code.

    When creating an insertion point one must care about the state that is
    kept:
    - formatting state (level, bol) is cloned and used in insertion points
      as well
    - labels, temps, exc_vars: One must construct a scope in which these can
      exist by calling enter_cfunc_scope/exit_cfunc_scope (these are for
      sanity checking and forward compatibility). Created insertion points
      looses this scope and cannot access it.
    - marker: Not copied to insertion point
    - filename_table, filename_list, input_file_contents: All codewriters
      coming from the same root share the same instances simultaneously.
    create_fromNFc                    |t                      }|| _        d | _        d | _        g | _        d | _        d | _        d | _        d| _        d| _	        d| _
        |f|                     |j                   |j        | _        |r$|j        | _        |j
        | _
        |j	        | _	        |j        | _        |j        | _        d S d S )Nr   r   )r   bufferlast_poslast_marked_pospyclass_stackr,  rt  rS  level
call_levelbolr_  )rd   r<  r>  copy_formattings       ri   rj   zCCodeWriter.__init__+  s    >LNN6#
"!!+"9:::(2DN 9(.
&?"-"8'0DM#.#>D    #"rk   c                 (    t          |||          }|S rt   r:  )rd   r<  r>  rE  r  s        ri   
create_newzCCodeWriter.create_newF  s     [&/BBrk   c                 >    | j         J || _         |j        | _        d S rt   )rt  rS  )rd   global_states     ri   r_  zCCodeWriter.set_global_stateL  s*    '''''3rk   c                 :    | j                             |           d S rt   )r>  copyto)rd   r   s     ri   rL  zCCodeWriter.copytoQ  s    1rk   c                 4    | j                                         S rt   )r>  getvalueru   s    ri   rN  zCCodeWriter.getvalueT  s    {##%%%rk   c                 f    d|v r|                      |           d S |                     |           d S )Nr   )_write_lines_write_to_bufferrd   r  s     ri   r   zCCodeWriter.writeW  s?    199a     !!!$$$$$rk   c                     | j         r| j         d d         nd}| j        j                            |g|                    d          z             |                     |           d S )Nr   Nr   r   )r@  r>  markersextendcountrQ  )rd   r  filename_lines      ri   rP  zCCodeWriter._write_lines]  sf     594HW,RaR00i""M?QWWT]]#BCCCa     rk   c                 :    | j                             |           d S rt   )r>  r   rR  s     ri   rQ  zCCodeWriter._write_to_bufferf  s    !rk   c                 d    |                      | | j                                        d          }|S )NT)r<  r>  rE  )rH  r>  rc  r-  s     ri   rc  zCCodeWriter.insertion_pointi  s-    D9T9T9V9Vhlmmrk   c                 "    t          |           S )z
        Creates a new CCodeWriter connected to the same global state, which
        can later be inserted using insert.
        r;  rG  ru   s    ri   
new_writerzCCodeWriter.new_writerm  s    
 t,,,,rk   c                 d    |j         | j         u sJ | j                            |j                   dS )z
        Inserts the contents of another code writer (created with
        the same global state) in the current location.

        It is ok to write to the inserted writer also after insertion.
        N)rt  r>  insert)rd   rZ  s     ri   r^  zCCodeWriter.insertt  s9     !T%555556=)))))rk   c                     d S rt   r   ru   s    ri   r|  zCCodeWriter.label_counter  s    !Trk   c                     d S rt   r   ru   s    ri   r  zCCodeWriter.return_label       Drk   c                     d S rt   r   ru   s    ri   r{  zCCodeWriter.error_label      4rk   c                     d S rt   r   ru   s    ri   r}  zCCodeWriter.labels_used  rc  rk   c                     d S rt   r   ru   s    ri   r  zCCodeWriter.continue_label  s    "drk   c                     d S rt   r   ru   s    ri   r  zCCodeWriter.break_label  rc  rk   c                     d S rt   r   ru   s    ri   return_from_error_cleanup_labelz+CCodeWriter.return_from_error_cleanup_label  s    /3trk   c                     d S rt   r   ru   s    ri   r  zCCodeWriter.yield_labels  ra  rk   Tc              #   &  K   t          ||          D ]}\  }}|                     |          s|r|                     |           d}||                     ||           |                     |           ||fV  |                     |           ~dS )a  
        Helper for generating multiple label interceptor code blocks.

        @param new_labels: the new labels that should be intercepted
        @param orig_labels: the original labels that we should dispatch to after the interception
        @param skip_to_label: a label to skip to before starting the code blocks
        @param pos: the node position to mark for each interceptor block
        @param trace: add a trace line for the pos marker or not
        N)trace)r  r  put_gotomark_posr|  )rd   r  orig_labelsskip_to_labelr  rk  r  
orig_labels           ri   label_interceptorzCCodeWriter.label_interceptor  s       "%Z!=!= 	& 	&E:??5))  %m,,, $c///NN5!!!*%%%%MM*%%%%	& 	&rk   c                 6    | j                             |          S rt   )r,  r~  rd   r   s     ri   r~  zCCodeWriter.new_label  s    dn.F.Ft.L.L'Lrk   c                       | j         j        | S rt   )r,  r  rd   r@  s     ri   r  zCCodeWriter.new_error_label      .Ldn.Ld.S'Srk   c                       | j         j        | S rt   )r,  r  ru  s     ri   r  zCCodeWriter.new_yield_label  rv  rk   c                 4    | j                                         S rt   )r,  r  ru   s    ri   r  zCCodeWriter.get_loop_labels  s    dn.L.L.N.N'Nrk   c                 6    | j                             |          S rt   )r,  r  r  s     ri   r  zCCodeWriter.set_loop_labels  s    dn.L.LV.T.T'Trk   c                       | j         j        | S rt   )r,  r  ru  s     ri   r  zCCodeWriter.new_loop_labels  rv  rk   c                 4    | j                                         S rt   )r,  r  ru   s    ri   r  zCCodeWriter.get_all_labels      dn.K.K.M.M'Mrk   c                 6    | j                             |          S rt   )r,  r  r  s     ri   r  zCCodeWriter.set_all_labels  s    dn.K.KF.S.S'Srk   c                 4    | j                                         S rt   )r,  r  ru   s    ri   r  zCCodeWriter.all_new_labels  r|  rk   c                 6    | j                             |          S rt   )r,  r  r  s     ri   r  zCCodeWriter.use_label  s    dn.F.Fs.K.K'Krk   c                 6    | j                             |          S rt   )r,  r  r  s     ri   r  zCCodeWriter.label_used  s    dn.G.G.L.L'Lrk   c                 2    t          | |          | _        d S )N)rz  )rv  r,  r  s     ri   re  zCCodeWriter.enter_cfunc_scope  s    &t5999rk   c                 F    | j                                          d | _         d S rt   )r,  r  ru   s    ri   r}  zCCodeWriter.exit_cfunc_scope  s!    $$&&&rk   c                 B    | j                             ||          j        S rt   )rt  r  r-  )rd   r  r  s      ri   
get_py_intzCCodeWriter.get_py_int  s    --iBBHHrk   c                 B    | j                             ||          j        S rt   )rt  r  r-  )rd   r  r  s      ri   get_py_floatzCCodeWriter.get_py_float  s    //	:FFLLrk   r   c                 F    | j                             ||||          j        S rt   rt  r  r-  )rd   r]   r  r  r  s        ri   r  zCCodeWriter.get_py_const  s"    ,,T6=)TTZZrk   c                 @    | j                             |          j        S rt   )rt  r  r-  r  s     ri   r  zCCodeWriter.get_string_const  s    0066<<rk   c                 6    | j                             |          S rt   )rt  r  r  s     ri   r  z#CCodeWriter.get_pyunicode_ptr_const  s    77===rk   c                 F    | j                             ||||          j        S rt   )rt  r+  r-  )rd   r  r*  r!  r  s        ri   r+  zCCodeWriter.get_py_string_const  s)    33*fm5 55:	;rk   c                 @    | j                             |          j        S rt   r  )rd   r]   s     ri   get_argument_default_constz&CCodeWriter.get_argument_default_const  s    ,,T2288rk   c                 ,    |                      |          S rt   r  r  s     ri   r%  zCCodeWriter.intern  s    ''---rk   c                 0    |                      |d          S r  r  r  s     ri   intern_identifierzCCodeWriter.intern_identifier  r  rk   c                 6    | j                             |          S rt   )rt  r  r  s     ri   r  z'CCodeWriter.get_cached_constants_writer  s    ;;FCCCrk   c                 x   | j         r| j        r|                                  | j        j        r@| j        r9| j        \  }}}|                     d|d|                                d           |r-|r|                     |           n| 	                    |           |                     d           d| _        d S )Nz
#line z "z"
r   r   )
r?  rD  emit_markerrS  rh  r@  rP  get_escaped_descriptionput_saferU  )rd   r}   r  r  r   rE   s         ri   r|   zCCodeWriter.putln  s    = 	TX 	) 	cd.B 	c#'#7 KqTTT;;^;^;`;`;`;`abbb 	 d####$rk   c                 h    |d S | j         r| j         d d         |d d         k    rd S ||f| _        d S )Nr   )r@  r?  rd   r  rk  s      ri   rm  zCCodeWriter.mark_pos  sI    ;F 	D$8!$<BQB$G$GFerk   c                    | j         \  }}|| _        d | _         |                     d           | j        j        r?|                                  |                     d|                     |          z             |rz| j        ru| j        j        rk| j	        j
        d         r[|                                  |                     d|d         | j        j         |                     |          fz             d S d S d S d S d S )Nr   z	/* %s */
	linetracez__Pyx_TraceLine(%d,%d,%s)
r   )r?  r@  rP  rS  r7  indent_build_markerr,  r  rt  r  r  r  r  s      ri   r  zCCodeWriter.emit_marker  s9   ]
U"$. 	FKKMMMlT-?-?-D-DDEEE 	MT^ 	M(@ 	MTEUE`alEm 	MKKMMM;ADN44dooc6J6J?L L M M M M M	M 	M 	M 	M 	M 	M 	M 	Mrk   c                 @   |\  }}}t          |t                    sJ | j                            |          }|t	          d|dz
            |         }|dxx         dz  cc<   ||||dz            z  }d|                                |d                    |          fz  S )Nr   r:  rY   z             # <<<<<<<<<<<<<<r   z"%s":%d
%s
r   )r  r   rt  r"  maxr  r   )rd   r  r  r   colcontentsr   s          ri   r  zCCodeWriter._build_marker  s    !$T3+'788888#;;KHHQQ,-b			55			$tAv+&&;#F#F#H#H$PUPZPZ[`PaPa"bbbrk   c                 >    |                      |           d| _        d S rT  )r   rD  rd   r}   s     ri   r  zCCodeWriter.put_safe  s    

4rk   c                 p   | j         j        }|rt          |          dk    r|dt          j        |                    d                                                    d}t          j        	                    ||          }t          j        
                    |          s{|dt          j                    }t          t          j        |                    5 }|                    |           d d d            n# 1 swxY w Y   t!          j        ||           d|z  }|                     |           d S )Ni   rE   r  z.hz.tmpz#include "%s"
)rt  rT  r   hashlibsha1encode	hexdigestr   r   r   existsgetpidr   r   open_new_filer   shutilmoverU  )rd   r}   r   include_dirinclude_filer   tmp_pathr   s           ri   rT  zCCodeWriter.put_or_include  sH   &A 		,3t99t++gl4;;v#6#677AACCCCEL7<<\::D7>>$'' ,)-ry{{{;U0::;; "qGGDMMM" " " " " " " " " " " " " " "Hd+++$t+Ds   C<<D D c                    d}d|v r|                     d          }nd}d|v rS||                     d          z  }|dk     r| xj        |z  c_        n$|dk    r|d         dk    rd}| xj        dz  c_        | j        r|                                  |                     |           d| _        |dk    r| xj        |z  c_        d S |r| xj        dz  c_        d S d S )NF{r   rz  Tr   )rW  rB  rD  r  r   )rd   r}   
fix_indentdls       ri   rU  zCCodeWriter.put  s    
$;;CBBB$;;$**S//!BAvv

b 


qT!W^^!


a

8 	KKMMM

466JJ"JJJJ 	JJ!OJJJJ	 	rk   c                 &    | xj         dz  c_         d S Nr   rB  ru   s    ri   increase_indentzCCodeWriter.increase_indent6      

a



rk   c                 &    | xj         dz  c_         d S r  r  ru   s    ri   decrease_indentzCCodeWriter.decrease_indent9  r  rk   c                 X    |                      d           |                                  d S )Nr  )r|   r  ru   s    ri   begin_blockzCCodeWriter.begin_block<  s)    

3rk   c                 X    |                                   |                     d           d S )Nrz  )r  r|   ru   s    ri   	end_blockzCCodeWriter.end_block@  s'    

3rk   c                 @    |                      d| j        z             d S )Nz  )rQ  rB  ru   s    ri   r  zCCodeWriter.indentD  s#    dTZ/00000rk   c                 <    dt          |          dz   d d         z  S )Nz0x%02X%02X%02X%02X)r   r   r   r   r  )r$  )rd   	pyversions     ri   get_py_version_hexzCCodeWriter.get_py_version_hexG  s#    #uY'7'7)'CRaR&HHHrk   c                 V    || j         j        v r|                     d|z             d S d S )Nz%s:;)r,  r}  r|   r  s     ri   r|  zCCodeWriter.put_labelJ  s6    $.,,,JJv|$$$$$ -,rk   c                 j    | j                             |           |                     d|z             d S )Ngoto %s;)r,  r  r|   r  s     ri   rl  zCCodeWriter.put_gotoN  s5      %%%

:#$$$$$rk   c                    |j         dk    r|s	|j        sd S |j         dk    r	|j        sd S |j        s|                     d           |r|                     d|z             |j        r5|                     |j                            |j        |                     n4|                     |j        	                    |j        |                     |j
        6|                     d|j                            |j
                  z             n!|j        j        r|                     d           |                     d           | j        j                            |           d S )NprivateCYTHON_UNUSED %s )dll_linkagez = %sz = NULLr  )
visibilitydefined_in_pxdr  cf_usedrU  is_cpp_optionalr]   cpp_optional_declaration_coder-  r  r  r  literal_codeis_pyobjectr|   r,  rz  r'  )rd   r  storage_classr  
definitions        ri   put_var_declarationzCCodeWriter.put_var_declarationR  sy    y((*(@T(Fy(((F} 	'HH%&&& 	,HHU]*+++  	7HHUZ== > 6 6 7 7 7 7 HHUZ00 1 6 6 7 7 7:!MM'EJ$;$;EJ$G$GGHHHHZ# 	 HHY

333E:::::rk   c                    |j         D ]\  }}}}|j        r/|j        s(|j        j        d         r|                    |          }n|                    |          }|j        r|                     d|z             r|j	        r4|                     |d|
                    |j                  d           |                     |rdpd|d           |j        r| j        j        rd}nd}|                     |dt          j        d	           |                     |d
t          j        d           |                     |dt          j        d	           d S d S )Nr  z
%s = NULL;r  r  zstatic r   r  zint z = 0;zconst char *z = NULL;)r  r  r  rz  r  r  r  r  r|   r  r  default_valuer  r,  r  r	   lineno_cnamefilename_cnameclineno_cname)rd   func_contextr   r]   r  r  r  unuseds           ri   put_temp_declarationsz!CCodeWriter.put_temp_declarationsl  s   .:.J 
	I 
	I*D$
F  3)? 3LDVDabnDo 399$??,,T22 I

<$.////( I

t/@/@AS/T/T/T/TUVVVV

f&:&@b&@$$$GHHHH6 	I~2 *)JJ&&&&2E2E2EFGGGJJVVVV=R=R=RSTTTJJ&&&&2F2F2FGHHHHH	I 	Irk   c                 n    |                      t          j                   |                      d           d S )Nr   )r|   r   GENERATED_BY_MARKERru   s    ri   put_generated_byzCCodeWriter.put_generated_by  s*    

5,---

2rk   c                 f    |                      d|z             |                      d|z             d S )Nz
#ifndef %sz
#define %sr|   )rd   guards     ri   put_h_guardzCCodeWriter.put_h_guard  s6    

<%'(((

<%'(((((rk   c                 (    t           j        rd|z  S |S )Nzunlikely(%s))r
   gcc_branch_hintsrd   conds     ri   unlikelyzCCodeWriter.unlikely  s    # 	!D((Krk   c                 T    |sdS dd                     fd|D                       z  S )Nr   r  r  c                 (    g | ]} ||          S r   r   )r   r   mappers     ri   r   z8CCodeWriter.build_function_modifiers.<locals>.<listcomp>  s#     @ @ @! @ @ @rk   )r   )rd   	modifiersr  s     `ri   build_function_modifiersz$CCodeWriter.build_function_modifiers  s<     	2sxx @ @ @ @i @ @ @AAAArk   c                     |j         }|j        s|j                                         r|j         j        r
d|j        z   S |j        S )Nz(PyObject *))r]   is_self_argis_completeis_extension_typer-  )rd   r  r]   s      ri   entry_as_pyobjectzCCodeWriter.entry_as_pyobject  sK    z! 	%**@*@*B*B 	:/	!EK//;rk   c                 ,    ddl m}m}  ||||          S )Nr   py_object_typetypecast)r  r  r  )rd   r-  r]   r  r  s        ri   as_pyobjectzCCodeWriter.as_pyobject  s.    88888888xe444rk   c                 2    |                     | |           d S rt   )generate_gotrefr  s      ri   
put_gotrefzCCodeWriter.put_gotref  s    T5)))))rk   c                 2    |                     | |           d S rt   )generate_giverefr  s      ri   put_giverefzCCodeWriter.put_giveref      dE*****rk   c                 2    |                     | |           d S rt   )generate_xgiverefr  s      ri   put_xgiverefzCCodeWriter.put_xgiveref  s    tU+++++rk   c                 2    |                     | |           d S rt   )generate_xgotrefr  s      ri   put_xgotrefzCCodeWriter.put_xgotref  r  rk   c                 6    |                     | ||           d S N)r  )generate_increfrd   r-  r]   r  s       ri   
put_increfzCCodeWriter.put_incref  s%     	T566666rk   c                 6    |                     | ||           d S r  )generate_xincrefr  s       ri   put_xincrefzCCodeWriter.put_xincref  s#    dE77777rk   c                 8    |                     | |||           d S N)r  have_gil)generate_decrefrd   r-  r]   r  r  s        ri   
put_decrefzCCodeWriter.put_decref  s%    T5IIIIIrk   c                 8    |                     | |||           d S r  )generate_xdecrefr  s        ri   put_xdecrefzCCodeWriter.put_xdecref  s%    dEJJJJJrk   c                 :    |                     | ||||           d S N)r  r  r  )generate_decref_clearrd   r-  r]   r  r  r  s         ri   put_decref_clearzCCodeWriter.put_decref_clear  s5    ""4DW$)H 	# 	> 	> 	> 	> 	>rk   c                 :    |                     | ||||           d S r  )generate_xdecref_clearr  s         ri   r  zCCodeWriter.put_xdecref_clear  s5    ##D%EX$)H 	$ 	> 	> 	> 	> 	>rk   c                 4    |                     | ||           d S rt   )generate_decref_setrd   r-  r]   	rhs_cnames       ri   put_decref_setzCCodeWriter.put_decref_set  s       ui88888rk   c                 4    |                     | ||           d S rt   )generate_xdecref_setr  s       ri   put_xdecref_setzCCodeWriter.put_xdecref_set  s     !!$y99999rk   c                 6    |                     | ||           d S N)r  )generate_incref_memoryviewslice)rd   slice_cnamer]   r  s       ri   put_incref_memoryviewslicez&CCodeWriter.put_incref_memoryviewslice  s#    ,,T;,RRRRRrk   c                 J    |                      |j        |j        |           d S r%  )r(  r-  r]   )rd   r  r  s      ri   put_var_incref_memoryviewslicez*CCodeWriter.put_var_incref_memoryviewslice  s'    ''UZ('SSSSSrk   c                 F    |                      |j        |j                   d S rt   )r  r-  r]   r  s     ri   put_var_gotrefzCCodeWriter.put_var_gotref  s     UZ00000rk   c                 F    |                      |j        |j                   d S rt   )r  r-  r]   r  s     ri   put_var_giverefzCCodeWriter.put_var_giveref  "    ej11111rk   c                 F    |                      |j        |j                   d S rt   )r  r-  r]   r  s     ri   put_var_xgotrefzCCodeWriter.put_var_xgotref  r/  rk   c                 F    |                      |j        |j                   d S rt   )r   r-  r]   r  s     ri   put_var_xgiverefzCCodeWriter.put_var_xgiveref  s"    %+uz22222rk   c                 8     | j         |j        |j        fi | d S rt   )r  r-  r]   rd   r  kwdss      ri   put_var_increfzCCodeWriter.put_var_incref  (    UZ88488888rk   c                 8     | j         |j        |j        fi | d S rt   )r  r-  r]   r5  s      ri   put_var_xincrefzCCodeWriter.put_var_xincref  )    ej99D99999rk   c                 8     | j         |j        |j        fi | d S rt   )r  r-  r]   r5  s      ri   put_var_decrefzCCodeWriter.put_var_decref  r8  rk   c                 8     | j         |j        |j        fi | d S rt   )r  r-  r]   r5  s      ri   put_var_xdecrefzCCodeWriter.put_var_xdecref  r;  rk   c                 F     | j         |j        |j        fd|j        i| d S Nr  )r  r-  r]   
in_closurer5  s      ri   put_var_decref_clearz CCodeWriter.put_var_decref_clear  s2    ek5:dd5K[d_cdddddrk   c                 :     | j         |j        |j        |fi | d S rt   )r   r-  r]   rd   r  r  r6  s       ri   put_var_decref_setzCCodeWriter.put_var_decref_set  s+    EKYGG$GGGGGrk   c                 :     | j         |j        |j        |fi | d S rt   )r#  r-  r]   rE  s       ri   put_var_xdecref_setzCCodeWriter.put_var_xdecref_set  s+    U[%*iHH4HHHHHrk   c                 F     | j         |j        |j        fd|j        i| d S rA  )r  r-  r]   rB  r5  s      ri   put_var_xdecref_clearz!CCodeWriter.put_var_xdecref_clear  s2    u{EJeeEL\e`deeeeerk   r   c                     |D ]=}|r|j         r2|j        r|                     |           (|                     |           >d S rt   )r  xdecref_cleanupr?  r=  )rd   entries	used_onlyr  s       ri   put_var_decrefszCCodeWriter.put_var_decrefs  sc     	/ 	/E /
 /( /((////''...	/ 	/rk   c                 :    |D ]}|                      |           d S rt   )r?  rd   rM  r  s      ri   put_var_xdecrefszCCodeWriter.put_var_xdecrefs 	  s2     	( 	(E  ''''	( 	(rk   c                 :    |D ]}|                      |           d S rt   )rJ  rQ  s      ri   put_var_xdecrefs_clearz"CCodeWriter.put_var_xdecrefs_clear	  s2     	. 	.E&&u----	. 	.rk   c                     ddl m}m}  |||d          }|r|                     |d|d           d S |                     |d|d           d S )Nr   r  Py_Noner  z; __Pyx_INCREF(Py_None);z; Py_INCREF(Py_None);)r  r  r  r|   )rd   r-  r]   r  r  r  py_nones          ri   put_init_to_py_nonezCCodeWriter.put_init_to_py_none	  s    88888888(4;; 	JJJEEE777KLLLLLJJHIIIIIrk   %sc                     ||j         z  }|                     ||j        |           |j        r|                     d           d S d S )NrV  )r-  rX  r]   rB  r  )rd   r  rc  r  r}   s        ri   put_init_var_to_py_nonez#CCodeWriter.put_init_var_to_py_none	  sY    %+% 	  uz5999 	(Y'''''	( 	(rk   c                 x   d}|j         s|j        dk    rRddlm} d}|j        t          vr<|                    |j                  s"|j        dk    r| j        j        d         sn|rd S |j        	                                }|sd S |j         r||j
        gz  }|r|                    |          n|j        }|j                                        }	|	dk    rd	|	d
|}|j                                        }
|rb|                    | j        j                                      |j                  }|                                }|r|                     |           |                     d|
d|dd                    |          d|j        r|j        ndd|
           |r|r|                     d           d S d S d S )NF__getattribute__r   )	TypeSlotsT__getattr__fast_getattrPyCFunctionz(void*)(r  r  z, (PyCFunction)r  |r  rz  r  )
is_specialr   r   r^  special_py_methodsis_reverse_number_slotrt  r  	signaturemethod_flagsmethod_coexistput_pymethoddef_wrapper
func_cnamemethod_function_typeas_c_string_literalget_slot_tableget_slot_by_method_namepreprocessor_guard_coder|   r   doc	doc_cname)rd   r  term
allow_skipwrapper_code_writerre  r^  rg  func_ptrcast
entry_nameslotpreproc_guards                ri   put_pymethoddefzCCodeWriter.put_pymethoddef	  s&   !& 
	uz-???######%)"z!333I<\<\]b]g<h<h3:..t7G7RSa7b.   F3355 	F 	7Y566LI\r&>>uEEEbgbr3355=   *.$$9HZ3355
! 	* ++D,<,GHH``afakllD 88::M *

=)))




&&&&#(95#55	 	 	 " 	!m 	!JJx     	! 	! 	! 	!rk   c                    |j         }|j        r|j                                        pg }ddlm} ||v rt          j        |z   }|                     d|z             d|j         z  }|j	        dk    rC|                     d|z             |                     d           |                     d           n|                     d	|z             |                     d
           |S )Nr   )method_noargszBstatic PyObject *%s(PyObject *self, CYTHON_UNUSED PyObject *arg) {z%s(self)rI   zPyObject *res = %s;zFif (!res && !PyErr_Occurred()) { PyErr_SetNone(PyExc_StopIteration); }zreturn res;z
return %s;rz  )
rj  rc  rf  rg  r^  r|  r	   method_wrapper_prefixr|   r   )rd   r  rj  rg  r|  	func_calls         ri   ri  z#CCodeWriter.put_pymethoddef_wrapperC	  s    %
 	  ?7799?RL000000,,#9JF


_bllmmm&)99	:++JJ4y@AAAJJghhhJJ}----JJ|i7888

3rk   c                     | j         j        d         r5| j                             t                              dd                     d S | j                             t                              dd                     d S )Nfast_gilFastGilrs  	NoFastGil)rt  r  rS  r   r   ru   s    ri   use_fast_gil_utility_codez%CCodeWriter.use_fast_gil_utility_codeY	  sr    &z2 	i--k.E.EiQd.e.efffff--k.E.EkSf.g.ghhhhhrk   c                 N   | j                             t                              dd                     |                                  |                     d           |sd}|r|                     d           |                     d|z             |                     d           dS )	a  
        Acquire the GIL. The generated code is safe even when no PyThreadState
        has been allocated for this thread (for threads not initialized by
        using the Python API). Additionally, the code generated by this method
        may be called recursively.
        ForceInitThreadsrs  #ifdef WITH_THREAD__pyx_gilstate_savezPyGILState_STATE z%s = __Pyx_PyGILState_Ensure();r  N)rt  rS  r   r   r  r|   rU  )rd   declare_gilstatevariables      ri   put_ensure_gilzCCodeWriter.put_ensure_gil_	  s     	))##$68KLL	N 	N 	N&&(((

'((( 	.,H .,---

4x?@@@

8rk   c                     |                                   |sd}|                     d           |                     d|z             |                     d           dS )zD
        Releases the GIL, corresponds to `put_ensure_gil`.
        r  r  z__Pyx_PyGILState_Release(%s);r  Nr  r|   )rd   r  s     ri   put_release_ensured_gilz#CCodeWriter.put_release_ensured_gilq	  sf     	&&((( 	-,H

'(((

2X=>>>

8rk   c                 f   |                                   |                     d           |                     d           |r|                     d|z             |r|                     d           |                     d           |r|                     d           |                     d           dS )	z
        Acquire the GIL. The thread's thread state must have been initialized
        by a previous `put_release_gil`
        r  z__Pyx_FastGIL_Forget();z_save = %s;zif (_save) {Py_BLOCK_THREADSrz  r  Nr  rd   r  unknown_gil_states      ri   put_acquire_gilzCCodeWriter.put_acquire_gil|	  s    
 	&&(((

'(((

,--- 	1JJ}x/000 	'JJ~&&&

%&&& 	JJsOOO

8rk   c                    |                                   |                     d           |                     d           |                     d           |r|                     d           |                     d           |r|                     d           |r|                     d|z             |                     d           |                     d	           d
S )z2Release the GIL, corresponds to `put_acquire_gil`.r  zPyThreadState *_save;z_save = NULL;zif (PyGILState_Check()) {Py_UNBLOCK_THREADSrz  z%s = _save;z__Pyx_FastGIL_Remember();r  Nr  r  s      ri   put_release_gilzCCodeWriter.put_release_gil	  s    &&(((

'(((

*+++

?### 	4 JJ2333

'((( 	JJsOOO 	1JJ}x/000

.///

8rk   c                     |                      d           |                      d           |                      d           d S )Nr  z%PyGILState_STATE __pyx_gilstate_save;r  r  ru   s    ri   r  zCCodeWriter.declare_gilstate	  s@    

'(((

:;;;

8rk   c                 ^    |                      d|d|                     |                    S )Nif (z < 0) )r|   r  )rd   r  r   s      ri   put_error_if_negzCCodeWriter.put_error_if_neg	  s0     zzzeeeT__S5I5I5IJKKKrk   c                 t   |j         r7d}| j                            t                              dd                     n|j        j        r8|r6d}| j                            t                              dd                     n|j        j        r=|j        r6d}| j                            t                              dd                     n|j        j        rP|j	        rI|j
        sB|j        j        r6d}| j                            t                              d	d                     n5d
}| j                            t                              dd                     |s|j                            |j                  }|                     d|d|d|j        d|                     |          d	           d S )N__Pyx_RaiseClosureNameErrorRaiseClosureNameErrorr  &__Pyx_RaiseUnboundMemoryviewSliceNogil RaiseUnboundMemoryviewSliceNogil__Pyx_RaiseCppGlobalNameErrorRaiseCppGlobalNameError__Pyx_RaiseCppAttributeErrorRaiseCppAttributeError__Pyx_RaiseUnboundLocalErrorRaiseUnboundLocalErrorzif (unlikely(!z)) { z("z"); z })from_closurert  rS  r   r   r]   r  r  
is_cglobalis_variable	is_memberrz  is_c_class_scopecheck_for_null_coder-  r|   r   r  )rd   r  r  in_nogil_contextunbound_check_coder2  s         ri   put_error_if_unboundz CCodeWriter.put_error_if_unbound	  s    	W0D--''(?ASTTV V V VZ* 	W/? 	W;D--''(JL^__a a a aZ$ 	W)9 	W2D--''(ACUVVX X X XZ$ 		W): 		W5? 		WW\WbWs 		W 2D--''(@BTUUW W W W 2D--''(@BTUUW W W " 	M!&!?!?!L!L


 2 2 2 $ %


 $ 4 4 4 4	6 	7 	7 	7 	7 	7rk   c                     d| j         _        |rd| j         _        d|                     |d                   d|d         dS )NTz__PYX_MARK_ERR_POS(r   r  r   r  )r,  r  r  r  )rd   r  r  s      ri   set_error_infozCCodeWriter.set_error_info	  sO    8<5 	726DN/  Q((((FFF 	rk   c                     | j         j        }| j                             |           |d|z  S d| j         _        |rd| j         _        d|                     |d                   d|d         d|dS )Nr  Tz
__PYX_ERR(r   r  r   r  )r,  r{  r  r  r  r  )rd   r  r  r  s       ri   r  zCCodeWriter.error_goto	  s    n(  %%%;##8<5 	726DN/  Q((((FFFCC 	rk   c                 ^    d|                      |          d|                     |          S )Nr  r  )r  r  )rd   r  r  s      ri   error_goto_ifzCCodeWriter.error_goto_if	  s0     #}}T2222DOOC4H4H4HIIrk   c                 4    |                      d|z  |          S )Nz!%sr  rd   r-  r  s      ri   r  zCCodeWriter.error_goto_if_null	  s    !!%%-555rk   c                 4    |                      d|z  |          S )Nz(%s < 0)r  r  s      ri   error_goto_if_negzCCodeWriter.error_goto_if_neg	  s    !!*u"4c:::rk   c                 .    |                      d|          S )NzPyErr_Occurred()r  )rd   r  s     ri   rW  zCCodeWriter.error_goto_if_PyErr	  s    !!"4c:::rk   c                 6    | j                             |          S rt   )rt  r  )rd   r   s     ri   r  zCCodeWriter.lookup_filename	  s    //999rk   c                 0    |                      d           d S )N__Pyx_RefNannyDeclarationsr  ru   s    ri   rf  z(CCodeWriter.put_declare_refcount_context	  s    

/00000rk   c                     |                                 }|r3| j                            t                              dd                     |                     d||rdpdfz             d S )Nr  rs  z#__Pyx_RefNannySetupContext(%s, %d);r   r   )rl  rt  rS  r   r   r|   )rd   r   acquire_gils      ri   rg  z&CCodeWriter.put_setup_refcount_context	  s~    '')) 	R--''(:<OPPR R R

8D+BSRSBXWX;YYZZZZZrk   c                 8    |                      |rdnd           d S )Nz"__Pyx_RefNannyFinishContextNogil()z__Pyx_RefNannyFinishContext();r  )rd   nogils     ri   r~  z'CCodeWriter.put_finish_refcount_context	  s&    

5f77Ffgggggrk   c                     |                                 }||rt          j        ndt          j        t          j        f}d| j        _        |                     d|z             dS )z
        Build a Python traceback for propagating exceptions.

        qualified_name should be the qualified name of the function.
        r   Tz#__Pyx_AddTraceback(%s, %s, %s, %s);N)rl  r	   r  r  r  r,  r  r|   )rd   qualified_nameinclude_clineformat_tuples       ri   put_add_tracebackzCCodeWriter.put_add_traceback	  se     (;;==$18F  q!	
 /3+

8<GHHHHHrk   c                     |t           j        t           j        t           j        | j        j        d         |f}d| j        _        |                     d|z             | j        	                    t                              dd                     dS )z
        Generate code to print a Python warning for an unraisable exception.

        qualified_name should be the qualified name of the function.
        unraisable_tracebacksTz0__Pyx_WriteUnraisable("%s", %s, %s, %s, %d, %d);WriteUnraisableExceptionzExceptions.cN)r	   r  r  r  rt  r  r,  r  r|   rS  r   r   )rd   r  r  r  s       ri   put_unraisablezCCodeWriter.put_unraisable
  s      !'(?@
 /3+

ETUUU))##$>OO	Q 	Q 	Q 	Q 	Qrk   c                 0    |                      d           d S )N__Pyx_TraceDeclarationsr  ru   s    ri   put_trace_declarationsz"CCodeWriter.put_trace_declarations!
      

,-----rk   c                 >    |r|                      d|z             d S d S )Nz__Pyx_TraceFrameInit(%s)r  )rd   codeobjs     ri   put_trace_frame_initz CCodeWriter.put_trace_frame_init$
  s2     	=JJ1G;<<<<<	= 	=rk   c                     |                      d|t          j        |                     |d                   |d         ||                     |          fz             d S )Nz*__Pyx_TraceCall("%s", %s[%s], %s, %d, %s);r   r   )r|   r	   filetable_cnamer  r  )rd   r   r  r  s       ri   put_trace_callzCCodeWriter.put_trace_call(
  sn    

?&($*>*>s1v*F*FAPUW[WfWfgjWkWkCm m 	n 	n 	n 	n 	nrk   c                 0    |                      d           d S )Nz__Pyx_TraceException();r  ru   s    ri   put_trace_exceptionzCCodeWriter.put_trace_exception,
  r  rk   c                 :    |                      d||fz             d S )Nz__Pyx_TraceReturn(%s, %d);r  )rd   retvalue_cnamer  s      ri   put_trace_returnzCCodeWriter.put_trace_return/
  s%    

/>52IIJJJJJrk   c                     |                      d           |                      |           |                      d           d S )Nz#ifdef _OPENMPz#endif /* _OPENMP */r  )rd   strings     ri   putln_openmpzCCodeWriter.putln_openmp2
  s@    

#$$$

6

)*****rk   c                    |                      d|z             |                      d           |                      d           |                      d           |                      d           |                      d           dS )zl
        Redefine the macros likely() and unlikely to no-ops, depending on
        condition 'cond'
        r      #undef likely    #undef unlikelyz    #define likely(x)   (x)z    #define unlikely(x) (x)r  Nr  r  s     ri   undef_builtin_expectz CCodeWriter.undef_builtin_expect7
  s~    
 	

8d?###

&'''

()))

0111

0111

8rk   c                    |                      d|z             |                      d           |                      d           |                      d           |                      d           |                      d           d S )Nr  r  r  z2    #define likely(x)   __builtin_expect(!!(x), 1)z2    #define unlikely(x) __builtin_expect(!!(x), 0)r  r  r  s     ri   redef_builtin_expectz CCodeWriter.redef_builtin_expectC
  s|    

8d?###

&'''

()))

GHHH

GHHH

8rk   )NNF)NNTrt   r)  r)  )r   F)T)r   NT)TT)FTTr  )rY  T)TNNT)FNr(  )r   r   r   r   cythonlocalsrj   rH  r_  rL  rN  r   rP  rQ  rc  r\  r^  r3  r|  r  r{  r}  r  r  rh  r  rq  r~  r  r  r  r  r  r  r  r  r  r  re  r}  r  r  r  r  r  r+  r  r%  r  r  r|   rm  r  r  r  rT  rU  r  r  r  r  r  r  r|  rl  r  r  r  r  r  modifier_output_mapperr  r  r  r  r  r   r  r  r  r  r  r  r  r   r#  r(  r*  r,  r.  r1  r3  r7  r:  r=  r?  rC  rF  rH  rJ  rO  rR  rT  rX  r[  rz  ri  r  r  r  r  r  r  r  r  r  r  r  r  r  rW  r  rf  rg  r~  r  r  r  r  r  r  r  r  r  r  r   rk   ri   r:  r:    s        < V]}---? ? ? .-?4  4 4 4
  & & &% % %! ! !    - - -* * * !! !      "" " 33 3    & & & &2 MLLLSSSSSSNNNTTTSSSMMMSSSMMMKKKLLL: : : :  I I IM M M[ [ [ [= = => > > 488<; ; ; ;
9 9 9. . .? ? ?D D D D
   % % % %M M Mc c c  
    .        1 1 1I I I% % %% % % 8:9=; ; ; ;4I I I.  ) ) )   :P B B B B  5 5 5* * *+ + +, , ,+ + +7 7 7 78 8 8 8J J J JK K K K> > > >> > > >9 9 9: : :S S ST T T1 1 12 2 22 2 23 3 39 9 9: : :9 9 9: : :e e eH H HI I If f f/ / / /( ( (. . .J J J J( ( ( ()! )! )! )!V  ,i i i   $	 	 	 	   "   $  L L L
7 7 7 7@      J J J6 6 6; ; ;; ; ;: : :1 1 1[ [ [ [h h h hI I I I"Q Q Q Q&. . .= = = =n n n n. . .K K K K+ + +

 
 
    rk   r:  c                   &    e Zd Zd Zd Zd Zd ZdS )PyrexCodeWriterc                 F    t          j        |          | _        d| _        d S rT  )r   r  r   rB  )rd   outfile_names     ri   rj   zPyrexCodeWriter.__init__P
  s    $\22


rk   c                 T    | j                             d| j        z  |d           d S )Nr  r   )r   r   rB  r  s     ri   r|   zPyrexCodeWriter.putlnT
  s/    tz!1!1444899999rk   c                 &    | xj         dz  c_         d S r  r  ru   s    ri   r  zPyrexCodeWriter.indentW
  r  rk   c                 &    | xj         dz  c_         d S r  r  ru   s    ri   dedentzPyrexCodeWriter.dedentZ
  r  rk   N)r   r   r   rj   r|   r  r  r   rk   ri   r  r  L
  sP          : : :      rk   r  c                   t    e Zd ZdZddZddZddZed	             Zd
 Z	d Z
ddZd ZddZd Zd Zd ZdS )PyxCodeWriterz7
    Can be used for writing out some Cython code.
    Nr   rC   c                 h    |pt                      | _        || _        || _        || _        || _        d S rt   )r   r>  rB  original_levelr  r   )rd   r>  indent_levelr  r   s        ri   rj   zPyxCodeWriter.__init__c
  s3    .!
* rk   r   c                 &    | xj         |z  c_         dS r  r  rd   levelss     ri   r  zPyxCodeWriter.indentj
  s    

f

trk   c                 &    | xj         |z  c_         d S rt   r  r  s     ri   r  zPyxCodeWriter.dedentn
  s    

f



rk   c              #      K   |                      |           |                                  dV  |                                  dS )zf
        with pyx_code.indenter("for i in range(10):"):
            pyx_code.putln("print i")
        N)r|   r  r  rd   r   s     ri   indenterzPyxCodeWriter.indenterq
  sA       	

4rk   c                 4    | j                                         S rt   )r>  emptyru   s    ri   r  zPyxCodeWriter.empty|
  s    {  """rk   c                     | j                                         }t          |t                    r|                    | j                  }|S rt   )r>  rN  r  r   r  r   )rd   r  s     ri   rN  zPyxCodeWriter.getvalue
  s?    %%''fe$$ 	2]]4=11Frk   c                 f    |p| j         }|rt          ||          }|                     |           d S rt   )r  rd  _putln)rd   r   r  s      ri   r|   zPyxCodeWriter.putln
  s=    )T\ 	.tW--DDrk   c                 T    | j                             | j        dz  |d           d S )Nz    r   )r>  r   rB  r  s     ri   r  zPyxCodeWriter._putln
  s1    tzG';';TTTBCCCCCrk   c                     |p| j         }|rt          ||          }t          j        |          }|                                D ]}|                     |           d S rt   )r  rd  r   r  rK  r  )rd   chunkr  r   s       ri   	put_chunkzPyxCodeWriter.put_chunk
  sn    )T\ 	0w//E&&$$&& 	 	DKK	 	rk   c                 x     t          |           | j                                        | j        | j                  S rt   )r]   r>  rc  rB  r  ru   s    ri   rc  zPyxCodeWriter.insertion_point
  s.    tDzz$+5577T\RRRrk   c                 P    | j                                          | j        | _        d S rt   )r>  resetr  rB  ru   s    ri   r  zPyxCodeWriter.reset
  s&     	(


rk   c                 L    t          | ||                                            d S rt   )r/  rc  rs  s     ri   named_insertion_pointz#PyxCodeWriter.named_insertion_point
  s&    dD002233333rk   )Nr   NrC   )r   rt   )r   r   r   r   rj   r  r  r   r  r  rN  r|   r  r  rc  r  r  r   rk   ri   r  r  ^
  s         ! ! ! !         ^# # #     D D D   S S S) ) )4 4 4 4 4rk   r  c                        e Zd Zd Zd Zd ZdS )r  c                 >    || _         i | _        i | _        d| _        d S rT  )klassr  r  temps_count)rd   r	  s     ri   rj   zClosureTempAllocator.__init__
  s&    
!rk   c                 r    | j                                         D ]\  }}t          |          | j        |<   d S rt   )r  r   r   r  )rd   r]   r  s      ri   r  zClosureTempAllocator.reset
  sC     06688 	1 	1LD&$(LLDOD!!	1 	1rk   c                 f   || j         vrg | j         |<   g | j        |<   n-| j        |         r | j        |                             d          S dt          j        | j        fz  }| j                            d |||d           | j         |                             |           | xj        dz  c_        |S )Nr   r  T)r  r   r-  r]   is_cdefr   )	r  r  r  r	   r  r
  r	  declare_varr   )rd   r]   r-  s      ri   r  z"ClosureTempAllocator.allocate_temp
  s    t+++)+D &$&DOD!!_T" 	0?4(,,Q///&79IJJ
4e5tUYZZZT"))%000Ark   N)r   r   r   rj   r  r  r   rk   ri   r  r  
  sA          1 1 1
 
 
 
 
rk   r  r   )J
__future__r   r  declareobjectr  r   r   r   r  r   r  r   	functoolsr   
contextlibr   r   collectionsr   r   r	   r
   r   r   r   Scanningr   r   __builtin__r   ImportErrorbuiltinsr   r  ctypedef_builtins_mapbasicsize_builtins_mapuncachable_builtins	frozensetrd  rx   r  rV   r   r   r   r   r   rd  r   ro  rv  r  r  r   r  Ur   r  r  r  r   r  findallr  r  r   r0  r3  r5  r:  r  r  r  r   rk   ri   <module>r     s   ' & & & & &   / / /&& /VV /ff /vv //'-v/7=v/NTf/V/.4f/CI6/ !&/ .4V/ BH/ v	/ (.v	/ /   				 				               . . . . . . . . # # # # # #                               & & & & & & ' ' ' ' ' '+&&&&&&& + + +********+ 76688   ))*1   & 
- - - ^ $V^Iyy : 0 0    o 
I' I' I' I' I'& I' I' I'X/ / /     6 ` ` ` ` `f ` ` `Fy8 y8 y8 y8 y8/ y8 y8 y8x "&D" ( ( ( (&= = = = = = = =>. . . . .o . . . I9 I9 I9 I9 I9F I9 I9 I9X. . . . .v . . .     F    6V"(A A A A(bj):)A)A')J)JBDQQW &BJ'7'>'>w'G'GHHN RZ 1226 ,--5M M M M M& M M M^( ( ( ( (F ( ( (.Z
A Z
A Z
A Z
A Z
A& Z
A Z
A Z
Az  7 7 7 7 7& 7 7 7} } } } }& } } }@    f   $C4 C4 C4 C4 C4F C4 C4 C4L    6     s   #B* *B87B8