
    J/Ph0                     6   d Z ddlZ	 ddlZddlZn# e$ r  ed          w xY w G d d          Z G d d          Z G d d	          Z G d
 d          Z G d d          Z	d Z
ej                             ej                     e
                       dS )z(gdb printing extension for Numba types.
    Nz$GDB python support is not available.c                       e Zd Zd Zd ZdS )NumbaArrayPrinterc                     || _         d S Nvalselfr   s     ^/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/numba/misc/gdb_print_extension.py__init__zNumbaArrayPrinter.__init__           c                    	 dd l }d}n# t          $ r d}Y nw xY w	 d}| j        d         }| j        d         }| j        d         }| j        d         }d}t          | j        j                  }	|rd|	v sd	|	v r|	                    d
d                                          }	t          j        d          }
d |
	                    |	          
                                D             }|\  }}}d}t          j	        ||          }|
                                \  }}}|dk    }|                    d          }g }|D ]}|                    d          }|d         }|dd          }t          |          dk    rt          d|z            |d         }d|v rt          d|z            |                    d          d                             d          d         }|                    |          }|                    ||f           |}nmt          j        d          }
d |
	                    |	          
                                D             }|\  }}}d|v r|dd                             dd          }d } ||          } ||          }||k    r|r|                    d |D                       }|                    |          } |                    || z            }!|!t%          |          z  }!|                    ||          }"|"}t'          j                    }#|#                    t%          |          |!          }$|                    |$|          }%|j        j                            |%||           }&d!t          |&          z   S d"|d#|d$S t5          d%g          }'d&d'                    |'          z   d(z   d$z   S # t8          $ r}(d)|(z  cY d }(~(S d }(~(ww xY w)*Nr   TFdataitemsizeshapestridesalignedRecordz
unaligned  z%array\((Record.*), (.*), (.*)\)\ \(.*c                 6    g | ]}|                                 S  strip.0xs     r   
<listcomp>z/NumbaArrayPrinter.to_string.<locals>.<listcomp>8        NNN!AGGIINNNr   z(Record\((.*\[.*\]);([0-9]+);(True|False)True,[   zUnsupported sub-type: %snestedarray;=zarray\((.*),(.*),(.*)\)\ \(.*c                 6    g | ]}|                                 S r   r   r   s     r   r   z/NumbaArrayPrinter.to_string.<locals>.<listcomp>R   r   r   z	unichr x z<Uc                       j                                         }|d         j                                         \  }}t           fdt          ||dz             D                       S )Nr   c                 :    g | ]}t          |                   S r   )int)r   r   dwarrs     r   r   zGNumbaArrayPrinter.to_string.<locals>.dwarr2inttuple.<locals>.<listcomp>\   s#    GGGc%(mmGGGr   r#   )typefieldsrangetuple)r,   r.   lohis   `   r   dwarr2inttuplez3NumbaArrayPrinter.to_string.<locals>.dwarr2inttupleX   sb    **,,--//BGGGGU2rAv5F5FGGGHHHr   c                 4    g | ]}t          d |dz
            S )r   r#   )maxr   s     r   r   z/NumbaArrayPrinter.to_string.<locals>.<listcomp>h   s$    'E'E'E!Aq1u'E'E'Er   )align)dtype)r   r   
zarray([...], dtype=z, shape=)zNULL/Uninitializedzarray([, ]z%array[Exception: Failed to parse. %s])numpyImportErrorr   strr-   replacer   recompilematchgroupssplitlen	TypeErrorr7   appendarraysumr+   gdbselected_inferiorread_memory
frombufferlibstride_tricks
as_stridedlistjoin	Exception))r
   np
HAVE_NUMPYNULLr   r   rshprstrides
is_alignedty_strmatcherarr_info	dtype_strndim_str	order_strrstr
rstr_matchr.   balignis_aligned_str	field_dtsstruct_entriesfsplittednamedt_part	dt_as_strr7   r3   r   r   shp_arrstrd_arrextentdtype_clazz	this_procmemarr_datanew_arrbufes)                                            r   	to_stringzNumbaArrayPrinter.to_string   sn   	JJ 	 	 	JJJ	d	?D 8F#D x
+H 8G$Dx	*H J ''F "KyF22h&6H6HR88>>@@*%MNNNNw}}V/D/D/K/K/M/MNNN19.	8YBXdI66
1;1B1B1D1D.+v5
"LL--	!#" 9 9A wws||H#A;D&qrrlG7||a'''(BQ(FGGG")!*(G33"+,F,J"K"KK$+MM#$6$6q$9$?$?$D$DQ$G	 " 3 3"))4-8888*		*%EFFNNw}}V/D/D/K/K/M/MNNN19.	8Y)++ )!B$ 7 7T J JII I I #N4((E$nX..G t|| / !hh'E'Eu'E'E'EFFG!xx00HVVGh$677Fc(mm+F"$((9J("G"GK'E # 5 7 7I#//D		6BBC!}}S}>>H f2==hDIFM > P PG  #g,,..!/$ >GYYNN 0122 499S>>1C7#== 	? 	? 	?:Q>>>>>>>	?s6   	 M4O O -O 
O!OO!O!N__name__
__module____qualname__r   ru   r   r   r   r   r      s7          k? k? k? k? k?r   r   c                       e Zd Zd Zd ZdS )NumbaComplexPrinterc                     || _         d S r   r   r	   s     r   r   zNumbaComplexPrinter.__init__   r   r   c                 >    | j         d         d| j         d         dS )Nreal+imagjr   )r
   s    r   ru   zNumbaComplexPrinter.to_string   s'    8F+++TXf-=-=-=>>r   Nrv   r   r   r   r{   r{      s2          ? ? ? ? ?r   r{   c                       e Zd Zd Zd ZdS )NumbaTuplePrinterc                     || _         d S r   r   r	   s     r   r   zNumbaTuplePrinter.__init__   r   r   c                     g }| j         j                                        }|D ]4}|                    t	          | j         |j                                      5dd                    |          z  S )N(%s)r:   )r   r-   r.   rG   r>   rh   rR   )r
   rs   r.   rf   s       r   ru   zNumbaTuplePrinter.to_string   sf    %%'' 	. 	.AJJs48AF+,,----		#&&r   Nrv   r   r   r   r   r      s2          ' ' ' ' 'r   r   c                       e Zd Zd Zd ZdS )NumbaUniTuplePrinterc                     || _         d S r   r   r	   s     r   r   zNumbaUniTuplePrinter.__init__   r   r   c                 <   | j         j                                        }|d         j                                        \  }}g }t          ||dz             D ]/}|                    t          | j         |                              0dd                    |          z  S )Nr   r#   r   r:   )r   r-   r.   r/   rG   r>   rR   )r
   r.   r1   r2   rs   is         r   ru   zNumbaUniTuplePrinter.to_string   s    %%''%%''Br26"" 	) 	)AJJs48A;''((((		#&&r   Nrv   r   r   r   r   r      s2          ' ' ' ' 'r   r   c                       e Zd Zd Zd ZdS )NumbaUnicodeTypePrinterc                     || _         d S r   r   r	   s     r   r   z NumbaUnicodeTypePrinter.__init__   r   r   c                    d}| j         d         }| j         d         }| j         d         }||k    rt          j                    }|                    t	          |          ||z            }t          |t                    r"t          |                                          }n%|                    d          }nt          |          }d|z  S )Nr   r   lengthkindzutf-8z'%s')
r   rJ   rK   rL   r+   
isinstance
memoryviewbytesdecoder>   )r
   rV   r   nitemsr   ro   rp   rs   s           r   ru   z!NumbaUnicodeTypePrinter.to_string   s    x(#x4<<-//I''D		6D=AAC#z** *Cjj''))jj))d))C|r   Nrv   r   r   r   r   r      s2              r   r   c                     t           j                            d          } |                     ddt                     |                     ddt                     |                     ddt
                     |                     dd	t                     |                     d
dt                     |                     ddt                     | S )NNumbazNumba unaligned array printerz^unaligned array\(zNumba array printerz^array\(zNumba complex printerz^complex[0-9]+\ zNumba Tuple printerz^Tuple\(zNumba UniTuple printerz^UniTuple\(zNumba unicode_type printerz^unicode_type\s+\()	rJ   printingRegexpCollectionPrettyPrinteradd_printerr   r{   r   r   r   )printers    r   _create_printersr      s    l88AAG79N)+ + +-{<MNNN/1D+- - --{)+ + +0.,. . .46L/1 1 1Nr   )__doc__r@   gdb.printingrJ   r=   r   r{   r   r   r   r   r   register_pretty_printercurrent_objfiler   r   r   <module>r      sv    				>JJJJ > > >
+<
=
==>p? p? p? p? p? p? p? p?f? ? ? ? ? ? ? ?
' 
' 
' 
' 
' 
' 
' 
'' ' ' ' ' ' ' '       .  "  $ $%8S%8%:%:<L<L<N<N O O O O Os    "