Mini Shell

Direktori : /lib64/python3.9/__pycache__/
Upload File :
Current File : //lib64/python3.9/__pycache__/symtable.cpython-39.pyc

a

�DOg��@sXdZddlZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlZgd�Zdd�ZGdd�d�Ze�ZGd	d
�d
�ZGdd�de�ZGd
d�de�ZGdd�d�Zedk�rTddlZddlZeejd��Ze� �Z!Wd�n1s�0Yee!ej"�#ejd�dd�Z$e$�%�D]$Z&e$�'e&�Z(e)e(e(�*�e(�+���q.dS)z2Interface to the compiler's internal symbol tables�N)�USE�
DEF_GLOBAL�DEF_NONLOCAL�	DEF_LOCAL�	DEF_PARAM�
DEF_IMPORT�	DEF_BOUND�	DEF_ANNOT�	SCOPE_OFF�
SCOPE_MASK�FREE�LOCAL�GLOBAL_IMPLICIT�GLOBAL_EXPLICIT�CELL)�symtable�SymbolTable�Class�Function�SymbolcCst�|||�}t||�S�N)�	_symtabler�_newSymbolTable)�code�filenameZcompile_type�top�r� /usr/lib64/python3.9/symtable.pyrsrc@s$eZdZdd�Zdd�Zdd�ZdS)�SymbolTableFactorycCst��|_dSr)�weakref�WeakValueDictionary�_SymbolTableFactory__memo��selfrrr�__init__szSymbolTableFactory.__init__cCs6|jtjkrt||�S|jtjkr,t||�St||�Sr)�typer�
TYPE_FUNCTIONr�
TYPE_CLASSrr)r#�tablerrrr�news


zSymbolTableFactory.newcCs8||f}|j�|d�}|dur4|�||�}|j|<|Sr)r!�getr))r#r(r�key�objrrr�__call__s
zSymbolTableFactory.__call__N)�__name__�
__module__�__qualname__r$r)r-rrrrrsrc@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)rcCs||_||_i|_dSr)�_table�	_filename�_symbols)r#Z	raw_tablerrrrr$'szSymbolTable.__init__cCsN|jtkrd}nd|jj}|jjdkr6d�||j�Sd�||jj|j�SdS)N�z%s rz<{0}SymbolTable for module {1}>z<{0}SymbolTable for {1} in {2}>)�	__class__rr.r1�name�formatr2)r#�kindrrr�__repr__,s
�zSymbolTable.__repr__cCsX|jjtjkrdS|jjtjkr$dS|jjtjkr6dS|jjdvsTJd�|jj���dS)N�module�function�class)���zunexpected type: {0})r1r%rZTYPE_MODULEr&r'r7r"rrr�get_type9s�zSymbolTable.get_typecCs|jjSr)r1�idr"rrr�get_idCszSymbolTable.get_idcCs|jjSr)r1r6r"rrr�get_nameFszSymbolTable.get_namecCs|jjSr)r1�linenor"rrr�
get_linenoIszSymbolTable.get_linenocCst|jjtjk�Sr)�boolr1r%rr&r"rrr�is_optimizedLszSymbolTable.is_optimizedcCst|jj�Sr)rFr1�nestedr"rrr�	is_nestedOszSymbolTable.is_nestedcCst|jj�Sr)rFr1�childrenr"rrr�has_childrenRszSymbolTable.has_childrencCs|jj��Sr)r1�symbols�keysr"rrr�get_identifiersUszSymbolTable.get_identifierscCsT|j�|�}|durP|jj|}|�|�}|jjdk}t||||d�}|j|<|S)Nr��module_scope)r3r*r1rL�_SymbolTable__check_childrenr6r)r#r6Zsym�flags�
namespacesrPrrr�lookupXs
�zSymbolTable.lookupcs�fdd����D�S)Ncsg|]}��|��qSr)rT��.0�identr"rr�
<listcomp>c�z+SymbolTable.get_symbols.<locals>.<listcomp>)rNr"rr"r�get_symbolsbszSymbolTable.get_symbolscs��fdd��jjD�S)Ncs"g|]}|j�krt|�j��qSr)r6rr2�rV�st�r6r#rrrXfs
�z0SymbolTable.__check_children.<locals>.<listcomp>�r1rJ)r#r6rr]rZ__check_childrenes�zSymbolTable.__check_childrencs�fdd��jjD�S)Ncsg|]}t|�j��qSr)rr2r[r"rrrXks�z,SymbolTable.get_children.<locals>.<listcomp>r^r"rr"r�get_childrenjs
�zSymbolTable.get_childrenN)r.r/r0r$r9r@rBrCrErGrIrKrNrTrZrQr_rrrrr%s


rc@sPeZdZdZdZdZdZdZdd�Zdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dS)rNcst��fdd����D��S)Nc3s"|]}��jj|�r|VqdSr)r1rLrU�r#Z	test_funcrr�	<genexpr>ys�z-Function.__idents_matching.<locals>.<genexpr>)�tuplerNr`rr`rZ__idents_matchingxszFunction.__idents_matchingcCs |jdur|�dd��|_|jS)NcSs|t@Sr)r��xrrr�<lambda>~rYz)Function.get_parameters.<locals>.<lambda>)�_Function__params�_Function__idents_matchingr"rrr�get_parameters|s
zFunction.get_parameterscs0|jdur*ttf��fdd�}|�|�|_|jS)Ncs|t?t@�vSr�r
rrc�Zlocsrrre�rYz%Function.get_locals.<locals>.<lambda>)�_Function__localsr
rrg�r#�testrrjr�
get_locals�s

zFunction.get_localscs0|jdur*ttf��fdd�}|�|�|_|jS)Ncs|t?t@�vSrrirc��globrrre�rYz&Function.get_globals.<locals>.<lambda>)�_Function__globalsrrrgrlrror�get_globals�s

zFunction.get_globalscCs |jdur|�dd��|_|jS)NcSs|t@Sr)rrcrrrre�rYz(Function.get_nonlocals.<locals>.<lambda>)�_Function__nonlocalsrgr"rrr�
get_nonlocals�s
zFunction.get_nonlocalscCs$|jdurdd�}|�|�|_|jS)NcSs|t?t@tkSr)r
rrrcrrrre�rYz$Function.get_frees.<locals>.<lambda>)�_Function__freesrg)r#�is_freerrr�	get_frees�s
zFunction.get_frees)r.r/r0rfrkrurqrsrgrhrnrrrtrwrrrrrosrc@seZdZdZdd�ZdS)rNcCs6|jdur0i}|jjD]}d||j<qt|�|_|jS)Nr=)�_Class__methodsr1rJr6rb)r#�dr\rrr�get_methods�s

zClass.get_methods)r.r/r0rxrzrrrrr�src@s�eZdZd$dd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)%rNFrOcCs.||_||_|t?t@|_|p d|_||_dS)Nr)�
_Symbol__name�_Symbol__flagsr
r�_Symbol__scope�_Symbol__namespaces�_Symbol__module_scope)r#r6rRrSrPrrrr$�s

zSymbol.__init__cCsd�|j�S)Nz<symbol {0!r}>)r7r{r"rrrr9�szSymbol.__repr__cCs|jSr)r{r"rrrrC�szSymbol.get_namecCst|jtj@�Sr)rFr|rrr"rrr�
is_referenced�szSymbol.is_referencedcCst|jt@�Sr)rFr|rr"rrr�is_parameter�szSymbol.is_parametercCs"t|jttfvp|jo|jt@�S)z0Return *True* if the sysmbol is global.
        )rFr}rrrr|rr"rrr�	is_global�s�zSymbol.is_globalcCst|jt@�Sr)rFr|rr"rrr�is_nonlocal�szSymbol.is_nonlocalcCst|jtk�Sr)rFr}rr"rrr�is_declared_global�szSymbol.is_declared_globalcCs"t|jttfvp|jo|jt@�S)z.Return *True* if the symbol is local.
        )rFr}r
rrr|rr"rrr�is_local�s�zSymbol.is_localcCst|jt@�Sr)rFr|r	r"rrr�is_annotated�szSymbol.is_annotatedcCst|jtk�Sr)rFr}rr"rrrrv�szSymbol.is_freecCst|jt@�Sr)rFr|rr"rrr�is_imported�szSymbol.is_importedcCst|jt@�Sr)rFr|rr"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.
        )rFr~r"rrr�is_namespace�szSymbol.is_namespacecCs|jS)z.Return a list of namespaces bound to this name)r~r"rrr�get_namespaces�szSymbol.get_namespacescCs t|j�dkrtd��|jdS)z�Returns the single namespace bound to this name.

        Raises ValueError if the name is bound to multiple namespaces.
        r=z$name is bound to multiple namespacesr)�lenr~�
ValueErrorr"rrr�
get_namespace�szSymbol.get_namespace)N)r.r/r0r$r9rCr�r�r�r�r�r�r�rvr�r�r�r�r�rrrrr�s 
r�__main__r=�exec),�__doc__rrrrrrrrr	r
rrr
rrrr�__all__rrrrrrrr.�os�sys�open�argv�f�read�src�path�split�modrNrWrT�info�printr�r�rrrr�<module>s&DJ,
M
&


Zerion Mini Shell 1.0