AlkantarClanX12

Your IP : 18.118.144.109


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/symtable.cpython-34.pyc

�
i f��@s�dZddlZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZddlZdddddgZd	d�ZGd
d�d�Ze�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�Zedkr�ddlZddlZeejd��Zej �Z!WdQXee!ej"j#ejd�dd�Z$xBe$j%�D]1Z&e$j'e&�Z(e)e(e(j*�e(j+��q�WndS)z2Interface to the compiler's internal symbol tables�N)�USE�
DEF_GLOBAL�	DEF_LOCAL�	DEF_PARAM�
DEF_IMPORT�	DEF_BOUND�OPT_IMPORT_STAR�	SCOPE_OFF�
SCOPE_MASK�FREE�LOCAL�GLOBAL_IMPLICIT�GLOBAL_EXPLICIT�CELL�symtable�SymbolTable�Class�Function�SymbolcCs"tj|||�}t||�S)N)�	_symtabler�_newSymbolTable)�code�filenameZcompile_type�top�r�-/opt/alt/python34/lib64/python3.4/symtable.pyrsc@s4eZdZdd�Zdd�Zdd�ZdS)�SymbolTableFactorycCstj�|_dS)N)�weakref�WeakValueDictionary�_SymbolTableFactory__memo)�selfrrr�__init__szSymbolTableFactory.__init__cCsK|jtjkrt||�S|jtjkr>t||�St||�S)N)�typer�
TYPE_FUNCTIONr�
TYPE_CLASSrr)r �tablerrrr�news


zSymbolTableFactory.newcCsQ||f}|jj|d�}|dkrM|j||�}|j|<n|S)N)r�getr&)r r%r�key�objrrr�__call__s
 zSymbolTableFactory.__call__N)�__name__�
__module__�__qualname__r!r&r*rrrrrsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"rcCs||_||_i|_dS)N)�_table�	_filename�_symbols)r Z	raw_tablerrrrr!'s		zSymbolTable.__init__cCsm|jtkrd}nd|jj}|jjdkrMdj||j�Sdj||jj|j�SdS)N�z%s �globalz<{0}SymbolTable for module {1}>z<{0}SymbolTable for {1} in {2}>)�	__class__rr+r.�name�formatr/)r Zkindrrr�__repr__,s			zSymbolTable.__repr__cCs||jjtjkrdS|jjtjkr2dS|jjtjkrKdS|jjdksxtdj|jj���dS)	N�moduleZfunction�class���zunexpected type: {0})r9r:r;)r.r"rZTYPE_MODULEr#r$�AssertionErrorr5)r rrr�get_type9szSymbolTable.get_typecCs
|jjS)N)r.�id)r rrr�get_idCszSymbolTable.get_idcCs
|jjS)N)r.r4)r rrr�get_nameFszSymbolTable.get_namecCs
|jjS)N)r.�lineno)r rrr�
get_linenoIszSymbolTable.get_linenocCs&t|jjtjko"|jj�S)N)�boolr.r"rr#�	optimized)r rrr�is_optimizedLszSymbolTable.is_optimizedcCst|jj�S)N)rCr.�nested)r rrr�	is_nestedPszSymbolTable.is_nestedcCst|jj�S)N)rCr.�children)r rrr�has_childrenSszSymbolTable.has_childrencCsdS)z7Return true if the scope uses exec.  Deprecated method.Fr)r rrr�has_execVszSymbolTable.has_execcCst|jjt@�S)z&Return true if the scope uses import *)rCr.rDr)r rrr�has_import_starZszSymbolTable.has_import_starcCs|jjj�S)N)r.�symbols�keys)r rrr�get_identifiers^szSymbolTable.get_identifierscCsa|jj|�}|dkr]|jj|}|j|�}t|||�}|j|<n|S)N)r0r'r.rL�_SymbolTable__check_childrenr)r r4Zsym�flags�
namespacesrrr�lookupas zSymbolTable.lookupcs�fdd��j�D�S)Ncsg|]}�j|��qSr)rR)�.0�ident)r rr�
<listcomp>js	z+SymbolTable.get_symbols.<locals>.<listcomp>)rN)r r)r r�get_symbolsiszSymbolTable.get_symbolscs ��fdd��jjD�S)Ncs1g|]'}|j�krt|�j��qSr)r4rr/)rS�st)r4r rrrUms	z0SymbolTable.__check_children.<locals>.<listcomp>)r.rH)r r4r)r4r rZ__check_childrenlszSymbolTable.__check_childrencs�fdd��jjD�S)Ncs"g|]}t|�j��qSr)rr/)rSrW)r rrrUrs	z,SymbolTable.get_children.<locals>.<listcomp>)r.rH)r r)r r�get_childrenqszSymbolTable.get_childrenN)r+r,r-r!r6r=r?r@rBrErGrIrJrKrNrRrVrOrXrrrrr%s 

c@sdeZdZdZdZdZdZdd�Zdd�Zdd�Z	dd	�Z
d
d�ZdS)rNcs&t��fdd��j�D��S)Ncs,g|]"}��jj|�r|�qSr)r.rL)rSrT)r �	test_funcrrrUs	z.Function.__idents_matching.<locals>.<listcomp>)�tuplerN)r rYr)r rYrZ__idents_matching~szFunction.__idents_matchingcCs1|jdkr*|jdd��|_n|jS)NcSs|t@S)N)r)�xrrr�<lambda>�sz)Function.get_parameters.<locals>.<lambda>)�_Function__params�_Function__idents_matching)r rrr�get_parameters�szFunction.get_parameterscsI|jdkrBttf��fdd�}|j|�|_n|jS)Ncs|t?t@�kS)N)r	r
)r[)�locsrrr\�sz%Function.get_locals.<locals>.<lambda>)�_Function__localsrrr^)r �testr)r`r�
get_locals�s
zFunction.get_localscsI|jdkrBttf��fdd�}|j|�|_n|jS)Ncs|t?t@�kS)N)r	r
)r[)�globrrr\�sz&Function.get_globals.<locals>.<lambda>)�_Function__globalsr
rr^)r rbr)rdr�get_globals�s
zFunction.get_globalscCs7|jdkr0dd�}|j|�|_n|jS)NcSs|t?t@tkS)N)r	r
r)r[rrrr\�sz$Function.get_frees.<locals>.<lambda>)�_Function__freesr^)r �is_freerrr�	get_frees�szFunction.get_frees)r+r,r-r]rargrer^r_rcrfrirrrrrvsc@s"eZdZdZdd�ZdS)rNcCsR|jdkrKi}x!|jjD]}d||j<q"Wt|�|_n|jS)Nr9)�_Class__methodsr.rHr4rZ)r �drWrrr�get_methods�szClass.get_methods)r+r,r-rjrlrrrrr�sc@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)rNcCs6||_||_|t?t@|_|p,f|_dS)N)�
_Symbol__name�_Symbol__flagsr	r
�_Symbol__scope�_Symbol__namespaces)r r4rPrQrrrr!�s		zSymbol.__init__cCsdj|j�S)Nz<symbol {0!r}>)r5rm)r rrrr6�szSymbol.__repr__cCs|jS)N)rm)r rrrr@�szSymbol.get_namecCst|jtj@�S)N)rCrnrr)r rrr�
is_referenced�szSymbol.is_referencedcCst|jt@�S)N)rCrnr)r rrr�is_parameter�szSymbol.is_parametercCst|jttfk�S)N)rCror
r)r rrr�	is_global�szSymbol.is_globalcCst|jtk�S)N)rCror)r rrr�is_declared_global�szSymbol.is_declared_globalcCst|jt@�S)N)rCrnr)r rrr�is_local�szSymbol.is_localcCst|jtk�S)N)rCror)r rrrrh�szSymbol.is_freecCst|jt@�S)N)rCrnr)r rrr�is_imported�szSymbol.is_importedcCst|jt@�S)N)rCrnr)r rrr�is_assigned�szSymbol.is_assignedcCs
t|j�S)a�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.
        )rCrp)r rrr�is_namespace�szSymbol.is_namespacecCs|jS)z.Return a list of namespaces bound to this name)rp)r rrr�get_namespaces�szSymbol.get_namespacescCs/t|j�dkr$td��n|jdS)z�Returns the single namespace bound to this name.

        Raises ValueError if the name is bound to multiple namespaces.
        r9z$name is bound to multiple namespacesr)�lenrp�
ValueError)r rrr�
get_namespace�szSymbol.get_namespace)r+r,r-r!r6r@rqrrrsrtrurhrvrwrxryr|rrrrr�s
�__main__r9�exec),�__doc__rrrrrrrrr	r
rrr
rrr�__all__rrr�objectrrrrr+�os�sys�open�argv�f�read�src�path�split�modrNrTrR�info�printrurxrrrr�<module>s&^	Q&
@)