%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/test/support/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/test/support/__pycache__/bytecode_helper.cpython-312.pyc

�

���f�����dZddlZddlZddlZddlmZmZmZe�Z	Gd�dej�ZGd�dej�ZGd�d	e�Z
Gd
�de�ZGd�d
e�Zy)zGbytecode_helper - support tools for testing correct bytecode generation�N)�compiler_codegen�optimize_cfg�assemble_code_objectc�*�eZdZdZd�Zefd�Zefd�Zy)�BytecodeTestCasez1Custom assertion methods for inspecting bytecode.c�x�tj�}tj||��|j�S)N)�file)�io�StringIO�dis�getvalue)�self�co�ss   �3/usr/lib/python3.12/test/support/bytecode_helper.py�get_disassembly_as_stringz*BytecodeTestCase.get_disassembly_as_string
s'���K�K�M���������z�z�|��c�F�|j|tj�tj|�D]-}|j|k(s�|t
us|j|k(s�+|cS|j|�}|t
ur|�d|��}n
d}||||fz}|j|�y)zAReturns instr if opname is found, otherwise throws AssertionErrorz not found in bytecode:
z!(%s,%r) not found in bytecode:
%sN)	�assertInr�opmap�get_instructions�opname�_UNSPECIFIED�argvalr�fail�r�xrr�instr�disassembly�msgs       r�assertInBytecodez!BytecodeTestCase.assertInBytecodes����
�
�f�c�i�i�(��)�)�!�,�	!�E��|�|�v�%��\�)�U�\�\�V�-C� �L�	!��4�4�Q�7���\�!�5;�[�I�C�6�C�����5�5�C��	�	�#�rc�R�|j|tj�tj|�D]o}|j|k(s�|j|�}|tur|�d|��}|j|��E|j|k(s�Ud}||||fz}|j|��qy)z(Throws AssertionError if opname is foundz occurs in bytecode:
z(%s,%r) occurs in bytecode:
%sN)	rrrrrrrrrrs       r�assertNotInBytecodez$BytecodeTestCase.assertNotInBytecode!s����
�
�f�c�i�i�(��)�)�!�,�		#�E��|�|�v�%�"�<�<�Q�?���\�)�:@�+�N�C��I�I�c�N��\�\�V�+�;�C����� =�=�C��I�I�c�N�		#rN)�__name__�
__module__�__qualname__�__doc__rrr!r#�rrrr
s��;��
2>�
�5A�#rrc���eZdZeej
�Zeejejzejz�Z
eje
�ZGd�d�Z
d�Zd�Zd�Zd�Zy)�CompilationStepTestCasec��eZdZy)�CompilationStepTestCase.LabelN)r$r%r&r(rr�Labelr,5s��rr-c��|j|t�|j|t�|j|�}|j|�}|jt	|�t	|��t||�D]�\}}t
|t�r|j||��)|j|t�|j|t�t	|�t	|�kDr|dt	|�}|j||���y�N)	�assertIsInstance�list�normalize_insts�assertEqual�len�zip�
isinstance�int�tuple)r�actual_�	expected_�actual�expected�act�exps       r�assertInstructionsMatchz/CompilationStepTestCase.assertInstructionsMatch8s���
	
���g�t�,����i��.��%�%�g�.���'�'�	�2������V��c�(�m�4��F�H�-�		'�H�C���#�s�#�� � ��c�*���!�!�#�u�-��!�!�#�u�-��3�x�#�c�(�"��)�3�s�8�n�����S�#�&�		'rc��d}g}|D]T}t||jtf�sJ�t||j�r||_�?|dz
}|j	|��V|S)Nr�)r6r-r8�value�append)r�insts�idx�res�items     r�resolveAndRemoveLabelsz.CompilationStepTestCase.resolveAndRemoveLabelsPse�������	!�D��d�T�Z�Z��$7�8�8�8��$��
�
�+� ��
��q����
�
�4� �
	!��
rc�d�|j|�}g}|D]�}t|t�sJ�|^}}}tjj||�}t||j�r
|j}n||jvr|nd}tj|}|j||g|�����|S)zN Map labels to instruction index.
            Map opcodes to opnames.
        N)rHr6r8rr�getr-rB�HAS_ARGrrC)rrDrFrG�opcode�oparg�loc�args        rr2z'CompilationStepTestCase.normalize_insts]s����+�+�E�2�����		,�D��d�E�*�*�*�"&��F�E�C��Y�Y�]�]�6�6�2�F��%����,��k�k��%����5�e�4���Z�Z��'�F��J�J���*�c�*�+�		,��
rc���g}|D]h}t|t�sJ�t|�}tj|d}|d}|dddgdt|�z
zz}|j
||g|����j|S)NrrA�����)r6r8r1rrr4rC)rrDrFrG�instrLrMrNs        r�complete_insts_infoz+CompilationStepTestCase.complete_insts_infoos������	.�D��d�E�*�*�*���:�D��Y�Y�t�A�w�'�F���G�E��q�r�(�b�T�Q��T��]�3�3�C��J�J���,��,�-�
	.��
rN)r$r%r&�setr�hasargrK�hasjrel�hasjabs�hasexc�
HAS_TARGET�union�HAS_ARG_OR_TARGETr-r?rHr2rUr(rrr*r*/s\���#�*�*�o�G��S�[�[�3�;�;�.����;�<�J��
�
�j�1��
�
�'�0��$
rr*c��eZdZd�Zy)�CodegenTestCasec�&�t|dd�\}}|S)Nz
my_file.pyr)r)r�astrD�_s    r�
generate_codezCodegenTestCase.generate_code~s��#�C��q�9���q��rN)r$r%r&rcr(rrr_r_|s��rr_c��eZdZdd�Zy)�CfgOptimizationTestCasec�h�|j|�}|j|�}t|||�}||fSr/)r2rUr)rrD�consts�nlocalss    r�
get_optimizedz%CfgOptimizationTestCase.get_optimized�s:���$�$�U�+���(�(��/���U�F�G�4���f�}�rN)r)r$r%r&rir(rrrere�s��rrec��eZdZd�Zy)�AssemblerTestCasec� �t|||�}|Sr/)r)r�filenamerD�metadatars     r�get_code_objectz!AssemblerTestCase.get_code_object�s��
!�(�E�8�
<���	rN)r$r%r&ror(rrrkrk�s��rrk)r'�unittestrr
�_testinternalcapirrr�objectr�TestCaserr*r_rerkr(rr�<module>rtsm��M��
�	�R�R��x��##�x�(�(�##�JJ�h�/�/�J�Z�-���5���/�r

Zerion Mini Shell 1.0