§
    (¶Õi€(  ã                   óÐ  — d Z ddlZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlZg d¢Zd„ Z G d„ d¦  «        Z e¦   «         Z G d„ d	¦  «        Z G d
„ de¦  «        Z G d„ de¦  «        Z G d„ d¦  «        Zedk    rÝddlZddlZ eej        d         ¦  «        5 Ze                      ¦   «         Z!ddd¦  «         n# 1 swxY w Y    ee!ej"         #                    ej        d         ¦  «        d         d¦  «        Z$e$ %                    ¦   «         D ]JZ&e$ '                    e&¦  «        Z( e)e(e( *                    ¦   «         e( +                    ¦   «         ¦  «         ŒIdS dS )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ÚSymbolc                 óN   — t          j        | ||¦  «        }t          ||¦  «        S )z« Return the toplevel *SymbolTable* for the source code.

    *filename* is the name of the file with the code
    and *compile_type* is the *compile()* mode argument.
    )Ú	_symtabler   Ú_newSymbolTable)ÚcodeÚfilenameÚcompile_typeÚtops       ú/usr/lib/python3.11/symtable.pyr   r      s(   € õ Ô
˜T 8¨\Ñ
:Ô
:€CÝ˜3 Ñ)Ô)Ð)ó    c                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )ÚSymbolTableFactoryc                 ó6   — t          j        ¦   «         | _        d S ©N)ÚweakrefÚWeakValueDictionaryÚ_SymbolTableFactory__memo©Úselfs    r   Ú__init__zSymbolTableFactory.__init__   s   € ÝÔ1Ñ3Ô3ˆŒˆˆr   c                 ó¶   — |j         t          j        k    rt          ||¦  «        S |j         t          j        k    rt          ||¦  «        S t          ||¦  «        S r#   )Útyper   ÚTYPE_FUNCTIONr   Ú
TYPE_CLASSr   r   )r(   Útabler   s      r   ÚnewzSymbolTableFactory.new   sR   € ØŒ:�Ô0Ò0Ð0Ý˜E 8Ñ,Ô,Ð,ØŒ:�Ô-Ò-Ð-Ý˜ Ñ)Ô)Ð)Ý˜5 (Ñ+Ô+Ð+r   c                 óˆ   — ||f}| j                              |d ¦  «        }|€ |                      ||¦  «        x}| j         |<   |S r#   )r&   Úgetr/   )r(   r.   r   ÚkeyÚobjs        r   Ú__call__zSymbolTableFactory.__call__    sI   € Ø�XˆoˆØŒk�oŠo˜c 4Ñ(Ô(ˆØˆ;Ø%)§X¢X¨e°XÑ%>Ô%>Ð>ˆC�$”+˜cÑ"Øˆ
r   N)Ú__name__Ú
__module__Ú__qualname__r)   r/   r4   © r   r   r!   r!      sA   € € € € € ð4ð 4ð 4ð,ð ,ð ,ðð ð ð ð r   r!   c                   ób   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ ZdS )r   c                 ó0   — || _         || _        i | _        d S r#   )Ú_tableÚ	_filenameÚ_symbols)r(   Ú	raw_tabler   s      r   r)   zSymbolTable.__init__,   s   € ØˆŒØ!ˆŒØˆŒˆˆr   c                 óè   — | j         t          k    rd}nd| j         j        z  }| j        j        dk    rd                     || j        ¦  «        S d                     || j        j        | j        ¦  «        S )NÚ z%s r   z<{0}SymbolTable for module {1}>z<{0}SymbolTable for {1} in {2}>)Ú	__class__r   r5   r;   ÚnameÚformatr<   )r(   Úkinds     r   Ú__repr__zSymbolTable.__repr__1   sw   € ØŒ>�[Ò(Ð(ØˆDˆDà˜4œ>Ô2Ñ2ˆDàŒ;Ô˜uÒ$Ð$Ø4×;Ò;¸DÀ$Ä.ÑQÔQÐQà4×;Ò;¸DØ<@¼KÔ<LØ<@¼NñLô Lð Lr   c                 ó  — | j         j        t          j        k    rdS | j         j        t          j        k    rdS | j         j        t          j        k    rdS | j         j        dv s'J d                     | j         j        ¦  «        ¦   «         ‚dS )zxReturn the type of the symbol table.

        The values returned are 'class', 'module' and
        'function'.
        ÚmoduleÚfunctionÚclass)é   é   é   zunexpected type: {0}N)r;   r+   r   ÚTYPE_MODULEr,   r-   rC   r'   s    r   Úget_typezSymbolTable.get_type>   s†   € ð Œ;Ô�yÔ4Ò4Ð4Ø�8ØŒ;Ô�yÔ6Ò6Ð6Ø�:ØŒ;Ô�yÔ3Ò3Ð3Ø�7ØŒ{Ô 9Ð,Ð,Ð,Ø%×,Ò,¨T¬[Ô-=Ñ>Ô>ñ -Ô,Ð,Ð,Ð,r   c                 ó   — | j         j        S )z,Return an identifier for the table.
        )r;   Úidr'   s    r   Úget_idzSymbolTable.get_idM   s   € ð Œ{Œ~Ðr   c                 ó   — | j         j        S )zµReturn the table's name.

        This corresponds to the name of the class, function
        or 'top' if the table is for a class, function or
        global respectively.
        )r;   rB   r'   s    r   Úget_namezSymbolTable.get_nameR   s   € ð Œ{ÔÐr   c                 ó   — | j         j        S )zPReturn the number of the first line in the
        block for the table.
        )r;   Úlinenor'   s    r   Ú
get_linenozSymbolTable.get_lineno[   s   € ð Œ{Ô!Ð!r   c                 óP   — t          | j        j        t          j        k    ¦  «        S )zJReturn *True* if the locals in the table
        are optimizable.
        )Úboolr;   r+   r   r,   r'   s    r   Úis_optimizedzSymbolTable.is_optimizeda   s   € õ �D”KÔ$­	Ô(?Ò?Ñ@Ô@Ð@r   c                 ó4   — t          | j        j        ¦  «        S )zAReturn *True* if the block is a nested class
        or function.)rX   r;   Únestedr'   s    r   Ú	is_nestedzSymbolTable.is_nestedg   s   € õ �D”KÔ&Ñ'Ô'Ð'r   c                 ó4   — t          | j        j        ¦  «        S )z:Return *True* if the block has nested namespaces.
        )rX   r;   Úchildrenr'   s    r   Úhas_childrenzSymbolTable.has_childrenl   s   € õ �D”KÔ(Ñ)Ô)Ð)r   c                 ó>   — | j         j                             ¦   «         S )zKReturn a view object containing the names of symbols in the table.
        )r;   ÚsymbolsÚkeysr'   s    r   Úget_identifierszSymbolTable.get_identifiersq   s   € ð Œ{Ô"×'Ò'Ñ)Ô)Ð)r   c                 óæ   — | j                              |¦  «        }|€T| j        j        |         }|                      |¦  «        }| j        j        dk    }t          ||||¬¦  «        x}| j         |<   |S )zLLookup a *name* in the table.

        Returns a *Symbol* instance.
        Nr   ©Úmodule_scope)r=   r1   r;   ra   Ú_SymbolTable__check_childrenrB   r   )r(   rB   ÚsymÚflagsÚ
namespacesrf   s         r   ÚlookupzSymbolTable.lookupv   sƒ   € ð
 Œm×Ò Ñ%Ô%ˆØˆ;Ø”KÔ'¨Ô-ˆEØ×.Ò.¨tÑ4Ô4ˆJØ œKÔ,°Ò5ˆLÝ(.¨t°U¸JØ<Hð)Jñ )Jô )Jð JˆC�$”- Ñ%àˆ
r   c                 óD   ‡ — ˆ fd„‰                       ¦   «         D ¦   «         S )zLReturn a list of *Symbol* instances for
        names in the table.
        c                 ó:   •— g | ]}‰                      |¦  «        ‘ŒS r8   )rk   )Ú.0Úidentr(   s     €r   ú
<listcomp>z+SymbolTable.get_symbols.<locals>.<listcomp>ˆ   s%   ø€ ÐGÐGÐG u�—’˜EÑ"Ô"ÐGÐGÐGr   )rc   r'   s   `r   Úget_symbolszSymbolTable.get_symbols„   s,   ø€ ð HÐGÐGÐG°×0DÒ0DÑ0FÔ0FÐGÑGÔGÐGr   c                 ó8   ‡ ‡— ˆˆ fd„‰ j         j        D ¦   «         S )Nc                 óP   •— g | ]"}|j         ‰k    ¯t          |‰j        ¦  «        ‘Œ#S r8   )rB   r   r<   )rn   ÚstrB   r(   s     €€r   rp   z0SymbolTable.__check_children.<locals>.<listcomp>‹   s8   ø€ ð $ð $ð $ØØ”7˜d’?�?õ    D¤NÑ3Ô3à"�?�?r   ©r;   r^   )r(   rB   s   ``r   Ú__check_childrenzSymbolTable.__check_childrenŠ   s9   øø€ ð$ð $ð $ð $ð $Øœ+Ô.ð$ñ $ô $ð 	$r   c                 ó4   ‡ — ˆ fd„‰ j         j        D ¦   «         S )z3Return a list of the nested symbol tables.
        c                 ó:   •— g | ]}t          |‰j        ¦  «        ‘ŒS r8   )r   r<   )rn   rt   r(   s     €r   rp   z,SymbolTable.get_children.<locals>.<listcomp>’   s5   ø€ ð 0ð 0ð 0Øõ    D¤NÑ3Ô3ð 0ð 0ð 0r   ru   r'   s   `r   Úget_childrenzSymbolTable.get_children�   s3   ø€ ð0ð 0ð 0ð 0Øœ+Ô.ð0ñ 0ô 0ð 	0r   N)r5   r6   r7   r)   rE   rN   rQ   rS   rV   rY   r\   r_   rc   rk   rq   rg   ry   r8   r   r   r   r   *   sï   € € € € € ðð ð ð
Lð Lð Lð?ð ?ð ?ðð ð ð
 ð  ð  ð"ð "ð "ðAð Að Að(ð (ð (ð
*ð *ð *ð
*ð *ð *ð
ð ð ðHð Hð Hð$ð $ð $ð
0ð 0ð 0ð 0ð 0r   r   c                   óF   — e Zd ZdZdZdZdZdZd„ Zd„ Z	d„ Z
d„ Zd„ Zd„ ZdS )r   Nc                 ób   ‡ ‡— t          ˆ ˆfd„‰                      ¦   «         D ¦   «         ¦  «        S )Nc              3   óR   •K  — | ]!} ‰‰j         j        |         ¦  «        ¯|V — Œ"d S r#   )r;   ra   )rn   ro   r(   Ú	test_funcs     €€r   ú	<genexpr>z-Function.__idents_matching.<locals>.<genexpr>    sO   øè è € ð ?ð ?˜uØ!˜	 $¤+Ô"5°eÔ"<Ñ=Ô=ð?�Uð ?ð ?ð ?ð ?ð ?ð ?r   )Útuplerc   )r(   r}   s   ``r   Ú__idents_matchingzFunction.__idents_matchingŸ   sL   øø€ Ýð ?ð ?ð ?ð ?ð ?¨×(<Ò(<Ñ(>Ô(>ð ?ñ ?ô ?ñ ?ô ?ð 	?r   c                 óT   — | j         €|                      d„ ¦  «        | _         | j         S )z6Return a tuple of parameters to the function.
        Nc                 ó   — | t           z  S r#   )r   ©Úxs    r   ú<lambda>z)Function.get_parameters.<locals>.<lambda>§   s
   € ¸AÅ	¹M€ r   )Ú_Function__paramsÚ_Function__idents_matchingr'   s    r   Úget_parameterszFunction.get_parameters£   s-   € ð Œ=Ð Ø ×2Ò2Ð3IÐ3IÑJÔJˆDŒMØŒ}Ðr   c                 óz   ‡— | j         €-t          t          fŠˆfd„}|                      |¦  «        | _         | j         S )z2Return a tuple of locals in the function.
        Nc                 ó,   •— | t           z	  t          z  ‰v S r#   ©r   r   )r„   Úlocss    €r   r…   z%Function.get_locals.<locals>.<lambda>¯   s   ø€ ˜q¥I™~µÑ;ÀÐD€ r   )Ú_Function__localsr   r   r‡   )r(   ÚtestrŒ   s     @r   Ú
get_localszFunction.get_localsª   sA   ø€ ð Œ=Ð Ý�4�=ˆDØDÐDÐDÐDˆDØ ×2Ò2°4Ñ8Ô8ˆDŒMØŒ}Ðr   c                 óz   ‡— | j         €-t          t          fŠˆfd„}|                      |¦  «        | _         | j         S )z3Return a tuple of globals in the function.
        Nc                 ó,   •— | t           z	  t          z  ‰v S r#   r‹   )r„   Úglobs    €r   r…   z&Function.get_globals.<locals>.<lambda>¸   s   ø€ ˜a¥9™nµ
Ñ:¸tÐC€ r   )Ú_Function__globalsr   r   r‡   )r(   rŽ   r’   s     @r   Úget_globalszFunction.get_globals³   sB   ø€ ð Œ>Ð!Ý#¥_Ð5ˆDØCÐCÐCÐCˆDØ!×3Ò3°DÑ9Ô9ˆDŒNØŒ~Ðr   c                 óT   — | j         €|                      d„ ¦  «        | _         | j         S )z5Return a tuple of nonlocals in the function.
        Nc                 ó   — | t           z  S r#   )r   rƒ   s    r   r…   z(Function.get_nonlocals.<locals>.<lambda>À   s   € ¸qÅ<Ñ?O€ r   )Ú_Function__nonlocalsr‡   r'   s    r   Úget_nonlocalszFunction.get_nonlocals¼   s0   € ð ÔÐ#Ø#×5Ò5Ð6OÐ6OÑPÔPˆDÔØÔÐr   c                 óX   — | j         €d„ }|                      |¦  «        | _         | j         S )z:Return a tuple of free variables in the function.
        Nc                 ó8   — | t           z	  t          z  t          k    S r#   )r   r   r   rƒ   s    r   r…   z$Function.get_frees.<locals>.<lambda>Ç   s   €  ¥i¡µ:Ñ =Å$ÒF€ r   )Ú_Function__freesr‡   )r(   Úis_frees     r   Ú	get_freeszFunction.get_freesÃ   s1   € ð Œ<ÐØFÐFˆGØ×1Ò1°'Ñ:Ô:ˆDŒLØŒ|Ðr   )r5   r6   r7   r†   r�   r›   r“   r—   r‡   rˆ   r�   r”   r˜   r�   r8   r   r   r   r   –   s‰   € € € € € ð €HØ€HØ€GØ€IØ€Kð?ð ?ð ?ðð ð ðð ð ðð ð ð ð  ð  ðð ð ð ð r   r   c                   ó   — e Zd ZdZd„ ZdS )r   Nc                 ó|   — | j         €/i }| j        j        D ]}d||j        <   Œt	          |¦  «        | _         | j         S )z9Return a tuple of methods declared in the class.
        NrJ   )Ú_Class__methodsr;   r^   rB   r   )r(   Údrt   s      r   Úget_methodszClass.get_methodsÐ   sG   € ð Œ>Ð!ØˆAØ”kÔ*ð ð �Ø��"”'‘
�
Ý" 1™XœXˆDŒNØŒ~Ðr   )r5   r6   r7   r    r¢   r8   r   r   r   r   Ì   s(   € € € € € à€Iðð ð ð ð r   r   c                   óv   — e Zd Zdddœd„Zd„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Z	d„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )r   NFre   c                óp   — || _         || _        |t          z	  t          z  | _        |pd| _        || _        d S )Nr8   )Ú_Symbol__nameÚ_Symbol__flagsr   r   Ú_Symbol__scopeÚ_Symbol__namespacesÚ_Symbol__module_scope)r(   rB   ri   rj   rf   s        r   r)   zSymbol.__init__Ý   s<   € ØˆŒØˆŒØ¥Ñ*­jÑ8ˆŒØ&Ð,¨"ˆÔØ*ˆÔÐÐr   c                 ó6   — d                      | j        ¦  «        S )Nz<symbol {0!r}>)rC   r¥   r'   s    r   rE   zSymbol.__repr__ä   s   € Ø×&Ò& t¤{Ñ3Ô3Ð3r   c                 ó   — | j         S )z#Return a name of a symbol.
        )r¥   r'   s    r   rS   zSymbol.get_nameç   s   € ð Œ{Ðr   c                 óD   — t          | j        t          j        z  ¦  «        S )zBReturn *True* if the symbol is used in
        its block.
        )rX   r¦   r   r   r'   s    r   Úis_referencedzSymbol.is_referencedì   s   € õ �D”L¥9¤=Ñ0Ñ1Ô1Ð1r   c                 ó:   — t          | j        t          z  ¦  «        S )z4Return *True* if the symbol is a parameter.
        )rX   r¦   r   r'   s    r   Úis_parameterzSymbol.is_parameterò   ó   € õ �D”L¥9Ñ,Ñ-Ô-Ð-r   c                 ór   — t          | j        t          t          fv p| j        o| j        t          z  ¦  «        S )z/Return *True* if the symbol is global.
        )rX   r§   r   r   r©   r¦   r	   r'   s    r   Ú	is_globalzSymbol.is_global÷   s?   € õ �D”L¥_µoÐ$FÐFð JØÔ+ÐH°´½yÑ0HñKô Kð 	Kr   c                 ó:   — t          | j        t          z  ¦  «        S )z(Return *True* if the symbol is nonlocal.)rX   r¦   r   r'   s    r   Úis_nonlocalzSymbol.is_nonlocalý   s   € å�D”L¥<Ñ/Ñ0Ô0Ð0r   c                 ó<   — t          | j        t          k    ¦  «        S )zOReturn *True* if the symbol is declared global
        with a global statement.)rX   r§   r   r'   s    r   Úis_declared_globalzSymbol.is_declared_global  s   € õ �D”L¥OÒ3Ñ4Ô4Ð4r   c                 ór   — t          | j        t          t          fv p| j        o| j        t          z  ¦  «        S )z.Return *True* if the symbol is local.
        )rX   r§   r   r   r©   r¦   r	   r'   s    r   Úis_localzSymbol.is_local  s>   € õ �D”L¥U­D MÐ1ð JØÔ+ÐH°´½yÑ0HñKô Kð 	Kr   c                 ó:   — t          | j        t          z  ¦  «        S )z2Return *True* if the symbol is annotated.
        )rX   r¦   r
   r'   s    r   Úis_annotatedzSymbol.is_annotated  r°   r   c                 ó<   — t          | j        t          k    ¦  «        S )zIReturn *True* if a referenced symbol is
        not assigned to.
        )rX   r§   r   r'   s    r   rœ   zSymbol.is_free  s   € õ �D”L¥DÒ(Ñ)Ô)Ð)r   c                 ó:   — t          | j        t          z  ¦  «        S )zQReturn *True* if the symbol is created from
        an import statement.
        )rX   r¦   r   r'   s    r   Úis_importedzSymbol.is_imported  s   € õ �D”L¥:Ñ-Ñ.Ô.Ð.r   c                 ó:   — t          | j        t          z  ¦  «        S )z)Return *True* if a symbol is assigned to.)rX   r¦   r   r'   s    r   Úis_assignedzSymbol.is_assigned  s   € å�D”L¥9Ñ,Ñ-Ô-Ð-r   c                 ó*   — 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.
        )rX   r¨   r'   s    r   Úis_namespacezSymbol.is_namespace!  s   € õ �DÔ%Ñ&Ô&Ð&r   c                 ó   — | j         S )z.Return a list of namespaces bound to this name)r¨   r'   s    r   Úget_namespaceszSymbol.get_namespaces.  s   € àÔ Ð r   c                 ó¸   — t          | j        ¦  «        dk    rt          d¦  «        ‚t          | j        ¦  «        dk    rt          d¦  «        ‚| j        d         S )z˜Return the single namespace bound to this name.

        Raises ValueError if the name is bound to multiple namespaces
        or no namespace.
        r   z#name is not bound to any namespacesrJ   z$name is bound to multiple namespaces)Úlenr¨   Ú
ValueErrorr'   s    r   Úget_namespacezSymbol.get_namespace2  s\   € õ ˆtÔ Ñ!Ô! QÒ&Ð&ÝÐBÑCÔCÐCÝ�Ô"Ñ#Ô# aÒ'Ð'ÝÐCÑDÔDÐDàÔ$ QÔ'Ð'r   r#   )r5   r6   r7   r)   rE   rS   r­   r¯   r²   r´   r¶   r¸   rº   rœ   r½   r¿   rÁ   rÃ   rÇ   r8   r   r   r   r   Û   s  € € € € € ð+ÀUð +ð +ð +ð +ð +ð4ð 4ð 4ðð ð ð
2ð 2ð 2ð.ð .ð .ð
Kð Kð Kð1ð 1ð 1ð5ð 5ð 5ð
Kð Kð Kð.ð .ð .ð
*ð *ð *ð/ð /ð /ð.ð .ð .ð'ð 'ð 'ð!ð !ð !ð(ð (ð (ð (ð (r   r   Ú__main__rJ   Úexec),Ú__doc__r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r$   Ú__all__r   r!   r   r   r   r   r   r5   ÚosÚsysÚopenÚargvÚfÚreadÚsrcÚpathÚsplitÚmodrc   ro   rk   ÚinfoÚprintr¸   rÁ   r8   r   r   ú<module>rØ      sý  ðØ 8Ð 8à Ð Ð Ð ð4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð 4ð €€€à
DÐ
DÐ
D€ð*ð *ð *ðð ð ð ð ñ ô ð ð$ %Ð$Ñ&Ô&€ði0ð i0ð i0ð i0ð i0ñ i0ô i0ð i0ðX3ð 3ð 3ð 3ð 3ˆ{ñ 3ô 3ð 3ðlð ð ð ð ˆKñ ô ð ðb(ð b(ð b(ð b(ð b(ñ b(ô b(ð b(ðH ˆzÒÐØ€N€N€N€N€N€N€NØ	ˆˆcŒh�qŒkÑ	Ô	ð ˜aØ�fŠf‰hŒhˆðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð à
ˆ(�3˜œŸš c¤h¨q¤kÑ2Ô2°1Ô5°vÑ
>Ô
>€CØ×$Ò$Ñ&Ô&ð :ð :ˆØ�zŠz˜%Ñ Ô ˆØˆˆd�D—M’M‘O”O T×%6Ò%6Ñ%8Ô%8Ñ9Ô9Ð9Ð9ð Ðð
:ð :s   Â%CÃC
ÃC
