Edit File: symtable.cpython-311.opt-1.pyc
� �����f�(����������������������������d�Z�ddlZddlmZmZmZmZmZmZmZm Z m Z mZmZm Z mZmZmZ�ddlZg�d�Zd��Z�G�d��d������������Z�e��������������Z�G�d��d ������������Z�G�d ��de������������Z�G�d��d e������������Z�G�d��d������������Zedk����r�ddlZddlZ�eej��������d���������������������5�Ze� ����������������������������������Z!ddd�������������n#�1�swxY�w�Y����ee!ej"���������#��������������������ej��������d���������������������d���������d������������Z$e$�%����������������������������������D�]JZ&e$�'��������������������e&������������Z(�e)e(e(�*����������������������������������e(�+������������������������������������������������IdS�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�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��� �//opt/alt/python311/lib64/python3.11/symtable.pyr���r������s(�������� �T�8�\� :� :�C��3��)�)�)�����c�������������������� �����e�Zd�Zd��Zd��Zd��ZdS�)�SymbolTableFactoryc������������������6�����t����������j����������������������|�_��������d�S��N)�weakref�WeakValueDictionary�_SymbolTableFactory__memo��selfs��� r����__init__zSymbolTableFactory.__init__���s�������1�3�3����r���c�����������������������|j���������t����������j��������k����rt����������||������������S�|j���������t����������j��������k����rt����������||������������S�t ����������||������������S�r#���)�typer���� TYPE_FUNCTIONr���� TYPE_CLASSr���r���)r(����tabler���s��� r����newzSymbolTableFactory.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__zSymbolTableFactory.__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�Zd�Zd��Zd��Zd��Zd��Zd��Zd��Zd��Z d��Z d ��Zd ��Zd��Z d��Zd ��Zd��ZdS�)r���c������������������0�����||�_���������||�_��������i�|�_��������d�S�r#���)�_table� _filename�_symbols)r(���� raw_tabler���s��� r���r)���zSymbolTable.__init__,���s���������!����� � � r���c������������������������|�j���������t����������k����rd}nd|�j���������j��������z��}|�j��������j��������dk����rd���������������������||�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__zSymbolTable.__repr__1���sw�������>�[�(�(��D�D��4�>�2�2�D��;��u�$�$�4�;�;�D�$�.�Q�Q�Q�4�;�;�D�<@�K�<L�<@�N�L��L�� Lr���c�����������������������|�j���������j��������t����������j��������k����rdS�|�j���������j��������t����������j��������k����rdS�|�j���������j��������t����������j��������k����rdS�dS�)zxReturn the type of the symbol table. The values returned are 'class', 'module' and 'function'. �module�function�classN)r;���r+���r����TYPE_MODULEr,���r-���r'���s��� r����get_typezSymbolTable.get_type>���sT��������;��y�4�4�4��8��;��y�6�6�6��:��;��y�3�3�3��7��4�3r���c�����������������������|�j���������j��������S�)z,Return an identifier for the table. )r;����idr'���s��� r����get_idzSymbolTable.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_namezSymbolTable.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_linenozSymbolTable.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_optimizedzSymbolTable.is_optimizeda���s��������D�K�$� �(?�?�@�@�@r���c������������������4�����t����������|�j��������j��������������������S�)zAReturn *True* if the block is a nested class or function.)rU���r;����nestedr'���s��� r���� is_nestedzSymbolTable.is_nestedg���s��������D�K�&�'�'�'r���c������������������4�����t����������|�j��������j��������������������S�)z:Return *True* if the block has nested namespaces. )rU���r;����childrenr'���s��� r����has_childrenzSymbolTable.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_identifierszSymbolTable.get_identifiersq���s��������{�"�'�'�)�)�)r���c������������������������|�j������������������������������|������������}|�T|�j��������j��������|���������}|����������������������|������������}|�j��������j��������dk����}t ����������||||�������������x}|�j���������|<���|S�)zLLookup a *name* in the table. Returns a *Symbol* instance. Nr�����module_scope)r=���r1���r;���r^����_SymbolTable__check_childrenrB���r���)r(���rB����sym�flags� namespacesrc���s��� r����lookupzSymbolTable.lookupv���s������� ��m����%�%���;��K�'��-�E��.�.�t�4�4�J� �K�,��5�L�(.�t�U�J�<H�)J��)J��)J�� J�C�$�-��%�� r���c������������������D���������fd���������������������������������������D���������������S�)zLReturn a list of *Symbol* instances for names in the table. c������������������:������g�|�]}�����������������������|��������������S�r8���)rh���)�.0�identr(���s��� �r���� <listcomp>z+SymbolTable.get_symbols.<locals>.<listcomp>����s%�������G�G�G�u����E�"�"�G�G�Gr���)r`���r'���s���`r����get_symbolszSymbolTable.get_symbols����s,��������H�G�G�G��0D�0D�0F�0F�G�G�G�Gr���c������������������8�����������fd���j���������j��������D���������������S�)Nc������������������P������g�|�]"}|j����������k����� t����������|�j����������������������#S�r8���)rB���r���r<���)rk����strB���r(���s��� ��r���rm���z0SymbolTable.__check_children.<locals>.<listcomp>����s8��������$��$��$���7�d�?�?�� ��D�N�3�3�"�?�?r����r;���r[���)r(���rB���s���``r����__check_childrenzSymbolTable.__check_children����s9��������$��$��$��$��$��+�.�$��$��$�� $r���c������������������4���������fd���j���������j��������D���������������S�)z3Return a list of the nested symbol tables. c������������������:������g�|�]}t����������|�j����������������������S�r8���)r���r<���)rk���rq���r(���s��� �r���rm���z,SymbolTable.get_children.<locals>.<listcomp>����s5��������0��0��0��� ��D�N�3�3��0��0��0r���rr���r'���s���`r����get_childrenzSymbolTable.get_children����s3�������0��0��0��0��+�.�0��0��0�� 0r���N)r5���r6���r7���r)���rE���rK���rN���rP���rS���rV���rY���r\���r`���rh���rn���rd���rv���r8���r���r���r���r���*���s�������������������� L��L��L� ?�� ?�� ?������ �� �� �"��"��"�A��A��A�(��(��(� *��*��*� *��*��*� �����H��H��H�$��$��$� 0��0��0��0��0r���r���c��������������������F�����e�Zd�ZdZdZdZdZdZd��Zd��Z d��Z d��Zd��Zd��Z dS�)r���Nc������������������b��������t�������������fd��������������������������������������D���������������������������S�)Nc��������������3����R����K����|�]!}���j���������j��������|����������������������|V����"d�S�r#���)r;���r^���)rk���rl���r(���� test_funcs��� ��r���� <genexpr>z-Function.__idents_matching.<locals>.<genexpr>����sO������������?��?�u�!� �$�+�"5�e�"<�=�=�?�U��?��?��?��?��?��?r���)�tupler`���)r(���rz���s���``r����__idents_matchingzFunction.__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_parameterszFunction.get_parameters����s-��������=� � �2�2�3I�3I�J�J�D�M��}�r���c������������������z������|�j����������-t����������t����������f��fd�}|����������������������|������������|�_���������|�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_localszFunction.get_locals����sA���������=� ��4�=�D�D�D�D�D�D� �2�2�4�8�8�D�M��}�r���c������������������z������|�j����������-t����������t����������f��fd�}|����������������������|������������|�_���������|�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_globalszFunction.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_nonlocalszFunction.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_freeszFunction.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�Zd�ZdZd��ZdS�)r���Nc������������������|�����|�j����������/i�}|�j��������j��������D�]}d||j��������<���� t ����������|������������|�_���������|�j���������S�)z9Return a tuple of methods declared in the class. N����)�_Class__methodsr;���r[���rB���r|���)r(����drq���s��� r����get_methodszClass.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�Zd�Zddd�d�Zd��Zd��Zd��Zd��Zd ��Zd ��Z d��Z d��Zd ��Zd��Z d��Zd��Zd��Zd��Zd��ZdS�)r���NFrb���c�����������������p�����||�_���������||�_��������|t����������z ��t����������z��|�_��������|pd|�_��������||�_��������d�S�)Nr8���)� _Symbol__name�_Symbol__flagsr���r����_Symbol__scope�_Symbol__namespaces�_Symbol__module_scope)r(���rB���rf���rg���rc���s��� r���r)���zSymbol.__init__����s<��������������*�j�8���&�,�"���*����r���c������������������6�����d����������������������|�j��������������������S�)Nz<symbol {0!r}>)rC���r����r'���s��� r���rE���zSymbol.__repr__����s�������&�&�t�{�3�3�3r���c�����������������������|�j���������S�)z#Return a name of a symbol. )r����r'���s��� r���rP���zSymbol.get_name����s��������{�r���c������������������D�����t����������|�j��������t����������j��������z��������������S�)zBReturn *True* if the symbol is used in its block. )rU���r����r���r���r'���s��� r���� is_referencedzSymbol.is_referenced����s��������D�L�9�=�0�1�1�1r���c������������������:�����t����������|�j��������t����������z��������������S�)z4Return *True* if the symbol is a parameter. )rU���r����r���r'���s��� r����is_parameterzSymbol.is_parameter�������������D�L�9�,�-�-�-r���c������������������r�����t����������|�j��������t����������t����������fv�p|�j��������o|�j��������t����������z��������������S�)z/Return *True* if the symbol is global. )rU���r����r���r���r����r����r ���r'���s��� r���� is_globalzSymbol.is_global����s?��������D�L�_�o�$F�F��J��+�H���y�0H�K��K�� Kr���c������������������:�����t����������|�j��������t����������z��������������S�)z(Return *True* if the symbol is nonlocal.)rU���r����r���r'���s��� r����is_nonlocalzSymbol.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.)rU���r����r���r'���s��� r����is_declared_globalzSymbol.is_declared_global��s��������D�L�O�3�4�4�4r���c������������������r�����t����������|�j��������t����������t����������fv�p|�j��������o|�j��������t����������z��������������S�)z.Return *True* if the symbol is local. )rU���r����r���r���r����r����r ���r'���s��� r����is_localzSymbol.is_local��s>��������D�L�U�D�M�1��J��+�H���y�0H�K��K�� Kr���c������������������:�����t����������|�j��������t����������z��������������S�)z2Return *True* if the symbol is annotated. )rU���r����r ���r'���s��� r����is_annotatedzSymbol.is_annotated��r����r���c������������������<�����t����������|�j��������t����������k����������������S�)zIReturn *True* if a referenced symbol is not assigned to. )rU���r����r ���r'���s��� r���r����zSymbol.is_free��s��������D�L�D�(�)�)�)r���c������������������:�����t����������|�j��������t����������z��������������S�)zQReturn *True* if the symbol is created from an import statement. )rU���r����r���r'���s��� r����is_importedzSymbol.is_imported��s��������D�L�:�-�.�.�.r���c������������������:�����t����������|�j��������t����������z��������������S�)z)Return *True* if a symbol is assigned to.)rU���r����r���r'���s��� r����is_assignedzSymbol.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. )rU���r����r'���s��� r����is_namespacezSymbol.is_namespace!��s��������D�%�&�&�&r���c�����������������������|�j���������S�)z.Return a list of namespaces bound to this name)r����r'���s��� r����get_namespaceszSymbol.get_namespaces.��s������� � r���c�����������������������t����������|�j��������������������dk����rt����������d�������������t����������|�j��������������������dk����rt����������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 namespacesr����z$name is bound to multiple namespaces)�lenr����� ValueErrorr'���s��� r���� get_namespacezSymbol.get_namespace2��s\��������t� �!�!�Q�&�&��B�C�C�C� ��"� #� #�a� '� '��C�D�D�D��$�Q�'�'r���r#���)r5���r6���r7���r)���rE���rP���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__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���r5����os�sys�open�argv�f�read�src�path�split�modr`���rl���rh����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��*��*��*����������������$�%�$�&�&��i0��i0��i0��i0��i0��i0��i0��i0�X3��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