ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/__pycache__/dis.cpython-38.pyc

U

.��cZP�@sdZddlZddlZddlZddlZddlTddlmZddddd	d
ddd
ddgeZ[ejej	ej
eee
fZedZdedfedfedffZedZdZdd�ZdVddd�dd�ZdWdd�dd�Zdddd d!d"d#d$d%d&d'�
Zd(d)�Zd*d+�Zd,d�Zd-d.�Zdd�d/d�Ze� d0d1�Z!d2e!j"_d3e!j_d4e!j#_d5e!j$_d6e!j%_d7e!j&_d8e!j'_d9e!j(_d:Z)d;Z*Gd<d�de!�Z+dd=�d>d
�Z,d?d@�Z-dAdB�Z.dXdCdD�Z/dYdd�dFd�Z0ddd�dGdH�Z1dZdddI�dJdK�Z2dLdM�Z3e0Z4dNdO�Z5dPd�Z6dQd
�Z7GdRd�d�Z8dSdT�Z9e:dUk�re9�dS)[z0Disassembler 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)�defaultsZ
kwdefaultsZannotationsZclosurecCs6zt||d�}Wn tk
r0t||d�}YnX|S)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�(/opt/alt/python38/lib64/python3.8/dis.py�_try_compiles
r��file�depthcCsh|dkrt|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]p\}}t
|t�r�td	||d�zt
|||d
�Wn0tk
r�}ztd||d�W5d}~XYnXt|d�q�nht|d��rt|||d
�nLt
|ttf��r6t||d�n.t
|t��rRt|||d
�ntd
t|�j��dS)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"r.rZx1�msgrrrr+s@	







 �r#cCsX|dkr@z
tj}Wntk
r0td�d�YnX|jr@|j}q2t|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!rrrrXs
Z	OPTIMIZEDZ	NEWLOCALSZVARARGSZVARKEYWORDSZNESTEDZ	GENERATORZNOFREEZ	COROUTINEZITERABLE_COROUTINEZASYNC_GENERATOR)
������ �@��icCs`g}td�D]:}d|>}||@r|�t�|t|���||N}|sqVq|�t|��d�|�S)z+Return pretty representation of code flags.rJrE�, )�range�append�COMPILER_FLAG_NAMES�get�hex�join)�flags�names�i�flagrrr�pretty_flagsrsrYcCs�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��d	S)
zDHelper to handle methods, compiled or raw code objects, and strings.r$r%r&r'r(z
<disassembly>r*r+N)r,r$r%r&r'r(r/rrr2r8r9�r:rrr�_get_code_object�s"







�r[cCstt|��S)z1Formatted details of methods, functions, or code.)�_format_code_infor[rZrrrr�scCs�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:�
)rP�co_name�co_filename�co_argcount�co_posonlyargcount�co_kwonlyargcount�
co_nlocals�co_stacksizerY�co_flags�	co_consts�	enumerate�co_names�co_varnames�co_freevars�co_cellvarsrT)�co�linesZi_cZi_nrrrr\�s<




r\cCstt|�|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)r1r)rlr!rrrr�s�_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
    �FrGcCs�g}|r:|jdk	r,d|}|�||j�n|�d|�|rJ|�d�n
|�d�|jrf|�d�n
|�d�|�t|j��|��|�|j�t��|j	dk	r�|�t|j	��t
��|jr�|�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_linerP�is_jump_targetr�offset�rjust�opname�ljust�
_OPNAME_WIDTH�arg�_OPARG_WIDTH�argreprrT�rstrip)�self�lineno_widthZmark_as_current�offset_widthZfieldsZ
lineno_fmtrrr�_disassemble�s&



zInstruction._disassembleN)rqFrG)r9�
__module__�__qualname__�__doc__r�rrrrr
�s
)�
first_linecCsTt|�}|j|j}tt|��}|dk	r4||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)r[rkrj�dictr	�co_firstlineno�_get_instructions_bytesr*rirhrf)r:r�rl�
cell_names�
linestarts�line_offsetrrrrs�cCs |}|dk	r||}|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)Zconst_indexZ
const_list�argvalrrr�_get_const_infosr�cCs*|}|dk	r||}|}nt|�}||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�)Z
name_indexZ	name_listr�r~rrr�_get_name_info'sr�c
#s�t|�}d}t|�D�]r\}	}
�|dk	rD|�|	d�}|dk	rD||7}|	|k}d}d}
�dk	�rl�}|
tkrzt�|�\}}
n�|
tkr�t�|�\}}
n�|
tkr�|	d�}dt|�}
n�|
t	kr�t�|�\}}
n�|
t
kr�t�}|}
n�|
tkr�t�|�\}}
nr|
t
k�rFt�d@\}}
|t�d@�f}|d�rl|
�r<|
d7}
|
d	7}
n&|
tk�rld��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.

    NrrFzto rqrGrErNzwith formatc3s"|]\}}�d|>@r|VqdS)rENr)�.0rW�s�r|rr�	<genexpr>gs�z*_get_instructions_bytes.<locals>.<genexpr>)r
�_unpack_opargsrRZhasconstr�Zhasnamer��hasjrelrZhaslocalZ
hascompareZcmp_opZhasfreer�FORMAT_VALUE_CONVERTERS�boolrrTrg�MAKE_FUNCTION_FLAGSr
ry)�code�varnamesrV�	constants�cellsr�r��labelsrurw�oprvr�r~rr�rr�7sV






�r����c
Cs<|j|j}tt|��}t|j||j|j|j|||d�dS)zDisassemble a code object.r#N)	rkrjr�r	r6r*rirhrf)rl�lastir!r�r�rrrrms�cCspt||d�|dks|dkrl|dk	r,|d}|jD]8}t|d�r2t|d�td|f|d�t|||d�q2dS)Nr#rrEr*zDisassembly of %r:r )rrfr,r1r3)rlr!r"r:rrrr3ts


r3)r!r�c	Cs�|dk	}	|	r8t|���|}
|
dkr2tt|
��}q<d}nd}t|�d}|dkr^tt|��}
nd}
t|||||||d�D]J}|	o�|jdk	o�|jdk}|r�t|d�|j|k}t|�|||
�|d�qxdS)	Ni�rqrrFi'rG�r�r#)	�max�values�lenrr�rurwr1r�)r�r�r�rVr�r�r�r!r�Zshow_linenoZ	maxlinenor�Z	maxoffsetr�ZinstrZnew_source_lineZis_current_instrrrrr6s8�
��

�r6cKstt|d�f|�dS)z<Compile the source string, then disassemble the code object.z<dis>N)r3r)r�kwargsrrrr7�sr7ccsdd}tdt|�d�D]J}||}|tkrN||d|B}|tkrH|d>nd}nd}|||fVqdS)NrrFrErH)rOr�Z
HAVE_ARGUMENTZEXTENDED_ARG)r�Zextended_argrWr�r|rrrr��sr�cCs\g}t|�D]J\}}}|dk	r|tkr4|d|}n|tkr|}nq||kr|�|�q|S)z`Detect all offsets in a byte code which are jump targets.

    Return the list of offsets.

    NrF)r�r�ZhasjabsrP)r�r�rwr�r|Zlabelrrrr
�sc	cs�|jddd�}|jddd�}t|j�}d}|j}d}t||�D]P\}}|rz||krd||fV|}||7}||krzdS|dkr�|d8}||7}qB||kr�||fVdS)z�Find the offsets in a byte code which are start of lines in the source.

    Generate pairs (offset, lineno) as described in Python/compile.c.

    rNrFrErLrM)�	co_lnotabr�r*r��zip)	r�Zbyte_incrementsZline_incrementsZbytecode_lenZ
lastlineno�linenoZaddrZ	byte_incrZ	line_incrrrrr	�s&


c@sLeZdZdZddd�dd�Zdd�Zdd	�Zed
d��Zdd
�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|�|_}|dkr&|j|_d|_n||_||j|_|j|j|_tt	|��|_
||_||_dS)Nr)
r[�codeobjr�r��_line_offsetrkrj�_cell_namesr�r	�_linestarts�_original_objectr�)r�r:r�r�rlrrr�__init__�szBytecode.__init__c	Cs*|j}t|j|j|j|j|j|j|jd�S)Nr�)	r�r�r*rirhrfr�r�r�)r�rlrrr�__iter__�s�zBytecode.__iter__cCsd�|jj|j�S)Nz{}({!r}))�format�	__class__r9r��r�rrr�__repr__�s
�zBytecode.__repr__cCs |jr|j}q||jj|jd�S)z/ Construct a Bytecode from the given traceback )r�)r@rArBrC)�clsrDrrr�from_traceback�szBytecode.from_tracebackcCs
t|j�S)z3Return formatted information about the code object.)r\r�r�rrr�infosz
Bytecode.infocCsl|j}|jdk	r|j}nd}t���>}t|j|j|j|j|j	|j
|j||d�	|��W5QR�SQRXdS)z3Return a formatted view of the bytecode operations.Nr�)r�rVr�r�r�r�r!r�)
r�r��io�StringIOr6r*rirhrfr�r�r��getvalue)r�rlrw�outputrrrr
s


�zBytecode.dis)r9r�r�r�r�r�r��classmethodr�r�rrrrrr�s

c	Csfddl}|��}|jd|�d�ddd�|��}|j�}|��}W5QRXt||jjd�}t	|�dS)	z*Simple test program to disassemble a file.rN�infile�rb�?�-)r8�nargs�defaultr)
�argparse�ArgumentParser�add_argumentZFileType�
parse_argsr��readrrr)r��parser�argsr�rr�rrr�_testsr��__main__)N)N)NNNNNr)r�)r�NNNNN);r�r<�types�collectionsr�ZopcoderZ_opcodes_all�
MethodType�FunctionType�CodeTyper��staticmethodr8r0Zopmaprrrrr�rr�rrrrQrYr[rr\r�
namedtuplernryr|r�r~rwrurvr{r}r
rr�r�r�rr3r6r7rr�r
r	rr�r9rrrr�<module>s�
����
-�
 �4�
6��=


Zerion Mini Shell 1.0