ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     o
    0i'                     @   sX  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d ZG dd dZe ZG d	d
 d
ZG dd deZG dd deZG dd dZedkrddlZddlZeejd Ze  Z!W d   n1 s~w   Y  ee!ej"#ejd d dZ$e$% D ]Z&e$'e&Z(e)e(e(* e(+  qd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                 C   s   t | ||}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filenameZcompile_typetop r   //opt/alt/python310/lib64/python3.10/symtable.pyr      s   
r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )SymbolTableFactoryc                 C   s   t  | _d S N)weakrefZWeakValueDictionary_SymbolTableFactory__memoselfr   r   r   __init__   s   zSymbolTableFactory.__init__c                 C   s6   |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   r   r   r   new   s
   


zSymbolTableFactory.newc                 C   s8   ||f}| j |d }|d u r| || }| j |< |S r   )r    getr(   )r"   r'   r   keyobjr   r   r   __call__    s
   zSymbolTableFactory.__call__N)__name__
__module____qualname__r#   r(   r,   r   r   r   r   r      s    r   c                   @   s|   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )r   c                 C   s   || _ || _i | _d S r   )_table	_filename_symbols)r"   Z	raw_tabler   r   r   r   r#   ,   s   
zSymbolTable.__init__c                 C   sJ   | j tkrd}nd| j j }| 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   r-   r0   nameformatr1   )r"   kindr   r   r   __repr__1   s   
zSymbolTable.__repr__c                 C   sX   | 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 )zwReturn the type of the symbol table.

        The values retuned are 'class', 'module' and
        'function'.
        moduleZfunctionclass)         zunexpected type: {0}N)r0   r$   r   ZTYPE_MODULEr%   r&   r6   r!   r   r   r   get_type>   s   zSymbolTable.get_typec                 C      | j jS )z,Return an identifier for the table.
        )r0   idr!   r   r   r   get_idM   s   zSymbolTable.get_idc                 C   r?   )zReturn 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.
        )r0   r5   r!   r   r   r   get_nameR   s   zSymbolTable.get_namec                 C   r?   )zPReturn the number of the first line in the
        block for the table.
        )r0   linenor!   r   r   r   
get_lineno[   s   zSymbolTable.get_linenoc                 C   s   t | jjtjkS )zJReturn *True* if the locals in the table
        are optimizable.
        )boolr0   r$   r   r%   r!   r   r   r   is_optimizeda   s   zSymbolTable.is_optimizedc                 C      t | jjS )zAReturn *True* if the block is a nested class
        or function.)rE   r0   nestedr!   r   r   r   	is_nestedg      zSymbolTable.is_nestedc                 C   rG   )z:Return *True* if the block has nested namespaces.
        )rE   r0   childrenr!   r   r   r   has_childrenl   rJ   zSymbolTable.has_childrenc                 C   s   | j j S )zKReturn a view object containing the names of symbols in the table.
        )r0   symbolskeysr!   r   r   r   get_identifiersq   rJ   zSymbolTable.get_identifiersc                 C   sT   | j |}|du r(| jj| }| |}| jjdk}t||||d }| j |< |S )zLLookup a *name* in the table.

        Returns a *Symbol* instance.
        Nr   module_scope)r2   r)   r0   rM   _SymbolTable__check_childrenr5   r   )r"   r5   Zsymflags
namespacesrQ   r   r   r   lookupv   s   
zSymbolTable.lookupc                    s    fdd   D S )zLReturn a list of *Symbol* instances for
        names in the table.
        c                    s   g | ]}  |qS r   )rU   .0identr!   r   r   
<listcomp>   s    z+SymbolTable.get_symbols.<locals>.<listcomp>)rO   r!   r   r!   r   get_symbols   s   zSymbolTable.get_symbolsc                    s    fddj jD S )Nc                    s"   g | ]}|j  krt|jqS r   )r5   r   r1   rW   str5   r"   r   r   rY      s
    

z0SymbolTable.__check_children.<locals>.<listcomp>r0   rK   )r"   r5   r   r]   r   Z__check_children   s   zSymbolTable.__check_childrenc                    s    fdd j jD S )z3Return a list of the nested symbol tables.
        c                    s   g | ]}t | jqS r   )r   r1   r[   r!   r   r   rY      s    z,SymbolTable.get_children.<locals>.<listcomp>r^   r!   r   r!   r   get_children   s   
zSymbolTable.get_childrenN)r-   r.   r/   r#   r8   r>   rA   rB   rD   rF   rI   rL   rO   rU   rZ   rR   r_   r   r   r   r   r   *   s    	r   c                   @   sP   e Zd ZdZdZdZdZdZdd Zdd Z	dd Z
dd	 Zd
d Zdd ZdS )r   Nc                    s   t  fdd  D S )Nc                 3   s$    | ]} j j| r|V  qd S r   )r0   rM   rV   r"   Z	test_funcr   r   	<genexpr>   s    z-Function.__idents_matching.<locals>.<genexpr>)tuplerO   r`   r   r`   r   Z__idents_matching   s   zFunction.__idents_matchingc                 C       | j du r| dd | _ | j S )z6Return a tuple of parameters to the function.
        Nc                 S      | t @ S r   )r   xr   r   r   <lambda>       z)Function.get_parameters.<locals>.<lambda>)_Function__params_Function__idents_matchingr!   r   r   r   get_parameters      
zFunction.get_parametersc                    0   | j du rttf  fdd}| || _ | j S )z2Return a tuple of locals in the function.
        Nc                       | t ? t@  v S r   r
   r   re   Zlocsr   r   rg          z%Function.get_locals.<locals>.<lambda>)_Function__localsr   r   rj   r"   testr   rp   r   
get_locals   
   
zFunction.get_localsc                    rm   )z3Return a tuple of globals in the function.
        Nc                    rn   r   ro   re   Zglobr   r   rg      rq   z&Function.get_globals.<locals>.<lambda>)_Function__globalsr   r   rj   rs   r   rw   r   get_globals   rv   zFunction.get_globalsc                 C   rc   )z5Return a tuple of nonlocals in the function.
        Nc                 S   rd   r   )r   re   r   r   r   rg      rh   z(Function.get_nonlocals.<locals>.<lambda>)_Function__nonlocalsrj   r!   r   r   r   get_nonlocals   rl   zFunction.get_nonlocalsc                 C   s$   | j du rdd }| || _ | j S )z:Return a tuple of free variables in the function.
        Nc                 S   s   | t ? t@ tkS r   )r
   r   r   re   r   r   r   rg      rq   z$Function.get_frees.<locals>.<lambda>)_Function__freesrj   )r"   is_freer   r   r   	get_frees   s   
zFunction.get_frees)r-   r.   r/   ri   rr   r|   rx   rz   rj   rk   ru   ry   r{   r~   r   r   r   r   r      s    		r   c                   @   s   e Zd ZdZdd ZdS )r   Nc                 C   s6   | j du ri }| jjD ]}d||j< qt|| _ | j S )z9Return a tuple of methods declared in the class.
        Nr;   )_Class__methodsr0   rK   r5   rb   )r"   dr\   r   r   r   get_methods   s   

zClass.get_methods)r-   r.   r/   r   r   r   r   r   r   r      s    r   c                   @   s   e Zd Zd$ddddZdd Zdd	 Zd
d Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# ZdS )%r   NFrP   c                C   s.   || _ || _|t? t@ | _|pd| _|| _d S )Nr   )_Symbol__name_Symbol__flagsr
   r   _Symbol__scope_Symbol__namespaces_Symbol__module_scope)r"   r5   rS   rT   rQ   r   r   r   r#      s
   

zSymbol.__init__c                 C   s   d | jS )Nz<symbol {0!r}>)r6   r   r!   r   r   r   r8      s   zSymbol.__repr__c                 C      | j S )z#Return a name of a symbol.
        )r   r!   r   r   r   rB      s   zSymbol.get_namec                 C   s   t | jtj@ S )zBReturn *True* if the symbol is used in
        its block.
        )rE   r   r   r   r!   r   r   r   is_referenced   s   zSymbol.is_referencedc                 C      t | jt@ S )z4Return *True* if the symbol is a parameter.
        )rE   r   r   r!   r   r   r   is_parameter      zSymbol.is_parameterc                 C   "   t | jttfv p| jo| jt@ S )z0Return *True* if the sysmbol is global.
        )rE   r   r   r   r   r   r   r!   r   r   r   	is_global      zSymbol.is_globalc                 C   r   )z(Return *True* if the symbol is nonlocal.)rE   r   r   r!   r   r   r   is_nonlocal      zSymbol.is_nonlocalc                 C      t | jtkS )zOReturn *True* if the symbol is declared global
        with a global statement.)rE   r   r   r!   r   r   r   is_declared_global  r   zSymbol.is_declared_globalc                 C   r   )z.Return *True* if the symbol is local.
        )rE   r   r   r   r   r   r   r!   r   r   r   is_local  r   zSymbol.is_localc                 C   r   )z2Return *True* if the symbol is annotated.
        )rE   r   r	   r!   r   r   r   is_annotated  r   zSymbol.is_annotatedc                 C   r   )zIReturn *True* if a referenced symbol is
        not assigned to.
        )rE   r   r   r!   r   r   r   r}        zSymbol.is_freec                 C   r   )zQReturn *True* if the symbol is created from
        an import statement.
        )rE   r   r   r!   r   r   r   is_imported  r   zSymbol.is_importedc                 C   r   )z)Return *True* if a symbol is assigned to.)rE   r   r   r!   r   r   r   is_assigned  r   zSymbol.is_assignedc                 C   s
   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.
        )rE   r   r!   r   r   r   is_namespace!  s   
zSymbol.is_namespacec                 C   r   )z.Return a list of namespaces bound to this name)r   r!   r   r   r   get_namespaces.  s   zSymbol.get_namespacesc                 C   s    t | jdkrtd| jd S )zReturn 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!   r   r   r   get_namespace2  s   
zSymbol.get_namespacer   )r-   r.   r/   r#   r8   rB   r   r   r   r   r   r   r   r}   r   r   r   r   r   r   r   r   r   r      s"    r   __main__r;   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   r-   ossysopenargvfreadsrcpathsplitmodrO   rX   rU   infoprintr   r   r   r   r   r   <module>   s.    D	l6`

