Hacked By AnonymousFox

Current Path : /proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/dis.cpython-35.pyc



��Yf�C�@stdZddlZddlZddlZddlZddlTddlmZddddd	d
ddd
ddgeZ[ejej	ej
eee
fZdd�Zddddd�Zddddd�Zdddddddddddd d!d"d#d$d%d&i	Zd'd(�Zd)d*�Zd+d�Zd,d-�Zddd.d�Zejd/d0�ZGd1d�de�Zd2dd3d
�Zd4d5�Zd6d7�Zddddddd8d9�ZdHddd:d�ZdIdddddddd;dd<d=�Z ddd>d?�Z!eZ"d@dA�Z#dBd�Z$dCd
�Z%GdDd�d�Z&dEdF�Z'e(dGkrpe'�dS)Jz0Disassembler of Python byte code into mnemonics.�N)�*)�__all__�	code_info�dis�disassemble�distb�disco�findlinestarts�
findlabels�	show_code�get_instructions�Instruction�BytecodecCsAyt||d�}Wn$tk
r<t||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/python35/lib64/python3.5/dis.py�_try_compiles

r�filecCs�|dkrtd|�dSt|d�r5|j}t|d�rM|j}t|d�re|j}t|d�r"t|jj��}x|D]�\}}t|t	�r�t
d|d|�yt|d|�Wn8tk
r
}zt
d|d|�WYdd}~XnXt
d|�q�Wn�t|d	�rDt
|d|�nct|ttf�rlt|d|�n;t|t�r�t|d|�ntd
t|�j��dS)zzDisassemble classes, methods, functions, generators, or code.

    With no argument, disassemble the last traceback.

    Nr�__func__�__code__�gi_code�__dict__zDisassembly of %s:zSorry:�co_codez(don't know how to disassemble %s objects)r�hasattrrrr�sortedr�items�
isinstance�
_have_code�printr�	TypeErrorr�bytes�	bytearray�_disassemble_bytes�str�_disassemble_str�type�__name__)�xrr!rZx1�msgrrrr s6
			&c
Css|dkrSy
tj}Wntk
r9td��YnXx|jrR|j}q=Wt|jj|jd|�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)�tbrrrrrCs


�Z	OPTIMIZED�Z	NEWLOCALS�ZVARARGS�ZVARKEYWORDS�ZNESTED� Z	GENERATOR�@ZNOFREE�Z	COROUTINE�ZITERABLE_COROUTINEcCs�g}xktd�D]J}d|>}||@r|jtj|t|���||N}|sPqW|jt|��dj|�S)z+Return pretty representation of code flags.r=r8z, )�range�append�COMPILER_FLAG_NAMES�get�hex�join)�flags�names�iZflagrrr�pretty_flags\s


rJcCs�t|d�r|j}t|d�r0|j}t|d�rH|j}t|t�rft|d�}t|d�ry|Stdt|�j	��dS)zMHelper to handle methods, functions, generators, strings and raw code objectsrrrz
<disassembly>rz(don't know how to disassemble %s objectsN)
rrrrr"r)rr%r+r,)r-rrr�_get_code_objectjs			rKcCstt|��S)z1Formatted details of methods, functions, or code.)�_format_code_inforK)r-rrrryscCs�g}|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�|jdt|j��|j	r�|jd�x(t
|j	�D]}|jd	|�q�W|jr|jd
�x(t
|j�D]}|jd|�q�W|jr[|jd�x(t
|j�D]}|jd|�q@W|j
r�|jd
�x(t
|j
�D]}|jd|�q�W|jr�|jd�x(t
|j�D]}|jd|�q�Wdj|�S)NzName:              %szFilename:          %szArgument count:    %szKw-only arguments: %szNumber of locals:  %szStack size:        %szFlags:             %sz
Constants:z%4d: %rzNames:z%4d: %szVariable names:zFree variables:zCell variables:�
)rB�co_name�co_filename�co_argcount�co_kwonlyargcount�
co_nlocals�co_stacksizerJ�co_flags�	co_consts�	enumerate�co_names�co_varnames�co_freevars�co_cellvarsrF)�co�linesZi_cZi_nrrrrL}s:	
	
	
	
	
rLcCstt|�d|�dS)z}Print details of methods, functions, or code to *file*.

    If *file* is not provided, the output is printed on stdout.
    rN)r$r)r[rrrrr�s�_InstructionzBopname opcode arg argval argrepr offset starts_line is_jump_targetc@s(eZdZdZdddd�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
    �FcCs0g}|rM|jdk	r<d|}|j||j�n|jd|�|rc|jd�n
|jd�|jr�|jd�n
|jd�|jt|j�jd��|j|jjd	��|jdk	r|jt|j�jd
��|j	r|jd|j	d�dj
|�j�S)
z�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
        Nz%%%dd� z-->z   z>>z  r:���(�))�starts_linerB�is_jump_target�repr�offset�rjust�opname�ljust�arg�argreprrF�rstrip)�self�lineno_widthZmark_as_currentZfieldsZ
lineno_fmtrrr�_disassemble�s&

	
	zInstruction._disassembleN)r,�
__module__�__qualname__�__doc__rprrrrr
�s�
first_linecCsxt|�}|j|j}tt|��}|dk	rJ||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)rKrZrY�dictr	�co_firstlineno�_get_instructions_bytesrrXrWrU)r-rtr[�
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)rf)Zconst_indexZ
const_list�argvalrrr�_get_const_info�s
r|cCs;|}|dk	r%||}|}nt|�}||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().
    N)rf)Z
name_indexZ	name_listr{rlrrr�_get_name_info�s
	r}c
cs�t|�}d}d}	x�t|�D]�\}
}}|dk	rh|j|
d�}|dk	rh||7}|
|k}
d}d}|dk	r�|}|tkr�t||�\}}n�|tkr�t||�\}}n�|tkr|
d|}dt|�}n�|t	kr+t||�\}}ng|t
krJt|}|}nH|tkrnt||�\}}n$|t
kr�d|d|df}tt||||||
||
�Vq%WdS)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.

    N�r^zto z%d positional, %d keyword pairr@)r
�_unpack_opargsrDZhasconstr|Zhasnamer}�hasjrelrfZhaslocalZ
hascompareZcmp_opZhasfreeZhasnargsr
ri)�code�varnamesrH�	constants�cellsryrz�labelsrdZfreerg�oprkrer{rlrrrrws@


	
	rwc
CsT|j|j}tt|��}t|j||j|j|j||d|�dS)zDisassemble a code object.rN)	rZrYrur	r(rrXrWrU)r[�lastirrxryrrrr:srzc	Cs�|dk	}	|	rdnd}
x�t||||||d|�D]h}|	og|jdk	og|jdk}|r}td|�|j|k}
t|j|
|
�d|�q@WdS)Nr^rrzr)rwrdrgr$rp)r�r�r�rHr�r�ryrrzZshow_linenoroZinstrZnew_source_lineZis_current_instrrrrr(As

r(cCstt|d�d|�dS)z<Compile the source string, then disassemble the code object.z<dis>rN)rr)rrrrrr*Ssr*ccs�d}t|�}d}x�||kr�||}|}|d}d}|tkr�||||dd|}d}|d}|tkr�|d}|||fVqWdS)Nrr8r@r9i)�lenZ
HAVE_ARGUMENTZEXTENDED_ARG)r�Zextended_arg�nrIr�rgrkrrrrYs



rcCs�g}x�t|�D]u\}}}|dk	rd}|tkrQ|d|}n|tkrc|}|dkr||kr|j|�qW|S)z`Detect all offsets in a byte code which are jump targets.

    Return the list of offsets.

    Nr8r^r���)rr�ZhasjabsrB)r�r�rgr�rkZlabelrrrr
lsccs�t|jddd��}t|jddd��}d}|j}d}xTt||�D]C\}}|r�||kr�||fV|}||7}||7}q]W||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.

    rNr9r8)�list�	co_lnotabrv�zip)r�Zbyte_incrementsZline_incrementsZ
lastlineno�linenoZaddrZ	byte_incrZ	line_incrrrrr	s	
c@speZdZdZdddddd�Zdd�Zd	d
�Zedd��Zd
d�Z	dd�Z
dS)rz�The bytecode operations of a piece of code

    Instantiate this with a function, method, string of code, or a code object
    (as returned by compile()).

    Iterating over this yields the bytecode operations as Instruction instances.
    rtN�current_offsetcCs�t|�|_}|dkr7|j|_d|_n||_||j|_|j|j|_tt	|��|_
||_||_dS)Nr)
rK�codeobjrvrt�_line_offsetrZrY�_cell_namesrur	�_linestarts�_original_objectr�)rnr-rtr�r[rrr�__init__�s		zBytecode.__init__c	Cs=|j}t|j|j|j|j|j|jd|j�S)Nrz)	r�rwrrXrWrUr�r�r�)rnr[rrr�__iter__�s
		zBytecode.__iter__cCsdj|jj|j�S)Nz{}({!r}))�format�	__class__r,r�)rnrrr�__repr__�szBytecode.__repr__cCs2x|jr|j}qW||jjd|j�S)z/ Construct a Bytecode from the given traceback r�)r3r4r5r6)�clsr7rrr�from_traceback�s
zBytecode.from_tracebackcCs
t|j�S)z3Return formatted information about the code object.)rLr�)rnrrr�info�sz
Bytecode.infocCs�|j}|jdk	r$|j}nd}tj��`}t|jd|jd|jd|jd|j	d|j
d|jd	|d
|�|j�SWdQRXdS)z3Return a formatted view of the bytecode operations.Nr8r�rHr�r�ryrzrr�r�)
r�r��io�StringIOr(rrXrWrUr�r�r��getvalue)rnr[rg�outputrrrr�s				zBytecode.dis)r,rqrrrsr�r�r��classmethodr�r�rrrrrr�s
cCs�ddl}|j�}|jdd|j�dddd�|j�}|j�}|j�}WdQRXt||jjd	�}t	|�dS)
z*Simple test program to disassemble a file.rN�infiler+�nargs�?�default�-r)
�argparse�ArgumentParser�add_argumentZFileType�
parse_argsr��readrrr)r��parser�argsr�rr�rrr�_test�s%r��__main__r�r�))rsr/�types�collectionsr�ZopcoderZ_opcodes_all�
MethodType�FunctionType�CodeTyper��staticmethodr+r#rrrrCrJrKrrLr�
namedtupler]r
rr|r}rwrr(r*rrr
r	rr�r,rrrr�<module>sd
	
#		3	.	=

Hacked By AnonymousFox1.0, Coded By AnonymousFox