Spade
Mini Shell
�
s�fc@sdZddlZddlZddlZddlmZddlmZmZm Z m
Z
dfd��YZd�Zdfd ��YZ
d
ZdZdZd
Zdefd��YZd�Zdfd��YZd�Zd�Zdfd��YZdfd��YZe�jZdS(s/A
flow graph representation for Python
bytecodei����N(tmisc(tCO_OPTIMIZEDtCO_NEWLOCALSt
CO_VARARGStCO_VARKEYWORDSt FlowGraphcBs}eZd�Zd�Zd
d�Zd�Zd�ZdZd�Z d�Z
d�Zd �Zd
�Z
d�Zd�ZRS(cCs[t�|_|_td�|_tj�|_|jj|j�|jj|j�dS(Ntexit(tBlocktcurrenttentryRRtSettblockstadd(tself((s(/usr/lib64/python2.7/compiler/pyassem.pyt__init__s
cCsr|jre|jrWdGt|j�GHdG|jjGHdG|jjGHdG|jj�GHnt|�GHn||_dS(Ntends
nexts prevs
(t_debugRtreprtnexttprevtget_children(R
tblock((s(/usr/lib64/python2.7/compiler/pyassem.pyt
startBlocks cCs<|dkr|j�}n|jj|�|j|�dS(N(tNonetnewBlockRtaddNextR(R
R((s(/usr/lib64/python2.7/compiler/pyassem.pyt nextBlockscCst�}|jj|�|S(N(RRR(R
tb((s(/usr/lib64/python2.7/compiler/pyassem.pyR5s cCs|j|j�dS(N(RR(R
((s(/usr/lib64/python2.7/compiler/pyassem.pytstartExitBlock:sicCs
d|_dS(Ni(R(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyt
_enable_debug?scCs
d|_dS(Ni(R(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyt_disable_debugBscGse|jrdG|GHnt|�dkrQt|dt�rQ|jj|d�n|jj|�dS(Ns ii(Rtlent
isinstanceRRt
addOutEdgetemit(R
tinst((s(/usr/lib64/python2.7/compiler/pyassem.pyR"Es
%cCst|j|j�}|S(slReturn the blocks in reverse postorder
i.e. each node appears before all of its successors
(torder_blocksR R(R
torder((s(/usr/lib64/python2.7/compiler/pyassem.pytgetBlocksInOrderLscCs
|jj�S(N(Rtelements(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyt getBlocksTscCs|jS(s/Return
nodes appropriate for use with
dominator(R (R
((s(/usr/lib64/python2.7/compiler/pyassem.pytgetRootWscCs4g}x'|j�D]}|j|j��qW|S(N(R(textendtgetContainedGraphs(R
tlR((s(/usr/lib64/python2.7/compiler/pyassem.pyR+[sN(t__name__t
__module__RRRRRRRRRR"R&R(R)R+(((s(/usr/lib64/python2.7/compiler/pyassem.pyRs
cs�g}t��|g}xh|r�|j�}|�kr?qn�j|�x0|j�D]"}|�krY|j|�qYqYWqWi�x��D]�}tr�|jr�n�j|t��xc|j�D]U}xL�j|t��j|�|j r|j d|k r|j d}q�Pq�q�Wq�W��fd�}|}xu|j|��j
|�|jrv|jd}q@n)||k r�|j�r�|j|�n�s�Pn|�}q@|S(s8Order
blocks so that they are emitted in the right
orderics>x7�D]/}x&�|D]}|�krPqqW|SqWdS(N((Rtc(t
dominatorst remaining(s(/usr/lib64/python2.7/compiler/pyassem.pyt find_next�s
(tsettpopRRtappendt __debug__Rt
setdefaultt
get_followersRtdiscardthas_unconditional_transfer(tstart_blockt
exit_blockR%ttodoRR/R2((R0R1s(/usr/lib64/python2.7/compiler/pyassem.pyR$bsH
RcBszeZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z dZ
d�Zd�Zd�Z
d�ZRS(itcCsPg|_t�|_||_tj|_g|_g|_tjdt_dS(Ni( tinstsR3toutEdgestlabelRt_counttbidRR(R
RA((s(/usr/lib64/python2.7/compiler/pyassem.pyR�s cCs,|jrd|j|jfSd|jSdS(Ns<block
%s id=%d>s
<block
id=%d>(RARC(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyt__repr__�s cCs2tt|j�}d|j|jdj|�fS(Ns<block
%s %d:
%s>s
(tmaptstrR?RARCtjoin(R
R?((s(/usr/lib64/python2.7/compiler/pyassem.pyt__str__�scCs|d}|jj|�dS(Ni(R?R5(R
R#top((s(/usr/lib64/python2.7/compiler/pyassem.pyR"�s
cCs|jS(N(R?(R
((s(/usr/lib64/python2.7/compiler/pyassem.pytgetInstructions�scCs|jj|�dS(N(R@R(R
R((s(/usr/lib64/python2.7/compiler/pyassem.pyR!�scCs$|jj|�|jj|�dS(N(RR5R(R
R((s(/usr/lib64/python2.7/compiler/pyassem.pyR�stRETURN_VALUEt
RAISE_VARARGSt
JUMP_ABSOLUTEtJUMP_FORWARDt
CONTINUE_LOOPcCs?y|jd\}}Wnttfk
r1dSX||jkS(s�Returns True if there is an unconditional transfer
to an other block
at the end of this block. This means there is no risk for the
bytecode
executer to go past this block's bytecode.i����N(R?t
IndexErrort
ValueErrort_uncond_transfer(R
RItarg((s(/usr/lib64/python2.7/compiler/pyassem.pyR:�s
cCst|j�|jS(N(tlistR@R(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyR�scCsNt|j�}x8|jD]-}|dtjkr|j|d�qqW|S(s:Get
the whole list of followers, including the next
block.ii(R3RR?tPyFlowGraphthasjrelR(R
t followersR#((s(/usr/lib64/python2.7/compiler/pyassem.pyR8�s
cCsbg}xU|jD]J}t|�dkr.qn|d}t|d�r|j|j�qqW|S(s�Return
all graphs contained within this block.
For example, a MAKE_FUNCTION block will contain a reference to
the graph for the function body.
itgraph(R?RthasattrR5RX(R
t containedR#RI((s(/usr/lib64/python2.7/compiler/pyassem.pyR+�s
(RKRLRMRNRO(R-R.RBRRDRHR"RJR!RRRR:RR8R+(((s(/usr/lib64/python2.7/compiler/pyassem.pyR�s
tRAWtFLATtCONVtDONERUcBsAeZejZdddd�Zd�Zd�Zd�Zd�Z d�Z
d�Zdd�Zd �Z
d
�Ze�Zx%ejD]Zejeje�q�We�Zx%ejD]Zejeje�q�Wd�Zd�Zd
�ZiZd�Zd�ZeZeZd�Zd�ZeZ
eZ!eZ"eZ#eZ$eZ%eZ&eZ'eZ(eZ)d�Z*e*Z+e*Z,d�Z-e.ej/�Z0d�Z1xDe2�j3�D]3\Z4Z5e4d
dkr�e4dZe5ee<q�q�W[4[5[d�Z6iZ7x.e8e9ej��D]Z:e:e7eje:<qW[:d�Z;d�Z<RS(icCs|j�||_||_d|_||_t|�|_||_|r\t t
B|_n d|_g|_g|_
g|_g|_g|_t|�p�g|_xOtt|j��D]8}|j|}t|t�r�|j�|j|<q�q�Wt|_dS(Ni(t
super_inittnametfilenameRt docstringtargstgetArgCounttargcounttklassRRtflagstconststnamestfreevarstcellvarstclosureRTtvarnamestrangeRR
tTupleArgtgetNameR[tstage(R
R`RaRct optimizedRftitvar((s(/usr/lib64/python2.7/compiler/pyassem.pyRs*
cCs
||_dS(N(Rb(R
tdoc((s(/usr/lib64/python2.7/compiler/pyassem.pytsetDocstringscCs3|j|B|_|tkr/|jd|_ndS(Ni(RgRRe(R
tflag((s(/usr/lib64/python2.7/compiler/pyassem.pytsetFlag"scCs|j|@rdSdS(Ni(Rg(R
Rw((s(/usr/lib64/python2.7/compiler/pyassem.pyt checkFlag's
cCst|�|_dS(N(RTRj(R
Ri((s(/usr/lib64/python2.7/compiler/pyassem.pytsetFreeVars+scCs
||_dS(N(Rk(R
Ri((s(/usr/lib64/python2.7/compiler/pyassem.pytsetCellVars.scCs2|j�|j�|j�|j�|j�S(sGet
a Python code
object(tcomputeStackDepthtflattenGraphtconvertArgstmakeByteCodet
newCodeObject(R
((s(/usr/lib64/python2.7/compiler/pyassem.pytgetCode1s
cCs�|rtj}|t_nd}x~|jD]s}|d}|dkrKHnt|�dkr{dGd|G|GH|d}q+dGd|G|G|dGH|d}q+W|r�|t_ndS(Nit
SET_LINENOis s%3di(tsyststdoutR?R(R
tiotsavetpctttopname((s(/usr/lib64/python2.7/compiler/pyassem.pytdump=s
cspi�d}x*�j�D]}t|j���|<qWi�����fd����jd��_dS(s�Compute
the max stack depth.
Approach is to compute the stack effect of each basic block.
Then find the path through the code with the largest total
effect.
cs�|�kr|Sd�|<|�|}|j�}|r`tg|D]}�||�^qD�S|jdks��j|�S|SdS(NiR(RtmaxRAR(RtdtchildrenR/(tdeptht max_depthtseenR
(s(/usr/lib64/python2.7/compiler/pyassem.pyR�]s
&iN(RR(t findDepthRJR t stacksize(R
RR((R�R�R�R
s(/usr/lib64/python2.7/compiler/pyassem.pyR|OscCs�g|_}d}i}i}x�|j�D]z}|||<x]|j�D]O}|j|�t|�dkr{|d}qI|ddkrI|d}qIqIW|||<q,Wd}x�tt|��D]�}||}t|�dkr�|d}n|ddkr|d}n|d}||jkrS|d} || |}
||
f||<q�||jkr�|||df||<q�q�Wt|_ dS(s-Arrange
the blocks in order and resolve jumpsiiR�iN(
R?R&RJR5RRnRVthasjabsR\Rq(R
R?R�tbeginRRR#RsR�topargtoffset((s(/usr/lib64/python2.7/compiler/pyassem.pyR}ms8
cCs�|jjd|j�|j�x�tt|j��D]n}|j|}t|�dkr6|\}}|jj|d�}|r�||||�f|j|<q�q6q6Wt
|_dS(s0Convert arguments from symbolic to concrete
formiiN(RhtinsertRbt
sort_cellvarsRnRR?t_converterstgetRR]Rq(R
RsR�R�R�tconv((s(/usr/lib64/python2.7/compiler/pyassem.pyR~�s
&cCs�i}x|jD]}d||<qWg|jD]}||kr.|^q.|_x|jD]
}||=qYW|j|j�|_|j|j|_dS(sHSort
cellvars in the order of varnames and prune from freevars.
iN(RkRmtkeysRjRl(R
tcellsR`((s(/usr/lib64/python2.7/compiler/pyassem.pyR��scCspt|�}xDtt|��D]0}|t||�kr|||kr|SqWt|�}|j|�|S(s�Return
index of name in list, appending if necessary
This routine uses a list instead of a dictionary, because a
dictionary can't store two different keys if the keys have the
same value but different types, e.g. 2 and 2L. The compiler
must treat these two separately, so it does an explicit type
comparison before comparing the values.
(ttypeRnRR5(R
R`RTR�RsR((s(/usr/lib64/python2.7/compiler/pyassem.pyt_lookupName�s &
cCs1t|d�r|j�}n|j||j�S(NR�(RYR�R�Rh(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt_convert_LOAD_CONST�scCs&|j||j�|j||j�S(N(R�RiRm(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt_convert_LOAD_FAST�scCs8|jdkr%|j||j�n|j||j�S(N(RfRR�RmRi(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt_convert_LOAD_NAME�scCs8|jdkr%|j||j�n|j||j�S(N(RfRR�RmRi(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt
_convert_NAME�scCs9|j||j�|j||j�|j||j�S(N(R�RiRmRl(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt_convert_DEREF�scCs&|j||j�|j||j�S(N(R�RmRl(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt_convert_LOAD_CLOSURE�scCs|jj|�S(N(t_cmptindex(R
RS((s(/usr/lib64/python2.7/compiler/pyassem.pyt_convert_COMPARE_OP�si t _convert_cCs�t�|_}x�|jD]�}|d}t|�dkrS|j|j|�q|d}|dkr||j|�qnt|�\}}y|j|j|||�Wqtk
r�|G|GH|j|G|G|GH�qXqWt |_
dS(NiiR�(t
LineAddrTabletlnotabR?RtaddCodetopnumtnextLinettwobyteRQR^Rq(R
R�R�R�R�thitlo((s(/usr/lib64/python2.7/compiler/pyassem.pyR�s"
cCs�|jt@dkrd}nt|j�}|j}|jt@rN|d}ntj|||j|j|j j
�|j�t|j
�t|j�|j|j|j j|j j�t|j�t|j��S(Nii(RgRRRmReRttypestCodeTypeR�R�R�t getConststtupleRiRaR`t firstlinetgetTableRjRk(R
tnlocalsRe((s(/usr/lib64/python2.7/compiler/pyassem.pyR�s
cCsOg}x<|jD]1}t|t�r4|j�}n|j|�qWt|�S(s�Return
a tuple for the const slot of the code object
Must convert references to code (MAKE_FUNCTION) to code
objects recursively.
(RhR
RUR�R5R�(R
R,telt((s(/usr/lib64/python2.7/compiler/pyassem.pyR�"s(N(=R-R.RRR_RRvRxRyRzR{R�R�R|R}R3RVtdisRsRR�R�R~R�R�R�R�R�t_convert_STORE_FASTt_convert_DELETE_FASTR�R�t_convert_STORE_NAMEt_convert_DELETE_NAMEt_convert_IMPORT_NAMEt_convert_IMPORT_FROMt_convert_STORE_ATTRt_convert_LOAD_ATTRt_convert_DELETE_ATTRt_convert_LOAD_GLOBALt_convert_STORE_GLOBALt_convert_DELETE_GLOBALR�t_convert_LOAD_DEREFt_convert_STORE_DEREFR�RTtcmp_opR�R�tlocalstitemsR`tobjRR�RnRtnumR�R�(((s(/usr/lib64/python2.7/compiler/pyassem.pyRU�sn !
cCs|d
dkrdSdS(NitJUMPi((R�((s(/usr/lib64/python2.7/compiler/pyassem.pytisJump/sRocBs)eZdZd�Zd�Zd�ZRS(s:Helper
for marking func defs with nested tuples in
arglistcCs||_||_dS(N(tcountRi(R
R�Ri((s(/usr/lib64/python2.7/compiler/pyassem.pyR5s cCsd|j|jfS(NsTupleArg(%s,
%s)(R�Ri(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyRD8scCsd|jS(Ns.%d(R�(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyRp:s(R-R.t__doc__RRDRp(((s(/usr/lib64/python2.7/compiler/pyassem.pyRo3s cCs^t|�}|rZxE|D]:}t|t�rttj|j��}||}qqWn|S(N(RR
RoRtflattenRi(RcReRStnumNames((s(/usr/lib64/python2.7/compiler/pyassem.pyRd=s
cCs
t|d�S(s/Convert
an int argument into high and low
bytesi(tdivmod(tval((s(/usr/lib64/python2.7/compiler/pyassem.pyR�FsR�cBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(s(lnotab
This class builds the lnotab, which is documented in compile.c.
Here's a brief recap:
For each SET_LINENO instruction after the first one, two bytes are
added to lnotab. (In some cases, multiple two-byte entries are
added.) The first byte is the distance in bytes between the
instruction for the last SET_LINENO and the current SET_LINENO.
The second byte is offset in line numbers. If either offset is
greater than 255, multiple two-byte entries are added -- see
compile.c for the delicate details.
cCs:g|_d|_d|_d|_d|_g|_dS(Ni(tcodet
codeOffsetR�tlastlinetlastoffR�(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyRZs cGsAx$|D]}|jjt|��qW|jt|�|_dS(N(R�R5tchrR�R(R
RcRS((s(/usr/lib64/python2.7/compiler/pyassem.pyR�bs
cCs|jdkr$||_||_n�|j|j}||j}|dkr|jj}x.|dkr�|d�|d�|d8}q\Wx4|dkr�||�|d�|d8}d}q�W|dks�|dkr�||�||�n||_|j|_ndS(Nii�(R�R�R�R�R�R5(R
tlinenotaddrtlinetpush((s(/usr/lib64/python2.7/compiler/pyassem.pyR�gs*
cCsdj|j�S(NR>(RGR�(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyR��scCsdjtt|j��S(NR>(RGRER�R�(R
((s(/usr/lib64/python2.7/compiler/pyassem.pyR��s(R-R.R�RR�R�R�R�(((s(/usr/lib64/python2.7/compiler/pyassem.pyR�Ks
tStackDepthTrackercBs�eZdd�Zi&dd6dd6dd6dd6dd 6dd
6dd6dd6dd
6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd
6dd!6dd"6dd#6dd$6dd%6dd&6dd'6d(d)6d(d*6dd+6dd,6Zd;d<gZd/�Zd0�Zd1�Zd2�Zd3�Z d4�Z
d5�Zd6�Zd7�Z
d8�Zd9�Zd:�ZRS(=icCsd}d}x|D]�}|d}|r0|Gn|jj|d�}|dk r^||}n�xA|jD]6\}} |t|�
|krh| }||}PqhqhW|dkr�t||d�}
|
dk r�||
|d�}q�n||kr�|}n|r|G|GHqqW|S(Nii(teffectR�RtpatternsRtgetattr(R
R?tdebugR�tmaxDepthRsR�tdeltatpatt pat_deltatmeth((s(/usr/lib64/python2.7/compiler/pyassem.pyR��s.
i����tPOP_TOPitDUP_TOPtLIST_APPENDtSET_ADDi����tMAP_ADDsSLICE+1sSLICE+2sSLICE+3s
STORE_SLICE+0s
STORE_SLICE+1s
STORE_SLICE+2i����s
STORE_SLICE+3sDELETE_SLICE+0sDELETE_SLICE+1sDELETE_SLICE+2sDELETE_SLICE+3tSTORE_SUBSCRt
DELETE_SUBSCRt
PRINT_ITEMRKtYIELD_VALUEt EXEC_STMTtBUILD_CLASSt
STORE_NAMEt
STORE_ATTRtDELETE_ATTRtSTORE_GLOBALt BUILD_MAPt
COMPARE_OPt
STORE_FASTtIMPORT_STARtIMPORT_NAMEtIMPORT_FROMt LOAD_ATTRitSETUP_EXCEPTt
SETUP_FINALLYtFOR_ITERtWITH_CLEANUPtBINARY_tLOAD_cCs|dS(Ni((R
R�((s(/usr/lib64/python2.7/compiler/pyassem.pytUNPACK_SEQUENCE�scCs |dS(Ni((R
R�((s(/usr/lib64/python2.7/compiler/pyassem.pytBUILD_TUPLE�scCs |dS(Ni((R
R�((s(/usr/lib64/python2.7/compiler/pyassem.pyt
BUILD_LIST�scCs |dS(Ni((R
R�((s(/usr/lib64/python2.7/compiler/pyassem.pyt BUILD_SET�scCs"t|d�\}}||dS(Nii(R�(R
targcR�R�((s(/usr/lib64/python2.7/compiler/pyassem.pyt
CALL_FUNCTION�scCs|j|�dS(Ni(R
(R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pytCALL_FUNCTION_VAR�scCs|j|�dS(Ni(R
(R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pytCALL_FUNCTION_KW�scCs|j|�dS(Ni(R
(R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pytCALL_FUNCTION_VAR_KW�scCs|S(N((R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pyt
MAKE_FUNCTION�scCs|S(N((R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pytMAKE_CLOSURE�scCs$|dkrdS|dkr
dSdS(Nii����ii����((R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pytBUILD_SLICE�scCs|S(N((R
R ((s(/usr/lib64/python2.7/compiler/pyassem.pytDUP_TOPX�s(Ri����(Ri(R-R.R�R�R�RRRRR
RRR
RRRR(((s(/usr/lib64/python2.7/compiler/pyassem.pyR��sl
(R�R�R�R�tcompilerRtcompiler.constsRRRRRR$RR[R\R]R^RUR�RoRdR�R�R�R�(((s(/usr/lib64/python2.7/compiler/pyassem.pyt<module>s*"W CT�2
Bn