
    hS                    n   S SK r \ R                  " S{0 S\_S\_S\_S\_S\_S\_S\_S	\_S
\_S\_S\_S\_S\_S\_S\_S\_6  S SKrS SKrS SKrS SKrS SKrS SKrS SK	J
r
  S SKJrJr  S SKJrJr  S SKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSS S!S".rS#S#S$S%S&.rS'S(0rS)r\ " / S*Q5      r!/ S+Qr"\ R                  " \ \ " S,5      5      r#S-S.0RH                  r%\ R                  " \SSSS/.RH                  5      r& " S0 S15      r'S2 r(Sr) S3 r*\*r) " S4 S55      r+ " S6 S7\+5      r, " S8 S9\,5      r-SS:S/S;.S< jr.\." S=S>S?9S@ 5       r/\." 5       SA\-4SB j5       r0\." SCSDSESF9SG 5       r1\." SHSISDSJSF9SK 5       r2\." SLSMS?9SN 5       r3\." SOS:SPSF9SQ 5       r4\." 5       SR 5       r5SS0 4SS jr6 " ST SU\-5      r7 " SV SW\,5      r8 " SX SY5      r9 " SZ S[5      r: " S\ S]5      r;\ R                  " \\\\S^9  \Rx                  " S_\Rz                  5      R|                  r?\Rx                  " S`5      R|                  r@\Rx                  " Sa5      R                  rB\Rx                  " Sb5      R                  rD " Sc Sd5      rE " Se Sf5      rF " Sg Sh5      rGSi rH " Sj Sk5      rI " Sl Sm5      rJ " Sn So5      rK " Sp Sq5      rL\ R                  \ R                  Sr\OSs\ R                  St\O4Su j5       5       rQ\ R                  " Sv5      \ R                  Sw\OSt\ R                  4Sx j5       5       rT " Sy Sz5      rUg)|    NosreoperatortextwrapTemplateNamingOptionsStringEncodingUtilsSourceDescriptorStringIOTree
DebugFlagsdefaultdictclosingpartialwrapsr   )r   r   )r   contextmanager)r      )r   )r	   )r   )r
      )r   )r   )r   strrangeinput)unicode
basestringxrange	raw_inputz&PyLong_Typez&PyFloat_Typez&PyWrapperDescr_Type)py_intpy_longpy_floatwrapper_descriptorPyTypeObjectPyHeapTypeObject)      r   alpha   )ArithmeticErrorAssertionErrorAttributeErrorBaseExceptionBaseExceptionGroupBlockingIOErrorBrokenPipeErrorBufferErrorBytesWarningChildProcessErrorConnectionAbortedErrorConnectionErrorConnectionRefusedErrorConnectionResetErrorDeprecationWarningEOFErrorEllipsisEncodingWarningEnvironmentError	ExceptionExceptionGroupFalseFileExistsErrorFileNotFoundErrorFloatingPointErrorFutureWarningGeneratorExitIOErrorImportErrorImportWarning_IncompleteInputErrorIndentationError
IndexErrorInterruptedErrorIsADirectoryErrorKeyErrorKeyboardInterruptLookupErrorMemoryErrorModuleNotFoundError	NameErrorNoneNotADirectoryErrorNotImplementedNotImplementedErrorOSErrorOverflowErrorPendingDeprecationWarningPermissionErrorProcessLookupErrorPythonFinalizationErrorRecursionErrorReferenceErrorResourceWarningRuntimeErrorRuntimeWarningStopAsyncIterationStopIterationSyntaxErrorSyntaxWarningSystemError
SystemExitTabErrorTimeoutErrorTrue	TypeErrorUnboundLocalErrorUnicodeDecodeErrorUnicodeEncodeErrorUnicodeErrorUnicodeTranslateErrorUnicodeWarningUserWarning
ValueErrorWarningWindowsErrorZeroDivisionError__build_class__	__debug__
__import__absaiterallanextanyasciibinbool
breakpoint	bytearraybytescallablechrclassmethodcompilecomplex	copyrightcreditsdelattrdictdirdivmod	enumerateevalexecexitfilterfloatformat	frozensetgetattrglobalshasattrhashhelphexidr   int
isinstance
issubclassiterlenlicenselistlocalsmapmax
memoryviewminnextobjectoctopenordpowprintpropertyquitr   reprreversedroundsetsetattrslicesortedstaticmethodr   sumsupertupletypevarszip)
rF   rZ   r,   r<   ry   r{   r9   r   rs   _)		__cinit____dealloc____richcmp____next__	__await__	__aiter__	__anext____getbuffer____releasebuffer__inlineCYTHON_INLINE)ustringr   r   c                   J    \ rS rSrSrSrSrSrSrSS jr	S r
S	 rS
 rS rSrg)IncludeCode   zQ
An include file and/or verbatim C code to be included in the
generated sources.
r   r   r   Nc                    U R                   U l        [        U 5      =R                   S-  sl         0 U l        U(       aQ  US   S:X  a*  US   S:X  a!  SR	                  U5      U R                  S'   SnOSR	                  U5      U R                  S'   U(       a  X R                  U R                  '   U(       a  U R
                  U l        g U(       a  U R                  U l        g U R                  U l        g )	Nr   r   <>z#include {}Fz#include "{}")	counterorderr   piecesr   INITIALlocationLATEEARLY)selfincludeverbatimlateinitials        N/var/www/fran/franai/venv/lib/python3.13/site-packages/Cython/Compiler/Code.py__init__IncludeCode.__init__  s    \\
T
aqzS WR[C%7!.!5!5g!>A!0!7!7!@A&.KK

# LLDM IIDM JJDM    c                     X!;   aO  X   n[        U R                  UR                  5      Ul        UR                  R                  U R                  5        gXU'   g)z
Insert `self` in dict `d` with key `key`. If that key already
exists, update the attributes of the existing value with `self`.
N)r   r   r   update)r   dkeyothers       r   dict_updateIncludeCode.dict_update.  sC    
 8FE ?ENLL,cFr   c                     U R                   $ N)r   r   s    r   sortkeyIncludeCode.sortkey:  s    zzr   c                 8    U R                   R                  S5      $ )zp
Return the main piece of C code, corresponding to the include
file. If there was no include file, return None.
r   )r   getr   s    r   	mainpieceIncludeCode.mainpiece=  s    
 {{q!!r   c                 x    [        U R                  5       H!  nUR                  U R                  U   5        M#     g r   )r   r   putln)r   codeks      r   writeIncludeCode.writeD  s)    $AJJt{{1~& %r   )r   r   r   )NNTF)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   r   r   __static_attributes__ r   r   r   r      s6    & GEDG',
"'r   r   c                      [         R                  R                  [         R                  R                  [         R                  R                  [        5      5      5      n [         R                  R                  U S5      $ )NUtility)r   pathdirnameabspath__file__join)
Cython_dirs    r   get_utility_dirr	  J  sE     1J!KLJ77<<
I..r   c                     [         R                  R                  [        5       U 5      n[	        [
        R                  " USS95       nUR                  5       sSSS5        $ ! , (       d  f       g= f)z\
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      r   read_utilities_from_utility_dirr  [  sH    
 ww||O-t4H	''7C	D{{} 
E	D	Ds   A!!
A/c                   *    \ rS rSrSrS rS rS rSrg)AbstractUtilityCodeih  Nc                     g r   r   )r   outputs     r   put_codeAbstractUtilityCode.put_codel  s    r   c                     g r   r   r   kwargss     r   get_treeAbstractUtilityCode.get_treeo      r   c                     g r   r   r  s     r   get_shared_library_scope,AbstractUtilityCode.get_shared_library_scoper  r  r   r   )	r   r   r   r   requiresr  r  r  r   r   r   r   r  r  h  s    Hr   r  c                       \ rS rSrSrSr0 r\SS j5       r\S 5       r	\S 5       r
\0 4S j5       r\SS	 j5       r\R                  " S
5      R                  4S jrS rS rS rSS jrSrg)UtilityCodeBaseiv  a  
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   Uc  g SR                  U5      nU(       aT  SU;   aN  SUS   ;   aE   [        U5      R                  [        [        5      5      nX:X  a  [        S	U SU S
US S35      eUnSU-  U-   nUS:X  a  XqS'   OUS:X  a  XqS'   O	US   n
XzU'   U(       aH  US   n
UR                  5        H.  u  p+U
R                  U[        5       5      R                  U5        M0     g g ! [
        [        4 a  n	[        SU SU SUS SU	 35      eS n	A	ff = f)N

substitutenamingz&Error parsing templated utility code '.z
' at line r   z: zFFound useless 'substitute: naming' declaration without replacements. (:)protor   implr   r   )r  r   r&  r   r   rK   rq   r^   items
setdefaultr   r   )clsutilitynamer   linesbegin_linenotagsr   new_codeeall_tagsvaluess               r   _add_utilityUtilityCodeBase._add_utility  sU   ?yyLD(Xl9K-Kk#D>44T&\B "\]a\bbcdhciijkwxyjzz{|~ ~D l"T)7?AJV^AJqzH!TNqzH $

##D#%077? !- ' j) k"<TF!D6T`abSccefgehik kks   'C( (D8DDc           	      *   U R                   R                  U5      nU(       a  U$ [        R                  R	                  U5      u  p4US;   a=  Sn[        [        R                  " S5      R                  S5      n[        R                  nOVSn[        [        R                  " S5      R                  S5      n[        [        R                  " S5      R                  S5      n[        R                  " S	S
U0-  5      R                  n[        R                  " S5      R                  n	[        U5      n
[        S 5      n/ n[        [        5      nS =n=pSn[        U
5       H  u  nnU" U5      nU(       a  UR!                  S5      (       ai  U R#                  XXUU5        US-   nUS S 2	 UR%                  5         UR!                  S5      nU	" U5      nU(       a  UR'                  5       u  pOSnX.   nM  UUR!                  S5         R)                  UR!                  S5      5        UR+                  S5        M  UR+                  U" U" U5      5      5        M     Uc  [-        S5      eU R#                  XXUU5        [/        U5      nX R                   U'   U$ )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|module_state_decls)$c                      S S 0 /$ r   r   r   r   r   <lambda>:UtilityCodeBase.load_utilities_from_file.<locals>.<lambda>  s    tR(8r   r   r1  r   r,  tagvaluezEmpty utility code file)_utility_cacher   r   r  splitextr   r   r   subr   rstripmatchread_utilities_hookr   r   r   groupr9  cleargroupsaddappendrq   r   )r/  r  	utilitiesr   extcommentstrip_commentsrH  match_special
match_type	all_linesr2  r4  r0  r1  r   r3  linenolinemmtypes                        r   load_utilities_from_file(UtilityCodeBase.load_utilities_from_file  s9   &&**40	!!$'11G$RZZ0K%L%P%PRTUNZZFG$RZZ0G%H%L%LbQNRZZ5995AF

C'N "E 	 ZZ bcii
'-	 89	3 $$$$%i0LFDd#A776??$$WDtT#)A:LaJJL776?D&t,E%*\\^
d%'oG(,,QWWW-=>LL$VN4$89:+ 1. ?677 	\4HO	#,4 r   c           	      "   SU;   a  UR                  SS5      u  p!U(       d   eU R                  U5      nXA   u  pVnU(       Ga  SU;   a5  SUS   ;   a,  [        U [        5      (       d  [        R                  " X40 UD6$ UR                  5       nUR                  5        H  u  pX;   a  M  U	S:X  a_  U(       a-  [        U
5       Vs/ s H  nU R                  " X40 UD6PM     n
nOi[        U
5       Vs/ s H  nU R                  X5      PM     n
nO>U	S:X  a  U
SS1-
  n
U
(       d  M  O'U
(       d  Sn
O[        U
5      S:X  a  [        U
5      S   n
XU	'   M     Ub  XSS	'   Ub  XcS
'   SU;  a  XS'   SU;  a  U(       a  X#S'   U " S0 UD6$ s  snf s  snf )zl
Load utility code from a file specified by from_file (relative to
Cython/Utility) and name util_code_name.
z::r   r&  tempitar!  r'  Nr   r+  r,  r1  filer   )rsplitr[  r   TempitaUtilityCodeloadcopyr-  r   load_cachedr   r   )r/  util_code_name	from_filer  rP  r+  r,  r4  orig_kwargsr1  r8  deps               r   rb  UtilityCodeBase.load  s    >!(6(=(=dA(F%Iy00;	%5Tt#	T,5G(G!#'9::-22>WPVWW ++-K $

>:%"-3F^"=-;c #&((3"I["I-;  "=
 .4F^"=-;c #&//#"A-;  "=\) $x&;;F!  "!F[A%!&\!_F%t- !-0 #7O!6N+6NI&6N}V}9"="=s   F2Fc                 b    XU 4n X4   $ ! [          a     Of = fU R                  X5      =oSU'   U$ )zP
Calls .load(), but using a per-type cache based on utility name and file name.
)rK   rb  )r/  utility_code_namerf  _UtilityCodeBase__cacher   r   s         r   rd  UtilityCodeBase.load_cached4  sH    
 !S1	< 		!hh'8DDs|s   
 
c                   ^^^ U R                   " X40 UD6nU(       d6  UR                  UR                  5      UR                  UR                  5      4$ / / smmUUU4S jmT" U5        SR	                  T5      SR	                  T5      4$ )an  
Load a utility code as a string. Returns (proto, implementation).

If 'include_requires=True', concatenates all requirements before the actually
requested utility code, separately for proto and impl part.

In a lot of cases it may be better to use regular "load" and "CCodeWriter.put_code_here"
since that is able to apply the code transformations to the code too.
c                 L  > U R                   (       a  U R                    H  nT" U5        M     U R                  (       a*  TR                  U R                  U R                  5      5        U R                  (       a+  TR                  U R                  U R                  5      5        g g r   )r!  r+  rO  format_coder,  )	util_coderh  implsprependprotoss     r   rs  /UtilityCodeBase.load_as_string.<locals>.prependS  sl    !!$--CCL .i33IOODE~~Y229>>BC r   r=  )rb  rp  r+  r,  r  )	r/  re  rf  include_requiresr  utilrr  rs  rt  s	         @@@r   load_as_stringUtilityCodeBase.load_as_stringA  s     xx<V<$$TZZ0$$TYY/1 1 B	D 	wwv..r   z\n\n+c                 H    U(       a  U" SUR                  5       5      S-   nU$ )z#
Format a code section for output.
r%  z

)strip)r   code_stringreplace_empty_liness      r   rp  UtilityCodeBase.format_code_  s'     -dK4E4E4GH6QKr   c                 R    S[        U 5      R                  < SU R                  < S3$ )Nr   (z)>)r   r   r1  r   s    r   __repr__UtilityCodeBase.__repr__g  s    !$Z00$))<<r   c                     g r   r   r  s     r   r  UtilityCodeBase.get_treej  r  r   c                     g r   r   r  s     r   r  (UtilityCodeBase.get_shared_library_scopem  r  r   c                     U $ r   r   )r   memodicts     r   __deepcopy__UtilityCodeBase.__deepcopy__p  s    r   r   r   F)r   r   r   r   r   is_cython_utilityrE  r   r9  r[  rb  rd  rx  r   r   rG  rp  r  r  r  r  r   r   r   r   r#  r#  v  s    #J N@ @@ ; ;z 3 3j ?A 
 
 / /: <>::h;O;S;S =r   r#  c                   n    \ rS rSrSr/ SQr   SS jrS rS rS r	SS	 jr
S
SSSS\4S jrS rS rSrg)UtilityCodeiu  a  
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)
)r+  r,  initcleanupmodule_state_declsNc
                    ^  UT l         UT l        UT l        UT l        UT l        UT l        0 T l        / T l        UT l        UT l	        U	T l
        [        U 4S jT R                   5       5      T l        g )Nc              3   >   >#    U  H  n[        TUS 5      v   M     g 7fr   )r   ).0partr   s     r   	<genexpr>'UtilityCode.__init__.<locals>.<genexpr>  s     !X'$d";";s   )r+  r,  r  r  r  r!  _cachespecialize_listproto_blockr1  r_  r   
code_parts_parts_tuple)
r   r+  r,  r  r  r  r!  r  r1  r_  s
   `         r   r   UtilityCode.__init__  sn     
		"4 !&		 "!X!XXr   c                 ,    [        U R                  5      $ r   )r   r  r   s    r   __hash__UtilityCode.__hash__  s    D%%&&r   c                     XL a  g[        U 5      [        U5      p2X#La!  [        X5      (       d  [        X5      (       d  gU R                  UR                  :H  $ )NTF)r   r   r  )r   r   	self_type
other_types       r   __eq__UtilityCode.__eq__  sO    = $T
DK:&
50L0LPZ[_PlPl  E$6$666r   c                     Uc  gX-  $ zI
Format a string in this utility code with context. If None, do nothing.
Nr   r   scontexts      r   none_or_subUtilityCode.none_or_sub  s     9{r   c                    U R                   nUb3  UR                  5       US'   UR                  5       US'   U< SUS   < S3n[        [	        UR                  5       5      5      n U R                  U   $ ! [         Ga    U R                  c  S nO0U R                   Vs/ s H  ofR                  U5      PM     Os  snf nn[        U R                  U R                  U5      U R                  U R                  U5      U R                  U R                  U5      U R                  U R                  U5      U R                  U R                   U5      UU R"                  U5      =opR                  U'   U R$                  R'                  U5        Us $ f = f)Nr   	type_name[])r1  empty_declaration_codespecialization_namer   r   r-  r  rK   r!  
specializer  r  r+  r,  r  r  r  r  r  rO  )r   
pyrex_typedatar1  r   r!  rr  s           r   r  UtilityCode.specialize  sV   yy!%<<>DL * > > @D#T+%67DF4::<()	;;s## 	}}$8<F1LL.FF#.  T2  D1  D1  t4  !8!8$?  	$ 	AC    ''*H%	s   &A5 5)FB98CFFwriterCCodeWriterr  GlobalState	code_typec                 <   [        X5      nU(       d  g US;   n[        XU5      u  pFUS:w  a  UOSnUR                  SU R                   U(       a  SOS U S35        U(       a(  U(       d!  UR	                  X@R                   SU 35        g UR                  U5        g )N)r+  r,  r,  r=  /* r(   */r   )r   process_utility_ccoder   r1  put_or_includeput)r   r  r  r  r|  can_be_reusedresult_is_module_specificcode_type_names           r   _put_code_sectionUtilityCode._put_code_section  s    d.!%661FtU`1a.&/6&9rs499+^c%D^DTTWXY!:!!+))Ai[/IJJJ{#r   c                     U R                   (       d  g US   nU R                  X!S5        UR                  UR                  UR                  5      5        UR                  5         g )Ninit_globalsr  )r  r  r   error_goto_if_PyErr
module_pos)r   r  r  s      r   _put_init_code_section"UtilityCode._put_init_code_section  sN    yy'vv6 	V//0A0ABCr   c                 (   U R                   (       a$  U R                    H  nUR                  U5        M     U R                  (       a  U R                  XR                     US5        U R
                  (       a  U R                  US   US5        U R                  (       a+  [        R                  (       a  U R                  US   US5        U R                  (       a  U R                  US   US5        U R                  (       a  U R                  U5        g g )Nr+  utility_code_defr,  cleanup_globalsr  module_state_contentsr  )r!  use_utility_coder+  r  r  r,  r  r	   generate_cleanup_coder  r  r  )r   r  
dependencys      r   r  UtilityCode.put_code  s    =="mm
''
3 , ::""6*:*:#;VWM99""6*<#=vvN<<G99""6*;#<fiP""""6*A#BFL`a99''/ r   )r  r  r  r_  r,  r  r  r1  r+  r  r!  r  )	NNNNNNutility_code_protoNNr   )r   r   r   r   r   r  r   r  r  r  r  r   r  r  r  r   r   r   r   r  r  u  sW    " LJAE37CGY&'7<$ $} $Y\ $$0r   r  F)regexis_module_specific_last_macro_processorc                 .   ^ ^^^^ TS   mUUUUU 4S jnU$ )z8Decorator to chain the code macro processors below.
    r   c                 `   >^  [        T 5      S[        S[        4U UUUU4S jj5       nUTS'   U$ )Nutility_coder|  c                   > SnTb  T" XU5      u  p#T(       a  T H
  nXB;   d  M
    O   X#4$ T	c
  T" XU5      nO"[         R                  " T	[        TU5      U5      nT H$  nXB;   d  M
  [        SU SU R                   S35      e   UT-  nX#4$ )NFzLeft-over utility code macro 'z()' found in '')r   rG  r   r^   r1  )
r  r  r|  r  macrofuncr  last_processormacro_namesr  s
        r   process=add_macro_processor.<locals>.build_processor.<locals>.process  s     ).%)9G^i9j6 (E+ ) 'AA }"<E ffUGD&,A;O %'&)Gwn]i]n]n\oop'qrr % &);;%99r   r   )r   r  r   )r  r  r  r  r  r  r  s   ` r   build_processor,add_macro_processor.<locals>.build_processor  s>    	t	:+ 	:C 	: 	: 
	:8 $+a r   r   )r  r  r  r  r  r  s   ```` @r   add_macro_processorr    s"     +1-N B r   CSTRINGz)CSTRING\(\s*"""([^"]*(?:"[^"]+)*)"""\s*\))r  c                     UR                  S5      R                  SS5      nSR                  S UR                  5        5       5      $ )zUReplace CSTRING('''xyz''') by a C compatible string, taking care of line breaks.
    r   "z\042r=  c              3      #    U  H@  nUR                  S 5      (       a  UR                  S5      (       a  SU S3OSUSS  S3v   MB     g7f)\z\\r  z\n"
Nr   "
)endswith)r  rX  s     r   r  !_wrap_c_string.<locals>.<genexpr>-  sW      *(D !%d 3 3t}}V7L7L!D6TUVZ[^\^V_U``cRdd(s   AA
)rK  replacer  
splitlines)r   matchobjcontents      r   _wrap_c_stringr  %  sF     nnQ''W5G77 *&&(* * *r   r  c                 $    U R                  U5      $ r   )rp  )r  r   r,  s      r   _format_impl_coder  2  s    ##D))r   CALL_UNBOUND_METHODTzLCALL_UNBOUND_METHOD\(([a-zA-Z_]+),\s*"([^"]+)",\s*([^),\s]+)((?:,[^),]+)*)\))r  r  c                 B   UR                  5       u  p#pESU-  nU(       a2  USS R                  S5       Vs/ s H  ofR                  5       PM     snO/ n[        U5      S:  d   S[        U5      S S35       eU R	                  [
        R                   S	3XBX55      $ s  snf )
zRReplace 'UNBOUND_METHOD(type, "name")' by a constant Python identifier cname.
    z&%sr   N,r$   z'CALL_UNBOUND_METHOD() does not support r   z call arguments->)rM  splitr{  r   cached_unbound_method_call_coder   modulestateglobal_cname)r  r  
type_cnamemethod_name	obj_cnameargsargs          r   _inject_unbound_methodr  7  s     08/@,JY#J;?48>>##67#6CIIK#67RDt9q=`CCIa=P_``=11))
*"-{2 2 8s   BPYIDENT	PYUNICODEzPY(IDENT|UNICODE)\("([^"]+)"\)c                     UR                  5       u  p#[        R                  < SU R                  [        R
                  " U5      US:H  S9R                  < 3$ )zDReplace 'PYIDENT("xyz")' by a constant Python identifier cname.
    r  IDENT
identifier)rM  r   r  get_py_string_constr
   EncodedStringcname)r  r  str_typer1  s       r   _inject_string_constantr  O  s\     __&NH&&""((.8w;N 	# 	PPUPU	VW Wr   EMPTYzEMPTY\((bytes|unicode|tuple)\)c                 t    UR                  S5      n[        R                  < S[        [        SU 35      < 3$ )zLReplace 'EMPTY(bytes|tuple|...)' by a constant Python identifier cname.
    r   r  empty_)rK  r   r  r   )r  r  r  s      r   !_inject_empty_collection_constantr  ^  s6     q!I&&&,-/ /r   CGLOBALz(NAMED_)?CGLOBAL\(([^)]+)\)c                 ~    UR                  5       u  p#U(       a  [        [        U5      n[        R                   SU 3$ Nr  )rM  r   r   r  )r  r  is_namedr1  s       r   _inject_cglobalr  m  s9     __&NHvt$,,-Rv66r   c                     U$ )z;Entry point for code processors, must be defined last.
    r   )r  r   r|  s      r   r  r  y  s
     r   c                     U (       d  gU(       a  U SU 3nU(       a  X1S'    X@   nUR                  U5      $ ! [          a    SSKJn  U" XS9=oTU '    N-f = f)z+Run tempita on string s with given context.Nr)  __namer   r   )r1  )rK   Tempitar   r&  )r  r  r_  r1  __cachetemplater   s          r   sub_tempitar    sj    q 7:
 w''	  7& ( 661:7s   8 AAc                   L   ^  \ rS rSrSU 4S jjr\SS0 4S j5       rS rSrU =r	$ )ra  i  Nc                    > Uc  0 nOUR                  5       n[        X&XQ5      n[        X6XQ5      n[        XFXQ5      n[        TU ]  " X#4XAUS.UD6  g )N)r  r1  r_  )rc  r  r   r   )	r   r1  r+  r,  r  r_  r  r  	__class__s	           r   r   TempitaUtilityCode.__init__  sc    ?G llnGED74$54$5	D"D	D<B	Dr   c                     U(       a"  [        [        UR                  5       5      5      OS n[        U5      c   eXX4n XF   $ ! [         a     Of = fU R                  XUS9=otU'   U$ )N)r  )r   r   r-  r   rK   rb  )r/  rk  rf  r  _TempitaUtilityCode__cachecontext_keyr   r   s           r   rd  TempitaUtilityCode.load_cached  su    8?eF7==?34TK ,,,0>	< 		!hh'8WhUUs|s   A 
AAc                 L    Uc  g[        XU R                  U R                  5      $ r  )r  r_  r1  r  s      r   r  TempitaUtilityCode.none_or_sub  s#     91tyy$))<<r   r   )NNNNNN)
r   r   r   r   r   r   rd  r  r   __classcell__)r   s   @r   ra  ra    s/    
D 6:DRT 	 	= =r   ra  c                   ,    \ rS rSrSrSr SrS rS rSrg)LazyUtilityCodei  z~
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                     Xl         g r   callback)r   r-  s     r   r   LazyUtilityCode.__init__  s     r   c                 \    U R                  UR                  5      nUR                  U5        g r   )r-  
rootwriterr  )r   globalstater0  s      r   r  LazyUtilityCode.put_code  s$    -- 6 67$$W-r   r,  )	r   r   r   r   r   r!  r   r  r   r   r   r   r*  r*    s     HH!.r   r*  c                       \ rS rSr\" 5       S4S jrS rSS jrSS jrSS jr	S r
S	 rSS
 jrS rS rS rS rS rSS jrS rS rS rS rS rS rS rS rSrg)FunctionStatei  Nc                    X l         Xl        X0l        S U l        SU l        [        5       U l        U R                  5       U l        U R                  5         S U l
        S U l        / U l        S U l        S U l        SU l        SU l        / U l        0 U l        0 U l        [        5       U l        SU l        S U l        / U l        SU l        SU l        SU l        SU l        g )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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)r   r7  r6  r8  s       r   r   FunctionState.__init__  s    &

5 NN,""!!E! $&  /4+$)!',$#r   c                 &   U R                   (       ay  U R                  5       nU(       aa  SU R                  R                  < SSR	                  [        U5       VVVs/ s H  u  p#nU< SU< S3PM     snnn5      < 3n[        U5      eg g s  snnnf )Nz&TEMPGUARD: Temps left over at end of 'z': , z [r  )rF  temps_in_user8  r1  r  r   r^   )r   	leftoversr1  ctype	is_pytempmsgs         r   validate_exitFunctionState.validate_exit  s    ))+IIMZ^ZcZc282CeE2C.Y "&u-2CeE [F 
 #3''   eEs   Bc                 r    U R                   nUS-   U l         S[        R                  U4-  nUb  USU-   -  nU$ )Nr   %s%dr   )r:  r   label_prefix)r   r1  nlabels       r   r<  FunctionState.new_label  sG    --U&--q11S4ZEr   c                     U R                  SU-  5      n[        U R                  5      S-   U4nU R                  R                  U5        U$ )Nzresume_from_%sr   )r<  r   rA  rO  )r   	expr_typer_  num_and_labels       r   new_yield_labelFunctionState.new_yield_label  sJ    /);<T../!3U;  /r   c                 P    U R                   nU R                  US-   5      U l         U$ )Nerror)r9  r<  )r   prefixold_err_lbls      r   r>  FunctionState.new_error_label  s)    &&>>&7*:;r   c                 2    U R                   U R                  4$ r   r?  r@  r   s    r   get_loop_labelsFunctionState.get_loop_labels  s     	r   c                 "    Uu  U l         U l        g r   rl  r   labelss     r   set_loop_labelsFunctionState.set_loop_labels#  s    #				r   c                     U R                  5       nU R                  U R                  US-   5      U R                  US-   5      45        U$ )Ncontinuebreak)rm  rr  r<  )r   rh  
old_labelss      r   new_loop_labelsFunctionState.new_loop_labels'  sM    ))+
^^FZ/0^^FW,-/	0 r   c                 ^    U R                   U R                  U R                  U R                  4$ r   r?  r@  r=  r9  r   s    r   get_all_labelsFunctionState.get_all_labels.  s0    	 	r   c                 :    Uu  U l         U l        U l        U l        g r   r{  rp  s     r   set_all_labelsFunctionState.set_all_labels5  s#     $								r   c                     U R                  5       n/ n[        U/ SQ5       H?  u  p4U(       a"  UR                  U R                  U5      5        M.  UR                  U5        MA     U R	                  U5        U$ )N)ru  rv  returnrg  )r|  r   rO  r<  r  )r   rw  
new_labels	old_labelr1  s        r   all_new_labelsFunctionState.all_new_labels;  sh    ((*

":/WXOI!!$.."67!!),	  Y
 	J'r   c                 :    U R                   R                  U5        g r   )r;  rN  r   lbls     r   	use_labelFunctionState.use_labelF  s    S!r   c                     XR                   ;   $ r   )r;  r  s     r   
label_usedFunctionState.label_usedI  s    &&&&r   c           	         UR                   (       a  UR                  (       d  UR                  nOUR                  (       a  UR                  (       d  UR                  nOUR
                  (       a  SSKJn  UR                  U5      nOoUR                  (       a^  UR                  (       dM  U R                  R                  S   (       a/  U R                  R                  [        R                  SS5      5        UR                  (       d  SnU R                   R#                  X45      nU(       a5  Ub2  US   (       a(  US   R%                  5       nUS   R'                  U5        O U =R(                  S-  sl        S[*        R,                  U R(                  4-  nXpR.                  ;  a  OMF  U R0                  R3                  XqX#45        U(       d  U R4                  R7                  U5        X4U R8                  U'   [:        R<                  (       a1  U R>                  RA                  S	U< S
U< SU(       a  SOS< S35        U RB                  (       a  U RB                  S   R7                  Xq45        U$ )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OptionalLocalsCppSupport.cppFr   r\  r  z allocated (r*  r=  	 - zombier  r   )"is_cv_qualifiedis_referencecv_base_typeis_fake_referenceref_base_typeis_cfunctionr=  r  
c_ptr_typeis_cpp_classr8  
directivesr  r  rd  needs_refcountingrG  r   popremoverJ  r   codewriter_temp_prefixr6  rF  rO  rI  rN  rH  r   debug_temp_code_commentsr7  r   rL  )r   r   
manage_refstaticreusabler  freelistresults           r   allocate_tempFunctionState.allocate_tempN  s   . (9(9$$Dt'='=%%D$((.Dt'='=$**BWBWXdBeJJ''(?(?@PRb(cd%% J??&&'9:,!a[__&FQKv&!!Q&!6#@#@$BSBS"TT!1!115    ''z(JK!!%%f-(,'9V$..JJFDPX"^iJijk##$$R(,,f^<r   c                    U R                   U   u  p#U R                  R                  X#45      nUc  / [        5       4nX@R                  X#4'   XS   ;   a  [	        SU-  5      eXR
                  ;  a  US   R                  U5        US   R                  U5        [        R                  (       a6  U R                  R                  SU< SXR
                  ;   a  SOS< S	35        gg)
z^
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=  */)rH  rG  r   r   r^   rI  rO  rN  r   r  r7  r   )r   r1  r   r  r  s        r   release_tempFunctionState.release_temp  s    
  //5??&&'9:CE{H2:OOT./A;5<==(((QKt$..JJT->->%>kBFH I /r   c                     / nU R                    HU  u  p#pEU R                  R                  X445      nUb
  X&S   ;  d  M/  UR                  X#U=(       a    UR                  45        MW     U$ )zhReturn a list of (cname,type,manage_ref) tuples of temp names and their type
that are currently in use.
r   )rF  rG  r   rO  r  )r   usedr1  r   r  r  r  s          r   rT  FunctionState.temps_in_use  sh     .2.B.B*D
**D+=>H4{#:T)N8N8NOP /C r   c                     U R                  5        VVVs/ s H%  u  pnU(       d  M  UR                  (       d  M"  X4PM'     snnn$ s  snnnf )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.
)rT  r  )r   r1  r   r  s       r   temps_holding_reference%FunctionState.temps_holding_reference  sL     /3.?.?.A:.A*D
 "&"8"8 .A: 	: :s   AAAc           
      r    U R                    VVVVs/ s H  u  pp4U(       d  M  X4PM     snnnn$ s  snnnnf )zRReturn a list of (cname, type) tuples of refcount-managed Python objects.
        )rF  )r   r  r   r  r  s        r   all_managed_tempsFunctionState.all_managed_temps  s;     8<7K7K7K3E 7K 	 s   1
1
c                     [        U R                  R                  5        VVVVs/ s H   u  u  po2(       d  M  US     H  nXA4PM     M"     snnnn5      $ s  snnnnf )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.
r   )r   rG  r-  )r   r   r  r  r  s        r   all_free_managed_temps$FunctionState.all_free_managed_temps  s`     040E0E0G
0G,"H: !! M$ 0G
  	 
s
   AAc                 J    U R                   R                  [        5       5        g)z:
Useful to find out which temps were used in a code block
N)rL  rO  r   r   s    r   start_collecting_temps$FunctionState.start_collecting_temps  s     	  ''.r   c                 6    U R                   R                  5       $ r   )rL  r  r   s    r   stop_collecting_temps#FunctionState.stop_collecting_temps  s    ''++--r   c                 $    [        U5      U l        g r   )ClosureTempAllocatorrK  r   r8  s     r   init_closure_temps FunctionState.init_closure_temps  s    1%8r   )r@  rD  rK  rL  r?  rC  r9  rO  rB  rE  r:  r;  r6  rP  r7  r=  r8  rM  rJ  rF  rG  rH  rN  rA  rI  r   )yield)r=  )FT)r   r   r   r   r   r   rY  r<  rd  r>  rm  rr  rx  r|  r  r  r  r  r  r  rT  r  r  r  r  r  r  r   r   r   r   r4  r4    s|     +.%t '$V
(

$$	"'
8tI&	:
/.9r   r4  c                   "    \ rS rSrSrSS jrSrg)NumConsti  zGlobal 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                 H    Xl         X l        X0l        U=(       d    UU l        g r   )r  rD  py_type
value_code)r   r  rD  r  r  s        r   r   NumConst.__init__  s    

$-r   )r  r  rD  r  r   r   r   r   r   r   r   r   r   r   r   r  r    s    .r   r  c                       \ rS rSrSrS rSrg)PyObjectConsti  z>Global info about a generic constant held by GlobalState.
    c                     Xl         X l        g r   r  r   r   r  r   s      r   r   PyObjectConst.__init__  s    
	r   r  Nr  r   r   r   r  r    s    
r   r  )possible_unicode_identifierpossible_bytes_identifierreplace_identifierfind_alphanumsz(?![0-9])\w+$s   (?![0-9])\w+$z[^a-zA-Z0-9_]+z([a-zA-Z0-9]+)c                   (    \ rS rSrSrS rSS jrSrg)StringConsti  z?Global info about a C string constant held by GlobalState.
    c                 `    Xl         X l        [        R                  " U5      U l        S U l        g r   )r  textr
   escape_byte_stringescaped_value
py_strings)r   r  r  byte_strings       r   r   StringConst.__init__  s&    
	+>>{Kr   Nc                    U R                   nU(       d  Uc  S =pSnO7SnUR                  5       nUS;   a  S nS nOSR                  [        U5      5      nU(       a  SnODUc?  [	        U[
        5      (       a  [        [        U5      5      nO[        [        U5      5      nOSnXeU4nU R                  c  0 U l	        O U R                  U   $ U(       a  [        R                  S   O[        R                   U(       a  SOS U(       a  SU-   OS SU R                  [        [        R                   5      S   3n[#        XXe5      n	XR                  U'   U	$ ! [         a     Nf = f)	NTF)utf8zutf-8r}   usasciizus-asciir=  r   ubr   )r  lowerr  r  r   r   r   r  r  r  rK   r   interned_prefixespy_const_prefixr  r   const_prefixPyStringConst)
r   r  r  r  encoding_key
is_unicodeinternr   pystring_cname	py_strings
             r   r	  StringConst.get_py_string_const  s]   yy )&**HJ J~~'HLL#!ww~h'?@F$&&7=>9$?@F<0??" DOs++
 39v''.f>T>TU sc*%1s\!r:

3v2234568 	 ".FO	(  s   <E 
E E )r  r  r  r  r   )r   r   r   r   r   r   r	  r   r   r   r   r  r    s    /r   r  c                   (    \ rS rSrSrSS jrS rSrg)r  i0  zDGlobal info about a Python string constant held by GlobalState.
    c                 4    Xl         X l        X@l        X0l        g r   )r  r  r  r  )r   r  r  r  r  s        r   r   PyStringConst.__init__8  s    
 $r   c                 4    U R                   UR                   :  $ r   r  r   r   s     r   __lt__PyStringConst.__lt__>  s    zzEKK''r   )r  r  r  r  NFF)r   r   r   r   r   r   r  r   r   r   r   r  r  0  s    (r   r  c                   @   \ rS rSr0 r/ SQr/ SQrS/S jrS rS r	S r
S	 rS
 rS rS/S jrS0S jrS rS/S jrS rS rS rS/S jrS rS rS rS/S jrS rS rS rS1S jrS\4S jrS r S r!S  r"S! r#S" r$S2S# jr%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.S- r/S.r0g)3r  iB  )%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_stater  module_state_endconstant_name_definesmodule_state_clearmodule_state_traversemodule_codemodule_exttypesinitfunc_declarationsinit_modulepystring_tablecached_builtinscached_constantsinit_constantsinit_codeobjectsr  r  cleanup_modulemain_methodutility_code_pragmasr  utility_code_pragmas_endend)r  r  r  r  r  Nc                 d   0 U l         / U l        0 U l        [        5       U l        0 U l        SU l        X0l        X@l        0 U l	        X l
        0 U l        0 U l        0 U l        0 U l        / U l        0 U l        / U l        0 U l        0 U l        [        5       U l        UR+                  U 5        Xl        g NF)r  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codeobject_constantsnum_const_indexarg_default_constantsconst_array_counterscached_cmethodsinitialised_constantsset_global_stater0  )r   r  r$  r!  r"  s        r   r   GlobalState.__init__  s     #%  U!*/'&*D'
& "$"$!#)+&$&!!%'"$&!!%(U"% r   c                 ,   U R                   n[        U R                  5       H?  u  p#UR                  5       =o@R                  U'   US:  d  M+  UR                  SU-  5        MA     [        R                  (       d  U R                  S	 OfU R                  S   nUR                  S[        R                   S[        R                   S35        UR                  S[        R                   S35        U R                  S	   nUR                  S
[        R                   S[        R                   S3SS9  UR                  S[        R                   S35        UR                  [        R                  " S5      5        U R                  S   nUR                  S5        U R                  S   nUR                  S[        R                   S[        R                   S35        UR                  S[        R                   S35        [        R                  (       d  U R                  S	 OfU R                  S   nUR                  S[        R                   S[        R                   S35        UR                  S[        R                   S35        U R                  S   nUR                  S5        UR                  S5        U R                  S   nU R                   R"                  (       a  UR%                  S5        UR                  S5        UR                  S5        g )Nr   z/* #### Code section: %s ### */r  zint __Pyx_InitCachedBuiltins( *r*  CYTHON_UNUSED_VAR();r  zint __Pyx_InitCachedConstants(T)refnanny__Pyx_InitCachedConstantsr  zint __Pyx_InitGlobals(void)r  zint __Pyx_InitConstants(r  zvoid __Pyx_CleanupGlobals(r  r=  z)/* --- Runtime support code (head) --- */r  z
#line 1 "cython_utility"
z"/* --- Runtime support code --- */)r0  r   code_layoutinsertion_pointr#  r   r	   cache_builtinsstart_initcfuncr   modulestatetype_cnamemodulestatevalue_cnameput_setup_refcount_contextr
   r
  r  r!  emit_linenumsr   )r   r0  ir  wr   s         r   initialize_main_c_code"GlobalState.initialize_main_c_code  s   __
 !1!12GA#-#=#=#??A

4 1u9D@A 3
 %%

,-

,-A///063P3P2QQRTU GG()F)F(GrJKJJ)*	,++,Bv/L/L.MQP 	 	 	
$V%B%B$C2FG	$$^%A%AB]%^_JJ~&	78JJ'(	&++,Bv/L/L.MQP	Q 	
$V%B%B$C2FG,,

,-

,-A,//063P3P2QQRTU GG()F)F(GrJKzz./

2

>?zz,-))JJ56

2

78r   c                 |    U R                   nU R                   H   nUR                  5       U R                  U'   M"     g r   )r0  h_code_layoutr8  r#  )r   r0  r  s      r   initialize_main_h_code"GlobalState.initialize_main_h_code  s2    __
&&D)99;DJJt 'r   c                 d   U R                  5         U R                  S   n[        R                  SS5      nUR	                  UR                  UR                  5      5        UR                  S5        U R                  S   n[        R                  SS5      nUR                  UR                  UR                  5      5        UR                  S5        U R                  S   n[        R                  S	S5      nUR                  UR                  UR                  5      5        UR                  S5        g )
Nr  TypeConversionszTypeConversion.cr=  r  UtilityCodePragmasModuleSetupCode.cr  UtilityCodePragmasEnd)	close_global_declsr#  ra  rd  r  rp  r,  r   r  )r   r   rw  s      r   finalize_main_c_code GlobalState.finalize_main_c_code  s    !
 zz,-!--.?AST!!$)),-

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

4##DII./

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

4##DII./

2r   c                      U R                   U   $ r   )r#  )r   r   s     r   __getitem__GlobalState.__getitem__  s    zz#r   c                    U R                  5         [        R                  (       a  U R                  S   nUR	                  S5        UR                  UR                  5      (       a,  UR                  UR                  5        UR	                  S5        UR	                  S5        UR                  5         U R                  S   nUR                  5         UR	                  S5        UR                  UR                  5      (       a<  UR                  UR                  5        UR                  5         UR	                  S5        UR	                  S5        UR                  5         S H  nU R                  U   nUR	                  S5        UR                  UR                  5      (       a,  UR                  UR                  5        UR	                  S5        UR	                  S5        UR                  5         M     [        R                  (       a0  U R                  S   nUR	                  S5        UR                  5         [        R                  (       a1  U R                  S   nUR	                  S5        UR                  5         g g )	Nr  	return 0;
return -1;}r  )r  r  r  r  )generate_const_declarationsr	   r9  r#  r   r  r9  	put_labelexit_cfunc_scopeput_finish_refcount_contextr  )r   r@  r  s      r   rL  GlobalState.close_global_decls  s    	((*!!

,-AGGK ||AMM**AMM*%GGCL JJ)*	%%'	<<&&KK&))+GGL!		6D

4 AGGK ||AMM**AMM*%GGCL  7 ((

,-AGGCL ((

+,AGGCL  )r   c                 F    U S   R                  SUR                  -  5        g )Nr  zstatic PyObject *%s;)r   r  r   entrys     r   put_pyobject_declGlobalState.put_pyobject_decl-  s    \  !7%++!EFr   c                 |    Ub+  XR                   ;   a  g U R                   R                  U5        U R                  S   $ )Nr  )r.  rN  r#  r   targets     r   get_cached_constants_writer'GlobalState.get_cached_constants_writer2  s;    333&&**62zz,--r   c                     U=(       a    S=(       d    Sn U R                   X4   nU$ ! [         a    U R                  X5      n U$ f = f)Nlongr   r*  rK   new_num_const)r   	str_valuelongnessr  cs        r   get_int_constGlobalState.get_int_const:  sV    %v.	7$$i%9:A   	7""96A	7s   ( AAc                 r     U R                   US4   nU$ ! [         a    U R                  USU5      n U$ f = f)Nr   rg  )r   ri  r  rk  s       r   get_float_constGlobalState.get_float_constB  sP    	C$$i%9:A   	C""9gzBA	Cs    66c                     Ub   U R                   R                  U5      nUb  U$ U R                  U5      nUb  X0R                   U'   U$ r   )r'  r   new_array_const_cname)r   rh  	dedup_keyconsts       r   get_py_constGlobalState.get_py_constI  sR     **..y9E **62 05""9-r   c                 t    U R                  S5      n[        X!5      nU R                  R                  U5        U$ Nr=  )new_const_cnamer  r+  rO  )r   r   r  rk  s       r   get_argument_default_const&GlobalState.get_argument_default_constS  s7    $$R(%&""))!, r   c                     UR                   (       a  UR                  5       nOUR                  5       n U R                  U   nU$ ! [         a    U R                  X5      n U$ f = fr   )r  
utf8encode
byteencoder&  rK   new_string_const)r   r  r  rk  s       r   get_string_constGlobalState.get_string_const\  sc    ??//+K//+K	9''4A   	9%%d8A	9s   A A$#A$c                     UR                   (       d   e U R                  U   nU$ ! [         a"    U R                  5       =o R                  U'    U$ f = fr   )r  r(  rK   ry  )r   r  rk  s      r   get_pyunicode_ptr_const#GlobalState.get_pyunicode_ptr_consth  s_    	N..t4A   	N7;7K7K7MMA..t4	Ns   & (AAc                 `    U R                  U5      nUR                  UR                  U5      nU$ r   )r  r	  r  )r   r  r  c_stringr  s        r   r	  GlobalState.get_py_string_constq  s.    ((.00
K	r   c                     [        U R                  5      n[        R                   SU S3nU R                  R	                  U5        U$ )Nr  r  )r   r)  r   codeobjtab_cnamerO  )r   nodeidxr1  s       r   get_py_codeobj_const GlobalState.get_py_codeobj_constw  sD    $++,))*!C52!!((.r   c                 "    U R                  USS9$ NTr  r	  r   r  s     r   get_interned_identifier#GlobalState.get_interned_identifier}      '''>>r   c                 \    U R                  U5      n[        X1U5      nX@R                  U'   U$ r   )new_string_const_cnamer  r&  )r   r  r  r  rk  s        r   r  GlobalState.new_string_const  s1    ++K8[1/0,r   c                 ^    U R                  X5      n[        XAX#5      nXPR                  X4'   U$ r   )new_num_const_cnamer  r*  )r   rD  r  r  r  rk  s         r   rh  GlobalState.new_num_const  s4    ((8U7712e-.r   c                 D    UR                  SS5      nU R                  US9$ )NASCIIignore)rD  )decodery  )r   bytes_valuerD  s      r   r  "GlobalState.new_string_const_cname  s(    ""7H5##%#00r   c                     U R                   nUR                  SSS9=p4X2;   a"  X$   S-   =oRU'   UR                  SUS9nX2;   a  M"  SX#'   U$ )Nr=  )sepr   r   r   )r%  r   )r   
format_strr  r  rD  r   s         r   unique_const_cnameGlobalState.unique_const_cname  sf    %%"))b")==m$(K!O3G5k%%#w%?E m r   c                 "   US:X  a  US-  nSn[         R                  U   nUR                  SS5      R                  SS5      R                  SS5      n[        U5      S	:  a%  U R	                  US
-   US S -   S-   USS  -   5      nU$ U< U< 3nU$ )Nrf  Lr   r(  r   +-neg_*   zlarge{counter}_   _xxx_i)r   r  r  r   r  )r   rD  r  rh  r  s        r   r  GlobalState.new_num_const_cname  s    fSLEG))'2c3'//S9AA#vNu:?++**U3BZ7'AE#$KOQE  %e,Er   c                     [        SU5      S S R                  S5      nU R                  US-   5      nU(       a  [        R                  U   nO[        R
                  nU< U< 3$ )Nr       z{sep}{counter})r  r{  r  r   r  r  )r   rh  rD  name_suffixs       r   ry  GlobalState.new_const_cname  s_    "3.s399#>--e6F.FG--f5F((F--r   rh  c                     U R                   R                  US5      nUS-   U R                   U'   [        R                   U SU S3$ )Nr   r   r  r  )r,  r   r   pyrex_prefix)r   rh  counts      r   rr  !GlobalState.new_array_const_cname  sL    ))--fa8,1!G!!&)%%&vhawa88r   c                     X4n U R                   U   nU$ ! [         a+    U R                  SU< SU< 35      =o@R                   U'    U$ f = f)Numethodr   )r-  rK   ry  )r   r  r  r   r  s        r   get_cached_unbound_method%GlobalState.get_cached_unbound_method  sk    '	@((-E   	@040D0Dj+>1@ @E((-	@s    1A
Ac           	          S[        U5      -  nU R                  [        R                  US5      5        U R	                  X45      nU/U-   nSU< SU< U< SSR                  U5      < S3$ )NzCallUnboundCMethod%dObjectHandling.c__Pyx_z(&rS  r*  )r   r  r  rd  r  r  )	r   modulestate_cnamer  r  r  
arg_cnamesrk  cache_cnamer   s	            r   r  +GlobalState.cached_unbound_method_call_code  sh    2S_Dk556GI[\]44ZM{Z'IIdO	
 	
r   c                 f   UR                   (       a  UR                  (       a  U R                  UR                  U5      (       al  U R	                  U5        UR
                  nU[        ;   a	  [        U   nU R                  UR                  [        R                  " U5      UR                  5        g g g g r   )
is_builtinis_constshould_declarer  r^  r1  renamed_py2_builtins_mapput_cached_builtin_initposr
   r
  )r   r]  r1  s      r   add_cached_builtin_decl#GlobalState.add_cached_builtin_decl  s    ""5;;66&&u-zz333D9D,,II~;;DAKK! 7 !/r   c                    U R                   S   nUR                  U R                  U5      R                  5      nU R	                  [
        R                  SS5      5        UR                  U< SU< SU< SUR                  U5      < 35        g )Nr  GetBuiltinNamer  z = __Pyx_GetBuiltinName(z); if (!) )	r#   name_in_main_c_code_module_stater  r  r  r  rd  r   
error_goto)r   r  r1  r  r@  cname_in_modulestates         r   r  #GlobalState.put_cached_builtin_init  s}    JJ() AA((.44 6##$46HI	K	 LL	 	 r   c                     U R                  5         U R                  5         U R                  5         U R                  5         U R	                  5         g r   )generate_cached_methods_declsgenerate_object_constant_declsgenerate_codeobject_constantsgenerate_string_constantsgenerate_num_constantsr   s    r   rV  'GlobalState.generate_const_declarations  s@    **,++-**, 	&&(##%r   c                     US:  a  SOSnU(       a  SOSnU R                   S   nUR                  SU SU S	U S
U S3	5        U R                   S   nUR                  SU SU SU S35        g )Ni   r   
Py_ssize_tPy_VISIT__Pyx_VISIT_CONSTr  zfor (z i=0; i<z	; ++i) { z(traverse_module_state->z[i]); }r
  z&; ++i) { Py_CLEAR(clear_module_state->)r#  r   )r   struct_attr_cnamer  may_have_refcyclescounter_type
visit_callr  s          r   )_generate_module_array_traverse_and_clear5GlobalState._generate_module_array_traverse_and_clear  s     %u<#5Z;N
34u\N(5'J<Oghygz  {C  D  	E01u\N(5'9`ar`ss{|}r   c                    U R                    Vs/ s H%  n[        UR                  5      UR                  U4PM'     nnUR                  5         U H  u  p4nU R                  S   R                  SUR                  R                  U5      -  5        UR                  R                  (       d  M]  U R                  S   R                  SU 3UR                  SSS9  UR                  R                  (       a  US-  nU R                  S	   R                  S
U S35        M     [        U R                  R                  5       5       H  u  pV[        R                   U 3nU R                  S   R                  SU SU S35        U R!                  XvSS9  [#        U5      nUc  M^  U[$        R&                  ::  d  Mt  U R                  S   n	U	R)                  SU S35        U	R                  SU	R+                  U S35      -  5        M     g s  snf )Nr  z%s;r
  zclear_module_state->TF)clear_before_decrefnannyz	->memviewr  z Py_VISIT(traverse_module_state->r4  
PyObject *r  ];r  r  zfor (size_t i=0; i<z; ++i) z{ Py_CLEAR(%s); }z[i])r+  r   r  sortr#  r   r   declaration_coder  put_xdecref_clearis_memoryviewslicer   r,  r-  r   r  r  cleanup_level_for_type_prefixr	   r  r  r  )
r   rk  constsr   r  rh  r  r  cleanup_levelpart_writers
             r   r  *GlobalState.generate_object_constant_decls  s   5575a qww<!,5 	 7!KAaJJ~&,,UQVV5L5LU5S-ST66++ JJ+,>>&ug.$(	 ?  vv(($JJ./5525'<>' ", $D$=$=$C$C$EFMF#)#6#6"7x @JJ~&,,z:K9LAeWTV-WX ::;Lhm:n9&AM(]g>[>[-["jj):;"5eWG DE!!'#DDHYGZZ]E^_` G37s   ,Hc                    U R                   (       d  g U R                  S   nU R                  S   n/ n[        U R                   R                  5       5       H  u  u  pEnUR	                  U5        U R                  [        R                  " U5      5      R                  nUR                  SU-  5        UR                  UR                  U5      < SU< S35        UR                  UR                  U5       SUR                  U5       S35        M     [        R                  (       a=  U R                  S   nU H'  nUR                  SUR                  U5       S	35        M)     g g )
Nr  r  z__Pyx_CachedCFunction %s;z.type = (PyObject*);z.method_name = &r  z	Py_CLEAR(z	.method);)r-  r#  r   r-  rO  r  r
   r
  r  r   r  r	   r  )	r   declr  cnamesr  r  r  method_name_cnamer  s	            r   r  )GlobalState.generate_cached_methods_decls"  sN   ##zz.)zz*+06t7K7K7Q7Q7S0T,%ZuMM%  $ < <^=Y=YZe=f g m mJJ2  JJ55e<jJ K JJ88?@ A99:KLMQPQ 1U ((jj!23G	$*O*OPU*V)WW`ab   )r   c                 0
   U R                   R                  5        Vs/ s H%  n[        UR                  5      UR                  U4PM'     nnUR	                  5         / nSn[        5       nS nU R                  S   nU H  u  pn[        R                  " UR                  5      n
UR                  SU	 SU
 S3SS9  UR                  c  ML  [        UR                  5      U:  a  [        UR                  5      nUR                  R                  5        HK  nUR                  U" U5      5        UR                  UR                  [        UR                  5      U45        MM     M     [        U R                  R!                  5       5       H  u  p[        R"                  " U5      u  pU(       a  UR                  S	5        UR                  S
U	< SU< S35        U(       d  MX  UR                  S5        UR                  S
U	< SU< S35        UR                  S5        M     U(       d  g UR	                  5         U R                  S   nUR                  S5        UR%                  [&        R(                  " S[+        U[        U5      S9-  5      5        [        U5      nU R                  S   R                  S[,        R.                   SU S35        U R1                  [,        R.                  USS9  [        U5      nUR	                  [        S9  U(       a  SU;  d  US   S:X  d   U5       e[3        U5       VVs0 s H	  u  nnUU_M     nnnUR                  S[,        R4                  < SSR7                  U5      < S35        UR                  S[,        R.                  -  5        [3        U5       H  u  nu  npUU" U5         nUR8                  nU R                  S   R                  SUR                  < S [,        R.                  < SU< S!35        UR                  S"UUUUUR:                  UR                  4-  5        M     UR                  S#5        UR                  S$5        U R=                  [>        RA                  S%S&5      5        U R                  S'   nUR                  S([,        R.                  < SURC                  [,        R.                  5      < S[,        R4                  < S)URE                  U RF                  5      < S*3	5        g s  snf s  snnf )+Nr   c                     U R                   (       a.  U R                   S;  a  SU R                   R                  5        S3$ g)N)r  USASCIIzUS-ASCIIUTF8r  r  0)r  r  )r  s    r   normalise_encoding_nameFGlobalState.generate_string_constants.<locals>.normalise_encoding_nameB  sB    !!i&8&8 AE 'E9--3356a88r   r  zstatic const char z[] = "z";T)safez#ifdef Py_UNICODE_WIDEzstatic Py_UNICODE z[] = { z };#else#endifr  r=  a          typedef struct {
            const char *s;
        #if %(max_length)d <= 65535
            const unsigned short n;
        #elif %(max_length)d / 2 < INT_MAX
            const unsigned int n;
        #elif %(max_length)d / 2 < LONG_MAX
            const unsigned long n;
        #else
            const Py_ssize_t n;
        #endif
        #if %(num_encodings)d <= 31
            const unsigned int encoding : 5;
        #elif %(num_encodings)d <= 255
            const unsigned char encoding;
        #elif %(num_encodings)d <= 65535
            const unsigned short encoding;
        #else
            const Py_ssize_t encoding;
        #endif
            const unsigned int is_unicode : 1;
            const unsigned int intern : 1;
        } __Pyx_StringTabEntry;
        )
max_lengthnum_encodingsr  r  r  r  Fr  )r   r  zstatic const char * const rS  z*static const __Pyx_StringTabEntry %s[] = {r	  z#define  r  z6{%s, sizeof(%s), %d, %d, %d}, /* PyObject cname: %s */z{0, 0, 0, 0, 0}z};InitStringszStringTools.cr  zif (__Pyx_InitStrings(z) < 0) r  )$r&  r8  r   r  r  r   r#  r
   split_string_literalr  r   r  rN  rO  r   r(  r-  encode_pyunicode_stringr  r   dedentr   r   stringtab_cnamer  r   stringtab_encodings_cnamer  r  r  r  r  rd  r  r  r  )r   rk  c_constsr  longest_pystring	encodingsr  decls_writerr   r  cliteralr  utf16_arrayutf32_arrayr@  py_string_countr?  r  encodings_mapr^  c_cnameencodings_indexr  r  s                           r   r  %GlobalState.generate_string_constants;  sL   8<8O8O8V8V8XY8X1S\177A.8XY
E		 zz.1#KAa%::1??KH$UG6(2>   ||'q'*:: (+1??';$!"!4!4!6IMM"9)"DE%%qwwIOO0Di&PQ "7 $ t==CCEFHA'5'M'Ma'P$K""#;<UKXY{""7+""P[#\]""8, G JJ'(	 	
hoo 0 'i.
1
  	: j/

>"((:f6L6L5MQN__a)bc66v7M7Msx6y9%	39 4	!8KVYVK8A)8LM8LH18LM	,,IIi 
 	
 	
<v?U?UUV*3J*?&A&+,CI,NOO"--JJJ./55&&7 
 GGL  P   +@" 	
!"	k55m_UV$45&&??@V@VW00))$//:	<	=e Zh Ns   ,T6Tc                 (   U R                   S   nS[        R                   S[        R                   S3nU R                  (       dg  UR                  U5        UR                  S[        R                   S35        UR                  S5        UR                  5         UR                  S5        g S	nS
nS
nS
nS
nS
nS
n	U R                   H  n
U
R                  nUR                  (       dV  [        U[        UR                  5      UR                  -
  5      n[        X[R                  5      n[        XkR                  5      n[        U[        U
R                  5      5      n[        XR                   S
   5      n[        U	[        UR"                  5      5      n	M     U	S-  nUR%                  [&        R(                  " SUR+                  5        SUR+                  5        SUR+                  5        SUR+                  5        SUR+                  5        SUR+                  5        SUR+                  5        S35      5        U R-                  [.        R1                  SS5      5        UR                  U5        UR                  S5        UR                  S5        U R                   H  n
U
R3                  US5        M     UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  5         UR                  S5        [        U R                  5      nU R                   S   R                  S[        R4                   SU S35        U R7                  [        R4                  US S!9  g )"Nr  zint __Pyx_CreateCodeObjects(r2  r*  r3  r4  rS  rU  i  r   /   z=        typedef struct {
            unsigned int argcount : z.;
            unsigned int num_posonly_args : z-;
            unsigned int num_kwonly_args : z%;
            unsigned int nlocals : z#;
            unsigned int flags : z(;
            unsigned int first_line : z/;
            unsigned int line_table_length : z;;
        } __Pyx_PyCode_New_function_description;
        
NewCodeObjrJ  z)PyObject* tuple_dedup_map = PyDict_New();z*if (unlikely(!tuple_dedup_map)) return -1;badzPy_DECREF(tuple_dedup_map);zbad:rT  r  r  r  r  Fr  )r#  r   r;  r<  r)  r:  r   rX  def_nodeis_generator_expressionr   r   r   num_kwonly_argsnum_posonly_argsvarnamesr  node_positionsr  r   r  
bit_lengthr  r  rd  generate_codeobjr  r  )r   r@  init_function	max_flagsmax_func_argsmax_kwonly_argsmax_posonly_argsmax_varsmax_linemax_positionsr  r  max_linetable_lencode_object_counts                 r   r  )GlobalState.generate_codeobject_constants  s3   JJ)**6+G+G*H6KhKhJiijk 	 ((m,GG()F)F(GrJKGGK  GGCL 	--D}}H33 #M3x}}3EH`H`3` a"%o7O7O"P#&'79R9R#S 8S%78H8\\!_5Hs83J3J/KLM . *B.	hoo #%%2%=%=%?$@ A--=-H-H-J,K L,,;,F,F,H+I J$$,$7$7$9#: ;""+"6"6"8!9 :''/':':'<&= >..?.J.J.L-M N	
 
 
	 	k55lDWXY	-(	;<	<=--D!!!U+ . 	
-.			-.			 9 9:

>"((:f6M6M5NaPaObbd)ef66v7N7NPav{6|r   c                 b   U R                   R                  5        Vs/ s HL  nUR                  UR                  S   S:H  [	        UR                  5      UR                  UR
                  U4PMN     nnUR                  5         U R                  S   nU GH  u  n  pVpqUR                  nU R                  S   R                  SU-  5        U R                  S   R                  SU-  5        U R                  S   R                  S	U-  5        US
:X  a  Sn	OJUS:X  a  Sn	OA[        R                  " U5      (       a  Sn	O#[	        UR                  S5      5      S:  a  Sn	OSn	UR                  U5      n
UR                  U
< SX-  < SUR                  XR                  5      < 35        GM     g s  snf )Nr   r  r  r  zPyObject *%s;r
  z!Py_CLEAR(clear_module_state->%s);r  z-__Pyx_VISIT_CONST(traverse_module_state->%s);r   zPyFloat_FromDouble(%s)rf  zPyLong_FromString("%s", 0, 0)   zPyLong_FromLong(%sL)zPyLong_FromLong(%s) = z; )r*  r8  r  rD  r   r  r  r#  r  r   r   long_literallstripr  error_goto_if_nullr  )r   rk  r  r  r  r   rD  r  r  function
init_cnames              r   r  "GlobalState.generate_num_constants  s   //668:8a 99aggajC/QWWqwwVWX8 	 :$4539/GQ*GGEJJ~&,,_u-DEJJ+,223e;=JJ./55?%GI'!3F":##E**:U\\#&'!+10'HHOJ  H111*ooN"P Q% 4:	:s   AF,c                     XR                   ;   aZ  U R                   U   n[        UR                  5      [        UR                  5      :X  d   eUR                  UR                  :X  d   egX R                   U'   g)NFT)r  r   r   r  )r   r  r]  r   s       r   r  GlobalState.should_declare  sf    (((((/Euzz?c%**o555::+++*/  'r   c                     UR                  5       n U R                  U   nU$ ! [         aB    [        U R                  5      nU R                  R                  U5        X0R                  U'    U$ f = fr   )get_filenametable_entryr  rK   r   r  rO  )r   source_descr]  indexs       r   lookup_filenameGlobalState.lookup_filename*  st    335	/''.E
 	  	/**+E%%k2).&		/s   # AA/.A/c                     U R                   U   $ ! [         a     Of = fUR                  SSS9n U Vs/ s H6  nSUR                  5       R	                  SS5      R	                  SS5      -   PM8     Os  snf nn[        US	5      (       a  UR                  5         O'! [        US	5      (       a  UR                  5         f f = fU(       d  UR                  S
5        X@R                   U'   U$ )Nr  r  )r  error_handlingz * r  z.*[inserted by cython to avoid comment closer]/z/*z-/[inserted by cython to avoid comment start]*closer=  )r  rK   	get_linesrH  r  r   rA  rO  )r   r;  source_filerX  Fs        r   commented_file_contents#GlobalState.commented_file_contents4  s    	++K88 		!++W;C , E		$ )*
 )T ..JgI
 )*A * {G,,!!# {G,,!!# -!((2,01  -s"    
B =A43B $Cc                     U(       a=  XR                   ;  a-  U R                   R                  U5        UR                  U 5        ggg)z
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)r  rN  r  )r   r  s     r   r  GlobalState.use_utility_codeM  s<     L0B0BB""<0!!$' C<r   c                     Uc  g UR                   (       a  U R                  UR                   5        UR                  (       a  U R                  UR                  5        g g r   )r  r  utility_code_definitionr\  s     r   use_entry_utility_code"GlobalState.use_entry_utility_codeZ  sI    =!!%"4"45((!!%"?"?@ )r   )r+  r-  r!  r)  r"  r,  r%  r  r'  r  r  r   r.  r  r$  r*  r#  r(  r0  r&  r  r   r  )r=  r=  T)1r   r   r   r   r  r7  rD  r   rA  rE  rM  rP  rL  r^  rc  rl  ro  ru  rz  r  r  r	  r  r  r  rh  r  r  r  ry  r   rr  r  r  r  r  rV  r  r  r  r  r  r  r  r=  rE  r  rK  r   r   r   r   r  r  B  s    : J&KRM!629h<
.(!TG
.
?1
.9C 9

	!
 &~(Tc2x=tE}NQ@2(Ar   r  c                 x   ^^ U R                   m[        R                  " T5      mU4S jnU4S jn[        X5      $ )Nc                 (   > T" U R                   5      $ r   )	funcstate)r   attribute_ofs    r   r   !funccontext_property.<locals>.getf  s    DNN++r   c                 4   > [        U R                  TU5        g r   )r   rP  )r   rD  r1  s     r   r   !funccontext_property.<locals>.seth  s    e,r   )r   r   
attrgetterr   )r  r   r   rQ  r1  s      @@r   funccontext_propertyrV  c  s1    ==D&&t,L,-Cr   c                       \ rS rSrSS jrSrg)CCodeConfigim  c                 (    X l         Xl        X0l        g r   )emit_code_commentsr>  c_line_in_traceback)r   r>  rZ  r[  s       r   r   CCodeConfig.__init__r  s    "4*#6 r   )r[  rZ  r>  N)TTT)r   r   r   r   r   r   r   r   r   rX  rX  m  s    
7r   rX  c                      \ rS rSrSr\R                  " S S9SS j5       rS rS r	S r
S	 rS
 rS rS rS rS rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rSS jrSS jrS rS rS rS r S r!S r"S  r#S! r$S" r%S# r&S$ r'S% r(SS& jr)SS' jr*S( r+S) r,SS* jr-S+ r.S, r/SS- jr0S. r1S/ r2S0 r3S1 r4SS2 jr5S3 r6\7S4 5       r8\7S5 5       r9S6 r:S7 r;SS8 jr<SS9 jr=S: r>S; r?S< r@S= rAS> rBS? rCS@\D4SA jrESB rFSC rGSD rHSE rISF rJSG rKSH rLSI rM  SSJ jrNSK rOSL rPSM rQSN rR\S4SO jrTSP rUSQ rVSR rWSS rXST rYSU rZSSV jr[SSW jr\SSX jr]SSY jr^SSZ jr_SS[ jr`S\ raS] rbS^ rcS_ rdS` reSa rfSb rgSc rhSd riSe rjSf rkSg rlSh rmSi rnSj roSk rpSSl jrqSm rrSn rsSSo jrtSSp jruSSq jrvSr rwSs rxSSt jrySSu jrzSv r{Sw r|SSx jr}SSy jr~Sz rS{ rSS| jrSS} jrSS~ jrS rS rS rS rS rS rSS jrSS jrSS jrSS jrS rS rSS jrSS jrSS jrSS jrS rS rSS jrS rS rSS jrS rSS jr\DGR9                  SS5      4S jrS rS rS rSrg)r  ix  ar  
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_fromNc                    Uc
  [        5       nX l        S U l        S U l        / U l        S U l        S U l        S U l        SU l        SU l	        SU l
        Ub  U R                  UR                  5        UR
                  U l        U(       a3  UR                  U l        UR                  U l
        UR                  U l	        UR                  U l        UR                  U l        g g )Nr   r   )r   bufferlast_poslast_marked_pospyclass_stackrP  r1  r!  level
call_levelbolr/  )r   r_  ra  copy_formattings       r   r   CCodeWriter.__init__  s    >LN6#
"!!+"9"9:(22DN(..
&??"-"8"8'00DM#.#>#>D  #r   c                     [        XU5      nU$ r   r  )r   r_  ra  rh  r  s        r   
create_newCCodeWriter.create_new  s     [/Br   c                 P    U R                   b   eXl         UR                  U l        g r   )r1  r!  )r   global_states     r   r/  CCodeWriter.set_global_state  s(    '''''33r   c                 :    U R                   R                  U5        g r   )ra  copyto)r   r  s     r   rr  CCodeWriter.copyto  s    1r   c                 6    U R                   R                  5       $ r   )ra  getvaluer   s    r   ru  CCodeWriter.getvalue  s    {{##%%r   c                 V    SU;   a  U R                  U5        g U R                  U5        g Nr%  )_write_lines_write_to_bufferr   r  s     r   r   CCodeWriter.write  s%    19a !!!$r   c                     U R                   (       a  U R                   S S OSnU R                  R                  R                  U/UR	                  S5      -  5        U R                  U5        g )Nr   Nr   r%  )rc  ra  markersextendr  rz  )r   r  filename_lines      r   ry  CCodeWriter._write_lines  sU     594H4H,,Ra0i""M?QWWT]#BCa r   c                 :    U R                   R                  U5        g r   )ra  r   r{  s     r   rz  CCodeWriter._write_to_buffer  s    !r   c                 V    U R                  X R                  R                  5       SS9nU$ )NT)r_  ra  rh  )rl  ra  r8  r  s     r   r8  CCodeWriter.insertion_point  s'    D9T9T9Vhlmr   c                     [        U S9$ )zi
Creates a new CCodeWriter connected to the same global state, which
can later be inserted using insert.
r^  rk  r   s    r   
new_writerCCodeWriter.new_writer  s    
 t,,r   c                     UR                   U R                   L d   eU R                  R                  UR                  5        g)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)r1  ra  insert)r   r  s     r   r  CCodeWriter.insert  s4     !!T%5%55556==)r   c                     g r   r   r   s    r   r:  CCodeWriter.label_counter  s    !r   c                     g r   r   r   s    r   r=  CCodeWriter.return_label       r   c                     g r   r   r   s    r   r9  CCodeWriter.error_label      r   c                     g r   r   r   s    r   r;  CCodeWriter.labels_used  r  r   c                     g r   r   r   s    r   r?  CCodeWriter.continue_label  s    "r   c                     g r   r   r   s    r   r@  CCodeWriter.break_label  r  r   c                     g r   r   r   s    r   return_from_error_cleanup_label+CCodeWriter.return_from_error_cleanup_label  s    /3r   c                     g r   r   r   s    r   rA  CCodeWriter.yield_labels  r  r   c              #   
  #    [        X5       Hp  u  pgU R                  U5      (       d  M  U(       a  U R                  U5        SnUb  U R                  XES9  U R	                  U5        Xg4v   U R                  U5        Mr     g7f)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_posrW  )r   r  orig_labelsskip_to_labelr  r  r_  
orig_labels           r   label_interceptorCCodeWriter.label_interceptor  ss      "%Z!=E??5))m, $c/NN5!%%MM*% ">s   BBc                 8    U R                   R                  U5      $ r   )rP  r<  r   r1  s     r   r<  CCodeWriter.new_label	  s    dnn.F.Ft.L'Lr   c                 4    U R                   R                  " U6 $ r   )rP  r>  r   r   s     r   r>  CCodeWriter.new_error_label	      dnn.L.Ld.S'Sr   c                 4    U R                   R                  " U6 $ r   )rP  rd  r  s     r   rd  CCodeWriter.new_yield_label	  r  r   c                 6    U R                   R                  5       $ r   )rP  rm  r   s    r   rm  CCodeWriter.get_loop_labels	  s    dnn.L.L.N'Nr   c                 8    U R                   R                  U5      $ r   )rP  rr  rp  s     r   rr  CCodeWriter.set_loop_labels	  s    dnn.L.LV.T'Tr   c                 4    U R                   R                  " U6 $ r   )rP  rx  r  s     r   rx  CCodeWriter.new_loop_labels	  r  r   c                 6    U R                   R                  5       $ r   )rP  r|  r   s    r   r|  CCodeWriter.get_all_labels	      dnn.K.K.M'Mr   c                 8    U R                   R                  U5      $ r   )rP  r  rp  s     r   r  CCodeWriter.set_all_labels	  s    dnn.K.KF.S'Sr   c                 6    U R                   R                  5       $ r   )rP  r  r   s    r   r  CCodeWriter.all_new_labels	  r  r   c                 8    U R                   R                  U5      $ r   )rP  r  r  s     r   r  CCodeWriter.use_label	  s    dnn.F.Fs.K'Kr   c                 8    U R                   R                  U5      $ r   )rP  r  r  s     r   r  CCodeWriter.label_used	  s    dnn.G.G.L'Lr   c                      [        XS9U l        g )N)r8  )r4  rP  r  s     r   enter_cfunc_scopeCCodeWriter.enter_cfunc_scope"	  s    &t9r   c                 b    U R                   c  g U R                   R                  5         S U l         g r   )rP  rY  r   s    r   rX  CCodeWriter.exit_cfunc_scope%	  s&    >>!$$&r   c                     U R                   R                  S   nUR                  SU S35        U R                  U5        U R                  S5        U R                  SU S35        U(       a  U R	                  5         gg)z
Init code helper function to start a cfunc scope and generate
the prototype and function header ("static SIG {") of the function.
r  zstatic CYTHON_SMALL_CODE ; /*proto*/r=  static  {N)r1  r#  r   r  put_declare_refcount_context)r   	signaturer8  r5  r+  s        r   r:  CCodeWriter.start_initcfunc+	  ss    
   &&'>?/	{+FGu%

2

WYKs+,--/ r   c                 @   UR                  U5      nSUR                  U5       SU S3nU(       a1  U R                  S   R                  UR	                  SS5      S-   5        U(       a  U R                  U5        U R                  S5        U R                  US-   5        g )	Nr  r  r*  r  CYTHON_UNUSED r=  r  r  )mangle_internalr  r1  r   r  r  )	r   class_scopereturn_typec_slot_nameargs_signatureneeds_funcstateneeds_prototypeslotfunc_cnamedeclarations	            r   start_slotfuncCCodeWriter.start_slotfunc8	  s    $44[A < <^ LMQ~N^^_`W%++K,?,?@PRT,UXe,ef"";/

2

;%&r   c                 j    U R                  U R                  R                  X5      R                  5      $ r   )name_in_module_stater1  rl  r  )r   ri  rj  s      r   
get_py_intCCodeWriter.get_py_intF	  s/    ((**9?EE
 	
r   c                 j    U R                  U R                  R                  X5      R                  5      $ r   )r  r1  ro  r  )r   ri  r  s      r   get_py_floatCCodeWriter.get_py_floatK	  s/    ((,,YCII
 	
r   c                 V    U R                  U R                  R                  X5      5      $ r   )r  r1  ru  )r   rh  rs  s      r   ru  CCodeWriter.get_py_constP	  s)    (())&<
 	
r   c                 L    U R                   R                  U5      R                  $ r   )r1  r  r  r  s     r   r  CCodeWriter.get_string_constU	  s    006<<<r   c                 8    U R                   R                  U5      $ r   )r1  r  r  s     r   r  #CCodeWriter.get_pyunicode_ptr_constX	  s    77==r   c                 n    U R                   R                  X5      R                  nU R                  U5      $ r   )r1  r	  r  r  )r   r  r  r  s       r   r	  CCodeWriter.get_py_string_const[	  s4      44#e 	((//r   c                 V    U R                  U R                  R                  U5      5      $ r   )r  r1  r  )r   r  s     r   r   CCodeWriter.get_py_codeobj_const`	  s$    (()9)9)N)Nt)TUUr   c                 j    U R                  U R                  R                  U5      R                  5      $ r   )r  r1  rz  r  r   r   s     r   rz  &CCodeWriter.get_argument_default_constc	  s+    (()9)9)T)TUY)Z)`)`aar   c                 $    U R                  U5      $ r   r  r  s     r   r  CCodeWriter.internf	  s    ''--r   c                 "    U R                  USS9$ r  r  r  s     r   intern_identifierCCodeWriter.intern_identifieri	  r  r   c                 8    U R                   R                  U5      $ r   )r1  rc  ra  s     r   rc  'CCodeWriter.get_cached_constants_writerl	  s    ;;FCCr   c                     U R                   R                  c  U R                  U5      $ U R                   R                  R                  U5      $ r   )rP  r8  r  r  )r   r  s     r   r   CCodeWriter.name_in_module_stateo	  s@    >>' 88??~~##88??r   c                 ,    [         R                   SU  3$ r  )r   r<  r  s    r   r  ,CCodeWriter.name_in_main_c_code_module_statey	  s    
 //05'::r   c                 ,    [         R                   SU  3$ r  )r   r  r  s    r   name_in_slot_module_state%CCodeWriter.name_in_slot_module_state	  s     001E7;;r   c                 r    UR                   (       a  UR                  $ U R                  UR                  5      $ r   )is_py_class_scopenamespace_cnamer  r  s     r   namespace_cname_in_module_state+CCodeWriter.namespace_cname_in_module_state	  s.    ""(((,,U-B-BCCr   c                 r    UR                   (       a  U R                  UR                  5      $ UR                  $ r   )is_extension_typer  typeptr_cnamer  s     r   typeptr_cname_in_module_state)CCodeWriter.typeptr_cname_in_module_state	  s.    !!,,T-?-?@@%%%r   c                    U R                   (       a!  U R                  (       a  U R                  5         U R                  R                  (       aF  U R
                  (       a5  U R
                  u  p4nU R                  SU SUR                  5        S35        U(       a*  U(       a  U R                  U5        OU R                  U5        U R                  S5        SU l        g )Nz
#line z "r  r%  r   )
rb  rg  emit_markerr!  r>  rc  ry  get_escaped_descriptionput_safer  )r   r   r  r;  rX  r   s         r   r   CCodeWriter.putln	  s    ==TXX))d.B.B#'#7#7 Kqb1T1T1V0WWZ[\d#$r   c                 l    Uc  g U R                   (       a  U R                   S S US S :X  a  g X4U l        g )Nr   )rc  rb  r   r  r  s      r   r  CCodeWriter.mark_pos	  s9    ;D$8$8!$<BQ$Gr   c                 $   U R                   u  pXl        S U l         U R                  S5        U R                  R                  (       a0  U R                  5         U R                  U R                  U5      5        U(       a  U R                  U5        g g rx  )rb  rc  ry  r!  rZ  indent_build_markerwrite_trace_liner  s      r   r	  CCodeWriter.emit_marker	  so    ]]
"$..KKMd0056!!#& r   c                 t   U R                   (       a  U R                   R                  (       a  U R                  R                  S   (       al  U R	                  5         U R                  SUS   S SU R                  U5      S SU R                   R                  (       + S SU R                  U5       S3	5        g g g g )N	linetracez__Pyx_TraceLine(r   r   r  z)
)	rP  rD  r1  r  r  ry  pos_to_offsetrE  r  r   r  s     r   r  CCodeWriter.write_trace_line	  s    >>dnn664;K;K;V;VWb;cKKM"3q6!*Ad.@.@.Ea-HdnnNfNfJfghIiijkokzkz{~k  kA  AD  EF <d6>r   c                    Uu  p#n[        U[        5      (       d   eU R                  R                  U5      nU[	        SUS-
  5      U nUS==   S-  ss'   XeX3S-    -  nSR                  U5      nSUR                  5        SUS	 SU S
3$ )Nr   r$   r   z             # <<<<<<<<<<<<<<r   r%  z/* "z":r   z
*/
)r   r   r1  rE  r   r  r
  )r   r  r;  rX  colcontentsr2  r   s           r   r  CCodeWriter._build_marker	  s    !$3+'78888##;;KHQQ-b	44	$Av&&yyk99;<BtAhbfUUr   c                 4    U R                  U5        SU l        g r~  )r   rg  r   r   s     r   r  CCodeWriter.put_safe	  s    

4r   c                 "   U R                   R                  nU(       GaL  [        U5      S:  Ga<  [        R                  " UR                  S5      5      R                  5       nU SU S3n[        R                  R                  X55      n[        R                  R                  U5      (       d  U S[        R                  " 5        3nSn [        R                  " U5       n	U	R                  U5        S S S 5        [        R                   " Xv5        SnU(       d:  [        R                  R                  U5      (       a  [        R&                  " U5        UR)                  SS	5      n
S
U
 S3nU R+                  U5        g ! , (       d  f       N= f! ["        [$        4 a(    [        R                  R                  U5      (       d  e  Nf = f! U(       d<  [        R                  R                  U5      (       a  [        R&                  " U5        f f f = f)Ni   r  r   z.hz.tmpFTr  r>  z
#include "r  )r1  r"  r   hashlibsha256encode	hexdigestr   r  r  existsgetpidr   open_new_filer   shutilmover>   rX   unlinkr  r  )r   r   r1  include_dirr   include_filer  tmp_pathdoner  c_paths              r   r  CCodeWriter.put_or_include	  s}   &&AA3t9t+>>$++f"56@@BD"V1TF"-L77<<:D77>>$''"V4		}5,,,X6! 7KK/D  BGGNN8$<$<		(+ \\$,Fxs+D! 76 (9  77>>$// 0  BGGNN8$<$<		(+ %=4s=   
F  E=2 F =
FF 5GG	 GG	 	AHc                    SnSU;   a  UR                  S5      nOSnSU;   aU  X1R                  S5      -  nUS:  a  U =R                  U-  sl        O&US:X  a   US   S:X  a  SnU =R                  S-  sl        U R                  (       a  U R                  5         U R	                  U5        SU l        US:  a  U =R                  U-  sl        g U(       a  U =R                  S-  sl        g g )NF{r   rU  Tr   )r  re  rg  r  r   )r   r   
fix_indentdls       r   r  CCodeWriter.put	  s    
$;CBB$;**S/!BAv

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

a
88KKM

46JJ"JJJ!OJ r   r0  c                 Z   UR                   (       a   UR                  5       eUR                  X R                  S5        UR	                  U R                  5        UR
                  (       aA  [        R                  (       a+  UR                  U R                  S   U R                  S5        g g g )Nr,  r  r  )r+  r1  r  r1  r  r  r	   r  )r   r0  s     r   put_code_hereCCodeWriter.put_code_here	  s     ==.',,. !!$(8(8&A&&t'7'78??w<<%%  !23T5E5EyR  =?r   c                 .    U =R                   S-  sl         g Nr   re  r   s    r   increase_indentCCodeWriter.increase_indent
      

a
r   c                 .    U =R                   S-  sl         g r;  r<  r   s    r   decrease_indentCCodeWriter.decrease_indent

  r?  r   c                 F    U R                  S5        U R                  5         g )Nr3  )r   r=  r   s    r   begin_blockCCodeWriter.begin_block
  s    

3r   c                 F    U R                  5         U R                  S5        g )NrU  )rA  r   r   s    r   	end_blockCCodeWriter.end_block
  s    

3r   c                 @    U R                  SU R                  -  5        g )Nz  )rz  re  r   s    r   r  CCodeWriter.indent
  s    dTZZ/0r   c                 *    S[        U5      S-   S S -  $ )Nz0x%02X%02X%02X%02X)r   r   r   r   r/  )r   )r   	pyversions     r   get_py_version_hexCCodeWriter.get_py_version_hex
  s    #uY'7)'CRa&HHHr   c                 `    XR                   R                  ;   a  U R                  SU-  5        g g )Nz%s:;)rP  r;  r   r  s     r   rW  CCodeWriter.put_label
  s'    ..,,,JJv|$ -r   c                 b    U R                   R                  U5        U R                  SU-  5        g )Ngoto %s;)rP  r  r   r  s     r   r  CCodeWriter.put_goto
  s%      %

:#$r   c                 R   UR                   S:X  a  U(       d  UR                  (       d  g UR                   S:X  a  UR                  (       d  g UR                  (       d  U R	                  S5        U(       a  U R	                  SU-  5        UR
                  (       a4  U R	                  UR                  R                  UR                  US95        O3U R	                  UR                  R                  UR                  US95        UR                  b8  U R                  SUR                  R                  UR                  5      -  5        O,UR                  R                  (       a  U R	                  S5        U R                  S5        U R                  R                   R#                  U5        g )Nprivater  %s )dll_linkagez = %sz = NULLr  )
visibilitydefined_in_pxdr  cf_usedr  is_cpp_optionalr   cpp_optional_declaration_coder  r  r  r  literal_codeis_pyobjectr   rP  r8  rK  )r   r]  storage_classrW  
definitions        r   put_var_declarationCCodeWriter.put_var_declaration#
  s)    y(*@T@Ty(}}HH%&HHU]*+  HHUZZ== > 6 7 HHUZZ00 1 6 7::!MM'EJJ$;$;EJJ$GGHZZ##HHY

333E:r   c                 t   UR                    GH   u  p#pEUR                  (       aA  UR                  (       d0  UR                  R                  S   (       a  UR                  U5      nOUR                  U5      nUR                  (       a  U R                  SU-  5        M  UR                  (       a4  U R                  U< SUR                  UR                  5      < S35        M  U R                  U=(       a    S=(       d    S< U< S35        GM     UR                  (       a  U R                  R                  (       a  SnOSnU R                  U< S[        R                   < S	35        U R                  U< S
[        R"                  < S35        U R                  U< S[        R$                  < S	35        g g )Nr  z
%s = NULL;r0  r  r  r=  r  zint z = 0;zconst char *z = NULL;)rF  r  r  r8  r  r\  r  r^  r   r  r]  default_valuerM  rP  rN  r   lineno_cnamefilename_cnameclineno_cname)r   func_contextr1  r   r  r  r  unuseds           r   put_temp_declarations!CCodeWriter.put_temp_declarations=
  s,   .:.J.J*D
  )?)?LDVDVDaDabnDo99$?,,T2

<$./((

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

f&:&@b&@$GH /K 66~~22)JJ&&2E2EFGJJVV=R=RSTJJ&&2F2FGH 7r   c                 d    U R                  [        R                  5        U R                  S5        g rx  )r   r   GENERATED_BY_MARKERr   s    r   put_generated_byCCodeWriter.put_generated_byT
  s    

5,,-

2r   c                 T    U R                  SU-  5        U R                  SU-  5        g )Nz
#ifndef %sz
#define %sr   )r   guards     r   put_h_guardCCodeWriter.put_h_guardX
  s$    

<%'(

<%'(r   c                 :    [         R                  (       a  SU-  $ U$ )Nzunlikely(%s))r	   gcc_branch_hintsr   conds     r   unlikelyCCodeWriter.unlikely\
  s    ##!D((Kr   c           
      p    U(       d  gSSR                  U Vs/ s H
  o2" X35      PM     sn5      -  $ s  snf )Nr=  rV  r  )r  )r   	modifiersmapperrY  s       r   build_function_modifiers$CCodeWriter.build_function_modifiersb
  s2    sxxi @ii @AAA @s   3
c                     UR                   nUR                  (       d  UR                   R                  5       (       a  UR                   R                  (       a  SUR                  -   $ UR                  $ )Nz(PyObject *))r   is_self_argis_completer  r  )r   r]  r   s      r   entry_as_pyobjectCCodeWriter.entry_as_pyobjecti
  sL    zz!!%***@*@*B*B:://!EKK//;;r   c                 $    SSK JnJn  U" X2U5      $ )Nr   py_object_typetypecast)r  r  r  )r   r  r   r  r  s        r   as_pyobjectCCodeWriter.as_pyobjectq
  s    8e44r   c                 &    UR                  X5        g r   )generate_gotrefr  s      r   
put_gotrefCCodeWriter.put_gotrefu
  s    T)r   c                 &    UR                  X5        g r   )generate_giverefr  s      r   put_giverefCCodeWriter.put_giverefx
      d*r   c                 &    UR                  X5        g r   )generate_xgiverefr  s      r   put_xgiverefCCodeWriter.put_xgiveref{
  s    t+r   c                 &    UR                  X5        g r   )generate_xgotrefr  s      r   put_xgotrefCCodeWriter.put_xgotref~
  r  r   c                 $    UR                  XUS9  g N)r  )generate_increfr   r  r   r  s       r   
put_increfCCodeWriter.put_incref
  s     	T6r   c                 $    UR                  XUS9  g r  )generate_xincrefr  s       r   put_xincrefCCodeWriter.put_xincref
  s    d7r   c                 $    UR                  XX4S9  g N)r  have_gil)generate_decrefr   r  r   r  r  s        r   
put_decrefCCodeWriter.put_decref
  s    TIr   c                 $    UR                  XX4S9  g r  )generate_xdecrefr  s        r   put_xdecrefCCodeWriter.put_xdecref
  s    dJr   c                 &    UR                  XUXES9  g N)r  r  r  )generate_decref_clearr   r  r   r  r  r  s         r   put_decref_clearCCodeWriter.put_decref_clear
  s    ""4DW$) 	# 	>r   c                 &    UR                  XUXES9  g r  )generate_xdecref_clearr  s         r   r  CCodeWriter.put_xdecref_clear
  s    ##DEX$) 	$ 	>r   c                 (    UR                  XU5        g r   )generate_decref_setr   r  r   	rhs_cnames       r   put_decref_setCCodeWriter.put_decref_set
  s      i8r   c                 (    UR                  XU5        g r   )generate_xdecref_setr  s       r   put_xdecref_setCCodeWriter.put_xdecref_set
  s    !!$y9r   c                 $    UR                  XUS9  g N)r  )generate_incref_memoryviewslice)r   slice_cnamer   r  s       r   put_incref_memoryviewslice&CCodeWriter.put_incref_memoryviewslice
  s    ,,T,Rr   c                 N    U R                  UR                  UR                  US9  g r  )r  r  r   )r   r]  r  s      r   put_var_incref_memoryviewslice*CCodeWriter.put_var_incref_memoryviewslice
  s    ''UZZ('Sr   c                 P    U R                  UR                  UR                  5        g r   )r  r  r   r\  s     r   put_var_gotrefCCodeWriter.put_var_gotref
  s    UZZ0r   c                 P    U R                  UR                  UR                  5        g r   )r  r  r   r\  s     r   put_var_giverefCCodeWriter.put_var_giveref
      ejj1r   c                 P    U R                  UR                  UR                  5        g r   )r  r  r   r\  s     r   put_var_xgotrefCCodeWriter.put_var_xgotref
  r  r   c                 P    U R                  UR                  UR                  5        g r   )r  r  r   r\  s     r   put_var_xgiverefCCodeWriter.put_var_xgiveref
  s    %++uzz2r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r  r  r   r   r]  kwdss      r   put_var_increfCCodeWriter.put_var_incref
      UZZ848r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r  r  r   r  s      r   put_var_xincrefCCodeWriter.put_var_xincref
      ejj9D9r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r  r  r   r  s      r   put_var_decrefCCodeWriter.put_var_decref
  r  r   c                 T    U R                   " UR                  UR                  40 UD6  g r   )r  r  r   r  s      r   put_var_xdecrefCCodeWriter.put_var_xdecref
  r  r   c                 l    U R                   " UR                  UR                  4SUR                  0UD6  g Nr  )r  r  r   
in_closurer  s      r   put_var_decref_clear CCodeWriter.put_var_decref_clear
  s+    ekk5::d5K[K[d_cdr   c                 V    U R                   " UR                  UR                  U40 UD6  g r   )r  r  r   r   r]  r  r  s       r   put_var_decref_setCCodeWriter.put_var_decref_set
  s!    EKKYG$Gr   c                 V    U R                   " UR                  UR                  U40 UD6  g r   )r  r  r   r  s       r   put_var_xdecref_setCCodeWriter.put_var_xdecref_set
  s!    U[[%**iH4Hr   c                 l    U R                   " UR                  UR                  4SUR                  0UD6  g r  )r  r  r   r  r  s      r   put_var_xdecref_clear!CCodeWriter.put_var_xdecref_clear
  s+    u{{EJJeEL\L\e`der   c                     U HR  nU(       a  UR                   (       d  M  UR                  (       a  U R                  U5        MA  U R                  U5        MT     g r   )r  xdecref_cleanupr  r  )r   entries	used_onlyr]  s       r   put_var_decrefsCCodeWriter.put_var_decrefs
  s<    E


((((/''. r   c                 8    U H  nU R                  U5        M     g r   )r  r   r  r]  s      r   put_var_xdecrefsCCodeWriter.put_var_xdecrefs
  s    E  ' r   c                 8    U H  nU R                  U5        M     g r   )r  r   s      r   put_var_xdecrefs_clear"CCodeWriter.put_var_xdecrefs_clear
  s    E&&u- r   c                     SSK JnJn  U" X$S5      nU(       a  U R                  U< SU< S35        g U R                  U< SU< S35        g )Nr   r  Py_Noner0  z; __Pyx_INCREF(Py_None);z; Py_INCREF(Py_None);)r  r  r  r   )r   r  r   r  r  r  py_nones          r   put_init_to_py_noneCCodeWriter.put_init_to_py_none
  s6    84;JJE7KLJJHIr   c                     X!R                   -  nU R                  XAR                  U5        UR                  (       a  U R	                  S5        g g )Nr  )r  r	  r   r  r  )r   r]  r  r  r   s        r   put_init_var_to_py_none#CCodeWriter.put_init_var_to_py_none
  s@    ++% 	  zz59Y' r   c                 F   SnUR                   (       d  UR                  S:X  at  SSKJn  UR                  [        ;  aZ  UR                  UR                  5      (       a  SnO7UR                  S:X  a  U R                  R                  S   (       d  OU(       a  g UR                  R                  5       nU(       d  g UR                   (       a  UWR                  /-  nU(       a  UR                  U5      OUR                  nUR                  R                  5       n	U	S:w  a
  S	U	< S
U< 3nUR                  R                  5       n
U(       af  WR                  U R                  R                  5      R!                  UR                  5      nUR#                  5       nU(       a  U R%                  U5        U R%                  SU
< SU< SSR'                  U5      < SUR(                  (       a  UR*                  OS< SU< 3
5        U(       a  W(       a  U R%                  S5        g g g )NF__getattribute__r   )	TypeSlotsT__getattr__fast_getattrPyCFunctionz(void(*)(void))(r*  r3  z, (PyCFunction)rS  |r  rU  r  )
is_specialr1  r=  r  special_py_methodsis_binop_number_slotr1  r  r  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)r   r]  term
allow_skipwrapper_code_writeris_number_slotr  r  func_ptrcast
entry_nameslotpreproc_guards                r   put_pymethoddefCCodeWriter.put_pymethoddef
  s   uzz-??#zz!3311%**== &*NZZ=09I9I9T9TUc9d  335Y5566LI\&>>uEbgbrbr335= 26AHZZ335
 ++D,<,<,G,GH``afakaklD 88:M

=)

&#(99#5	 mJJx  ,>r   c                    UR                   nUR                  (       a  UR                  R                  5       =(       d    / nSSKJn  XC;   a  [        R                  U-   nU R                  SU-  5        SUR                   -  nUR                  S:X  a7  U R                  SU-  5        U R                  S5        U R                  S5        OU R                  S	U-  5        U R                  S
5        U$ )Nr   )method_noargszBstatic PyObject *%s(PyObject *self, CYTHON_UNUSED PyObject *arg) {z%s(self)r   zPyObject *res = %s;zFif (!res && !PyErr_Occurred()) { PyErr_SetNone(PyExc_StopIteration); }zreturn res;z
return %s;rU  )
r  r  r  r  r  r/  r   method_wrapper_prefixr   r1  )r   r]  r  r  r/  	func_calls         r   r  #CCodeWriter.put_pymethoddef_wrapper  s    %%
 ??779?RL0,#99JF


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

3r   c                     U R                   R                  S   (       a0  U R                   R                  [        R	                  SS5      5        g U R                   R                  [        R	                  SS5      5        g )Nfast_gilFastGilrJ  	NoFastGil)r1  r  r  r  rd  r   s    r   use_fast_gil_utility_code%CCodeWriter.use_fast_gil_utility_code0  sZ    &&z2--k.E.EiQd.ef--k.E.EkSf.ghr   c                 Z   U R                   R                  S   S:w  a  SSKJn  U" U R                  SS5        U R                   R                  [        R                  SS5      5        U R                  5         U(       d  S	nU(       a  U R                  S
5        U R                  SU-  5        g)z
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.
subinterpreters_compatiblenor   )warningzTAcquiring the GIL is currently very unlikely to work correctly with subinterpreters.r   ForceInitThreadsrJ  __pyx_gilstate_savezPyGILState_STATE z%s = __Pyx_PyGILState_Ensure();N)r1  r  Errorsr<  rc  r  r  rd  r7  r  r   )r   declare_gilstatevariabler<  s       r   put_ensure_gilCCodeWriter.put_ensure_gil6  s     &&'CDL'$$f
 	))##$68KL	N&&(,H,-

4x?@r   c                 ^    U R                  5         U(       d  SnU R                  SU-  5        g)z4
Releases the GIL, corresponds to `put_ensure_gil`.
r>  z__Pyx_PyGILState_Release(%s);N)r7  r   )r   rA  s     r   put_release_ensured_gil#CCodeWriter.put_release_ensured_gilM  s*     	&&(,H

2X=>r   c                     U R                  S5        U R                  S[        R                   S35        U R                  S5        g )N-#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADINGzPyMutex_Lock(&r4  r  r   r   parallel_freethreading_mutexr   s    r   put_acquire_freethreading_lock*CCodeWriter.put_acquire_freethreading_lockV  s7    

BC

^F$G$G#HKL

8r   c                     U R                  S5        U R                  S[        R                   S35        U R                  S5        g )NrH  zPyMutex_Unlock(&r4  r  rI  r   s    r   put_release_freethreading_lock*CCodeWriter.put_release_freethreading_lock[  s8    

BC

%f&I&I%J"MN

8r   c                 d   U R                  5         U R                  S5        U(       a  U R                  SU-  5        U(       a  U R                  S5        U R                  S5        U(       aD  U R                  S5        U R                  S5        U R                  5         U R                  S5        gg)	zg
Acquire the GIL. The thread's thread state must have been initialized
by a previous `put_release_gil`
z__Pyx_FastGIL_Forget();z_save = %s;zif (_save) {Py_BLOCK_THREADSrU  ##if CYTHON_COMPILING_IN_LIMITED_APIr  N)r7  r   rE  r   rA  unknown_gil_states      r   put_acquire_gilCCodeWriter.put_acquire_gil`  s    
 	&&(

,-JJ}x/0JJ~&

%&JJsOJJ<=((*JJx 	 r   c                    U R                  5         U R                  S5        U R                  S5        U(       ae  U R                  S5        U R                  5         U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U(       a  U R                  S	5        U(       a  U R                  S
U-  5        U R                  S5        g)z2Release the GIL, corresponds to `put_acquire_gil`.zPyThreadState *_save;z_save = NULL;rR  r   zif (PyGILState_Check())r  r3  Py_UNBLOCK_THREADSrU  z%s = _save;z__Pyx_FastGIL_Remember();N)r7  r   rB  rS  s      r   put_release_gilCCodeWriter.put_release_gilr  s    &&(

*+

?# JJ<= !JJwJJ01JJx JJsO

'(JJsOJJ}x/0

./r   c                 &    U R                  S5        g )Nz%PyGILState_STATE __pyx_gilstate_save;rq  r   s    r   r@  CCodeWriter.declare_gilstate  s    

:;r   c                 R    U R                  SU< SU R                  U5      < 35      $ )Nif (z < 0) )r   r  )r   r  rD  s      r   put_error_if_negCCodeWriter.put_error_if_neg  s!     zzeT__S5IJKKr   c                    U(       a  SOSnUR                   (       a  SnOUR                  R                  (       a  UR                  (       a  SnO]UR                  R                  (       a@  UR                  (       a/  UR
                  (       d  UR                  R                  (       a  SnOSnU R                  R                  [        R                  U U 3S5      5        U(       d%  UR                  R                  UR                  5      nU R                  SU< S	S
U U 3< SUR                  R!                  5       < SU R#                  U5      < S3	5        g )NNogilr=  RaiseClosureNameErrorRaiseCppGlobalNameErrorRaiseCppAttributeErrorRaiseUnboundLocalErrorr  zif (unlikely(!z)) { r  r  z); z })from_closurer   r  
is_cglobalis_variable	is_memberr8  is_c_class_scoper1  r  r  rd  check_for_null_coder  r   r1  r  r  )r   r  r]  in_nogil_contextunbound_check_code	nogil_tagr  s          r   put_error_if_unbound CCodeWriter.put_error_if_unbound  s    /GR	*DZZ$$)9)9,DZZ$$):):5??W\WbWbWsWs ,D+D))''4&(<>PQ	S "!&!?!?!L

 2"(yk : %

 > > @ $ 4	6 	7r   c                     SU R                   l        U(       a  SU R                   l        SU R                  US   5      < SUS   < S3$ )NTz__PYX_MARK_ERR_POS(r   rS  r   r*  )rP  rM  rN  r=  )r   r  r  s      r   set_error_infoCCodeWriter.set_error_info  sA    8<526DNN/  Q(F 	r   c                    U R                   R                  nU R                   R                  U5        Uc  SU-  $ SU R                   l        U(       a  SU R                   l        SU R                  US   5      < SUS   < SU< S3$ )NrR  Tz
__PYX_ERR(r   rS  r   r*  )rP  r9  r  rM  rN  r=  )r   r  r  r  s       r   r  CCodeWriter.error_goto  su    nn((  %;##8<526DNN/  Q(F 	r   c                 R    SU R                  U5      < SU R                  U5      < 3$ )Nr^  r  )ry  r  )r   rx  r  s      r   error_goto_ifCCodeWriter.error_goto_if  s    #}}T2DOOC4HIIr   c                 ,    U R                  SU-  U5      $ )Nz!%srx  r   r  r  s      r   r3  CCodeWriter.error_goto_if_null  s    !!%%-55r   c                 ,    U R                  SU-  U5      $ )Nz(%s < 0)r{  r|  s      r   error_goto_if_negCCodeWriter.error_goto_if_neg  s    !!*u"4c::r   c                 &    U R                  SU5      $ )NzPyErr_Occurred()r{  r  s     r   r  CCodeWriter.error_goto_if_PyErr  s    !!"4c::r   c                 8    U R                   R                  U5      $ r   )r1  r=  )r   r  s     r   r=  CCodeWriter.lookup_filename  s    //99r   c                 &    U R                  S5        g )N__Pyx_RefNannyDeclarationsrq  r   s    r   r  (CCodeWriter.put_declare_refcount_context  s    

/0r   c                     UR                  5       nU(       a/  U R                  R                  [        R	                  SS5      5        U R                  SX=(       a    S=(       d    S4-  5        g )Nr=  rJ  z#__Pyx_RefNannySetupContext(%s, %d);r   r   )r  r1  r  r  rd  r   )r   r1  acquire_gils      r   r=  &CCodeWriter.put_setup_refcount_context  s[    '')--''(:<OPR

8DBSRSBXWX;YYZr   c                 B    U R                  U(       a  S5        g S5        g )Nz"__Pyx_RefNannyFinishContextNogil()z__Pyx_RefNannyFinishContext();rq  r   nogils     r   rY  'CCodeWriter.put_finish_refcount_context  s    

57gFfgr   c                     UR                  5       nUU(       a  [        R                  OS[        R                  [        R                  4nSU R
                  l        U R                  SU-  5        g)zt
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)r  r   rg  re  rf  rP  rN  r   )r   qualified_nameinclude_clineformat_tuples       r   put_add_tracebackCCodeWriter.put_add_traceback  s[     (;;=$1F  q!!	
 /3+

8<GHr   c                 >   U[         R                  [         R                  [         R                  U R                  R
                  S   U4nSU R                  l        U R                  SU-  5        U R                  R                  [        R                  SS5      5        g)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   rg  re  rf  r1  r  rP  rN  r   r  r  rd  )r   r  r  r  s       r   put_unraisableCCodeWriter.put_unraisable  s       !!''(?@
 /3+

ETU))##$>O	Qr   c                 t    U R                   R                  S   =(       d    U R                   R                  S   $ )Nprofiler  )r1  r  r   s    r   
is_tracingCCodeWriter.is_tracing  s0    **95a9I9I9T9TU`9aar   c                     U R                   R                  nU(       a3  XR                  ;  a$  UR                  nU(       a  XR                  ;  a  M$  U(       a  UR                  U   $ S$ )z[
Calculate a fake 'instruction offset' from a node position as 31 bit int (32 bit signed).
r   )rP  r8  node_positions_to_offsetparent_scope)r   r  r8  s      r   r  CCodeWriter.pos_to_offset  sT     $$#A#AA&&E #A#AA6;u--c2BBr   c                 B    U R                  U(       a  S5        g S5        g )N__Pyx_TraceDeclarationsGen__Pyx_TraceDeclarationsFuncrq  )r   is_generators     r   put_trace_declarations"CCodeWriter.put_trace_declarations  s    

</cEbcr   c                 <    U(       a  U R                  SU-  5        g g )Nz__Pyx_TraceFrameInit(%s)rq  )r   codeobjs     r   put_trace_frame_init CCodeWriter.put_trace_frame_init  s    JJ1G;< r   c                 B   U(       a  SOSnU R                  U SUR                  5        S[        R                   SU R	                  US   5       SUS    SU R                  U5      S	 SUS	 SU(       a  [        R                  OS
 SU R                  U5       S35        g )N__Pyx_TraceStartGen__Pyx_TraceStartFuncr  rS  r  r   ], r   r   r  r4  )r   r  r   filetable_cnamer=  r  skip_dispatch_cnamer  )r   r1  r  r  r  is_cpdef_func
trace_funcs          r   put_trace_startCCodeWriter.put_trace_start  s    .:*@V


l!'')*"%%&a(<(<SV(D'ES1vhb!!#&q)Qir-:v))DBs#$
	
r   c                 B    U R                  S[        U5      S S35        g )Nz__Pyx_PyMonitoring_ExitScope(r   r4  )r   r   r  s     r   put_trace_exitCCodeWriter.put_trace_exit"  s    

24;q/DEr   c           	      z    U R                  U5      nU R                  SU SU R                  U5       SU S35        g )Nz__Pyx_TraceYield(rS  r4  r  r   r  )r   retvalue_cnamer  r  s       r   put_trace_yieldCCodeWriter.put_trace_yield%  sC    __S)


&~&6b9K9KC9P8QQST^S__abcr   c                    U R                   R                  nUR                  (       a  UR                  R                  S   OUS   nUR                  R                  5       nU R                  US   5      nU R                  U5      nU R                  SU S[        R                   SU SU SU R                  U5       SU S35        g )Nr   r   z__Pyx_TraceResumeGen(rS  r  r  r4  )rP  r8  scope_classr  r1  r  r=  r  r   r   r  r  )r   r  r8  
first_liner1  filename_indexr  s          r   put_trace_resumeCCodeWriter.put_trace_resume)  s    $$161B1BU&&**1-A
zz--/--c!f5__S)


#fB%%&a'7sl"!!#&'rl	
r   c           
          U R                  SU R                  U5       S[        U5      S S[        U5      S S35        g )N__Pyx_TraceException(rS  r   r4  r   r  r   )r   r  reraisefreshs       r   put_trace_exceptionCCodeWriter.put_trace_exception:  sE    

*4+=+=c+B*C2d7mTUEVVXY]^cYdefXggijkr   c                 J    U R                  S[        R                   S35        g )Nr  z, 0, 0);)r   r   re  r   s    r   put_trace_exception_propagating+CCodeWriter.put_trace_exception_propagating=  s    

*6+>+>*?xHIr   c                 L    U R                  SU R                  U5       S35        g )Nz__Pyx_TraceExceptionHandled(r4  )r   r  r  s     r   put_trace_exception_handled'CCodeWriter.put_trace_exception_handled@  s$    

1$2D2DS2I1J"MNr   c                 f    U R                  SU R                  U5       S[        U5      S S35        g )Nz__Pyx_TraceExceptionUnwind(rS  r   r4  r  )r   r  r  s      r   put_trace_unwindCCodeWriter.put_trace_unwindC  s3    

01C1CC1H0IDQVKXY?Z\]^r   c           	      z    U R                  U5      nU R                  SU SU R                  U5       SU S35        g )Nz__Pyx_TraceStopIteration(rS  r4  r  )r   r  rD  r  s       r   put_trace_stopiteration#CCodeWriter.put_trace_stopiterationF  sB    __S)


.ugR8J8J38O7PPRS]R^^`abr   c                    SnSnUc  OpUR                   (       a  UR                  U5      nOMUR                  (       a  SnO9UR                  (       a  SnO%UR                  (       a  SnSUR                   3nOSnU R                  U5      nU R                  U SU U SU R                  U5       S[        U5      S SU S35        g )	Nr=  __Pyx_TraceReturnValuer  __Pyx_TraceReturnCValuerS  r  r   r4  )	r^  r  is_void	is_stringto_py_functionr  r   r  r   )r   r  r  r  r  	extra_argr  r@  s           r   put_trace_returnCCodeWriter.put_trace_returnJ  s    	-
$$(44^DN  &N""&N''2J[7789I 'N-

j\>"29+R@R@RSV@W?XXZ[_`e[fghZiiklzk{{}~r   DefaultPlacementNewr  c                 d    U R                   R                  U5        U R                  SU S35        g )Nz$__Pyx_default_placement_construct(&(z));)r1  r  r   )r   rb  _utility_codes      r   put_cpp_placement_new!CCodeWriter.put_cpp_placement_newb  s,    ))-8

9&EFr   c                 j    U R                  S5        U R                  U5        U R                  S5        g )Nz#ifdef _OPENMPz#endif /* _OPENMP */rq  )r   strings     r   putln_openmpCCodeWriter.putln_openmpg  s(    

#$

6

)*r   c                     U R                  SU-  5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g)zT
Redefine the macros likely() and unlikely to no-ops, depending on
condition 'cond'
#if %s    #undef likely    #undef unlikelyz    #define likely(x)   (x)z    #define unlikely(x) (x)r  Nrq  rw  s     r   undef_builtin_expect CCodeWriter.undef_builtin_expectl  sT    
 	

8d?#

&'

()

01

01

8r   c                     U R                  SU-  5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        U R                  S5        g )Nr  r  r  z2    #define likely(x)   __builtin_expect(!!(x), 1)z2    #define unlikely(x) __builtin_expect(!!(x), 0)r  rq  rw  s     r   redef_builtin_expect CCodeWriter.redef_builtin_expectx  sR    

8d?#

&'

()

GH

GH

8r   )
rg  ra  rf  r!  rP  r1  rc  rb  re  rd  )NNF)NNTr   r  )TF)r=  FrM  )r=  NT)TT)FTT)r   )z%sT)TNNT)FNr  )FFFr  )r   r   r   r   r   cythonr   r   rl  r/  rr  ru  r   ry  rz  r8  r  r  rV  r:  r=  r9  r;  r?  r@  r  rA  r  r<  r>  rd  rm  rr  rx  r|  r  r  r  r  r  rX  r:  r  r  r  ru  r  r  r	  r  rz  r  r  rc  r  r   r  r  r  r  r   r  r	  r  r  r  r  r  r  r8  r=  rA  rD  rG  r  rM  rW  r  ra  rj  rn  rs  ry  modifier_output_mapperr~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r,  r  r7  rB  rE  rK  rN  rU  rY  r@  r_  rp  rs  r  rx  r3  r  r  r=  r  r=  rY  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rb  r  r  r  r  r   r   r   r   r  r  x  s   < ]]}-? .?44
&%!-* ! !     " " 3 3   &2 MSSNTSMSMKL:0
'





=>0
Vb.?D@ ; ; < <
D&%	'FV
8.	R[ 	R1I%% 8:9=;4I.) :P B5*+,+78JK>>9:ST12239:9:eHIf/(.J(/!b,iA.?

!$0.<
L
70J6;;:1[hI"Q&bCd=
Fd
"lJO_c@2 -8,<,<=RTd,eG
+

r   r  c                   ,    \ rS rSrS rS rS rS rSrg)PyrexCodeWriteri  c                 H    [         R                  " U5      U l        SU l        g r~  )r   r(  r  re  )r   outfile_names     r   r   PyrexCodeWriter.__init__  s    $$\2
r   c                 b    U R                   R                  SU R                  -  < U< S35        g )Nr  r%  )r  r   re  r  s     r   r   PyrexCodeWriter.putln  s     tzz!1489r   c                 .    U =R                   S-  sl         g r;  r<  r   s    r   r  PyrexCodeWriter.indent  r?  r   c                 .    U =R                   S-  sl         g r;  r<  r   s    r   r  PyrexCodeWriter.dedent  r?  r   )r  re  N)	r   r   r   r   r   r   r  r  r   r   r   r   r  r    s    :r   r  c                   ~    \ rS rSrSrSS jrSS jrSS jr\S 5       r	S r
S	 rSS
 jrSS jrS rS rS rS rSrg)PyxCodeWriteri  z/
Can be used for writing out some Cython code.
Nc                 r    U=(       d
    [        5       U l        X l        X l        X0l        X@l        0 U l        g r   )r   ra  re  original_levelr  r  _insertion_points)r   ra  indent_levelr  r  s        r   r   PyxCodeWriter.__init__  s-    .!
* !#r   c                 .    U =R                   U-  sl         gr  r<  r   levelss     r   r  PyxCodeWriter.indent  s    

f
r   c                 .    U =R                   U-  sl         g r   r<  r  s     r   r  PyxCodeWriter.dedent  s    

f
r   c              #   v   #    U R                  U5        U R                  5         Sv   U R                  5         g7f)zN
with pyx_code.indenter("for i in range(10):"):
    pyx_code.putln("print i")
N)r   r  r  )r   rX  s     r   indenterPyxCodeWriter.indenter  s(      	

4s   79c                 6    U R                   R                  5       $ r   )ra  emptyr   s    r   r  PyxCodeWriter.empty  s    {{  ""r   c                     U R                   R                  5       n[        U[        5      (       a  UR	                  U R
                  5      nU$ r   )ra  ru  r   r   r  r  )r   r  s     r   ru  PyxCodeWriter.getvalue  s8    %%'fe$$]]4==1Fr   c                     Uc  U R                   b  U R                   nUb  [        X5      nU R                  R                  U(       a  U R                  S-   U S35        g S5        g )Nz    r%  )r  r  ra  r   re  )r   rX  r  s      r   r   PyxCodeWriter.putln  sX    ?||',,t-DdTZZ&01$r:MMr   c                     Uc  U R                   b  U R                   nUb  [        X5      n[        XR                  S-  5      nU R                  R                  U5        g )Nr/  )r  r  _indent_chunkre  ra  r   )r   chunkr  s      r   	put_chunkPyxCodeWriter.put_chunk  sN    ?||',,/EeZZ!^4% r   c                     [        U 5      " U R                  R                  5       U R                  U R                  5      $ r   )r   ra  r8  re  r  r   s    r   r8  PyxCodeWriter.insertion_point  s*    Dz$++557T\\RRr   c                 Z    U R                   R                  5         U R                  U l        g r   )ra  resetr  re  r   s    r   r  PyxCodeWriter.reset  s!     	((
r   c                 >    U R                  5       U R                  U'   g r   )r8  r  r  s     r   named_insertion_point#PyxCodeWriter.named_insertion_point  s    '+';';'=t$r   c                      U R                   U   $ r   )r  r  s     r   rP  PyxCodeWriter.__getitem__  s    %%d++r   )r  ra  r  r  re  r  )Nr   Nr}   )r   r   )r   r   r   r   r   r   r  r  r   r  r  ru  r   r  r8  r  r"  rP  r   r   r   r   r  r    sT    $  #N!S)>,r   r  r  indentation_lengthr  c                 (   SU ;  d   eU R                  SS9nU(       d  U $ US   R                  S5      nU(       a  X2S'   OUS	 U(       d  g[        U 5      S-   n[        U5       H1  u  pV[	        U5      nUS-   [        U5      :X  a  SX%'   M(  Xt:  d  M/  UnM3     U[        U 5      :  a  SnXA:  a$  SX-
  -  nU Vs/ s H  nUS:w  a  X-   OSPM     nnO%XA:  a   XA-
  n	U Vs/ s H  nUS:w  a  XiS	 OSPM     nnS
R                  U5      $ s  snf s  snf )zONormalise leading space to the intended indentation and strip empty lines.
    	T)keependsr   r  r%  r   r   Nr=  )r  rH  r   r   _count_indentationr  )
r  r&  r2  	last_linemin_indentationr?  rX  line_indentation
add_indentstarts
             r   r  r    s\   
 ud+Eb	  %Ib	"I #&e*q.O U#-d3a3t9,EH/.O $ U#+.@A
 
 "&J47 	 
 
	-+@ 
 !DLDLd2 	 

 775>

s   ;D
!Dr   r  c                 D    Sn[        U 5       H  u  pUS:w  d  M    U$    U$ )Nr   r  )r   )r  r?  chs      r   r*  r*    s/     A19H  Hr   c                   &    \ rS rSrS rS rS rSrg)r  i  c                 :    Xl         0 U l        0 U l        SU l        g r~  )klassrF  rG  temps_count)r   r4  s     r   r   ClosureTempAllocator.__init__  s    
!r   c                 z    U R                   R                  5        H  u  p[        U5      U R                  U'   M     g r   )rF  r-  r   rG  )r   r   r  s      r   r  ClosureTempAllocator.reset!  s/     00668LD$(LDOOD! 9r   c                    XR                   ;  a  / U R                   U'   / U R                  U'   O2U R                  U   (       a  U R                  U   R                  S5      $ S[        R                  U R
                  4-  nU R                  R                  S X"USS9  U R                   U   R                  U5        U =R
                  S-  sl        U$ )Nr   r\  T)r  r1  r  r   is_cdefr   )	rF  rG  r  r   r  r5  r4  declare_varrO  )r   r   r  s      r   r  "ClosureTempAllocator.allocate_temp%  s    +++)+D  &$&DOOD!__T"??4(,,Q//&779I9IJJ

4etUYZT"))%0Ar   )r4  rF  r5  rG  N)r   r   r   r   r   r  r  r   r   r   r   r  r    s    1
r   r  r   )Vr  declarer   r"  r   r   r   r)  r   r  r   	functoolsr   r   
contextlibr   r   collectionsr   r=  r   r	   r   r
   r   Scanningr   r   r  ctypedef_builtins_mapbasicsize_builtins_mapKNOWN_PYTHON_BUILTINS_VERSIONr   KNOWN_PYTHON_BUILTINSuncachable_builtinsr  r   r  r  r   r	  rJ  r  r  r#  r  r  r  r  r  r  r  r  r  r  ra  r*  r4  r  r  r   UrI  r  r  rG  r  findallr  r  r  r  rV  rX  r  r  r  finalccallr   r   r  	exceptvalcfuncr*  r  r   r   r   <module>rM     so     =& =V =f =v =='-=7==NT==.4=CI= != /5= 	= (.	= 6<	=   	 	    $ . #      & '
   *)*1  &  !7 ! \# \ | * ^^Iy : 0   o#  !'v8 #	! I' I'X/   6  |) |~D0/ D0N -1Ueidj &R 
6*	* *K * * 			2	2 {
+
W
W  ,	// 
(
7
7   "&D" (&= =D.o . G9 G9T. .   6V"(A jj)9244@FF JJ'89?? ZZ 1266 ,-55< <~( ($^A ^AB7 7F FR  $H, H,V , ,&** , ,  ,^ "# &**    r   