o
    @a l                     @   s   d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ dd	lZddlmZ ddlmZ dd	lZe Z G dd de!Z"dd Z#e$ D ]Z%e#e% qgG dd deZ&G dd de&Z'd	S )z' Aliases gather aliasing informations.     )GlobalDeclarations)	IntrinsicClassUnboundValue)ModuleAnalysis)PythranSyntaxError)	functionsmethodsMODULES)Unparser)demangleN)isnumdeepcopy)productc                       s<   e Zd ZdZedZdZi Z fddZefddZ	  Z
S )ContainerOfz
    Represents a container of something

    We just know that if indexed by the integer value `index',
    we get `containee'
    nanindex	containeec                    sB   t |t | f}|tjvrtt| | }|tj|< tj| S N)tupleitemsr   cachesuper__new__)clsargskwargskeyZnew_obj	__class__ :/usr/lib/python3/dist-packages/pythran/analyses/aliases.pyr   #   s
   


zContainerOf.__new__c                 C   s   || _ || _d S r   r   )selfr   r   r"   r"   r#   __init__,   s   
zContainerOf.__init__)__name__
__module____qualname____doc__floatZUnknownIndex	__slots__r   r   r%   __classcell__r"   r"   r    r#   r      s    	r   c                 C   sH   |   D ]}t|trt| qt|ft|< t|tr!t|j qdS )z: Recursively save default aliases for pythonic functions. N)values
isinstancedictsave_intrinsic_alias	frozensetIntrinsicAliasesr   Zfields)modulevr"   r"   r#   r0   1   s   



r0   c                       s  e Zd ZdZdZ fddZed:ddZdd	 Zed
d Z	d:ddZ
dd Zdd ZeZeZdd Zdd Zdd Zdd Zdd Zdd ZeZdd Zd d! Zd"d# Zd$d% Zd&d' ZeZd(d) Zd*d+ ZeZeZd,d- Z d.d/ Z!d0d1 Z"d2d3 Z#d4d5 Z$d6d7 Z%d8d9 Z&  Z'S );Aliasesz
    Gather aliasing informations across nodes

    As a result, each node from the module is associated to a set of node or
    Intrinsic to which it *may* alias to.
    @c                    s,   t  | _d | _tj  tt| t	 d S r   )
r/   resultaliasesr   r   clearr   r5   r%   r   r$   r    r"   r#   r%   J   s   
zAliases.__init__Nc              	   C   s   dd }t | tr,|  D ]\}}|d u st ||r)td||tt|| qd S t | ttfr>ttt||  d S d S )Nc                 S   s   t  }t| | |  S r   )ioStringIOr   getvaluestrip)noutputr"   r"   r#   ppR   s   
zAliases.dump.<locals>.ppz{} => {})	r.   r/   r   printformatsortedmapr1   set)r7   filterrA   kr4   r"   r"   r#   dumpP   s   
zAliases.dumpc                 C   s   t hS r   )r   r:   r"   r"   r#   get_unbound_value_set^      zAliases.get_unbound_value_setc                 C   sz   t | tjrtt| j| jS t | tjr2t| j}t	
| j}||vr.td|| j|| S t | tjr;| jS | S )Nz*Unsupported attribute '{}' for this object)r.   astNamer
   getr   id	Attributeattrr5   access_pathvaluer   rC   FunctionDefname)nodeZattr_keyZ
value_dictr"   r"   r#   rR   a   s   
zAliases.access_pathc                 C   s0   |d u rt |tr|h}n|  }|| j|< |S r   )r.   r   rJ   r7   )r$   rV   r-   r"   r"   r#   addt   s   

zAliases.addc                    s"     |tj fdd|jD  S )af  
        Resulting node may alias to either operands:

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return a or b')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.BoolOp)
        (a or b) => ['a', 'b']

        Note that a literal does not create any alias

        >>> module = ast.parse('def foo(a, b): return a or 0')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.BoolOp)
        (a or 0) => ['<unbound-value>', 'a']
        c                       g | ]}  |qS r"   visit.0r?   r:   r"   r#   
<listcomp>       z(Aliases.visit_BoolOp.<locals>.<listcomp>)rW   rF   unionr-   r$   rV   r"   r:   r#   visit_BoolOp}   s   "zAliases.visit_BoolOpc                 C   s   |  | | |S )a[  
        Resulting node does not alias to anything

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a): return -a')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.UnaryOp)
        (- a) => ['<unbound-value>']
        )generic_visitrW   r`   r"   r"   r#   visit_UnaryOp   s   

zAliases.visit_UnaryOpc                    s8     |j  fdd|j|jfD } |tj| S )ag  
        Resulting node alias to either branch

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b, c): return a if c else b')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.IfExp)
        (a if c else b) => ['a', 'b']
        c                    rX   r"   rY   r[   r:   r"   r#   r]      r^   z'Aliases.visit_IfExp.<locals>.<listcomp>)rZ   testbodyorelserW   rF   r_   )r$   rV   Zrecr"   r:   r#   visit_IfExp   s   zAliases.visit_IfExpc                 C   sZ   |j r%t }t|j |jD ]\}}| | | |}|tt| qnd}| ||S )a  
        A dict is abstracted as an unordered container of its values

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return {0: a, 1: b}')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Dict)
        {0: a, 1: b} => ['|a|', '|b|']

        where the |id| notation means something that may contain ``id``.
        N)	keysrF   zipr-   rZ   updaterE   r   rW   )r$   rV   elts_aliasesr   valelt_aliasesr"   r"   r#   
visit_Dict   s   

zAliases.visit_Dictc                    s,   |j r fdd|j D }nd} ||S )a  
        A set is abstracted as an unordered container of its elements

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return {a, b}')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Set)
        {a, b} => ['|a|', '|b|']

        where the |id| notation means something that may contain ``id``.
        c                    s$   h | ]}  |D ]}t|q	qS r"   )rZ   r   )r\   eltaliasr:   r"   r#   	<setcomp>   s    z$Aliases.visit_Set.<locals>.<setcomp>N)eltsrW   )r$   rV   rk   r"   r:   r#   	visit_Set   s   
zAliases.visit_Setc                 C   sD   |j sdS | |j }tj| jv r|| jtj }|| jtj< dS )a#  
        A side effect of computing aliases on a Return is that it updates the
        ``return_alias`` field of current function

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return a')
        >>> result = pm.gather(Aliases, module)
        >>> module.body[0].return_alias # doctest: +ELLIPSIS
        <function ...merge_return_aliases at...>

        This field is a function that takes as many nodes as the function
        argument count as input and returns an expression based on
        these arguments if the function happens to create aliasing
        between its input and output. In our case:

        >>> f = module.body[0].return_alias
        >>> Aliases.dump(f([ast.Name('A', ast.Load(), None, None),
        ...                 ast.Constant(1, None)]))
        ['A']

        This also works if the relationship between input and output
        is more complex:

        >>> module = ast.parse('def foo(a, b): return a or b[0]')
        >>> result = pm.gather(Aliases, module)
        >>> f = module.body[0].return_alias
        >>> List = ast.List([ast.Name('L0', ast.Load(), None, None)],
        ...                 ast.Load())
        >>> Aliases.dump(f([ast.Name('B', ast.Load(), None, None), List]))
        ['B', '[L0][0]']

        Which actually means that when called with two arguments ``B`` and
        the single-element list ``[L[0]]``, ``foo`` may returns either the
        first argument, or the first element of the second argument.
        N)rS   rZ   r5   RetIdr8   r_   )r$   rV   Zret_aliasesr"   r"   r#   visit_Return   s   %zAliases.visit_Returnc                    s    fdd}dd  fdd}|j }t }|jrnHt|tjr?t|jt	|jdgd \}}|r>|||}|||}n$t|tj
rcj| }	|	D ]}
t|
d	ra||
|}|||
| qL	 qLfd
d|D  |pq S )Nc                    sH   fdd|D }t  }t| D ]
}|| | q fdd|D S )Nc                    s   g | ]
} j | p|hqS r"   )r7   r\   argr:   r"   r#   r]     s    zNAliases.call_return_alias.<locals>.interprocedural_aliases.<locals>.<listcomp>c                    s   h | ]} |qS r"   r"   )r\   ra)expand_subscriptr"   r#   rq         zMAliases.call_return_alias.<locals>.interprocedural_aliases.<locals>.<setcomp>)rF   r   rj   return_alias)funcr   Zarg_aliasesreturn_aliasesZargs_combinationry   r$   r"   r#   interprocedural_aliases  s   z:Aliases.call_return_alias.<locals>.interprocedural_aliasesc                 S   s$   t | tjrt | jtr| jjS | S r   )r.   rL   	SubscriptrS   r   r   )rV   r"   r"   r#   ry     s   z3Aliases.call_return_alias.<locals>.expand_subscriptc                    sd   |j }t| tjr0t| j j t| }|r0dd | j j|d  D }|D ]} | q$|| }|S )Nc                 S   s   g | ]}t |qS r"   r   r[   r"   r"   r#   r]     rz   z@Aliases.call_return_alias.<locals>.full_args.<locals>.<listcomp>)r   r.   rL   rT   lendefaultsrZ   )r|   callr   Zextratailrw   r:   r"   r#   	full_args  s   z,Aliases.call_return_alias.<locals>.full_args)NNr   r{   c                    s    g | ]}| j vr |qS r"   )r7   rW   )r\   ar:   r"   r#   r]   :  s     z-Aliases.call_return_alias.<locals>.<listcomp>)r|   rF   keywordsr.   rL   rP   r	   rN   rQ   r   rM   r7   hasattrrj   rJ   )r$   rV   r   r   r|   r8   _Z	signaturer   Zfunc_aliasesZ
func_aliasr"   r~   r#   call_return_alias	  s8   




zAliases.call_return_aliasc              	   C   s   |  | |j}t|tjr|jdkr| ||hS | |}t }|D ]>}t|t	tj
tfr5|| q$|| jv rC|| j|  q$zt|}|| j|d W q$ tyb   || Y q$w | ||S )a  
        Resulting node alias to the return_alias of called function,
        if the function is already known by Pythran (i.e. it's an Intrinsic)
        or if Pythran already computed it's ``return_alias`` behavior.

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> fun = """
        ... def f(a): return a
        ... def foo(b): c = f(b)"""
        >>> module = ast.parse(fun)

        The ``f`` function create aliasing between
        the returned value and its first argument.

        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Call)
        f(b) => ['b']

        This also works with intrinsics, e.g ``dict.setdefault`` which
        may create alias between its third argument and the return value.

        >>> fun = 'def foo(a, d): builtins.dict.setdefault(d, 0, a)'
        >>> module = ast.parse(fun)
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Call)
        builtins.dict.setdefault(d, 0, a) => ['<unbound-value>', 'a']

        Note that complex cases can arise, when one of the formal parameter
        is already known to alias to various values:

        >>> fun = """
        ... def f(a, b): return a and b
        ... def foo(A, B, C, D): return f(A or B, C or D)"""
        >>> module = ast.parse(fun)
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Call)
        f((A or B), (C or D)) => ['A', 'B', 'C', 'D']
        partialr"   )rb   r|   r.   rL   rP   rQ   rW   r   rF   r   rT   r   r7   rj   r5   rR   r8   rN   NotImplementedError)r$   rV   fr{   Zall_aliasesrS   Zapr"   r"   r#   
visit_Call=  s(   
(



zAliases.visit_Callc                 C   s   |  |t|hS r   )rW   r5   rR   r`   r"   r"   r#   visit_Attribute  s   zAliases.visit_Attributec                 C   s   t |jtjr| |j |jjD ]}| | qd}nRt }| |j | |j}|D ]<}t |trPt |jtj	r<q-t
|jrI|jj|jkrIq-||j q-t t|ddtjtjfri|t||j|j q-|snd}| ||S )a  
        Resulting node alias stores the subscript relationship if we don't know
        anything about the subscripted node.

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a): return a[0]')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Subscript)
        a[0] => ['a[0]']

        If we know something about the container, e.g. in case of a list, we
        can use this information to get more accurate informations:

        >>> module = ast.parse('def foo(a, b, c): return [a, b][c]')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Subscript)
        [a, b][c] => ['a', 'b']

        Moreover, in case of a tuple indexed by a constant value, we can
        further refine the aliasing information:

        >>> fun = """
        ... def f(a, b): return a, b
        ... def foo(a, b): return f(a, b)[0]"""
        >>> module = ast.parse(fun)
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Subscript)
        f(a, b)[0] => ['a']

        Nothing is done for slices, even if the indices are known :-/

        >>> module = ast.parse('def foo(a, b, c): return [a, b, c][1:]')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Subscript)
        [a, b, c][1:] => ['<unbound-value>']
        Nctx)r.   slicerL   ZTuplerZ   rS   rr   rF   r   ZSlicer   r   rW   r   getattrZParamZStorer   r   )r$   rV   ro   r8   value_aliasesrp   r"   r"   r#   visit_Subscript  s0   &

zAliases.visit_Subscriptc                 C   s   |j D ]}| | qdS )zO
        omp directive may introduce new variables, just register them
        N)ZdepsrW   )r$   rV   Zdepr"   r"   r#   visit_OMPDirective  s   
zAliases.visit_OMPDirectivec                 C   s6   |j | jvrd}t||j || || j|j  S )Nzxidentifier {0} unknown, either because it is an unsupported intrinsic, the input code is faulty, or... pythran is buggy.)rO   r8   r   rC   rW   )r$   rV   errr"   r"   r#   
visit_Name  s   zAliases.visit_Namec                    sT   |j r"t }t|j D ]\ }| |}| fdd|D  qnd}| ||S )a  
        A tuple is abstracted as an ordered container of its values

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return a, b')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Tuple)
        (a, b) => ['|[0]=a|', '|[1]=b|']

        where the |[i]=id| notation means something that
        may contain ``id`` at index ``i``.
        c                 3   s    | ]}t | V  qd S r   r   )r\   rp   ir"   r#   	<genexpr>  s    z&Aliases.visit_Tuple.<locals>.<genexpr>N)rr   rF   	enumeraterZ   rj   rW   )r$   rV   rk   ro   rm   r"   r   r#   visit_Tuple  s   

zAliases.visit_Tuplec                 C   s    |j h| j|j j< | | d S r   )targetr8   rO   rb   r`   r"   r"   r#   visit_comprehension  s   zAliases.visit_comprehensionc                 C   s,   |j D ]}| | q| |j | |S )aw  
        A comprehension is not abstracted in any way

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return [a for i in b]')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.ListComp)
        [a for i in b] => ['<unbound-value>']
        )
generatorsr   rZ   ro   rW   r$   rV   	generatorr"   r"   r#   visit_ListComp  s   

zAliases.visit_ListCompc                 C   s8   |j D ]}| | q| |j | |j | |S )a}  
        A comprehension is not abstracted in any way

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a, b): return {i: i for i in b}')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.DictComp)
        {i: i for i in b} => ['<unbound-value>']
        )r   r   rZ   r   rS   rW   r   r"   r"   r#   visit_DictComp  s
   

zAliases.visit_DictCompc                    s   t  _jdd j D  jdd  jjD    tj	jv rK fddfddjtj	 D fdd	}| _
d
S d
S )z
        Initialise aliasing default value before visiting.

        Add aliasing values for :
            - Pythonic
            - globals declarations
            - current function arguments
        c                 s   s    | ]
\}}||hfV  qd S r   r"   )r\   rH   r4   r"   r"   r#   r   #  s    z,Aliases.visit_FunctionDef.<locals>.<genexpr>c                 s   s    | ]	}|j |hfV  qd S r   )rO   rv   r"   r"   r#   r   &  s    c                    s   t  tjttjfr fddS t  tr$ j jfddS t  tjrKzj	j	 fdd}|W S  t
yJ   fdd Y S w t  tjrb j jfddS fddS )	Nc                    s    hS r   r"   r   )expr"   r#   <lambda>/  s    z@Aliases.visit_FunctionDef.<locals>.parametrize.<locals>.<lambda>c                    s    fdd| D S )Nc                    s   h | ]}t | qS r"   r   )r\   Zpc)r   r"   r#   rq   3  s    SAliases.visit_FunctionDef.<locals>.parametrize.<locals>.<lambda>.<locals>.<setcomp>r"   r   )r   
pcontaineer"   r#   r   3  s   
 c                    s,   t | k r|  hS  jjt |   hS r   )r   r   r   r   )rV   wr"   r#   r{   ;  s   
zDAliases.visit_FunctionDef.<locals>.parametrize.<locals>.return_aliasc                          S r   rJ   r   r:   r"   r#   r   B      c                    s    fdd D S )Nc              	      s,   h | ]} D ]}t ||t  qqS r"   )rL   r   ZLoad)r\   rS   r   )r   slicesr"   r#   rq   F  s    r   r"   r   )r   r-   r   r#   r   F  s    c                    r   r   r   r   r:   r"   r#   r   K  r   )r.   rL   ZConstantr   rT   r   r   r   rM   r   
ValueErrorr   rS   r   )r   r{   )rV   parametrizer$   )r   r   r   r   r-   r   r#   r   ,  s&   



z.Aliases.visit_FunctionDef.<locals>.parametrizec                    s   g | ]} |qS r"   r"   )r\   Z	ret_alias)r   r"   r#   r]   R  s    z-Aliases.visit_FunctionDef.<locals>.<listcomp>c                    s    fddD S )Nc                    s   h | ]}| D ]}|qqS r"   r"   )r\   r{   rx   r   r"   r#   rq   W  s    
zJAliases.visit_FunctionDef.<locals>.merge_return_aliases.<locals>.<setcomp>r"   r   )r}   r   r#   merge_return_aliasesV  s   
z7Aliases.visit_FunctionDef.<locals>.merge_return_aliasesN)r2   copyr8   rj   Zglobal_declarationsr   r   rb   r5   rt   r{   )r$   rV   r   r"   )rV   r   r}   r$   r#   visit_FunctionDef  s    
	

&

zAliases.visit_FunctionDefc                 C   s   t | | | |j}|jD ]?}t|tjrIt|p|h| j|j	< t
|D ]}t|tjr=|j	}| j| |f| j|< q&| || j|j	  q| | qdS )a  
        Assignment creates aliasing between lhs and rhs

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse('def foo(a): c = a ; d = e = c ; {c, d, e}')
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Set)
        {c, d, e} => ['|a|']

        Everyone points to the formal parameter 'a' \o/
        N)mdrZ   rS   targetsr.   rL   rM   rF   r8   rO   listr_   rW   )r$   rV   r   trp   Za_idr"   r"   r#   visit_Assign]  s   
zAliases.visit_Assignc                 C   sr   |  |j}tdd |D rdd |D }n|jh}| |j| | j|j | j|jj< | | | | dS )a  
        For loop creates aliasing between the target
        and the content of the iterator

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> module = ast.parse("""
        ... def foo(a):
        ...     for i in a:
        ...         {i}""")
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Set)
        {i} => ['|i|']

        Not very useful, unless we know something about the iterated container

        >>> module = ast.parse("""
        ... def foo(a, b):
        ...     for i in [a, b]:
        ...         {i}""")
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Set)
        {i} => ['|a|', '|b|']
        c                 s   s    | ]}t |tV  qd S r   )r.   r   )r\   xr"   r"   r#   r     s    z$Aliases.visit_For.<locals>.<genexpr>c                 S   s   h | ]}|j qS r"   )r   )r\   Z
iter_aliasr"   r"   r#   rq     s    z$Aliases.visit_For.<locals>.<setcomp>N)	rZ   iterallr   rW   r7   r8   rO   rb   )r$   rV   Ziter_aliasesZtarget_aliasesr"   r"   r#   	visit_Forw  s   
zAliases.visit_Forc                 C   s   |  | |  | dS )aD  

        While statement evaluation is somehow equivalent to the evaluation of a
        sequence, except the fact that in some subtle cases, the first rounds
        of analyse fails because we do not follow the regular execution order

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> fun = """
        ... def foo(a):
        ...     while(a):
        ...         if a == 1: builtins.print(b)
        ...         else: b = a"""
        >>> module = ast.parse(fun)
        >>> result = pm.gather(Aliases, module)
        N)rb   r`   r"   r"   r#   visit_While  s   
zAliases.visit_Whilec                 C   sZ  t | | | |j d }}z| j }|jD ]}| | q| j}|| _W n	 ty1   Y nw z|jD ]}| | q6| j}W n	 tyK   Y nw |ra|sa|| _|jD ]}| | qV| j}|rv|sv|| _|jD ]}| | qk| j}|r|r| D ]#\}}|| jv r| j| 	|| j|< q~t
|ttfsJ || j|< q~dS |r|| _dS dS )a  
        After an if statement, the values from both branches are merged,
        potentially creating more aliasing:

        >>> from pythran import passmanager
        >>> pm = passmanager.PassManager('demo')
        >>> fun = """
        ... def foo(a, b):
        ...     if a: c=a
        ...     else: c=b
        ...     return {c}"""
        >>> module = ast.parse(fun)
        >>> result = pm.gather(Aliases, module)
        >>> Aliases.dump(result, filter=ast.Set)
        {c} => ['|a|', '|b|']
        N)r   rZ   rd   r8   r   re   r   rf   r   r_   r.   r1   rF   )r$   rV   Ztrue_aliasesZfalse_aliasestmpZstmtrH   r4   r"   r"   r#   visit_If  sN   








zAliases.visit_Ifc                 C   s&   |j r|j h| j|j j< | | d S r   )rU   r8   rO   rb   r`   r"   r"   r#   visit_ExceptHandler  s   zAliases.visit_ExceptHandlerr   )(r&   r'   r(   r)   rt   r%   staticmethodrI   rJ   rR   rW   ra   rc   Zvisit_BinOpZvisit_Comparerg   rn   rs   ru   r   r   Zvisit_Constantr   r   r   r   r   Z
visit_Listr   r   Zvisit_SetCompZvisit_GeneratorExpr   r   r   r   r   r   r   r,   r"   r"   r    r#   r5   @   sL    

	,4A@	E'?r5   c                   @   s   e Zd ZdZdd ZdS )StrictAliaseszW
    Gather aliasing informations across nodes,
    without adding unsure aliases.
    c                 C   s   t  S r   )rF   r:   r"   r"   r#   rJ     rK   z#StrictAliases.get_unbound_value_setN)r&   r'   r(   r)   rJ   r"   r"   r"   r#   r     s    r   )(r)   Z$pythran.analyses.global_declarationsr   Zpythran.intrinsicr   r   r   Zpythran.passmanagerr   Zpythran.syntaxr   Zpythran.tablesr   r	   r
   Zpythran.unparser   Zpythran.conversionr   Zpythran.metadataZmetadatar   Zpythran.utilsr   ZgastrL   r   r   	itertoolsr   r;   r/   r2   objectr   r0   r-   r3   r5   r   r"   r"   r"   r#   <module>   s4    
     <