ó
†Å•Zc           @   s‹   d  d l  Z d  d l Z d  d l Z d  d l m Z m Z m Z m Z d „  Z	 d „  Z
 d e f d „  ƒ  YZ d e j f d „  ƒ  YZ d S(	   iÿÿÿÿN(   t	   pyobjectst   evaluatet   astutilst	   argumentsc         C   s   t  |  | | | | ƒ d S(   s˜   Analyze `pymodule` for static object inference

    Analyzes scopes for collecting object information.  The analysis
    starts from inner scopes.

    N(   t   _analyze_node(   t   pycoret   pymodulet   should_analyzet   search_subscopest   followed_calls(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   analyze_module   s    c   	         sò   | | ƒ rE x6 | j  ƒ  j ƒ  D] } t ˆ | j | | | ƒ q Wn  | | ƒ rî t d | d ƒ ‰  d „  ‰ d „  ‰ ‡  ‡ ‡ ‡ f d †  } | s d  } n  t ˆ | | ƒ } x< t j j	 j
 | j ƒ  ƒ D] } t j j	 j | | ƒ qË Wn  d  S(   Ni    i   c         S   s   t  S(   N(   t   True(   t	   pydefined(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   <lambda>   t    c         S   s   t  S(   N(   t   False(   R   (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyR      R   c            s   t  ˆ |  ˆ ˆ ˆ  ƒ d  S(   N(   R   (   t
   pyfunction(   t   new_followed_callsR   t   return_falset   return_true(    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   _follow   s    (   t	   get_scopet
   get_scopesR   t   pyobjectt   maxt   Nonet
   SOAVisitort   ropet   baset   astt   get_child_nodest   get_astt   walk(	   R   R   R   R   R	   t   scopeR   t   visitort   child(    (   R   R   R   R   s/   lib/python2.7/site-packages/rope/base/oi/soa.pyR      s    			"R   c           B   sS   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   c         C   s4   | |  _  | j ƒ  |  _ | j ƒ  |  _ | |  _ d  S(   N(   R   t
   get_moduleR   R   R!   t   follow(   t   selfR   R   t   follow_callback(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   __init__+   s    	c         C   s   d  S(   N(    (   R&   t   node(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   _FunctionDef1   s    c         C   s   d  S(   N(    (   R&   R)   (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt	   _ClassDef4   s    c         C   s_  x3 t  j j j | ƒ D] } t  j j j | |  ƒ q Wt j |  j | j ƒ \ } } | d  k rd d  S| j
 ƒ  } t | t j ƒ r  t j | | | |  j ƒ } n« t | t j ƒ r| } d | k r× | d j
 ƒ  } n  t  j j j t j | ƒ ƒ } |  j | | | | ƒ } n; d | k rG| d j
 ƒ  } |  j | | | | ƒ } n d  S|  j | | ƒ d  S(   NR(   t   __call__(   R   R   R   R   R    R   t
   eval_node2R!   t   funcR   t
   get_objectt
   isinstanceR    t   AbstractFunctionR   t   create_argumentst   PyClasst   pynamest   UnboundNamet   PyObjectt   _args_with_selft   _call(   R&   R)   R#   t   primaryt   pynameR   t   argst   pyclass(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   _Call7   s(    c         C   s1   t  j | | | |  j ƒ } t  j | | |  j ƒ S(   N(   R   R2   R!   t   MixedArguments(   R&   R9   t   self_pynameR   R)   t	   base_args(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyR7   N   s    c         C   sÑ   t  | t j ƒ r¥ |  j d  k	 r3 |  j | ƒ } n  |  j j j | | j	 | j
 ƒ  ƒ ƒ | j d  ƒ |  j d  k	 r¥ |  j | ƒ } | | k r¢ |  j | ƒ q¢ q¥ n  t  | t j j j ƒ rÍ | j | ƒ n  d  S(   N(   R0   R    t
   PyFunctionR%   R   t   _parameter_objectsR   t   object_infot   function_calledt   get_argumentst   get_param_namest   _set_parameter_pyobjectsR   R   t   builtinst   BuiltinFunctiont   get_returned_object(   R&   R   R;   t   beforet   after(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyR8   S   s    c         C   sF   g  } x9 t  t | j t ƒ ƒ ƒ D] } | j | j | ƒ ƒ q" W| S(   N(   t   ranget   lenRF   R   t   appendt   get_parameter(   R&   R   t   resultt   i(    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyRB   b   s    "c         C   s•  x3 t  j j j | ƒ D] } t  j j j | |  ƒ q Wt ƒ  } g  } x7 | j D], } t  j j j | | ƒ | j | j ƒ qO Wx| D]\ } } t	 j
 |  j | j ƒ } g  } | j t	 j
 |  j | j j ƒ ƒ t  j j j j t  j j j | j | ƒ |  j ƒ }	 | j t  j j j |	 ƒ ƒ | d  k	 r† |	 d  k	 r† | j ƒ  }
 d |
 k r|
 d j ƒ  } t j | g | ƒ } |  j | | ƒ qq† q† Wd  S(   Nt   __setitem__(   R   R   R   R   R    t   _SOAAssignVisitort   targetst   extendt   nodesR   t	   eval_nodeR!   t   valueRO   t   slicet   oit   soit   _infer_assignmentR4   t   AssignmentValueR   R5   R   R/   R   t   ObjectArgumentsR8   (   R&   R)   R#   R"   RW   t	   subscriptt   levelst   instancet   args_pynamesRY   R   R   R;   (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   _Assignh   s,    	N(   t   __name__t
   __module__R   R(   R*   R+   R=   R7   R8   RB   Rd   (    (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyR   )   s   						RT   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s    t  t |  ƒ j ƒ  g  |  _ d  S(   N(   t   superRT   R(   RW   (   R&   (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyR(   „   s    c         C   sP   t  | t j j j ƒ rL t  | j t j j j ƒ rL |  j j | | f ƒ n  d  S(   N(	   R0   R   R   R   t	   SubscriptRZ   t   IndexRW   RO   (   R&   R)   Ra   (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   _addedˆ   s    (   Re   Rf   R(   Rj   (    (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyRT   ‚   s   	(   t   rope.base.astR   t   rope.base.oi.soit   rope.base.pynamest	   rope.baseR    R   R   R   R
   R   t   objectR   t   _NodeNameCollectorRT   (    (    (    s/   lib/python2.7/site-packages/rope/base/oi/soa.pyt   <module>   s   "		Y