³ò
™›\Kc        	   @   sÇ   d  Z  d d k Z d d k Z d d k Td d k l Z d d d d g e Z [ d d	 „ Z d d
 „ Z d d „ Z	 d d d d d „ Z
 e	 Z d „  Z d „  Z d „  Z e d j o e ƒ  n d S(   s0   Disassembler of Python byte code into mnemonics.iÿÿÿÿN(   t   *(   t   __all__t   dist   disassemblet   distbt   discoc         C   s{  |  d j o t ƒ  d Sn t |  ƒ t i j o |  i }  n t |  d ƒ o |  i }  n t |  d ƒ o |  i }  n t |  d ƒ oœ |  i	 i
 ƒ  } | i ƒ  xÒ | D]t \ } } t | ƒ t i t i t i t i f j o= d | GHy t | ƒ Wn t j
 o } d G| GHn XHq© q© WnS t |  d ƒ o t |  ƒ n5 t |  t ƒ o t |  ƒ n t d t |  ƒ i ‚ d S(	   sn   Disassemble classes, methods, functions, or code.

    With no argument, disassemble the last traceback.

    Nt   im_funct	   func_codet   __dict__s   Disassembly of %s:s   Sorry:t   co_codes(   don't know how to disassemble %s objects(   t   NoneR   t   typet   typest   InstanceTypet	   __class__t   hasattrR   R   R   t   itemst   sortt
   MethodTypet   FunctionTypet   CodeTypet	   ClassTypeR   t	   TypeErrorR   t
   isinstancet   strt   disassemble_stringt   __name__(   t   xR   t   namet   x1t   msg(    (    s   /usr/lib/python2.5/dis.pyR      s>    
 	c         C   sr   |  d j oK y t i }  Wn t j
 o t d ‚ n Xx |  i o |  i }  q< Wn t |  i i |  i	 ƒ d S(   s2   Disassemble a traceback (default: last traceback).s    no last traceback to disassembleN(
   R
   t   syst   last_tracebackt   AttributeErrort   RuntimeErrort   tb_nextR   t   tb_framet   f_codet   tb_lasti(   t   tb(    (    s   /usr/lib/python2.5/dis.pyR   2   s     
 c         C   s}  |  i  } t | ƒ } t t |  ƒ ƒ } t | ƒ } d } d } d } x1| | j  o#| | }	 t |	 ƒ }
 | | j o" | d j o Hn d | | Gn d G| | j o d Gn d G| | j o d Gn d Gt | ƒ i d ƒ Gt	 |
 i
 d ƒ G| d	 } |
 t j oht | | ƒ t | | d	 ƒ d
 | } d } | d } |
 t j o | d } n t | ƒ i d ƒ G|
 t j o d t |  i | ƒ d Gqs|
 t j o d |  i | d Gqs|
 t j o d t | | ƒ d Gqs|
 t j o d |  i | d Gqs|
 t j o d t | d Gqs|
 t j o5 | d j o |  i |  i } n d | | d Gqsn HqH Wd S(   s   Disassemble a code object.i    s   %3ds      s   -->s   >>s     i   i   i   i   i   l      i   t   (t   )s   (to N(   R	   t
   findlabelst   dictt   findlinestartst   lenR
   t   ordt   reprt   rjustt   opnamet   ljustt   HAVE_ARGUMENTt   EXTENDED_ARGt   hasconstt	   co_constst   hasnamet   co_namest   hasjrelt   haslocalt   co_varnamest
   hascomparet   cmp_opt   hasfreet   co_cellvarst   co_freevars(   t   cot   lastit   codet   labelst
   linestartst   nt   it   extended_argt   freet   ct   opt   oparg(    (    s   /usr/lib/python2.5/dis.pyR   <   s^    	 
  
*
c         C   sò  t  |  ƒ } t |  ƒ } d } xÍ| | j  o¿|  | } t | ƒ }	 | | j o d Gn d G| | j o d Gn d Gt | ƒ i d ƒ Gt |	 i d ƒ G| d } |	 t j o7t |  | ƒ t |  | d ƒ d	 }
 | d
 } t |
 ƒ i d ƒ G|	 t j o- | o d t | |
 ƒ d Gqäd |
 Gqè|	 t	 j o- | d  j	 o d | |
 d Gqäd |
 Gqè|	 t j o d t | |
 ƒ d Gqè|	 t j o' | o d | |
 d Gqäd |
 Gqè|	 t j o d t |
 d Gqèn Hq! Wd  S(   Ni    s   -->s      s   >>s     i   i   i   i   i   i   R(   R)   s   (%d)s   (to (   R*   R-   R.   R/   R0   R1   R2   R3   R5   R7   R
   R9   R:   R<   R=   (   RC   RB   t   varnamest   namest	   constantsRD   RF   RG   RJ   RK   RL   (    (    s   /usr/lib/python2.5/dis.pyR   m   sJ     
  
&
c         C   sù   g  } t  |  ƒ } d } xÚ | | j  oÌ |  | } t | ƒ } | d } | t j o› t |  | ƒ t |  | d ƒ d } | d } d } | t j o | | } n | t j o
 | } n | d j o" | | j o | i | ƒ qì qð q q W| S(   s`   Detect all offsets in a byte code which are jump targets.

    Return the list of offsets.

    i    i   i   i   iÿÿÿÿ(   R-   R.   R3   R9   t   hasjabst   append(   RC   RD   RF   RG   RJ   RK   RL   t   label(    (    s   /usr/lib/python2.5/dis.pyR*   —   s(     

&

c         c   s  g  } |  i  d d d … D] } | t | ƒ q ~ } g  } |  i  d d d … D] } | t | ƒ qR ~ } d } |  i } d } x^ t | | ƒ D]M \ }	 }
 |	 o0 | | j o | | f V| } n | |	 7} n | |
 7} q“ W| | j o | | f Vn d S(   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.

    i    Ni   i   (   t	   co_lnotabR.   R
   t   co_firstlinenot   zip(   RC   t   _[1]RJ   t   byte_incrementst   _[2]t   line_incrementst
   lastlinenot   linenot   addrt	   byte_incrt	   line_incr(    (    s   /usr/lib/python2.5/dis.pyR,   ±   s    77	 
c          C   sæ   t  i d o_ t  i d o! t  i i d ƒ t  i d ƒ n t  i d }  |  p |  d j o
 d }  qs n d }  |  d j o t  i } n t |  ƒ } | i ƒ  } |  d j	 o | i	 ƒ  n d }  t
 | |  d ƒ } t | ƒ d S(   s*   Simple test program to disassemble a file.i   i   s   usage: python dis.py [-|file]
t   -s   <stdin>t   execN(   R   t   argvt   stderrt   writet   exitR
   t   stdint   opent   readt   closet   compileR   (   t   fnt   ft   sourceRC   (    (    s   /usr/lib/python2.5/dis.pyt   _testÇ   s"    t   __main__(   t   __doc__R   R   t   opcodeR   t   _opcodes_allR
   R   R   R   R   R   R*   R,   Rm   R   (    (    (    s   /usr/lib/python2.5/dis.pys   <module>   s"   
&
1	'			