a �DOgZP� @sddlZddlZddlZddlZddlTddlmZgd�eZ[ejejej e e e fZ edZdedfedfed ffZed Zd Zd d �ZdUddd�dd�ZdVdd�dd�Zddddddddddd� Zdd �Zd!d"�Zd#d$�Zd%d&�Zdd�d'd(�Ze�d)d*�Z d+e j!_"d,e j_"d-e j#_"d.e j$_"d/e j%_"d0e j&_"d1e j'_"d2e j(_"d3Z)d4Z*Gd5d6�d6e �Z+dd7�d8d9�Z,d:d;�Z-dd?�Z/dXdd�dAdB�Z0ddd�dCdD�Z1dYdddE�dFdG�Z2dHdI�Z3e0Z4dJdK�Z5dLdM�Z6dNdO�Z7GdPdQ�dQ�Z8dRdS�Z9e:dTk�r�e9�dS)Z�N)�*)�__all__) � code_info�dis� disassemble�distb�disco�findlinestarts� findlabels� show_code�get_instructions� Instruction�Bytecode� FORMAT_VALUE)N��str�repr�ascii� MAKE_FUNCTION)�defaults� kwdefaults� annotationsZclosurecCs4zt||d�}Wnty.t||d�}Yn0|S)N�eval�exec)�compile� SyntaxError)�source�name�c�r�/usr/lib64/python3.9/dis.py� _try_compiles  r!��file�depthc Csj|durt|d�dSt|d�r&|j}t|d�r8|j}n4t|d�rJ|j}n"t|d�r\|j}nt|d�rl|j}t|d�r�t|j� ��}|D]r\}}t |t �r�t d||d�zt |||d �Wn2ty�}zt d ||d�WYd}~n d}~00t |d�q�nht|d ��rt|||d �nLt |ttf��r8t||d�n.t |t��rTt|||d �ntd t|�j��dS) N�r#�__func__�__code__�gi_code�ag_code�cr_code�__dict__zDisassembly of %s:r"zSorry:�co_code�(don't know how to disassemble %s objects)r�hasattrr&r'r(r)r*�sortedr+�items� isinstance� _have_code�printr� TypeError�_disassemble_recursive�bytes� bytearray�_disassemble_bytesr�_disassemble_str�type�__name__)�xr#r$r0rZx1�msgrrr r+s@          $  �rr%cCsV|dur>z tj}Wnty.td�d�Yn0|jr>|j}q0t|jj|j|d�dS)Nz no last traceback to disassembler%) �sys�last_traceback�AttributeError� RuntimeError�tb_nextr�tb_frame�f_code�tb_lasti)�tbr#rrr rXs  rZ OPTIMIZEDZ NEWLOCALSZVARARGSZ VARKEYWORDSZNESTEDZ GENERATORZNOFREEZ COROUTINEZITERABLE_COROUTINEZASYNC_GENERATOR) ������ �@��icCs`g}td�D]:}d|>}||@r |�t�|t|���||N}|s qVq |�t|��d�|�S)NrLrG�, )�range�append�COMPILER_FLAG_NAMES�get�hex�join)�flags�names�i�flagrrr � pretty_flagsrs r[cCs�t|d�r|j}t|d�r"|j}n4t|d�r4|j}n"t|d�rF|j}nt|d�rV|j}t|t�rjt|d�}t|d�rx|St dt |�j ��dS) Nr&r'r(r)r*z r,r-) r.r&r'r(r)r*r1rr!r4r:r;�r<rrr �_get_code_object�s"        �r]cCs tt|��S�N)�_format_code_infor]r\rrr r�srcCs�g}|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�dt|j ��|j r�|�d �t |j �D]}|�d |�q�|j r�|�d �t |j �D]}|�d |�q�|j �r|�d �t |j �D]}|�d |��q|j�rH|�d�t |j�D]}|�d |��q2|j�rz|�d�t |j�D]}|�d |��qdd�|�S)NzName: %szFilename: %szArgument count: %szPositional-only arguments: %szKw-only arguments: %szNumber of locals: %szStack size: %szFlags: %sz Constants:z%4d: %rzNames:z%4d: %szVariable names:zFree variables:zCell variables:� )rR�co_name� co_filename� co_argcount�co_posonlyargcount�co_kwonlyargcount� co_nlocals� co_stacksizer[�co_flags� co_consts� enumerate�co_names� co_varnames� co_freevars� co_cellvarsrV)�co�linesZi_cZi_nrrr r_�s<     r_cCstt|�|d�dS�Nr%)r3r)ror#rrr r �sr � _InstructionzBopname opcode arg argval argrepr offset starts_line is_jump_targetz!Human readable name for operationzNumeric code for operationz6Numeric argument to operation (if any), otherwise Nonez4Resolved arg value (if known), otherwise same as argz0Human readable description of operation argumentz1Start index of operation within bytecode sequencez4Line started by this opcode (if any), otherwise Nonez1True if other code jumps to here, otherwise False��c@seZdZddd�ZdS)r �FrIcCs�g}|r:|jdur,d|}|�||j�n|�d|�|rJ|�d�n |�d�|jrf|�d�n |�d�|�t|j��|��|�|j�t��|j dur�|�t|j ��t ��|j r�|�d|j d�d� |�� �S) Nz%%%dd� z-->z z>>z �(�))� starts_linerR�is_jump_targetr�offset�rjust�opname�ljust� _OPNAME_WIDTH�arg� _OPARG_WIDTH�argreprrV�rstrip)�self� lineno_widthZmark_as_current� offset_width�fieldsZ lineno_fmtrrr � _disassemble�s&      zInstruction._disassembleN)ruFrI)r;� __module__� __qualname__r�rrrr r �sr )� first_linecCsTt|�}|j|j}tt|��}|dur4||j}nd}t|j|j|j |j |||�S�Nr) r]rnrm�dictr �co_firstlineno�_get_instructions_bytesr,rlrkri)r<r�ro� cell_names� linestarts� line_offsetrrr r s    �r cCs |}|dur||}|t|�fSr^�r)Z const_indexZ const_list�argvalrrr �_get_const_infosr�cCs*|}|dur||}|}nt|�}||fSr^r�)Z name_indexZ name_listr�r�rrr �_get_name_info's r�c #s�t|�}d}t|�D�]r\} } �|durD|�| d�}|durD||7}| |v} d} d} �du�rl�} | tvrzt�|�\} } n�| tvr�t�|�\} } n�| tvr�| d�} dt| �} n�| t vr�t�|�\} } n�| t vr�t �} | } n�| t vr�t�|�\} } nr| t k�rFt�d@\} } | t�d@�f} | d�rl| �r<| d7} | d7} n&| tk�rld��fd d �tt�D��} tt| | �| | | || �VqdS) NrrHzto rurIrGrPz with formatc3s"|]\}}�d|>@r|VqdS)rGNr)�.0rY�s�r�rr � gs  �z*_get_instructions_bytes..)r �_unpack_opargsrTZhasconstr�Zhasnamer��hasjrelrZhaslocalZ hascompareZcmp_opZhasfreer�FORMAT_VALUE_CONVERTERS�boolrrVrj�MAKE_FUNCTION_FLAGSr r})�code�varnamesrX� constants�cellsr�r��labelsryr{�oprzr�r�rr�r r�7sN         �r������c Cs<|j|j}tt|��}t|j||j|j|j|||d�dSrq) rnrmr�r r8r,rlrkri)ro�lastir#r�r�rrr rms    �rcCspt||d�|dus|dkrl|dur,|d}|jD]8}t|d�r2t|d�td|f|d�t|||d�q2dS)Nr%rrGr,zDisassembly of %r:r")rrir.r3r5)ror#r$r<rrr r5ts    r5)r#r�c Cs�|du} | r8t|���|} | dkr2tt| ��} q)r5r!)r�kwargsrrr r9�sr9ccsdd}tdt|�d�D]J}||}|tkrN||d|B}|tkrH|d>nd}nd}|||fVqdS)NrrHrGrJ)rQr�Z HAVE_ARGUMENTZ EXTENDED_ARG)r�Z extended_argrYr�r�rrr r��sr�cCs\g}t|�D]J\}}}|dur |tvr4|d|}n|tvr |}nq ||vr |�|�q |S)NrH)r�r�ZhasjabsrR)r�r�r{r�r�Zlabelrrr r �s r c cs�|jddd�}|jddd�}t|j�}d}|j}d}t||�D]P\}}|rz||krd||fV|}||7}||krzdS|dkr�|d8}||7}qB||kr�||fVdS)NrrHrGrNrO)� co_lnotabr�r,r��zip) r�Zbyte_incrementsZline_incrementsZ bytecode_lenZ lastlineno�lineno�addrZ byte_incrZ line_incrrrr r �s&   r c@sHeZdZddd�dd�Zdd�Zdd�Zed d ��Zd d �Zd d�Z dS)rN)r��current_offsetcCsdt|�|_}|dur&|j|_d|_n||_||j|_|j|j|_tt |��|_ ||_ ||_ dSr�) r]�codeobjr�r�� _line_offsetrnrm� _cell_namesr�r � _linestarts�_original_objectr�)r�r<r�r�rorrr �__init__�s zBytecode.__init__c Cs*|j}t|j|j|j|j|j|j|jd�S)Nr�) r�r�r,rlrkrir�r�r�)r�rorrr �__iter__�s �zBytecode.__iter__cCsd�|jj|j�S)Nz{}({!r}))�format� __class__r;r��r�rrr �__repr__�s �zBytecode.__repr__cCs |jr|j}q||jj|jd�S)N)r�)rBrCrDrE)�clsrFrrr �from_traceback�szBytecode.from_tracebackcCs t|j�Sr^)r_r�r�rrr �infosz Bytecode.infoc Csx|j}|jdur|j}nd}t���@}t|j|j|j|j|j |j |j ||d� |� �Wd�S1sj0YdS)Nr�)r�rXr�r�r�r�r#r�) r�r��io�StringIOr8r,rlrkrir�r�r��getvalue)r�ror{�outputrrr r s   �z Bytecode.dis) r;r�r�r�r�r�� classmethodr�r�rrrrr r�s  rcCszddl}|��}|jd|�d�ddd�|��}|j�}|��}Wd�n1sT0Yt||jjd�}t |�dS)Nr�infile�rb�?�-)r:�nargs�defaultr) �argparse�ArgumentParser� add_argument�FileType� parse_argsr��readrrr)r��parser�argsr�rr�rrr �_tests&r��__main__)N)N)NNNNNr)r�)r�NNNNN);r>�types� collectionsr�ZopcoderZ _opcodes_all� MethodType� FunctionType�CodeTyper�� staticmethodr:r2Zopmaprrrrr�rr�r!rrrSr[r]rr_r � namedtuplerrr}�__doc__r�r�r�r{ryrzrr�r r r�r�r�rr5r8r9rr�r r rr�r;rrrr �s� � �� -�  �4 � 6 ��  =