Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/dis.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c	@s�dZddkZddkZddkTddklZddddgeZ[dd	�Zdd
�Zdd�Z	ddddd�Z
e	Zd
�Zd�Z
d�Zedjoe�ndS(s0Disassembler of Python byte code into mnemonics.i�N(t*(t__all__tdistdisassembletdistbtdiscocCs{|djot�dSnt|�tijo
|i}nt|d�o
|i}nt|d�o
|i}nt|d�o�|i	i
�}|i�x�|D]t\}}t|�titi
titifjo=d|GHyt|�Wntj
o}dG|GHnXHq�q�WnSt|d�ot|�n5t|t�ot|�ntdt|�i�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(tNoneRttypettypestInstanceTypet	__class__thasattrRRRtitemstsortt
MethodTypetFunctionTypetCodeTypet	ClassTypeRt	TypeErrorRt
isinstancetstrtdisassemble_stringt__name__(txRtnametx1tmsg((s/sys/lib/python/dis.pyRs>




	
cCsr|djoKy
ti}Wntj
otd�nXx|io
|i}q<Wnt|ii|i	�dS(s2Disassemble a traceback (default: last traceback).s no last traceback to disassembleN(
R
tsystlast_tracebacktAttributeErrortRuntimeErrorttb_nextRttb_frametf_codettb_lasti(ttb((s/sys/lib/python/dis.pyR2s

cCs}|i}t|�}tt|��}t|�}d}d}d}x1||jo#||}	t|	�}
||jo"|djoHnd||GndG||jodGndG||jodGndGt|�id�Gt	|
i
d�G|d	}|
tjoht||�t||d	�d
|}d}|d}|
tjo|d}nt|�id
�G|
t
jodt|i|�dGqs|
tjod|i|dGqs|
tjodt||�dGqs|
tjod|i|dGqs|
tjodt|dGqs|
tjo5|djo|i|i}nd||dGqsnHqHWdS(sDisassemble a code object.is%3ds   s-->s>>s  iiiiilit(t)s(to N(R	t
findlabelstdicttfindlinestartstlenR
tordtreprtrjusttopnametljustt
HAVE_ARGUMENTtEXTENDED_ARGthasconstt	co_conststhasnametco_namesthasjrelthaslocaltco_varnamest
hascomparetcmp_opthasfreetco_cellvarstco_freevars(tcotlastitcodetlabelst
linestartstntitextended_argtfreetctoptoparg((s/sys/lib/python/dis.pyR<sX	




*








cCs�t|�}t|�}d}x�||jo�||}t|�}	||jodGndG||jodGndGt|�id�Gt|	id�G|d}|	tjo7t||�t||d�d	}
|d
}t|
�id�G|	tjo-|odt||
�d
Gq�d|
Gq�|	t	jo-|dj	od||
d
Gq�d|
Gq�|	tjodt||
�d
Gq�|	tjo'|od||
d
Gq�d|
Gq�|	t
jodt|
d
Gq�nHq!WdS(Nis-->s   s>>s  iiiiiiR(R)s(%d)s(to (R*R-R.R/R0R1R2R3R5R7R
R9R:R<R=(RCRBtvarnamestnamest	constantsRDRFRGRJRKRL((s/sys/lib/python/dis.pyRmsD


&






cCs�g}t|�}d}x�||jo�||}t|�}|d}|tjo�t||�t||d�d}|d}d}|tjo||}n|tjo
|}n|djo"||jo|i|�q�q�qW|S(s`Detect all offsets in a byte code which are jump targets.

    Return the list of offsets.

    iiiii�(R-R.R3R9thasjabstappend(RCRDRFRGRJRKRLtlabel((s/sys/lib/python/dis.pyR*�s&


&





ccsg}|iddd�D]}|t|�q~}g}|iddd�D]}|t|�qR~}d}|i}d}x^t||�D]M\}	}
|	o0||jo||fV|}n||	7}n||
7}q�W||jo||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.R
tco_firstlinenotzip(RCt_[1]RJtbyte_incrementst_[2]tline_incrementst
lastlinenotlinenotaddrt	byte_incrt	line_incr((s/sys/lib/python/dis.pyR,�s77	


cCs�tido_tido!tiid�tid�ntid}|p
|djo
d}qsnd}|djo
ti}n
t|�}|i�}|dj	o|i	�nd}t
||d�}t|�dS(s*Simple test program to disassemble a file.iisusage: python dis.py [-|file]
t-s<stdin>texecN(RtargvtstderrtwritetexitR
tstdintopentreadtclosetcompileR(tfntftsourceRC((s/sys/lib/python/dis.pyt_test�s"



t__main__(t__doc__RRtopcodeRt_opcodes_allR
RRRRRR*R,RmR(((s/sys/lib/python/dis.pys<module>s"
&
1	'			


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.