Current Path : /lib/python3.10/__pycache__/ |
Current File : //lib/python3.10/__pycache__/dis.cpython-310.pyc |
o �*�g4N�@sdZddlZddlZddlZddlZddlTddlmZgd�eZ[ejej ej eee fZedZdedfed fed ffZedZdZd d�ZdVddd�dd�ZdVdd�dd�Zddddddddddd� Zd d!�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$_d0e!j%_d1e!j&_d2e!j'_d3e!j(_d4Z)d5Z*Gd6d7�d7e!�Z+dd8�d9d:�Z,d;d<�Z-d=d>�Z. dWd?d@�Z/dXdd�dBdC�Z0ddd�dDdE�Z1 dYdddF�dGdH�Z2dIdJ�Z3e0Z4dKdL�Z5dMdN�Z6dOdP�Z7GdQdR�dR�Z8dSdT�Z9e:dUk�re9�dSdS)Zz0Disassembler of Python byte code into mnemonics.�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�annotations�closurecCs4z t||d�}W|Styt||d�}Y|Sw)z�Attempts to compile the given source, first as an expression and then as a statement if the first approach fails. Utility function to accept strings in functions that otherwise expect code objects �eval�exec)�compile�SyntaxError)�source�name�c�r �/usr/lib/python3.10/dis.py�_try_compiles��r"��file�depthcCsh|durt|d�dSt|d�r|j}t|d�r|j}nt|d�r%|j}nt|d�r.|j}nt|d�r6|j}t|d�r�t|j� ��}|D]9\}}t |t�r}td ||d�z t |||d �Wntyw}z td||d�WYd}~nd}~wwt|d�qDdSt|d�r�t|||d �dSt |ttf�r�t||d�dSt |t�r�t|||d �dStd t|�j��)a0Disassemble classes, methods, functions, and other compiled objects. With no argument, disassemble the last traceback. Compiled objects currently include generator objects, async generator objects, and coroutine objects, all of which store their code object in a special attribute. 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%r1r�x1�msgr r r!r+sH �� �� �rr&cCsV|durztj}Wntytd�d�w|jr|j}|jst|jj|j|d�dS)z2Disassemble a traceback (default: last traceback).Nz no last traceback to disassembler&) �sys�last_traceback�AttributeError�RuntimeError�tb_nextr�tb_frame�f_code�tb_lasti)�tbr$r r r!rXs �r� OPTIMIZED� NEWLOCALS�VARARGS�VARKEYWORDS�NESTED� GENERATOR�NOFREE� COROUTINE�ITERABLE_COROUTINE�ASYNC_GENERATOR) ������ �@��icCs`g}td�D]}d|>}||@r#|�t�|t|���||N}|s#nq|�t|��d�|�S)z+Return pretty representation of code flags.rXrS�, )�range�append�COMPILER_FLAG_NAMES�get�hex�join)�flags�names�i�flagr r r!�pretty_flagsrs� rgcCs�t|d�r|j}t|d�r|j}nt|d�r|j}nt|d�r#|j}nt|d�r+|j}t|t�r5t|d�}t|d�r<|St dt |�j��) zDHelper to handle methods, compiled or raw code objects, and strings.r'r(r)r*r+z <disassembly>r-r.)r/r'r(r)r*r+r2rr"r5r;r<�r=r r r!�_get_code_object�s" �ricCstt|��S)z1Formatted details of methods, functions, or code.)�_format_code_inforirhr r r!r�srcCsxg}|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�d|j�|�dt|j ��|j r[|�d �t|j �D] }|�d |�qQ|jrr|�d�t|j�D] }|�d|�qh|j r�|�d �t|j �D] }|�d|�q|jr�|�d�t|j�D] }|�d|�q�|jr�|�d�t|j�D] }|�d|�q�d�|�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:� )r^�co_name�co_filename�co_argcount�co_posonlyargcount�co_kwonlyargcount� co_nlocals�co_stacksizerg�co_flags� co_consts� enumerate�co_names�co_varnames�co_freevars�co_cellvarsrb)�co�lines�i_c�i_nr r r!rj�s< rjcCstt|�|d�dS)z}Print details of methods, functions, or code to *file*. If *file* is not provided, the output is printed on stdout. r&N)r4r)rzr$r r r!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@seZdZdZddd�ZdS) r aKDetails for a bytecode operation Defined fields: opname - human readable name for operation opcode - numeric code for operation arg - numeric argument to operation (if any), otherwise None argval - resolved arg value (if known), otherwise same as arg argrepr - human readable description of operation argument offset - start index of operation within bytecode sequence starts_line - line started by this opcode (if any), otherwise None is_jump_target - True if other code jumps to here, otherwise False �FrUcCs�g}|r|jdurd|}|�||j�n|�d|�|r%|�d�n|�d�|jr3|�d�n|�d�|�t|j��|��|�|j�t��|j duri|�t|j ��t ��|jri|�d|jd �d�|�� �S) a%Format instruction details for inclusion in disassembly output *lineno_width* sets the width of the line number field (0 omits it) *mark_as_current* inserts a '-->' marker arrow as part of the line *offset_width* sets the width of the instruction offset field Nz%%%dd� z-->z z>>z �(�))�starts_liner^�is_jump_targetr�offset�rjust�opname�ljust� _OPNAME_WIDTH�arg�_OPARG_WIDTH�argreprrb�rstrip)�self�lineno_width�mark_as_current�offset_width�fields� lineno_fmtr r r!�_disassemble�s& zInstruction._disassembleN)r�FrU)r<� __module__�__qualname__�__doc__r�r r r r!r �s r )� first_linecCsTt|�}|j|j}tt|��}|dur||j}nd}t|j|j|j |j |||�S)a�Iterator for the opcodes in methods, functions or code Generates a series of Instruction named tuples giving the details of each operations in the supplied code. If *first_line* is not None, it indicates the line number that should be reported for the first source line in the disassembled code. Otherwise, the source line information (if any) is taken directly from the disassembled code object. Nr)riryrx�dictr �co_firstlineno�_get_instructions_bytesr-rwrvrt)r=r�rz� cell_names� linestarts�line_offsetr r r!rs�rcCs |}|dur ||}|t|�fS)z�Helper to get optional details about const references Returns the dereferenced constant and its repr if the constant list is defined. Otherwise returns the constant index and its repr(). N�r)�const_index� const_list�argvalr r r!�_get_const_infosr�cCs0|}|dur||}|}||fSt|�}||fS)z�Helper to get optional details about named references Returns the dereferenced name as both value and repr if the name list is defined. Otherwise returns the name index and its repr(). Nr�)� name_index� name_listr�r�r r r!�_get_name_info's�r�c #s��t|�}d}t|�D]�\} } �|dur"|�| d�}|dur"||7}| |v}d}d} �dur}| tvr<t�|�\}} n�| tvrHt�|�\}} nz| tvrW�d}dt|�} nk| t vrj| d�d}dt|�} nX| t vrvt�|�\}} nL| tvr�t�}|} nA| t vr�t�|�\}} n5| tkr�t�d@\}} |t�d@�f}|dr�| r�| d7} | d 7} n| tkr�d��fd d�tt�D��} tt| | �|| | ||�VqdS)a&Iterate over the instructions in a bytecode string. Generates a sequence of Instruction namedtuples giving the details of each opcode. Additional information about the code's runtime environment (e.g. variable names, constants) can be specified using optional arguments. NrrTzto r�rUrSr\zwith formatc3s$�|] \}}�d|>@r|VqdS)rSNr )�.0re�s�r�r r!� <genexpr>js� �z*_get_instructions_bytes.<locals>.<genexpr>)r �_unpack_opargsr`�hasconstr��hasnamer��hasjabsr�hasjrel�haslocal� hascompare�cmp_op�hasfreer�FORMAT_VALUE_CONVERTERS�boolrrbru�MAKE_FUNCTION_FLAGSr r�)�code�varnamesrd� constants�cellsr�r��labelsr�r��opr�r�r�r r�r!r�7sZ� � ��r����c Cs<|j|j}tt|��}t|j||j|j|j|||d�dS)zDisassemble a code object.r&N) ryrxr�r r9r-rwrvrt)rz�lastir$r�r�r r r!rps �rcCstt||d�|dus|dkr6|dur|d}|jD]}t|d�r5t|d�td|f|d�t|||d�qdSdS)Nr&rrSr-zDisassembly of %r:r#)rrtr/r4r6)rzr$r%r=r r r!r6ws ��r6)r$r�c Cs�t|�} | rt|���|} | dkrtt| ��}nd}nd}t|�d}|dkr/tt|��} nd} t|||||||d�D]%}| oI|jduoI|jdk}|rQt|d�|j|k}t|� ||| �|d�q<dS) Ni�r�rrTi'rU�r�r&) r��max�values�lenrr�r�r�r4r�)r�r�r�rdr�r�r�r$r��show_lineno� maxlinenor�� maxoffsetr��instr�new_source_line�is_current_instrr r r!r9�s6 ��� ��r9cKstt|d�fi|��dS)z<Compile the source string, then disassemble the code object.z<dis>N)r6r")r�kwargsr r r!r:�sr:ccsj�d}tdt|�d�D]'}||}|tkr(||d|B}|tkr%|d>nd}nd}d}|||fVqdS)NrrTrSrV)r]r�� HAVE_ARGUMENT�EXTENDED_ARG)r��extended_argrer�r�r r r!r��s��r�cCsdg}t|�D])\}}}|dur/|tvr|d|d}n |tvr%|d}nq||vr/|�|�q|S)z`Detect all offsets in a byte code which are jump targets. Return the list of offsets. NrT)r�r�r�r^)r�r�r�r�r��labelr r r!r �s �r ccs<�d}|��D]\}}}|dur||kr|}||fVqdS)zqFind the offsets in a byte code which are start of lines in the source. Generate pairs (offset, lineno) N)�co_lines)r��lastline�start�end�liner r r!r �s� �r c@sLeZdZdZddd�dd�Zdd�Zdd �Zed d��Zdd �Z dd�Z dS)raThe bytecode operations of a piece of code Instantiate this with a function, method, other compiled object, string of code, or a code object (as returned by compile()). Iterating over this yields the bytecode operations as Instruction instances. N)r��current_offsetcCsdt|�|_}|dur|j|_d|_n ||_||j|_|j|j|_tt |��|_ ||_||_dS)Nr) ri�codeobjr�r��_line_offsetryrx�_cell_namesr�r �_linestarts�_original_objectr�)r�r=r�r�rzr r r!�__init__�s zBytecode.__init__c Cs*|j}t|j|j|j|j|j|j|jd�S)Nr�) r�r�r-rwrvrtr�r�r�)r�rzr r r!�__iter__�s�zBytecode.__iter__cCsd�|jj|j�S)Nz{}({!r}))�format� __class__r<r��r�r r r!�__repr__�s �zBytecode.__repr__cCs$|jr |j}|js||jj|jd�S)z/ Construct a Bytecode from the given traceback )r�)rDrErFrG)�clsrHr r r!�from_traceback�s�zBytecode.from_tracebackcCs t|j�S)z3Return formatted information about the code object.)rjr�r�r r r!�info�s z Bytecode.infocCsx|j}|jdur|j}nd}t��� }t|j|j|j|j|j |j |j||d� |��Wd�S1s5wYdS)z3Return a formatted view of the bytecode operations.Nr�)r�rdr�r�r�r�r$r�) r�r��io�StringIOr9r-rwrvrtr�r�r��getvalue)r�rzr��outputr r r!r�s �$�zBytecode.dis)r<r�r�r�r�r�r��classmethodr�r�rr r r r!r�s rcCszddl}|��}|jd|�d�ddd�|��}|j�}|��}Wd�n1s*wYt||jjd�}t |�dS) z*Simple test program to disassemble a file.rN�infile�rb�?�-)r;�nargs�defaultr) �argparse�ArgumentParser�add_argument�FileType� parse_argsr��readrrr)r��parser�argsr�rr�r r r!�_tests �r��__main__)N)NNNNNr)r�)r�NNNNN);r�r@�types�collectionsr��opcoder�_opcodes_all� MethodType�FunctionType�CodeTyper��staticmethodr;r3�opmaprrrrr�rr�r"rrr_rgrirrjr� namedtupler~r�r�r�r�r�r�r�r�r�r rr�r�r�rr6r9r:rr�r r rr�r<r r r r!�<module>s���� -� �4 �9�� = �
Sorry, this page is not available...