grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B ¸²¨ý7¾Ìã @sNdZddlZddlmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZddlZdddddgZd d„ZGd d „d ƒZeƒZGd d„deƒZGd d„deƒZGdd„deƒZGdd„deƒZedk�rJddlZddlZeejdƒ�Ze  ¡Z!WdQRXee!ej" #ejd¡ddƒZ$x0e$ %¡D]$Z&e$ 'e&¡Z(e)e(e( *¡e( +¡ƒ�q"WdS)z2Interface to the compiler's internal symbol tableséN)ÚUSEÚ DEF_GLOBALÚ 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ú-/opt/alt/python37/lib64/python3.7/symtable.pyr sc@s$eZdZdd„Zdd„Zdd„ZdS)ÚSymbolTableFactorycCst ¡|_dS)N)ÚweakrefZWeakValueDictionaryÚ_SymbolTableFactory__memo)ÚselfrrrÚ__init__szSymbolTableFactory.__init__cCs6|jtjkrt||ƒS|jtjkr,t||ƒSt||ƒS)N)ÚtyperÚ TYPE_FUNCTIONrÚ TYPE_CLASSrr)rÚtablerrrrÚnews     zSymbolTableFactory.newcCs8||f}|j |d¡}|dkr4| ||¡}|j|<|S)N)rÚgetr%)rr$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„Zdd„ZdS) rcCs||_||_i|_dS)N)Ú_tableÚ _filenameÚ_symbols)rZ raw_tablerrrrr 'szSymbolTable.__init__cCsN|jtkrd}n d|jj}|jjdkr6d ||j¡Sd ||jj|j¡SdS)NÚz%s Úglobalz<{0}SymbolTable for module {1}>z<{0}SymbolTable for {1} in {2}>)Ú __class__rr*r-ÚnameÚformatr.)rZkindrrrÚ__repr__,s   zSymbolTable.__repr__cCsX|jjtjkrdS|jjtjkr$dS|jjtjkr6dS|jjdksTtd |jj¡ƒ‚dS)NÚmoduleZfunctionÚclass)ééézunexpected type: {0})r-r!rZ TYPE_MODULEr"r#ÚAssertionErrorr4)rrrrÚget_type9szSymbolTable.get_typecCs|jjS)N)r-Úid)rrrrÚget_idCszSymbolTable.get_idcCs|jjS)N)r-r3)rrrrÚget_nameFszSymbolTable.get_namecCs|jjS)N)r-Úlineno)rrrrÚ get_linenoIszSymbolTable.get_linenocCst|jjtjkƒS)N)Úboolr-r!rr")rrrrÚ is_optimizedLszSymbolTable.is_optimizedcCs t|jjƒS)N)rBr-Únested)rrrrÚ is_nestedOszSymbolTable.is_nestedcCs t|jjƒS)N)rBr-Úchildren)rrrrÚ has_childrenRszSymbolTable.has_childrencCsdS)z7Return true if the scope uses exec. Deprecated method.Fr)rrrrÚhas_execUszSymbolTable.has_execcCs |jj ¡S)N)r-ÚsymbolsÚkeys)rrrrÚget_identifiersYszSymbolTable.get_identifierscCsD|j |¡}|dkr@|jj|}| |¡}t|||ƒ}|j|<|S)N)r/r&r-rIÚ_SymbolTable__check_childrenr)rr3ZsymÚflagsÚ namespacesrrrÚlookup\s    zSymbolTable.lookupcs‡fdd„ˆ ¡DƒS)Ncsg|]}ˆ |¡‘qSr)rO)Ú.0Úident)rrrú esz+SymbolTable.get_symbols..)rK)rr)rrÚ get_symbolsdszSymbolTable.get_symbolscs‡‡fdd„ˆjjDƒS)Ncs"g|]}|jˆkrt|ˆjƒ‘qSr)r3rr.)rPÚst)r3rrrrRhsz0SymbolTable.__check_children..)r-rF)rr3r)r3rrZ__check_childrengs zSymbolTable.__check_childrencs‡fdd„ˆjjDƒS)Ncsg|]}t|ˆjƒ‘qSr)rr.)rPrT)rrrrRmsz,SymbolTable.get_children..)r-rF)rr)rrÚ get_childrenls zSymbolTable.get_childrenN)r*r+r,r r5r<r>r?rArCrErGrHrKrOrSrLrUrrrrr%s  c@sDeZdZdZdZdZdZdd„Zdd„Zdd„Z dd „Z d d „Z dS) rNcst‡‡fdd„ˆ ¡DƒƒS)Nc3s"|]}ˆˆjj|ƒr|VqdS)N)r-rI)rPrQ)rÚ test_funcrrú zsz-Function.__idents_matching..)ÚtuplerK)rrVr)rrVrZ__idents_matchingyszFunction.__idents_matchingcCs |jdkr| dd„¡|_|jS)NcSs|t@S)N)r)ÚxrrrÚóz)Function.get_parameters..)Ú_Function__paramsÚ_Function__idents_matching)rrrrÚget_parameters}s zFunction.get_parameterscs0|jdkr*ttf‰‡fdd„}| |¡|_|jS)Ncs|t?t@ˆkS)N)r r )rY)ÚlocsrrrZ…r[z%Function.get_locals..)Ú_Function__localsr rr])rÚtestr)r_rÚ get_locals‚s    zFunction.get_localscs0|jdkr*ttf‰‡fdd„}| |¡|_|jS)Ncs|t?t@ˆkS)N)r r )rY)ÚglobrrrZŒr[z&Function.get_globals..)Ú_Function__globalsr rr])rrar)rcrÚ get_globals‰s    zFunction.get_globalscCs$|jdkrdd„}| |¡|_|jS)NcSs|t?t@tkS)N)r r r )rYrrrrZ’r[z$Function.get_frees..)Ú_Function__freesr])rÚis_freerrrÚ get_frees�s  zFunction.get_frees) r*r+r,r\r`rfrdr]r^rbrerhrrrrrqsc@seZdZdZdd„ZdS)rNcCs:|jdkr4i}x|jjD]}d||j<qWt|ƒ|_|jS)Nr8)Ú_Class__methodsr-rFr3rX)rÚdrTrrrÚ get_methods›s   zClass.get_methods)r*r+r,rirkrrrrr—sc@s†eZdZd dd„Zdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS)!rNcCs(||_||_|t?t@|_|p d|_dS)Nr)Ú _Symbol__nameÚ_Symbol__flagsr r Ú_Symbol__scopeÚ_Symbol__namespaces)rr3rMrNrrrr ¦szSymbol.__init__cCs d |j¡S)Nz)r4rl)rrrrr5¬szSymbol.__repr__cCs|jS)N)rl)rrrrr?¯szSymbol.get_namecCst|jtj@ƒS)N)rBrmrr)rrrrÚ is_referenced²szSymbol.is_referencedcCst|jt@ƒS)N)rBrmr)rrrrÚ is_parameterµszSymbol.is_parametercCst|jttfkƒS)N)rBrnr r)rrrrÚ is_global¸szSymbol.is_globalcCst|jtkƒS)N)rBrnr)rrrrÚis_declared_global»szSymbol.is_declared_globalcCst|jttfkƒS)N)rBrnr r)rrrrÚis_local¾szSymbol.is_localcCst|jt@ƒS)N)rBrmr)rrrrÚ is_annotatedÁszSymbol.is_annotatedcCst|jtkƒS)N)rBrnr )rrrrrgÄszSymbol.is_freecCst|jt@ƒS)N)rBrmr)rrrrÚ is_importedÇszSymbol.is_importedcCst|jt@ƒS)N)rBrmr)rrrrÚ 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. )rBro)rrrrÚ is_namespaceÍs zSymbol.is_namespacecCs|jS)z.Return a list of namespaces bound to this name)ro)rrrrÚ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. r8z$name is bound to multiple namespacesr)ÚlenroÚ ValueError)rrrrÚ get_namespaceÞszSymbol.get_namespace)N)r*r+r,r r5r?rprqrrrsrtrurgrvrwrxryr|rrrrr¤s  Ú__main__r8Úexec),Ú__doc__rrrrrrrrr r r r r rrrÚ__all__rrrÚobjectrrrrr*ÚosÚsysÚopenÚargvÚfÚreadÚsrcÚpathÚsplitÚmodrKrQrOÚinfoÚprintrtrxrrrrÚs&@L& C