³ò
Ú‘RMc           @   sê   d  d k  Z  d  d k Z d  d k l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 e i	 f d
 „  ƒ  YZ
 e
 ƒ  Z e  i ƒ  Z e  i ƒ  Z d „  Z d d „ Z d d „ Z d „  Z d d „ Z d d „ Z d S(   iÿÿÿÿN(   t   Hashablet   AutoRegisteringTypec           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s’   t  i |  | | | ƒ d | j o |  i | d ƒ |  ` n d | j o |  i | d ƒ |  ` n d | j o |  i | d ƒ |  ` n d  S(   Nt   _about_t   _type_t
   _metatype_(   t   typet   __init__t   _register_valueR   t   _register_typeR   t   _register_metatypeR   (   t   selfclst   namet   basest   dict(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR      s    

c         C   sº   t  | t ƒ o% x£ | D] } |  i | | ƒ q Wn‚ x9 |  i D]( } d | i j o | i d } Pq? q? Wd  } y | | } Wn$ t j
 o t ƒ  } | | <n X| i |  | ƒ d  S(   Nt   _condition_(	   t
   isinstancet   tuplet	   _registert   __mro__t   __dict__t   Nonet   KeyErrort   ClassFamilyt   add(   R
   R   t   keyt   kt   baseclst   condt   family(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR      s     
 	c         C   s   |  i  t | ƒ d  S(   N(   R   t   EXT_REGISTRY_BY_VALUE(   R
   R   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   %   s    c         C   s   |  i  t | ƒ d  S(   N(   R   t   EXT_REGISTRY_BY_TYPE(   R
   R   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   (   s    c         C   s   |  i  t | ƒ d  S(   N(   R   t   EXT_REGISTRY_BY_METATYPE(   R
   R   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR	   +   s    (   t   __name__t
   __module__R   R   R   R   R	   (    (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR      s
   				R   c           B   s&   e  Z d  „  Z d d „ Z d „  Z RS(   c         C   s   d  |  _ g  |  _ d  S(   N(   R   t   defaultt   conditionals(   t   self(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   0   s    	c         C   sU   | d  j o. |  i d  j p t d | f ‚ | |  _ n |  i i | | f ƒ d  S(   Ns   duplicate extregistry entry %r(   R   R"   t   AssertionErrorR#   t   append(   R$   t   clsR   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   4   s
    c         C   s¨   | d  j	 ov g  } |  i D]$ \ } } | | ƒ o | | q q ~ } | o0 t | ƒ d j p t d | f ‚ | d Sqƒ n |  i o |  i Sn t d ƒ ‚ d  S(   Ni   s    multiple extregistry matches: %ri    s   no default extregistry entry(   R   R#   t   lenR%   R"   R   (   R$   t   configt   _[1]R'   R   t   matches(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   match<   s    !
N(   R    R!   R   R   R   R,   (    (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   .   s   	t   ExtRegistryEntryc           B   sP   e  Z e Z d d  „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   R   t   instance(   R$   R   R.   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   L   s    	c         C   s6   |  i  | i  j o# |  i | i j o |  i | i j S(   N(   t	   __class__R   R.   (   R$   t   other(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   __eq__S   s    c         C   s   |  i  | ƒ S(   N(   R1   (   R$   R0   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   __ne__X   s    c         C   s"   t  |  i |  i t |  i ƒ f ƒ S(   N(   t   hashR/   R   R    R.   (   R$   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   __hash__[   s    c         C   s   | |  _  |  i ƒ  S(   N(   t
   bookkeepert   compute_annotation(   R$   t   bk(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   compute_annotation_bk^   s    	c         C   s[   |  i  } | d  j	 p t ‚ d d k l } |  i } t | d d  ƒ } | i | d | ƒS(   Niÿÿÿÿ(   t   modelR    t
   methodname(   R.   R   R%   t   pypy.annotationR9   t   compute_result_annotationt   getattrt   SomeBuiltin(   R$   t   funct   annmodelt   analyserR:   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR6   b   s    		c         O   s   |  i  S(   N(   t   s_result_annotation(   R$   t   args_st   kwds_s(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR<   m   s    N(   R    R!   R   t   __metaclass__R   R   R1   R2   R4   R8   R6   R<   (    (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR-   I   s   					t   FlexibleWeakDictc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s†   A WeakKeyDictionary that accepts more or less anything as keys:
    weakly referenceable objects or not, hashable objects or not.
    c         C   s%   h  |  _  t i ƒ  |  _ h  |  _ d  S(   N(   t   _regdictt   weakreft   WeakKeyDictionaryt	   _weakdictt   _iddict(   R$   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyR   x   s    	c         C   s|   y t  | ƒ Wn& t j
 o |  i t | ƒ f Sn Xy t i | ƒ Wn  t j
 o |  i | f Sn X|  i | f Sd  S(   N(   R3   t	   TypeErrorRK   R    RH   t   refRG   RJ   (   R$   R   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyRM   }   s    c         C   s   |  i  | ƒ \ } } | | S(   N(   RM   (   R$   R   t   d(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   __getitem__‰   s    c         C   s#   |  i  | ƒ \ } } | | | <d  S(   N(   RM   (   R$   R   t   valueRN   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   __setitem__   s    c         C   s    |  i  | ƒ \ } } | | =d  S(   N(   RM   (   R$   R   RN   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   __delitem__‘   s    c         C   s?   |  i  i ƒ  |  i i ƒ  g  } |  i D] } | | i q' ~ S(   N(   RG   t   keysRJ   RK   RP   (   R$   R*   t   hashable(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyRS   •   s    (	   R    R!   t   __doc__R   RM   RO   RQ   RR   RS   (    (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyRF   t   s   					c         C   sL   y t  |  i | ƒ SWn0 t t f j
 o t t |  ƒ i | ƒ Sn Xd  S(   N(   R   R,   R   RL   R   R   (   t   tpR)   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   _lookup_type_cls¢   s    c         C   s   t  |  | ƒ } | |  ƒ S(   N(   RW   (   RV   R)   t   Entry(    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   lookup_type¨   s    c         C   s/   y t  |  | ƒ Wn t j
 o t Sn Xt S(   N(   RW   R   t   Falset   True(   RV   R)   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   is_registered_type¬   s
    	c         C   sH   y t  |  i | ƒ SWn, t t f j
 o t t |  ƒ | ƒ Sn Xd  S(   N(   R   R,   R   RL   RW   R   (   R.   R)   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   _lookup_cls³   s    c         C   s"   t  |  | ƒ } | t |  ƒ |  ƒ S(   N(   R]   R   (   R.   R)   RX   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   lookup¹   s    c         C   s/   y t  |  | ƒ Wn t j
 o t Sn Xt S(   N(   R]   R   RZ   R[   (   R.   R)   (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pyt   is_registered½   s
    	(   RH   t   UserDictt   pypy.tool.uidR    R   R   t   objectR   R-   t	   DictMixinRF   R   RI   R   R   RW   R   RY   R\   R]   R^   R_   (    (    (    s,   /64/home/arigo/u/pypy/rpython/extregistry.pys   <module>   s   (+'			
