U e5dU @sFddlZddlmZmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZddlZdddddgZddZGd d d ZeZGd ddZGd ddeZGd ddeZGdddZedkrBddlZddlZeejdZeZ W5QRXee ej!"ejdddZ#e#$D]$Z%e#&e%Z'e(e'e')e'*qdS)N)USE DEF_GLOBAL DEF_NONLOCAL DEF_LOCAL DEF_PARAM DEF_IMPORT DEF_BOUND DEF_ANNOT SCOPE_OFF SCOPE_MASKFREELOCALGLOBAL_IMPLICITGLOBAL_EXPLICITCELLsymtable SymbolTableClassFunctionSymbolcCst|||}t||SN) _symtabler_newSymbolTable)codefilenameZ compile_typetopr /usr/lib64/python3.8/symtable.pyr sc@s$eZdZddZddZddZdS)SymbolTableFactorycCst|_dSr)weakrefZWeakValueDictionary_SymbolTableFactory__memoselfrrr__init__szSymbolTableFactory.__init__cCs6|jtjkrt||S|jtjkr,t||St||Sr)typer TYPE_FUNCTIONr TYPE_CLASSrr)r"tablerrrrnews     zSymbolTableFactory.newcCs8||f}|j|d}|dkr4|||}|j|<|Sr)r getr()r"r'rkeyobjrrr__call__s zSymbolTableFactory.__call__N)__name__ __module__ __qualname__r#r(r,rrrrrsrc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) rcCs||_||_i|_dSr)_table _filename_symbols)r"Z raw_tablerrrrr#'szSymbolTable.__init__cCsN|jtkrd}n d|jj}|jjdkr6d||jSd||jj|jSdS)Nz%s rz<{0}SymbolTable for module {1}>z<{0}SymbolTable for {1} in {2}>) __class__rr-r0nameformatr1)r"Zkindrrr__repr__,s   zSymbolTable.__repr__cCs:|jjtjkrdS|jjtjkr$dS|jjtjkr6dSdS)NmoduleZfunctionclass)r0r$rZ TYPE_MODULEr%r&r!rrrget_type9szSymbolTable.get_typecCs|jjSr)r0idr!rrrget_idCszSymbolTable.get_idcCs|jjSr)r0r5r!rrrget_nameFszSymbolTable.get_namecCs|jjSr)r0linenor!rrr get_linenoIszSymbolTable.get_linenocCst|jjtjkSr)boolr0r$rr%r!rrr is_optimizedLszSymbolTable.is_optimizedcCs t|jjSr)r@r0nestedr!rrr is_nestedOszSymbolTable.is_nestedcCs t|jjSr)r@r0childrenr!rrr has_childrenRszSymbolTable.has_childrencCsdS)NFrr!rrrhas_execUszSymbolTable.has_execcCs |jjSr)r0symbolskeysr!rrrget_identifiersYszSymbolTable.get_identifierscCsT|j|}|dkrP|jj|}||}|jjdk}t||||d}|j|<|S)Nr module_scope)r2r)r0rG_SymbolTable__check_childrenr5r)r"r5Zsymflags namespacesrKrrrlookup\s    zSymbolTable.lookupcsfddDS)Ncsg|]}|qSr)rO.0identr!rr gsz+SymbolTable.get_symbols..)rIr!rr!r get_symbolsfszSymbolTable.get_symbolscsfddjjDS)Ncs"g|]}|jkrt|jqSr)r5rr1rQstr5r"rrrSjs z0SymbolTable.__check_children..r0rD)r"r5rrWrZ__check_childrenis zSymbolTable.__check_childrencsfddjjDS)Ncsg|]}t|jqSr)rr1rUr!rrrSosz,SymbolTable.get_children..rXr!rr!r get_childrenns zSymbolTable.get_childrenN)r-r.r/r#r7r:r<r=r?rArCrErFrIrOrTrLrYrrrrr%s   c@sPeZdZdZdZdZdZdZddZddZ ddZ dd Z d d Z d d Z dS)rNcstfddDS)Nc3s"|]}jj|r|VqdSr)r0rGrPr"Z test_funcrr }sz-Function.__idents_matching..)tuplerIrZrrZrZ__idents_matching|szFunction.__idents_matchingcCs |jdkr|dd|_|jS)NcSs|t@Sr)rxrrrz)Function.get_parameters..)_Function__params_Function__idents_matchingr!rrrget_parameterss zFunction.get_parameterscs0|jdkr*ttffdd}|||_|jS)Ncs|t?t@kSrr r r]Zlocsrrr_r`z%Function.get_locals..)_Function__localsr rrbr"Ztestrrer get_localss    zFunction.get_localscs0|jdkr*ttffdd}|||_|jS)Ncs|t?t@kSrrdr]Zglobrrr_r`z&Function.get_globals..)_Function__globalsrrrbrgrrir get_globalss    zFunction.get_globalscCs |jdkr|dd|_|jS)NcSs|t@Sr)rr]rrrr_r`z(Function.get_nonlocals..)_Function__nonlocalsrbr!rrr get_nonlocalss zFunction.get_nonlocalscCs$|jdkrdd}|||_|jS)NcSs|t?t@tkSr)r r r r]rrrr_r`z$Function.get_frees..)_Function__freesrb)r"is_freerrr get_freess  zFunction.get_frees)r-r.r/rarfrnrjrlrbrcrhrkrmrprrrrrssc@seZdZdZddZdS)rNcCs6|jdkr0i}|jjD]}d||j<qt||_|jS)N)_Class__methodsr0rDr5r\)r"drVrrr get_methodss     zClass.get_methods)r-r.r/rrrtrrrrrsc@seZdZd$ddddZddZdd Zd d Zd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#ZdS)%rNFrJcCs.||_||_|t?t@|_|p d|_||_dS)Nr) _Symbol__name_Symbol__flagsr r _Symbol__scope_Symbol__namespaces_Symbol__module_scope)r"r5rMrNrKrrrr#s  zSymbol.__init__cCs d|jS)Nz)r6rur!rrrr7szSymbol.__repr__cCs|jSr)rur!rrrr=szSymbol.get_namecCst|jtj@Sr)r@rvrrr!rrr is_referencedszSymbol.is_referencedcCst|jt@Sr)r@rvrr!rrr is_parameterszSymbol.is_parametercCs"t|jttfkp|jo|jt@Sr)r@rwrrryrvrr!rrr is_globalszSymbol.is_globalcCst|jt@Sr)r@rvrr!rrr is_nonlocalszSymbol.is_nonlocalcCst|jtkSr)r@rwrr!rrris_declared_globalszSymbol.is_declared_globalcCs"t|jttfkp|jo|jt@Sr)r@rwr rryrvrr!rrris_localszSymbol.is_localcCst|jt@Sr)r@rvr r!rrr is_annotatedszSymbol.is_annotatedcCst|jtkSr)r@rwr r!rrrroszSymbol.is_freecCst|jt@Sr)r@rvrr!rrr is_importedszSymbol.is_importedcCst|jt@Sr)r@rvrr!rrr is_assignedszSymbol.is_assignedcCs t|jSr)r@rxr!rrr is_namespaces zSymbol.is_namespacecCs|jSr)rxr!rrrget_namespacesszSymbol.get_namespacescCs t|jdkrtd|jdS)Nrqz$name is bound to multiple namespacesr)lenrx ValueErrorr!rrr get_namespaceszSymbol.get_namespace)N)r-r.r/r#r7r=rzr{r|r}r~rrrorrrrrrrrrrs  __main__rqexec)+rrrrrrrrr r r r r rrrr__all__rrrrrrrr-ossysopenargvfreadsrcpathsplitmodrIrRrOinfoprintrrrrrrs$DN, M