
\Kc        
   @   s  d  Z  d d k Z d d k l Z l Z l Z l Z l Z l Z l Z l	 Z	 l
 Z
 l Z l Z l Z l Z l Z l Z d d k Z d d d d d d	 g Z d
   Z d d d     YZ e   Z d   Z d d d     YZ d e f d     YZ d e f d     YZ d	 d d     YZ e d j o d d k Z d d k Z e e i d  i    Z! e e! e i" i# e i d  d d  Z$ x@ e$ i%   D]. Z& e$ i' e&  Z( e( Ge( i)   Ge( i*   GHqWn d S(   s2   Interface to the compiler's internal symbol tablesiN(   t   USEt
   DEF_GLOBALt	   DEF_LOCALt	   DEF_PARAMt   DEF_STARt   DEF_DOUBLESTARt   DEF_INTUPLEt   DEF_FREEt   DEF_FREE_GLOBALt   DEF_FREE_CLASSt
   DEF_IMPORTt	   DEF_BOUNDt   OPT_IMPORT_STARt   OPT_EXECt   OPT_BARE_EXECt   symtablet   SymbolTablet   newSymbolTablet   Classt   Functiont   Symbolc         C   sN   t  i |  | |  } x) | i   D] } | i d j o Pq" q" Wt | |  S(   Nt   top(   t	   _symtableR   t
   itervaluest   nameR   (   t   codet   filenamet   compile_typet   rawR   (    (    s   /usr/lib/python2.5/symtable.pyR      s     	t   SymbolTableFactoryc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   t  i   |  _ d  S(   N(   t   weakreft   WeakValueDictionaryt   _SymbolTableFactory__memo(   t   self(    (    s   /usr/lib/python2.5/symtable.pyt   __init__   s    c         C   sU   | i  t i j o t | |  Sn | i  t i j o t | |  Sn t | |  S(   N(   t   typeR   t   TYPE_FUNCTIONR   t
   TYPE_CLASSR   R   (   R!   t   tableR   (    (    s   /usr/lib/python2.5/symtable.pyt   new   s
    c         C   sS   | | f } |  i  i | d   } | d  j o! |  i | |  } |  i  | <n | S(   N(   R    t   gett   NoneR'   (   R!   R&   R   t   keyt   obj(    (    s   /usr/lib/python2.5/symtable.pyt   __call__    s
    !(   t   __name__t
   __module__R"   R'   R,   (    (    (    s   /usr/lib/python2.5/symtable.pyR      s   		c         C   sA   |  t  t B@o |  t t Bt B@o t Sn |  t @o t Sn t S(   N(   R    R   R   R   R   t   TrueR	   t   False(   t   flags(    (    s   /usr/lib/python2.5/symtable.pyt   is_free)   s    c           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   | |  _  | |  _ h  |  _ d  S(   N(   t   _tablet	   _filenamet   _symbols(   R!   t	   raw_tableR   (    (    s   /usr/lib/python2.5/symtable.pyR"   2   s    		c         C   sp   |  i  t j o
 d } n d |  i  i } |  i i d j o d | |  i f Sn d | |  i i |  i f Sd  S(   Nt    s   %s t   globals   <%sSymbolTable for module %s>s   <%sSymbolTable for %s in %s>(   t	   __class__R   R-   R3   R   R4   (   R!   t   kind(    (    s   /usr/lib/python2.5/symtable.pyt   __repr__7   s    
c         C   s   |  i  i t i j o d Sn |  i  i t i j o d Sn |  i  i t i j o d Sn |  i  i d j p t d |  i  i  d  S(	   Nt   modulet   functiont   classi   i   i   s   unexpected type: %s(   i   i   i   (   R3   R#   R   t   TYPE_MODULER$   R%   t   AssertionError(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_typeC   s    c         C   s
   |  i  i S(   N(   R3   t   id(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_idM   s    c         C   s
   |  i  i S(   N(   R3   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_nameP   s    c         C   s
   |  i  i S(   N(   R3   t   lineno(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt
   get_linenoS   s    c         C   s'   t  |  i i t i j o |  i i  S(   N(   t   boolR3   R#   R   R$   t	   optimized(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_optimizedV   s    c         C   s   t  |  i i  S(   N(   RG   R3   t   nested(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt	   is_nestedZ   s    c         C   s   t  |  i i  S(   N(   RG   R3   t   children(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   has_children]   s    c         C   s   t  |  i i t t B@ S(   s"   Return true if the scope uses exec(   RG   R3   RH   R   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   has_exec`   s    c         C   s   t  |  i i t @ S(   s&   Return true if the scope uses import *(   RG   R3   RH   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   has_import_stard   s    c         C   s   |  i  i i   S(   N(   R3   t   symbolst   keys(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_identifiersh   s    c         C   sc   |  i  i |  } | d  j o@ |  i i | } |  i |  } t | | |  } |  i  | <n | S(   N(   R5   R(   R)   R3   RP   t   _SymbolTable__check_childrenR   (   R!   R   t   symR1   t
   namespaces(    (    s   /usr/lib/python2.5/symtable.pyt   lookupk   s    !c         C   s.   g  } |  i    D] } | |  i |  q ~ S(   N(   RR   RV   (   R!   t   _[1]t   ident(    (    s   /usr/lib/python2.5/symtable.pyt   get_symbolss   s    c         C   sE   g  } |  i  i D]- } | i | j o | t | |  i  q q ~ S(   N(   R3   RL   R   R   R4   (   R!   R   RW   t   st(    (    s   /usr/lib/python2.5/symtable.pyt   __check_childrenv   s    c         C   s1   g  } |  i  i D] } | t | |  i  q ~ S(   N(   R3   RL   R   R4   (   R!   RW   RZ   (    (    s   /usr/lib/python2.5/symtable.pyt   get_children{   s    (   R-   R.   R"   R;   RA   RC   RD   RF   RI   RK   RM   RN   RO   RR   RV   RY   RS   R\   (    (    (    s   /usr/lib/python2.5/symtable.pyR   1   s    			
												c           B   sM   e  Z d Z d Z d Z d Z d    Z d   Z d   Z	 d   Z
 d   Z RS(   c         C   sF   t  g  } |  i   D]( } | |  i i |  o | | q q ~  S(   N(   t   tupleRR   R3   RP   (   R!   t	   test_funcRW   RX   (    (    s   /usr/lib/python2.5/symtable.pyt   __idents_matching   s    c         C   s0   |  i  d  j o |  i d    |  _  n |  i  S(   Nc         S   s   |  t  @S(    (   R   (   t   x(    (    s   /usr/lib/python2.5/symtable.pyt   <lambda>   s    (   t   _Function__paramsR)   t   _Function__idents_matching(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_parameters   s    c         C   s0   |  i  d  j o |  i d    |  _  n |  i  S(   Nc         S   s   |  t  @S(    (   R   (   R`   (    (    s   /usr/lib/python2.5/symtable.pyRa      s    (   t   _Function__localsR)   Rc   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt
   get_locals   s    c            s@   |  i  d  j o) t t B  |  i   f d    |  _  n |  i  S(   Nc            s   |    @S(    (    (   R`   (   t   glob(    s   /usr/lib/python2.5/symtable.pyRa      s    (   t   _Function__globalsR)   R   R   Rc   (   R!   (    (   Rg   s   /usr/lib/python2.5/symtable.pyt   get_globals   s    
c         C   s-   |  i  d  j o |  i t  |  _  n |  i  S(   N(   t   _Function__freesR)   Rc   R2   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt	   get_frees   s    N(   R-   R.   R)   Rb   Re   Rj   Rh   Rc   Rd   Rf   Ri   Rk   (    (    (    s   /usr/lib/python2.5/symtable.pyR      s   				c           B   s   e  Z d Z d    Z RS(   c         C   sT   |  i  d  j o= h  } x! |  i i D] } d | | i <q# Wt |  |  _  n |  i  S(   Ni   (   t   _Class__methodsR)   R3   RL   R   R]   (   R!   t   dRZ   (    (    s   /usr/lib/python2.5/symtable.pyt   get_methods   s     N(   R-   R.   R)   Rl   Rn   (    (    (    s   /usr/lib/python2.5/symtable.pyR      s   c           B   s   e  Z d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s&   | |  _  | |  _ | p d |  _ d  S(   N(    (   t   _Symbol__namet   _Symbol__flagst   _Symbol__namespaces(   R!   R   R1   RU   (    (    s   /usr/lib/python2.5/symtable.pyR"      s    		c         C   s   d |  i  S(   Ns   <symbol '%s'>(   Ro   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyR;      s    c         C   s   |  i  S(   N(   Ro   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyRD      s    c         C   s   t  |  i t i @ S(   N(   RG   Rp   R   R    (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_referenced   s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_parameter   s    c         C   s   t  |  i t @p |  i t @ S(   N(   RG   Rp   R   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt	   is_global   s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt	   is_vararg   s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_keywordarg   s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_local   s    c         C   sJ   |  i  t t B@o |  i  t t Bt B@o t Sn |  i  t @o t Sn t S(   N(	   Rp   R    R   R   R   R   R/   R	   R0   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyR2      s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R
   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_imported   s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_assigned   s    c         C   s   t  |  i t @ S(   N(   RG   Rp   R   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_in_tuple   s    c         C   s   t  |  i  S(   s  Returns true if name binding introduces new namespace.

        If the name is used as the target of a function or class
        statement, this will be true.

        Note that a single name can be bound to multiple objects.  If
        is_namespace() is true, the name may also be bound to other
        objects, like an int or list, that does not introduce a new
        namespace.
        (   RG   Rq   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   is_namespace   s    c         C   s   |  i  S(   s.   Return a list of namespaces bound to this name(   Rq   (   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_namespaces   s    c         C   s.   t  |  i  d j o t d  n |  i d S(   s   Returns the single namespace bound to this name.

        Raises ValueError if the name is bound to multiple namespaces.
        i   s$   name is bound to multiple namespacesi    (   t   lenRq   t
   ValueError(   R!   (    (    s   /usr/lib/python2.5/symtable.pyt   get_namespace   s    N(   R-   R.   R)   R"   R;   RD   Rr   Rs   Rt   Ru   Rv   Rw   R2   Rx   Ry   Rz   R{   R|   R   (    (    (    s   /usr/lib/python2.5/symtable.pyR      s    														t   __main__i    i   t   exec(    (    (    (+   t   __doc__R   R    R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   t   __all__R   R   R   R2   R   R   R   R   R-   t   ost   syst   opent   argvt   readt   srct   patht   splitt   modRR   RX   RV   t   infoRw   R{   (    (    (    s   /usr/lib/python2.5/symtable.pys   <module>   s*   d			N!J) 