a
    b                     @   s   d dl mZ d dlZddlmZmZmZmZmZm	Z	 ddlm
Z
mZmZ ddlmZmZmZmZ ddlmZ G d	d
 d
eZdS )    )absolute_importN   )	ExprNodes
PyrexTypes
MemoryViewParseTreeTransformsStringEncodingErrors)	CloneNode	ProxyNode	TupleNode)FuncDefNodeCFuncDefNodeStatListNodeDefNode   )
OrderedSetc                       s  e Zd ZdZdZdZdZdZdZe	j
g d Z
 fddZdd Zdd	 Zd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd ZdZdZd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Z d.d/ Z!d0d1 Z"d2d3 Z#d4d5 Z$d6d7 Z%d8d9 Z&  Z'S ):FusedCFuncDefNodea  
    This node replaces a function with fused arguments. It deep-copies the
    function for every permutation of fused types, and allocates a new local
    scope for it. It keeps track of the original function in self.node, and
    the entry of the original function in the symbol table is given the
    'fused_cfunction' attribute which points back to us.
    Then when a function lookup occurs (to e.g. call it), the call can be
    dispatched to the right function.

    node    FuncDefNode    the original function
    nodes   [FuncDefNode]  list of copies of node with different specific types
    py_func DefNode        the fused python function subscriptable from
                           Python space
    __signatures__         A DictNode mapping signature specialization strings
                           to PyCFunction nodes
    resulting_fused_function  PyCFunction for the fused DefNode that delegates
                              to specializations
    fused_func_assignment   Assignment of the fused function to the function name
    defaults_tuple          TupleNode of defaults (letting PyCFunctionNode build
                            defaults would result in many different tuples)
    specialized_pycfuncs    List of synthesized pycfunction nodes for the
                            specializations
    code_object             CodeObjectNode shared by all specializations and the
                            fused function

    fused_compound_types    All fused (compound) types (e.g. floating[:])
    N)__signatures__resulting_fused_functionfused_func_assignmentc                    s   t t| |j g | _|| _t| jt}|r:| | n
| 	| | jD ]L}|j
jjr\J |jjjrjJ |jjr~|jjr~J |sJ|jjrJ|jjsJJ qJ| |j
_| jd d  | _d S N)superr   __init__posnodesnode
isinstancer   copy_def	copy_cdefentrytypeis_fusedlocal_scopereturn_typecfunc_declaratoroptional_arg_countZop_arg_structfused_cfunctionstats)selfr   envis_defn	__class__ i/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/Cython/Compiler/FusedNode.pyr   2   s     

zFusedCFuncDefNode.__init__c                 C   s  t dd | jjD }| |}t |}|| _| jj|jv rP|j	| jj |D ]\}}t
| j}| jjj|j_| |j| | jj||_|| | ||| | ||| jj|| t |j| d|j_|j|j|jj< | |sT qqT| j| _| j| j|dd| _dS )zh
        Create a copy of the original def or lambda function for specialized
        versions.
        c                 S   s   g | ]}|j jr|j qS r/   r!   r"   .0argr/   r/   r0   
<listcomp>U       z.FusedCFuncDefNode.copy_def.<locals>.<listcomp>Tr+   N)r   uniquer   args_get_fused_base_types get_all_specialized_permutationsfused_compound_typesr    pyfunc_entriesremovecopydeepcopy	signature_specialize_function_argsr$   
specializeanalyse_declarationscreate_new_local_scopespecialize_copied_defspecialize_entryusedentriesnamereplace_fused_typechecksorig_py_funcmake_fused_cpdefpy_func)r)   r*   r<   fused_typespermutationscnamefused_to_specificcopied_noder/   r/   r0   r   O   s6    



zFusedCFuncDefNode.copy_defc                 C   s  | j j }| j j | _}d| j _|r4|j|j | j j }|| _	g }|D ]`\}}t
| j }|j|}	|j}
|	|
| t|jD ]N\}}|
j|jkr|	|jr|j| |_|jjs|
j|j_|j}
|
j}	 qq||
 |	|_|	|
 |
_|	_|
jp| j jjp|jp|
j|
_| j jjr>| j jj|	||d |	j|_| ||| | |jj| || |jr|j|jj |  |j|| j jj!|| | "|sN qqNz|j#| j j}W n  t$y   |j%| Y n0 ||j||d < |r| j&||dd| _n|| _dS )zf
        Create a copy of the original c(p)def function for all specialized
        versions.
        N)Zfused_cnamer   Fr7   )'r   r!   r;   rN   rL   r=   r>   r    get_fused_typesr<   r?   r@   rC   rG   	enumerateZcfunc_entriesrQ   Zsame_as_resolved_type
func_cnameappendrH   Zdefined_in_pxdZis_c_class_scopeZ
is_cmethodr%   r&   Zdeclare_optional_arg_structr$   rE   rB   r9   Zdeclare_cpdef_wrapperrF   as_variablerK   index
ValueErrorextendrM   )r)   r*   rP   rL   rO   Znew_cfunc_entriesrQ   rR   rS   r!   r    iZ
orig_entryZcindexr/   r/   r0   r   x   sv    





zFusedCFuncDefNode.copy_cdefc                 C   s&   g }t  }|D ]}|j||d q|S )zq
        Get a list of unique basic fused types, from a list of
        (possibly) compound fused types.
        )resultseen)setrT   )r)   r<   Z
base_typesr^   
fused_typer/   r/   r0   r:      s
    z'FusedCFuncDefNode._get_fused_base_typesc                 C   s:   |D ]0}|j jr|j ||_ |j jr|j |j qd S r   )r!   r"   rC   is_memoryviewsliceZvalidate_memslice_dtyper   )r)   r9   rR   r4   r/   r/   r0   rB      s
    z+FusedCFuncDefNode._specialize_function_argsc                 C   s(   | | ||j_d|_| j| dS )a  
        Create a new local scope for the copied node and append it to
        self.nodes. A new local scope is needed because the arguments with the
        fused types are already in the local scope, and we need the specialized
        entries created after analyse_declarations on each specialized version
        of the (CFunc)DefNode.
        f2s is a dict mapping each fused type to its specialized version
        FN)Zcreate_local_scoper#   rR   Zhas_fused_argumentsr   rW   )r)   r   r*   f2sr/   r/   r0   rE      s    	
z(FusedCFuncDefNode.create_new_local_scopec                    sT   |  |} fdd|D }d||_t||jj|j_|j|j_|j|j_dS )zwSpecialize the copy of a DefNode given the copied node,
        the specialization cname and the original DefNode entryc                    s   g | ]}t | qS r/   )r   Zspecialization_signature_string)r3   r`   rb   r/   r0   r5      s   z;FusedCFuncDefNode.specialize_copied_def.<locals>.<listcomp>|N)	r:   joinspecialized_signature_stringr   Zget_fused_cnamer    pymethdef_cnamedoc	doc_cname)r)   r   rQ   Zpy_entryrb   r<   rO   Ztype_stringsr/   rc   r0   rF      s    


z'FusedCFuncDefNode.specialize_copied_defc                 C   s,   t j}t|j}|| t j|kr(dS dS )z
        Branch-prune fused type checks like

            if fused_t is int:
                ...

        Returns whether an error was issued and whether we should stop in
        in order to prevent a flood of errors.
        FT)r	   
num_errorsr   ZReplaceFusedTypeChecksr#   )r)   rS   rj   Z	transformr/   r/   r0   rK     s    

z*FusedCFuncDefNode.replace_fused_typechecksc                 C   s.   |D ]$}|j j| |jd |d qdS )zl
        Generate Cython code for instance checks, matching an object to
        specialized types.
        )py_type_namespecialized_type_namez
                    if isinstance(arg, {{py_type_name}}):
                        dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'; break
                N)contextupdaterk   specialization_string	put_chunk)r)   normal_typespyx_coder*   specialized_typer/   r/   r0   _fused_instance_checks  s    z(FusedCFuncDefNode._fused_instance_checksc                 C   s   |j rd| S t|ddS )Nz	___pyx_%s _)
is_typedefstrreplacer)   dtyper/   r/   r0   _dtype_name&  s    zFusedCFuncDefNode._dtype_namec                 C   s   |j r| |S t|S r   )rw   r|   rx   rz   r/   r/   r0   _dtype_type+  s    
zFusedCFuncDefNode._dtype_typec                 C   s   |j r
dS d| | S d S )Nzsizeof(void *)z
sizeof(%s))Zis_pyobjectr}   rz   r/   r/   r0   _sizeof_dtype0  s    zFusedCFuncDefNode._sizeof_dtypec                 C   s   | dr&|d |d |  | drL|d |d |  | drr|d |d |  | dr|d |d	 |  d
S )z?Setup some common cases to match dtypes against specializationszif kind in b'iu':pass	dtype_intzelif kind == b'f':dtype_floatzelif kind == b'c':dtype_complexzelif kind == b'O':Zdtype_objectN)indenterputlnnamed_insertion_pointdedentr)   rr   r/   r/   r0   %_buffer_check_numpy_dtype_setup_cases6  s     











z7FusedCFuncDefNode._buffer_check_numpy_dtype_setup_casesz8dest_sig[{{dest_sig_idx}}] = '{{specialized_type_name}}'z!dest_sig[{{dest_sig_idx}}] = Nonec                 C   s   |  | || D ]}|}|jr&|j}|j}|jj| |d d| | ||jd |j	|j
f|j|jf|j|jfg}|D ]`\}}	|r|d|jf }
|j	r|
d7 }
|jr|
d7 }
|	d|
 r||	| j |	d |	  q|qd	S )
zO
        Match a numpy dtype object to the individual specializations.
        z == itemsizez!not (%s_is_signed ^ dtype_signed))Zitemsize_matchZsigned_matchr{   rl   z3{{itemsize_match}} and (<Py_ssize_t>arg.ndim) == %dz and {{signed_match}}z and arg_is_pythran_compatiblezif %s:breakN)r   is_pythran_expr
org_bufferr{   rm   rn   r~   r|   ro   is_intr   Zis_floatr   
is_complexr   ndimr   r   matchr   )r)   rr   Zspecialized_buffer_typespythran_typesrs   Z
final_typer{   ZdtypesZdtype_categoryZ
codewriterZcondr/   r/   r0   _buffer_check_numpy_dtypeN  s:    




z+FusedCFuncDefNode._buffer_check_numpy_dtypec                 C   s~   |j }|jrdg|j }n|j}t||}|| |jj|j	|d |
d |jj|j| |d |d| j  dS )z
        For each specialized type, try to coerce the object to a memoryview
        slice of that type. This means obtaining a buffer and parsing the
        format string.
        TODO: separate buffer acquisition from format parsing
        )directZstrided)Zcoerce_from_py_funcr{   z;{{memviewslice_cname}} {{coerce_from_py_func}}(object, int))rl   Zsizeof_dtypea  
                # try {{dtype}}
                if itemsize == -1 or itemsize == {{sizeof_dtype}}:
                    memslice = {{coerce_from_py_func}}(arg, 0)
                    if memslice.memview:
                        __PYX_XDEC_MEMVIEW(&memslice, 1)
                        # print 'found a match for the buffer through format parsing'
                        %s
                        break
                    else:
                        __pyx_PyErr_Clear()
            N)r{   	is_bufferr   axesr   ZMemoryViewSliceTypeZcreate_from_py_utility_coderm   rn   Zfrom_py_functionr   ro   r~   rp   r   )r)   rr   	decl_coders   r*   r{   r   Zmemslice_typer/   r/   r0   !_buffer_parse_format_string_checku  s,    
z3FusedCFuncDefNode._buffer_parse_format_string_checkc                 C   s   | d|rdnd d |rdnd d  |d |rB| d |d	 | ||| |d |D ]}| |||| qhd
S )a^  
        Generate Cython code to match objects to buffer specializations.
        First try to get a numpy dtype object and match it against the individual
        specializations. If that fails, try naively to coerce the object
        to each specialization, which obtains the buffer each time and tries
        to match the format string.
        z
                z!arg_is_pythran_compatible = False z
                if ndarray is not None:
                    if isinstance(arg, ndarray):
                        dtype = arg.dtype
                        z arg_is_pythran_compatible = TrueaC  
                    elif __pyx_memoryview_check(arg):
                        arg_base = arg.base
                        if isinstance(arg_base, ndarray):
                            dtype = arg_base.dtype
                        else:
                            dtype = None
                    else:
                        dtype = None

                    itemsize = -1
                    if dtype is not None:
                        itemsize = dtype.itemsize
                        kind = ord(dtype.kind)
                        dtype_signed = kind == 'i'
            r   aS  
                        # Pythran only supports the endianness of the current compiler
                        byteorder = dtype.byteorder
                        if byteorder == "<" and not __Pyx_Is_Little_Endian():
                            arg_is_pythran_compatible = False
                        elif byteorder == ">" and __Pyx_Is_Little_Endian():
                            arg_is_pythran_compatible = False
                        if arg_is_pythran_compatible:
                            cur_stride = itemsize
                            shape = arg.shape
                            strides = arg.strides
                            for i in range(arg.ndim-1, -1, -1):
                                if (<Py_ssize_t>strides[i]) != cur_stride:
                                    arg_is_pythran_compatible = False
                                    break
                                cur_stride *= <Py_ssize_t> shape[i]
                            else:
                                arg_is_pythran_compatible = not (arg.flags.f_contiguous and (<Py_ssize_t>arg.ndim) > 1)
                Znumpy_dtype_checksN)rp   indentr   r   r   r   )r)   buffer_typesr   rr   r   r*   rs   r/   r/   r0   _buffer_checks  s.    	




z FusedCFuncDefNode._buffer_checksc           
      C   s   | d |j d |r&|j d |j d t }t }|D ]}|j}| |}	|jr|	|vr||	 |d|	 |	|
 f  |jjrBt||vrB|t| |jj|	| |d |j d qBdS )	zr
        If we have any buffer specializations, write out some variable
        declarations and imports.
        z
                ctypedef struct {{memviewslice_cname}}:
                    void *memview

                void __PYX_XDEC_MEMVIEW({{memviewslice_cname}} *, int have_gil)
                bint __pyx_memoryview_check(object)
            z
                cdef {{memviewslice_cname}} memslice
                cdef Py_ssize_t itemsize
                cdef bint dtype_signed
                cdef char kind

                itemsize = -1
            zl
                cdef bint arg_is_pythran_compatible
                cdef Py_ssize_t cur_stride
            zq
                cdef type ndarray
                ndarray = __Pyx_ImportNumPyArrayTypeIfAvailable()
            zctypedef %s %s "%s")
dtype_nameZ
dtype_typez
                            cdef bint {{dtype_name}}_is_signed
                            {{dtype_name}}_is_signed = not (<{{dtype_type}}> -1 > 0)
                        N)rp   local_variable_declarationsimportsr_   r{   r|   rw   addr   resolveZempty_declaration_coder   rx   rm   rn   r}   )
r)   rr   r   all_buffer_typesr   Zseen_typedefsZseen_int_dtypesZbuffer_typer{   r   r/   r/   r0   _buffer_declarations  sB    	



z&FusedCFuncDefNode._buffer_declarationsc           
      C   s   t |j}|  t }g g g   }}}d}|D ]f}| }	|	rp|	|v rLq2||	 |	dkrdd}q|| q2|jr|| q2|j	s|j
r2|| q2||||fS )zV
        Specialize fused types and split into normal types and buffer types.
        FobjectT)r   Zget_specialized_typesr!   sortr_   rk   r   rW   r   r   ra   )
r)   r4   Zspecialized_typesZseen_py_type_namesrq   r   r   has_object_fallbackrs   rk   r/   r/   r0   _split_fused_types  s&    
z$FusedCFuncDefNode._split_fused_typesc                 C   s   | d d S )Na  
                # PROCESSING ARGUMENT {{arg_tuple_idx}}
                if {{arg_tuple_idx}} < len(<tuple>args):
                    arg = (<tuple>args)[{{arg_tuple_idx}}]
                elif kwargs is not None and '{{arg.name}}' in <dict>kwargs:
                    arg = (<dict>kwargs)['{{arg.name}}']
                else:
                {{if arg.default}}
                    arg = (<tuple>defaults)[{{default_idx}}]
                {{else}}
                    {{if arg_tuple_idx < min_positional_args}}
                        raise TypeError("Expected at least %d argument%s, got %d" % (
                            {{min_positional_args}}, {{'"s"' if min_positional_args != 1 else '""'}}, len(<tuple>args)))
                    {{else}}
                        raise TypeError("Missing keyword-only argument: '%s'" % "{{arg.default}}")
                    {{endif}}
                {{endif}}
            )rp   r   r/   r/   r0   _unpack_argument2  s    z"FusedCFuncDefNode._unpack_argumentc                 C   s*  ddl m}m}m} | dd | jjD }tj| jjt	||rP| jj
| jj ntdd | jjD |jjd}|j|d}	|j|d}
|
d	 |
  |	d
 |	  |	d |	d |	d d}d}t }t }t| jjD ]L\}}|jjr&|j }t	|dkrtd|d }|jjr*||vr*|| |j||||d | |\}}}}| |	 |	dr|r| ||	| |s|r| |j!dd | "|||	|
| |r|	j#jdd |	$| j% n|	$| j& |	$d |	'  |d7 }|| |dd |D  |j(r|d7 }q|rx| )|	|
|| | |j!dd | |j!dd |	d |	* }ddl+m,} |j|d| gd}|-| jj.|j/}|0|
* |1  ||_2|3| |j4d }|j2| _5t6| jt7r| j8d d  |_9nd!d | j8D |_9|S )"a!  
        This creates the function that is indexable from Python and does
        runtime dispatch based on the argument types. The function gets the
        arg tuple and kwargs dict (or None) and the defaults tuple
        as arguments from the Binding Fused Function's tp_call.
        r   )TreeFragmentCodeUtilityCodec                 S   s   g | ]}|j jr|j qS r/   r1   r2   r/   r/   r0   r5   P  s   z6FusedCFuncDefNode.make_fused_cpdef.<locals>.<listcomp>c                 s   s   | ]}|j d u rdV  qd S )Nr   )defaultr2   r/   r/   r0   	<genexpr>Z  r6   z5FusedCFuncDefNode.make_fused_cpdef.<locals>.<genexpr>)memviewslice_cname	func_argsZn_fusedZmin_positional_argsrJ   )rm   z
                cdef extern from *:
                    void __pyx_PyErr_Clear "PyErr_Clear" ()
                    type __Pyx_ImportNumPyArrayTypeIfAvailable()
                    int __Pyx_Is_Little_Endian()
            a  
                def __pyx_fused_cpdef(signatures, args, kwargs, defaults):
                    # FIXME: use a typed signature - currently fails badly because
                    #        default arguments inherit the types we specify here!

                    dest_sig = [None] * {{n_fused}}

                    if kwargs is not None and not kwargs:
                        kwargs = None

                    cdef Py_ssize_t i

                    # instance check body
            r   Z	func_defsr   r   zODetermination of more than one fused base type per argument is not implemented.)Zarg_tuple_idxr4   Zdest_sig_idxdefault_idxzwhile 1:ZIsLittleEndianzModuleSetupCode.cr   )rl   r   c                 s   s   | ]}|j V  qd S r   )r   )r3   tyr/   r/   r0   r     r6   ImportzImportExport.cZImportNumPyArraya  
                candidates = []
                for sig in <dict>signatures:
                    match_found = False
                    src_sig = sig.strip('()').split('|')
                    for i in range(len(dest_sig)):
                        dst_type = dest_sig[i]
                        if dst_type is not None:
                            if src_sig[i] == dst_type:
                                match_found = True
                            else:
                                match_found = False
                                break

                    if match_found:
                        candidates.append(sig)

                if not candidates:
                    raise TypeError("No matching signature found")
                elif len(candidates) > 1:
                    raise TypeError("Function call with ambiguous argument types")
                else:
                    return (<dict>signatures)[candidates[0]]
            )ConstantFoldingmodule)levelZpipelineNc                 S   s   g | ]
}|j qS r/   rN   )r3   r,   r/   r/   r0   r5     r6   ):r   r   r   r   r:   r   r9   r   r   lenZnum_required_argsZnum_required_kw_argssumr    rJ   ZPyxCodeWriterrp   r   r   r   r_   rU   r!   r"   rT   NotImplementedErrorr   rn   r   r   r   rt   Zuse_utility_codeZload_cachedr   rm   r   r   no_matchr   r   r   getvalueZOptimizer   ZSetPosTransformr   rootZdeclare_declarations_in_scopeZglobal_scopescoperD   r(   Zfragment_scoper   r   r   Zspecialized_cpdefs)r)   rL   r*   r+   r   r   r   rO   rm   rr   r   Zfused_indexr   r   Zseen_fused_typesr\   r4   Zarg_fused_typesr`   rq   r   r   r   Zfragment_coder   fragmentastrN   r/   r/   r0   rM   G  s    













z"FusedCFuncDefNode.make_fused_cpdefc                 C   s   d}| j j}|D ]}t||t| jj| q| jj| j _| jj| j _|jdd  t	| j
trl||j|j< n||j|j _|j| | | j j_| jD ],}t	| j
tr| j |_q| j |j _||j_q|   | j| j d S )N)
rJ   r   rQ   rV   Zpyfunc_cnamerg   rh   ri   Z	is_memberr   Z__pyx_fused_cpdef)rN   r    setattrgetattrrL   rJ   rh   rI   popr   r   r   rX   r=   rW   r'   r   Zfused_py_funcsynthesize_defnodesr(   r   )r)   r*   Zcopy_attributesr    attrr   r/   r/   r0   update_fused_defnode_entry  s*    




z,FusedCFuncDefNode.update_fused_defnode_entryc                 C   s  | j D ].}| D ] }|jD ]}|jr|| qqq| jrt| j|| _| j|| _| j|| _| j	|| _	g  | _
}| jjD ]4}|jr|j||_|t|j q|d qt| jD ]X\}}|| }| j|< t|trt|j|D ]$\}}	|	durt|	|j||_qq| jrdd |D }
t| j|
d| _| jj|dd|| _t| j| _t| jd j| _| jj}t| j|_t| j|_t| jD ]6\}}t| j|_|| }| j|< t| j|_q| S )z
        Analyse the expressions. Take care to only evaluate default arguments
        once and clone the result for all specializations
        Nc                 S   s   g | ]}|rt |qS r/   )r
   )r3   r   r/   r/   r0   r5   '  r6   z9FusedCFuncDefNode.analyse_expressions.<locals>.<listcomp>)r9   T)Zskip_childrenr   ) r<   rT   typesr   Zcreate_declaration_utility_coderN   r   analyse_expressionsr   r   defaultsr   r9   r   rW   r   rU   r(   r   r   zipr
   Z	coerce_tor!   r   r   defaults_tupleZanalyse_typesZcoerce_to_pyobjectspecialized_pycfuncscode_objectr4   )r)   r*   Zfused_compound_typer`   Zspecialization_typer   r4   r\   statr   r9   Z
fused_funcZpycfuncr/   r/   r0   r     sH    



z%FusedCFuncDefNode.analyse_expressionsc                 C   s   t | jd tr"dd | jD }n| j}dd |D }dd t||D }dd |D }tj| jt||| _|| _	|D ]
}d|_
qzdS )	zT
        Create the __signatures__ dict of PyCFunctionNode specializations.
        r   c                 S   s   g | ]
}|j qS r/   r   r3   r   r/   r/   r0   r5   <  r6   z9FusedCFuncDefNode.synthesize_defnodes.<locals>.<listcomp>c                 S   s   g | ]}t |jqS r/   )r   ZEncodedStringrf   r   r/   r/   r0   r5   @  s   c                 S   s    g | ]\}}t j|j|d qS ))value)r   Z
StringNoder   )r3   r   sigr/   r/   r0   r5   B  s   c                 S   s   g | ]}t jj|d dqS )T)Zbinding)r   ZPyCFunctionNodeZfrom_defnoder   r/   r/   r0   r5   D  s   TN)r   r   r   r   r   ZDictNodeZ
from_pairsr   r   r   Zis_specialization)r)   r   Z
signatureskeysvaluesZpycfuncnoder/   r/   r0   r   7  s     z%FusedCFuncDefNode.synthesize_defnodesc                 C   sV   | j rd| j _| j|| | jD ].}t|tr"|jjr"|	|j
 ||| q"d S )NT)rN   Zpymethdef_requiredr   generate_function_definitionsr(   r   r   r    rH   mark_posr   )r)   r*   coder   r/   r/   r0   r   M  s    
z/FusedCFuncDefNode.generate_function_definitionsc                 C   sT  | j D ]}|d ur|| q| jr<| j| | j| | jD ]2}||j t|t	j
rj|| qB|| qB| jr$| j| |d| j | j f  || j  | j| | j| | j| | j| | j| | j| | j| | j| | j| | j D ]$}|d ur*|| || q*d S )Nz8((__pyx_FusedFunctionObject *) %s)->__signatures__ = %s;)r   Zgenerate_evaluation_coderN   r   r   r(   r   r   r   r   ZExprNodegenerate_execution_coder   r   r   r]   Zput_giverefZgenerate_post_assignment_codeZ
free_tempsr   Zgenerate_disposal_code)r)   r   r   r   r/   r/   r0   r   W  sD    




z)FusedCFuncDefNode.generate_execution_codec                 C   s   | j D ]}|| qd S r   )r(   annotate)r)   r   r   r/   r/   r0   r     s    
zFusedCFuncDefNode.annotate)(__name__
__module____qualname____doc__r   r   r   r   Z
decoratorsr   Zchild_attrsr   r   r   r:   rB   rE   rF   rK   rt   r|   r}   r~   r   r   r   r   r   r   r   r   r   rM   r   r   r   r   r   r   __classcell__r/   r/   r-   r0   r      sH   )V'(=; #2
,r   )
__future__r   r?   r   r   r   r   r   r   r	   r
   r   r   ZNodesr   r   r   r   ZUtilsr   r   r/   r/   r/   r0   <module>   s    