grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a XC?háã@sXdZddlZddlmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZddlZgd¢Zdd„ZGdd„dƒZeƒZGd d „d ƒZGd d „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ú-/opt/alt/python39/lib64/python3.9/symtable.pyr src@s$eZdZdd„Zdd„Zdd„ZdS)ÚSymbolTableFactorycCst ¡|_dSr)ÚweakrefZWeakValueDictionaryÚ_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-r0ÚnameÚformatr1)r"ÚkindrrrÚ__repr__,s   þzSymbolTable.__repr__cCsX|jjtjkrdS|jjtjkr$dS|jjtjkr6dS|jjdvsTJd |jj¡ƒ‚dS)NÚmoduleZfunctionÚclass)ééézunexpected type: {0})r0r$rZ TYPE_MODULEr%r&r6r!rrrÚget_type9s ÿzSymbolTable.get_typecCs|jjSr)r0Úidr!rrrÚget_idCszSymbolTable.get_idcCs|jjSr)r0r5r!rrrÚget_nameFszSymbolTable.get_namecCs|jjSr)r0Úlinenor!rrrÚ get_linenoIszSymbolTable.get_linenocCst|jjtjkƒSr)Úboolr0r$rr%r!rrrÚ is_optimizedLszSymbolTable.is_optimizedcCs t|jjƒSr)rDr0Únestedr!rrrÚ is_nestedOszSymbolTable.is_nestedcCs t|jjƒSr)rDr0Úchildrenr!rrrÚ has_childrenRszSymbolTable.has_childrencCs |jj ¡Sr)r0ÚsymbolsÚkeysr!rrrÚget_identifiersUszSymbolTable.get_identifierscCsT|j |¡}|durP|jj|}| |¡}|jjdk}t||||d�}|j|<|S)Nr©Ú module_scope)r2r)r0rJÚ_SymbolTable__check_childrenr5r)r"r5ZsymÚflagsÚ namespacesrNrrrÚlookupXs    ÿzSymbolTable.lookupcs‡fdd„ˆ ¡DƒS)Ncsg|]}ˆ |¡‘qSr)rR©Ú.0Úidentr!rrÚ cóz+SymbolTable.get_symbols..)rLr!rr!rÚ get_symbolsbszSymbolTable.get_symbolscs‡‡fdd„ˆjjDƒS)Ncs"g|]}|jˆkrt|ˆjƒ‘qSr)r5rr1©rTÚst©r5r"rrrVfs þz0SymbolTable.__check_children..©r0rH)r"r5rr[rZ__check_childrenes ÿzSymbolTable.__check_childrencs‡fdd„ˆjjDƒS)Ncsg|]}t|ˆjƒ‘qSr)rr1rYr!rrrVksÿz,SymbolTable.get_children..r\r!rr!rÚ get_childrenjs ÿzSymbolTable.get_childrenN)r-r.r/r#r8r>r@rArCrErGrIrLrRrXrOr]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)r0rJrS©r"Z test_funcrrÚ ysÿz-Function.__idents_matching..)ÚtuplerLr^rr^rZ__idents_matchingxszFunction.__idents_matchingcCs |jdur| dd„¡|_|jS)NcSs|t@Sr)r©ÚxrrrÚ~rWz)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 ra©Zlocsrrrc„rWz%Function.get_locals..)Ú_Function__localsr rre©r"ÚtestrrhrÚ get_locals�s    zFunction.get_localscs0|jdur*ttf‰‡fdd„}| |¡|_|jS)Ncs|t?t@ˆvSrrgra©Zglobrrrc‹rWz&Function.get_globals..)Ú_Function__globalsrrrerjrrmrÚ get_globalsˆs    zFunction.get_globalscCs |jdur| dd„¡|_|jS)NcSs|t@Sr)rrarrrrc‘rWz(Function.get_nonlocals..)Ú_Function__nonlocalsrer!rrrÚ get_nonlocals�s zFunction.get_nonlocalscCs$|jdurdd„}| |¡|_|jS)NcSs|t?t@tkSr)r r r rarrrrc–rWz$Function.get_frees..)Ú_Function__freesre)r"Úis_freerrrÚ get_frees”s  zFunction.get_frees)r-r.r/rdrirrrnrprerfrlrorqrtrrrrrosrc@seZdZdZdd„ZdS)rNcCs6|jdur0i}|jjD]}d||j<qt|ƒ|_|jS)Nr;)Ú_Class__methodsr0rHr5r`)r"ÚdrZrrrÚ get_methodsŸs     zClass.get_methods)r-r.r/rurwrrrrr›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)%rNFrMcCs.||_||_|t?t@|_|p d|_||_dS)Nr)Ú _Symbol__nameÚ_Symbol__flagsr r Ú_Symbol__scopeÚ_Symbol__namespacesÚ_Symbol__module_scope)r"r5rPrQrNrrrr#ªs  zSymbol.__init__cCs d |j¡S)Nz)r6rxr!rrrr8±szSymbol.__repr__cCs|jSr)rxr!rrrrA´szSymbol.get_namecCst|jtj@ƒSr)rDryrrr!rrrÚ is_referenced·szSymbol.is_referencedcCst|jt@ƒSr)rDryrr!rrrÚ is_parameterºszSymbol.is_parametercCs"t|jttfvp|jo|jt@ƒS)z0Return *True* if the sysmbol is global. )rDrzrrr|ryrr!rrrÚ is_global½sÿzSymbol.is_globalcCst|jt@ƒSr)rDryrr!rrrÚ is_nonlocalÃszSymbol.is_nonlocalcCst|jtkƒSr)rDrzrr!rrrÚis_declared_globalÆszSymbol.is_declared_globalcCs"t|jttfvp|jo|jt@ƒS)z.Return *True* if the symbol is local. )rDrzr rr|ryrr!rrrÚis_localÉsÿzSymbol.is_localcCst|jt@ƒSr)rDryr r!rrrÚ is_annotatedÏszSymbol.is_annotatedcCst|jtkƒSr)rDrzr r!rrrrsÒszSymbol.is_freecCst|jt@ƒSr)rDryrr!rrrÚ is_importedÕszSymbol.is_importedcCst|jt@ƒSr)rDryrr!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. )rDr{r!rrrÚ is_namespaceÛs zSymbol.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.r/r#r8rAr}r~rr€r�r‚rƒrsr„r…r†r‡rŠrrrrr¨s  rÚ__main__r;Úexec),Ú__doc__rrrrrrrrr r r r r rrrrÚ__all__rrrrrrrr-ÚosÚsysÚopenÚargvÚfÚreadÚsrcÚpathÚsplitÚmodrLrUrRÚinfoÚprintr‚r†rrrrÚs&DJ, M &