
    ȅi;                     0    S SK r S SKJrJr   " S S5      rg)    N)AnyOptionalc                       \ rS rSrSrS\S\SS4S jrS\S\4S jrSS	 jr	S\
\   4S
 jrS\4S jrS\
\   4S jrSrg)_PyInstDecoder   z@
Decodes Python bytecode instructions to extract variable names
code_objectlastireturnNc                     Xl         [        [        R                  " U5      5      U l        U R                  U5      U l        g )N)r   listdisget_instructionsinstructions_find_instruction_indexoffset)selfr   r	   s      X/home/james-whalen/.local/lib/python3.13/site-packages/functorch/dim/_py_inst_decoder.py__init___PyInstDecoder.__init__
   s2    & !5!5k!BC2259    c                 p    Sn[        U R                  5       H  u  p4UR                  U::  a  UnM    U$    U$ )z<Find instruction index corresponding to lasti (byte offset).r   )	enumerater   r   )r   r	   best_idxiinstrs        r   r   &_PyInstDecoder._find_instruction_index   s@     !$"3"34HA||u$ 5
 r   c                 .    U =R                   S-  sl         g)z Advance to the next instruction.   N)r   r   s    r   next_PyInstDecoder.next   s    qr   c                     U R                   [        U R                  5      :  a#  U R                  U R                      R                  $ g)z/Get the opcode name of the current instruction.N)r   lenr   opnamer   s    r   opcode_PyInstDecoder.opcode   s7    ;;T..//$$T[[1888r   c                     U R                   [        U R                  5      :  a,  U R                  U R                      R                  =(       d    S$ g)z,Get the argument of the current instruction.r   )r   r#   r   argr   s    r   oparg_PyInstDecoder.oparg%   s<    ;;T..//$$T[[155::r   c                    U R                  5       nU(       d  gSnUS;   a  U R                  R                  nOXUS:X  a  U R                  R                  nO;US:X  a4  U R                  R                  nU(       d  U R                  R
                  nOgU R                  5       nU(       a  SUs=::  a  [        U5      :  a   X#   $   gg)z1
Extract variable name from current instruction.
N)
STORE_NAMESTORE_GLOBAL
STORE_FASTSTORE_DEREFr   )r%   r   co_namesco_varnamesco_cellvarsco_freevarsr)   r#   )r   r$   namesr(   s       r   name_PyInstDecoder.name+   s     33$$--E|#$$00E}$$$00E((44jjlQ#*E
*: + r   )r   r   r   )r
   N)__name__
__module____qualname____firstlineno____doc__r   intr   r   r    r   strr%   r)   r5   __static_attributes__ r   r   r   r      se    :C : : :

S 
S 
 s hsm r   r   )r   typingr   r   r   r?   r   r   <module>rA      s    
  > >r   