a �DOg��@sTddlZddlmZmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZddlZgd�Zdd�ZGdd�d�Ze�ZGdd �d �ZGd d �d e�ZGd d �d e�ZGdd�d�Zedk�rPddlZddlZeejd��Ze��Z Wd�n1s�0Yee ej!�"ejd�dd�Z#e#�$�D]$Z%e#�&e%�Z'e(e'e'�)�e'�*���q*dS)�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 �Zd d �Zd d�Z dd�Z dd�Z dd�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__cCs:|jjtjkrdS|jjtjkr$dS|jjtjkr6dSdS)N�module�function�class)r1r%rZ TYPE_MODULEr&r'r"rrr�get_type9szSymbolTable.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)rCr1�nestedr"rrr� is_nestedOszSymbolTable.is_nestedcCs t|jj�Sr)rCr1�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*r1rI�_SymbolTable__check_childrenr6r)r#r6Zsym�flags� namespacesrMrrr�lookupXs    �zSymbolTable.lookupcs�fdd����D�S)Ncsg|]}��|��qSr)rQ��.0�identr"rr� c�z+SymbolTable.get_symbols..)rKr"rr"r� get_symbolsbszSymbolTable.get_symbolscs��fdd��jjD�S)Ncs"g|]}|j�krt|�j��qSr)r6rr2�rS�st�r6r#rrrUfs �z0SymbolTable.__check_children..�r1rG)r#r6rrZrZ__check_childrenes �zSymbolTable.__check_childrencs�fdd��jjD�S)Ncsg|]}t|�j��qSr)rr2rXr"rrrUks�z,SymbolTable.get_children..r[r"rr"r� get_childrenjs �zSymbolTable.get_childrenN)r.r/r0r$r9r=r?r@rBrDrFrHrKrQrWrNr\rrrrr%s   rc@sPeZdZdZdZdZdZdZdd�Zdd�Z dd�Z dd �Z d d �Z d d �Z dS)rNcst��fdd����D��S)Nc3s"|]}��jj|�r|VqdSr)r1rIrR�r#Z test_funcrr� ys�z-Function.__idents_matching..)�tuplerKr]rr]rZ__idents_matchingxszFunction.__idents_matchingcCs |jdur|�dd��|_|jS)NcSs|t@Sr)r��xrrr�~rVz)Function.get_parameters..)�_Function__params�_Function__idents_matchingr"rrr�get_parameters|s zFunction.get_parameterscs0|jdur*ttf��fdd�}|�|�|_|jS)Ncs|t?t@�vSr�r r r`�Zlocsrrrb�rVz%Function.get_locals..)�_Function__localsr rrd�r#�testrrgr� get_locals�s    zFunction.get_localscs0|jdur*ttf��fdd�}|�|�|_|jS)Ncs|t?t@�vSrrfr`��globrrrb�rVz&Function.get_globals..)�_Function__globalsrrrdrirrlr� get_globals�s    zFunction.get_globalscCs |jdur|�dd��|_|jS)NcSs|t@Sr)rr`rrrrb�rVz(Function.get_nonlocals..)�_Function__nonlocalsrdr"rrr� get_nonlocals�s zFunction.get_nonlocalscCs$|jdurdd�}|�|�|_|jS)NcSs|t?t@tkSr)r r r r`rrrrb�rVz$Function.get_frees..)�_Function__freesrd)r#�is_freerrr� get_frees�s  zFunction.get_frees)r.r/r0rcrhrrrnrprdrerkrorqrtrrrrrosrc@seZdZdZdd�ZdS)rNcCs6|jdur0i}|jjD]}d||j<qt|�|_|jS)N�)�_Class__methodsr1rGr6r_)r#�drYrrr� get_methods�s     zClass.get_methods)r.r/r0rvrxrrrrr�src@s�eZdZd$dd�dd�Zdd�Zdd �Zd d �Zd d �Zdd�Zdd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd�Zd d!�Zd"d#�ZdS)%rNFrLcCs.||_||_|t?t@|_|p d|_||_dS)Nr)� _Symbol__name�_Symbol__flagsr r �_Symbol__scope�_Symbol__namespaces�_Symbol__module_scope)r#r6rOrPrMrrrr$�s  zSymbol.__init__cCs d�|j�S)Nz)r7ryr"rrrr9�szSymbol.__repr__cCs|jSr)ryr"rrrr@�szSymbol.get_namecCst|jtj@�Sr)rCrzrrr"rrr� is_referenced�szSymbol.is_referencedcCst|jt@�Sr)rCrzrr"rrr� is_parameter�szSymbol.is_parametercCs"t|jttfvp|jo|jt@�Sr)rCr{rrr}rzrr"rrr� is_global�s�zSymbol.is_globalcCst|jt@�Sr)rCrzrr"rrr� is_nonlocal�szSymbol.is_nonlocalcCst|jtk�Sr)rCr{rr"rrr�is_declared_global�szSymbol.is_declared_globalcCs"t|jttfvp|jo|jt@�Sr)rCr{r rr}rzrr"rrr�is_local�s�zSymbol.is_localcCst|jt@�Sr)rCrzr r"rrr� is_annotated�szSymbol.is_annotatedcCst|jtk�Sr)rCr{r r"rrrrs�szSymbol.is_freecCst|jt@�Sr)rCrzrr"rrr� is_imported�szSymbol.is_importedcCst|jt@�Sr)rCrzrr"rrr� is_assigned�szSymbol.is_assignedcCs t|j�Sr)rCr|r"rrr� is_namespace�s zSymbol.is_namespacecCs|jSr)r|r"rrr�get_namespaces�szSymbol.get_namespacescCs t|j�dkrtd��|jdS)Nruz$name is bound to multiple namespacesr)�lenr|� ValueErrorr"rrr� get_namespace�szSymbol.get_namespace)N)r.r/r0r$r9r@r~rr�r�r�r�r�rsr�r�r�r�r�rrrrr�s  r�__main__ru�exec)+rrrrrrrrr r r r r rrrr�__all__rrrrrrrr.�os�sys�open�argv�f�read�src�path�split�modrKrTrQ�info�printr�r�rrrr�s$DJ, M &