�`^c@s�dZddlZddlZddlTddlmZddddd d
geZ[ejejejej e
fZdd�Z
dd�Zdd
�Zddddd�ZeZd�Zd�Zd�Zedkr��ndS(s0Disassembler of Python byte code into mnemonics.i�N(t*(t__all__tdistdisassembletdistbtdiscotfindlinestartst
findlabelscCsH|dkrt�dSt|tj�r5|j}nt|d�rP|j}nt|d�rk|j}nt|d�r�j j
�}|j�x�|D]U\}}t|t�r�d|GHyt
|�Wntk
r�}dG|GHnXHq�q�WnNt|d�rt|�n2t|t�r.t|�ntdt|�j�dS( snDisassemble classes, methods, functions, or code.
With no argument, disassemble the last traceback.
Ntim_funct func_codet__dict__sDisassembly of %s:sSorry:tco_codes(don't know how to disassemble %s objects(tNoneRt
isinstancettypestInstanceTypet __class__thasattrRR R
titemstsortt
_have_codeRt TypeErrorRtstrtdisassemble_stringttypet__name__(txRtnametx1tmsg((s/sys/lib/python2.7/dis.pyRs6
cCsl|dkrRy
tj}Wntk
r5td�nXx|jrN|j}q9Wnt|jj|j �dS(s2Disassemble a traceback (default: last traceback).s no last traceback to disassembleN(
Rtsystlast_tracebacktAttributeErrortRuntimeErrorttb_nextRttb_frametf_codettb_lasti(ttb((s/sys/lib/python2.7/dis.pyR3s
cCsa|j}t|�}tt|��}t|�}d}d}d}x||kr\||} t| �}
||kr�|dkr�Hnd||GndG||kr�dGndG||kr�dGndGt|�jd�Gt |
j
d�G|d }|
tkrXt||�t||d �d
|}d}|d}|
tkrT|d}nt|�jd
�G|
t
kr�dt|j|�dGqX|
tkr�d|j|dGqX|
tkr�dt||�dGqX|
tkr�|j|dGqX|
tkrdt|dGqX|
tkrX|dkrB|j|j}nd||dGqXnHqHWdS(sDisassemble a code object.is%3ds s-->s>>s iiiiilit(t)s(to N(RRtdictRtlenRtordtreprtrjusttopnametljustt
HAVE_ARGUMENTtEXTENDED_ARGthasconstt co_conststhasnametco_namesthasjrelthaslocaltco_varnamest
hascomparetcmp_opthasfreetco_cellvarstco_freevars(tcotlastitcodetlabelst
linestartstntitextended_argtfreetctoptoparg((s/sys/lib/python2.7/dis.pyR=s\
*
cCs�t|�}t|�}d}x�||kr�||}t|�} ||krVdGndG||krmdGndGt|�jd�Gt| jd�G|d}| tkr�t||�t||d�d }
|d
}t|
�jd�G| tkr$|rdt||
�d
Gq�d|
Gq�| t krZ|dk rOd||
d
Gq�d|
Gq�| tkrdt||
�d
Gq�| tkr�|r�d||
d
Gq�d|
Gq�| t
kr�dt|
d
Gq�nHq!WdS(Nis-->s s>>s iiiiiiR'R(s(%d)s(to (RR*R+R,R-R.R/R0R2R4RR6R7R9R:(R@R?tvarnamestnamest constantsRARCRDRGRHRI((s/sys/lib/python2.7/dis.pyRnsH
&
cCs�g}t|�}d}x�||kr�|}t|�}|d}|tkrt||�t||d�d}|d}d}|tkr�||}n|tkr�|}n|dkr�|kr�j|�q��qW|S(s`Detect all offsets in a byte code which are jump targets.
Return the list of offsets.
iiiii�(R*R+R0R6thasjabstappend(R@RARCRDRGRHRItlabel((s/sys/lib/python2.7/dis.pyR�s&
&
c cs�g|jddd�D]}t|�^q}g|jddd�D]}t|�^qF}d}|j}d}xZt||�D]I\}}|r�||kr�||fV|}n||7}n||7}q�W||kr�|fVndS(s�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.
iNii(t co_lnotabR+Rtco_firstlinenotzip( R@RGtbyte_incrementstline_incrementst
lastlinenotlinenotaddrt byte_incrt line_incr((s/sys/lib/python2.7/dis.pyR�s//
cCs�tjdrftjdr:tjjd�tjd�ntjd}|sZ|dkrld}qlnd}|dkr�tj}nt|�}|j�}|dk r�|j �nd}t
||d�}t|�dS(s*Simple test program to disassemble a file.iisusage: python dis.py [-|file]
t-s<stdin>texecN(RtargvtstderrtwritetexitRtstdintopentreadtclosetcompileR(tfntftsourceR@((s/sys/lib/python2.7/dis.pyt_test�s"
t__main__(t__doc__RRtopcodeRt_opcodes_allt
MethodTypetFunctionTypetCodeTypet ClassTypeRRRRRRRRRRRhR(((s/sys/lib/python2.7/dis.pyt<module>s(
#
1 '
|