grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026U iÛfUã @sJdZddlZddlmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZddlZdddddgZd d„ZGd d „d ƒZeƒZGd d„dƒZGd d„deƒZGdd„deƒZGdd„dƒZedk�rFddlZddlZeejdƒ�Ze  ¡Z!W5QRXee!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/python38/lib64/python3.8/symtable.pyr sc@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¡}|dkr4| ||¡}|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„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"ZkindrrrÚ__repr__,s   þzSymbolTable.__repr__cCsX|jjtjkrdS|jjtjkr$dS|jjtjkr6dS|jjdksTtd |jj¡ƒ‚dS)NÚmoduleZfunctionÚclass)ééézunexpected type: {0})r0r$rZ TYPE_MODULEr%r&ÚAssertionErrorr6r!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_childrencCsdS)z7Return true if the scope uses exec. Deprecated method.Frr!rrrÚhas_execUszSymbolTable.has_execcCs |jj ¡Sr)r0ÚsymbolsÚkeysr!rrrÚget_identifiersYszSymbolTable.get_identifierscCsT|j |¡}|dkrP|jj|}| |¡}|jjdk}t||||d�}|j|<|S)Nr©Ú module_scope)r2r)r0rKÚ_SymbolTable__check_childrenr5r)r"r5ZsymÚflagsÚ namespacesrOrrrÚlookup\s    ÿzSymbolTable.lookupcs‡fdd„ˆ ¡DƒS)Ncsg|]}ˆ |¡‘qSr)rS©Ú.0Úidentr!rrÚ gsz+SymbolTable.get_symbols..)rMr!rr!rÚ get_symbolsfszSymbolTable.get_symbolscs‡‡fdd„ˆjjDƒS)Ncs"g|]}|jˆkrt|ˆjƒ‘qSr)r5rr1©rUÚst©r5r"rrrWjs þz0SymbolTable.__check_children..©r0rH)r"r5rr[rZ__check_childrenis ÿzSymbolTable.__check_childrencs‡fdd„ˆjjDƒS)Ncsg|]}t|ˆjƒ‘qSr)rr1rYr!rrrWosÿz,SymbolTable.get_children..r\r!rr!rÚ get_childrenns ÿzSymbolTable.get_childrenN)r-r.r/r#r7r>r@rArCrErGrIrJrMrSrXrPr]rrrrr%s   c@sPeZdZdZdZdZdZdZdd„Zdd„Z dd„Z dd „Z d d „Z d d „Z dS)rNcst‡‡fdd„ˆ ¡DƒƒS)Nc3s"|]}ˆˆjj|ƒr|VqdSr)r0rKrT©r"Z test_funcrrÚ }sÿz-Function.__idents_matching..)ÚtuplerMr^rr^rZ__idents_matching|szFunction.__idents_matchingcCs |jdkr| dd„¡|_|jS)NcSs|t@Sr)r©ÚxrrrÚ‚óz)Function.get_parameters..)Ú_Function__paramsÚ_Function__idents_matchingr!rrrÚget_parameters€s zFunction.get_parameterscs0|jdkr*ttf‰‡fdd„}| |¡|_|jS)Ncs|t?t@ˆkSr©r r ra©Zlocsrrrcˆrdz%Function.get_locals..)Ú_Function__localsr rrf©r"ZtestrrirÚ get_locals…s    zFunction.get_localscs0|jdkr*ttf‰‡fdd„}| |¡|_|jS)Ncs|t?t@ˆkSrrhra©Zglobrrrc�rdz&Function.get_globals..)Ú_Function__globalsrrrfrkrrmrÚ get_globalsŒs    zFunction.get_globalscCs |jdkr| dd„¡|_|jS)NcSs|t@Sr)rrarrrrc•rdz(Function.get_nonlocals..)Ú_Function__nonlocalsrfr!rrrÚ get_nonlocals“s zFunction.get_nonlocalscCs$|jdkrdd„}| |¡|_|jS)NcSs|t?t@tkSr)r r r rarrrrcšrdz$Function.get_frees..)Ú_Function__freesrf)r"Úis_freerrrÚ get_frees˜s  zFunction.get_frees)r-r.r/rerjrrrnrprfrgrlrorqrtrrrrrssc@seZdZdZdd„ZdS)rNcCs6|jdkr0i}|jjD]}d||j<qt|ƒ|_|jS)Nr:)Ú_Class__methodsr0rHr5r`)r"ÚdrZrrrÚ get_methods£s     zClass.get_methods)r-r.r/rurwrrrrrŸsc@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)%rNFrNcCs.||_||_|t?t@|_|p d|_||_dS)Nr)Ú _Symbol__nameÚ_Symbol__flagsr r Ú_Symbol__scopeÚ_Symbol__namespacesÚ_Symbol__module_scope)r"r5rQrRrOrrrr#®s  zSymbol.__init__cCs d |j¡S)Nz)r6rxr!rrrr7µ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|jttfkp|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|jttfkp|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#r7rAr}r~rr€r�r‚rƒrsr„r…r†r‡rŠrrrrr¬s  Ú__main__r:Úexec),Ú__doc__rrrrrrrrr r r r r rrrrÚ__all__rrrrrrrr-ÚosÚsysÚopenÚargvÚfÚreadÚsrcÚpathÚsplitÚmodrMrVrSÚinfoÚprintr‚r†rrrrÚs&DN, M