mň %U˛Ic@sťdZdkZdkZdkTdklZddddgeZ[dd„Zdd „Zd d „Z d dddd „Z e Z d „Z d„Z d„Zedjo eƒndS(s0Disassembler of Python byte code into mnemonics.N(t*(s__all__tdist disassembletdistbtdiscocCs{|djotƒdSnt|ƒtijo |i}nt|dƒo |i}nt|dƒo |i }nt|dƒoœ|i i ƒ}|i ƒxŇ|D]t\}}t|ƒtitititifjo=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(txtNoneRttypettypest InstanceTypet __class__thasattrRRRtitemstsorttnametx1t MethodTypet FunctionTypetCodeTypet ClassTypeRt TypeErrortmsgRt isinstancetstrtdisassemble_stringt__name__(R RRRR((t /data/zmath/lib/python2.4/dis.pyR s6      +  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( ttbR tsystlast_tracebacktAttributeErrort RuntimeErrorttb_nextRttb_frametf_codettb_lasti(R((RR2s   i˙˙˙˙c Cs}|i}t|ƒ}tt|ƒƒ}t|ƒ} d} d}d}x1| | jo#|| }t|ƒ} | |jo"| djoHnd|| GndG| |jodGndG| |jodGndGt| ƒidƒGt| idƒG| d } | tjoht|| ƒt|| d ƒd |}d}| d } | tjo|d }nt|ƒid ƒG| tjodt|i|ƒdGqs| tjod|i|dGqs| tjodt| |ƒdGqs| tjod|i|dGqs| t jodt!|dGqs| t"jo5|djo|i#|i$}nd||dGqsnHqHWdS(sDisassemble a code object.is%3ds s-->s>>s iiiiilit(t)s(to N(%tcoRtcodet findlabelstlabelstdicttfindlinestartst linestartstlentntit extended_argR tfreetctordtoptlastitreprtrjusttopnametljustt HAVE_ARGUMENTtopargt EXTENDED_ARGthasconstt co_conststhasnametco_namesthasjrelthaslocalt co_varnamest hascomparetcmp_opthasfreet co_cellvarst co_freevars( R*R9R4R+R-R0R6R?R5R3R2R8((RR<s`            *         c Csňt|ƒ}t|ƒ} d}xÍ|| joż||}t|ƒ} ||jodGndG||jodGndGt |ƒi dƒGt | i dƒG|d}| tjo7t||ƒt||dƒd }|d }t |ƒi d ƒG| tjo-|od t ||ƒd Gqäd|Gqč| tjo-|dj od ||d Gqäd|Gqč| tjodt ||ƒd Gqč| tjo'|od ||d Gqäd|Gqč| tjod t|d GqčnHq!WdS(Nis-->s s>>s iiiiiiR(R)s(%d)s(to (R,R+R-R1R2R3R6R7R8R9R:R;R<R=R>R?RAt constantsRCtnamesR RERFtvarnamesRHRI( R+R9RORNRMR-R?R6R3R2R8((RRmsJ         &          cCsůg}t|ƒ}d}xÚ||joĚ||}t|ƒ}|d}|tjo›t||ƒt||dƒd}|d}d}|t jo||}n|t jo |}n|djo"||jo|i |ƒqěqđqqW|S(s`Detect all offsets in a byte code which are jump targets. Return the list of offsets. iiiii˙˙˙˙N(R-R1R+R2R3R6R7R8R>R?tlabelREthasjabstappend(R+R6R3R-R2R?RPR8((RR,—s*      &      c csg}|iddd…D]}|t|ƒq~}g}|iddd…D]}|t|ƒqR~}d}|i }d}x]t ||ƒD]L\} }| o/||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_[1]R+t co_lnotabR6R7tbyte_incrementstline_incrementsR t lastlinenotco_firstlinenotlinenotaddrtzipt byte_incrt line_incr( R+R6RZRSRVR]RYRURWR\((RR/ąs 77      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-stexecN(R targvtstderrtwritetexittfnR tstdintftopentreadtsourcetclosetcompileR+R(R+RfRiRd((Rt_testÇs$      t__main__(t__doc__R R topcodet__all__t _opcodes_allR RRRRRR,R/RlR( RpRR,RRR RqR/RRlR R((Rt?s     & 1(