
    |hK                        S SK r S SKrS SKrS SKJr  S SKJr  S SKJr	  S SK
Jr  S SKJrJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  \ R2                  " \5      rS/r\R:                  " \	R<                  S5      r\R:                  " \	R@                  S 5      r!\R:                  " \	R@                  S5      r"\R:                  " \	R@                  S5      r#S r$ " S S\%5      r& " S S\%5      r' " S S\'5      r(g)    N)ir)Linkage)
llvm_types)create_constant_array)compile_extraFlags)global_compiler_lock)
cpu_target)	nrtdynmod)cgutils)lookup_environmentCompiler      c                  N    SS K n SS KnUR                  S[        U S5      -  5      $ )Nr   a      #include <stdint.h>

    #ifndef HAVE_LONGDOUBLE
        #define HAVE_LONGDOUBLE %d
    #endif

    typedef struct {
        float real;
        float imag;
    } complex64;

    typedef struct {
        double real;
        double imag;
    } complex128;

    #if HAVE_LONGDOUBLE
    typedef struct {
        long double real;
        long double imag;
    } complex256;
    #endif

    typedef float float32;
    typedef double float64;
    #if HAVE_LONGDOUBLE
    typedef long double float128;
    #endif
    
complex256)numpytextwrapdedenthasattr)r   r   s     M/home/james-whalen/.local/lib/python3.13/site-packages/numba/pycc/compiler.py
get_headerr      s/    ?? : %
&;' ( (    c                   $    \ rS rSrSrS rS rSrg)ExportEntryC   z(
A simple record for exporting symbols.
c                 (    Xl         X l        X0l        g N)symbol	signaturefunction)selfr   r    r!   s       r   __init__ExportEntry.__init__H   s    " r   c                 @    SU R                   < SU R                  < S3$ )NzExportEntry(, ))r   r    )r"   s    r   __repr__ExportEntry.__repr__M   s    (,T^^DDr   )r!   r    r   N)__name__
__module____qualname____firstlineno____doc__r#   r(   __static_attributes__ r   r   r   r   C   s    !
Er   r   c                      \ rS rSrSr\R                  " \R                  \R                  \R                  \R                  45      r\R                  " \5      r\R                  " \R                  \R                  \R                  \R                  \R                  45      r\R                  " \5      rSS jrS rS r\S 5       rSS jrSS jrS	 rS
 rS rS rS rS rSrg)_ModuleCompilerQ   zA base class to compile Python modules to a single shared library or
extension module.

:param export_entries: a list of ExportEntry instances.
:param module_name: the name of the exported module.
c                     X l         SU l        / U l        Xl        S U l        X0l        [        R                  U l        [        R                  R                  " U R                   40 UD6U l
        g )NF)module_nameexport_python_wrapdll_exportsexport_entriesexternal_init_functionuse_nrtr
   typing_contexttarget_contextwith_aot_codegencontext)r"   r8   r5   r:   aot_optionss        r   r#   _ModuleCompiler.__init__q   sb    &"',&*#(77!00AA- +-r   c                     SU< 3$ )Nz._pycc_method_r0   )r"   	func_names     r   _mangle_method_symbol%_ModuleCompiler._mangle_method_symbol   s    %.00r   c                     [         e)zAEmit generated Python wrapper and extension module code.
        )NotImplementedError)r"   llvm_modules     r   _emit_python_wrapper$_ModuleCompiler._emit_python_wrapper   s
     "!r   c                    0 U l         0 U l        0 U l        0 U l        U R                  R                  5       nUR                  U R                  5      n[        5       nSUl	        U R                  (       d  SUl        SUl        U R                  (       a:  SUl        [        R                   " U R                  5      u  pEUR#                  U5        U R$                   GH  n['        U R(                  U R                  UR*                  UR,                  R.                  UR,                  R0                  U0 US9nUR2                  nUR4                   H,  n	U	R6                  R9                  S5      (       d  M%  SU	l        M.     UR<                  R>                  n
UR@                  RC                  U
5      nU R                  (       Ga  SUl        UR<                  RD                  nUR@                  RC                  U5      nU RG                  URH                  5      Ul        SUl        URJ                  RL                  RO                  UR<                  RP                  UR<                  RR                  5      nXR                   U'   URT                  U R                  U'   UR<                  RV                  U R                  U'   URX                   H|  nUR2                  nURZ                   H]  n	U	R6                  nUR9                  S5      (       d  M'  []        U5      nUc  M7  UR_                  5       (       d  MN  UU R                  U'   M_     M~     GMk  URH                  Ul        U R`                  Rc                  URH                  5        GM     U R                  (       a3  URe                  S5      nU Rg                  U5        UR#                  U5        URi                  5         URk                  5        H]  nUR6                  U R`                  ;  d  M  UR:                  [l        Rn                  [l        Rp                  1;   a	  S	Ul9        MV  S
Ul9        M_     U$ )zpRead all the exported functions/modules in the translator
environment, and join them into a single LLVM module.
T)localslibrary__excinfo_unwrap_argslinkonce_odrinternalexternal_ZN08NumbaEnvwrapperdefaulthidden):exported_function_typesfunction_environmentsenvironment_gvsextra_environmentsr>   codegencreate_libraryr5   r   
no_compiler6   no_cpython_wrapperno_cfunc_wrapperr:   nrtr   create_nrt_moduleadd_ir_moduler8   r   r;   r!   r    argsreturn_type_final_module	functionsname
startswithlinkagefndescllvm_func_namerL   get_functionllvm_cpython_wrapper_namerC   r   r<   	call_convget_function_typerestypeargtypesenvironmentenv_name_linking_librariesglobal_variablesr   	can_cacher7   appendcreate_ir_modulerH   finalizeget_defined_functionsr   privaterO   
visibility)r"   rY   rL   flags
nrt_module_entrycresmodulegvrB   	llvm_funcwrappernamerR   fnty	linkedlib	linkedmodgvnenvwrapper_modulefns                        r   _cull_exports_ModuleCompiler._cull_exports   sN   
 (*$%'"!"$,,&&((()9)9: &&'+E$%)E"<<EI%77EMJ!!*-((E !4!4dll % % 4 4 % ; ;U')7	<D **F&&77%%&=>>!/BJ ' 22I11)<I&&&$.	!"kkCC,,33K@#99%,,G",**44FFKK'')=)=?6:,,U3484D4D**51.2kk.B.B$$U+ ")!;!;I ) 7 7I'88 gg>>/::"4S"9C"#&==??CFD$;$;C$@ 9 "< "'	  ''5S )V ""$55i@N%%n5!!.1 	//1Bwwd...::'//73C3C!DD$-BM$,BM 2 r   c                     X l         U R                  5       n[        US5       nUR                  UR	                  5       5        S S S 5        g ! , (       d  f       g = fNwb)r6   r   openwriteemit_bitcoder"   outputwrapkwsrL   fouts         r   write_llvm_bitcode"_ModuleCompiler.write_llvm_bitcode   sC    "&$$&&$4JJw++-.      A
Ac                     X l         U R                  5       n[        US5       nUR                  UR	                  5       5        S S S 5        g ! , (       d  f       g = fr   )r6   r   r   r   emit_native_objectr   s         r   write_native_object#_ModuleCompiler.write_native_object   sC    "&$$&&$4JJw1134  r   c                 ^    [        U5      nSU;   a  UR                  S5      (       a  US-  nU$ )Nint)8163264_t)strendswith)r"   tyobjret_vals      r   	emit_type_ModuleCompiler.emit_type   s3    e*G 7884r   c                   ^  [         R                  R                  U5      u  p#[        US-   S5       nUR	                  [        5       5        UR	                  S5        T R                   H  nUR                  nT R                  UR                  R                  5      nSR                  U 4S jUR                  R                   5       5      nUR	                  SU< SU< SU< S	35        M     S S S 5        g ! , (       d  f       g = f)
Nz.hwz
/* Prototypes */
r&   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr   )r   ).0argtyper"   s     r   	<genexpr>._ModuleCompiler.emit_header.<locals>.<genexpr>   s%      !M0KW "&!8!80Ks   !zextern  (z);
)ospathsplitextr   r   r   r8   r   r   r    rb   joinra   )	r"   r   fnameextr   export_entryre   rn   ra   s	   `        r   emit_header_ModuleCompiler.emit_header   s    WW%%f-
%$,$JJz|$JJ-. $ 3 3#**..)?)?)K)KLyy !M0<0F0F0K0K!M M

GT4HI !4 %$$s   B<C77
Dc                 "   / nU R                    H  nUR                  nU R                  U5      nU R                  U   n[        R
                  " XU5      nU R                  R                  X5      n[        R                  R                  U[        R                  R                  U[        R                  5      [        [        45      n	UR                  U	5        M     [        R                  R                  [        [        [         [        /5      n
UR                  U
5        [#        U R$                  U5      n[&        R(                  " UUR*                  S5      nXl        SUl        [        R                  R1                  U[         [         /5      nU$ )zg
Collect exported methods and emit a PyMethodDef array.

:returns: a pointer to the PyMethodDef array.
z.module_methodsrO   )r8   r   rC   rU   r   Functionr>   insert_const_stringConstantliteral_structbitcastlt
_void_starMETH_VARARGS_AND_KEYWORDSNULLru   ZEROr   method_def_tyr   add_global_variabletypeinitializerrg   gep)r"   rG   method_defsr~   re   ri   r   lfuncmethod_namemethod_def_constsentinelmethod_array_initmethod_arraymethod_array_ptrs                 r   _emit_method_array"_ModuleCompiler._emit_method_array   s@    ((E<<D!77=N//6DKK>BE,,::;MK!{{99$$UBMM:* 
 /0 ) ;;--tT4.FG8$1$2D2DkR22;3D3I3I3DF $5 );;??<$Fr   c                    / nU R                    H>  nU R                  U   nUR                  UR                  5      nUR	                  U5        M@     UR                  U R                  R                  5        Vs/ s H  nUR                  UR                  5      PM      sn5        [        U R                  U5      nU R                  R                  USU5      n	U	R                  [        [        /5      $ s  snf )z
Emit an array of env_def_t structures (see modulemixin.c)
storing the pickled environment constants for each of the
exported functions.
z.module_environments)r8   rV   serialize_uncachedconstsru   extendrX   valuesr   
env_def_tyr>   insert_unique_constr   r   )
r"   rG   builderpyapienv_defsr~   r   env_defenv_defs_initr   s
             r   _emit_environment_array'_ModuleCompiler._emit_environment_array  s     ((E,,U3C..szz:GOOG$	 ) 	..557
7 $$SZZ07
 	 .dooxH\\--k.D.;= vvtTl##
s   8%C2c           	         / nU R                    H]  nU R                  U   nU R                  R                  X5      nUR	                  [
        R                  5      nUR                  U5        M_     UR                  U R                   Vs/ s H<  nU R                  R                  UU5      R	                  [
        R                  5      PM>     sn5        UR                  [
        R                  " S5      5        [        [
        R                  U5      n	U R                  R                  USU	5      nUR                  [        [        /5      $ s  snf )zR
Emit an array of Environment pointers that needs to be filled at
initialization.
Nz.module_envgvs)r8   rW   r>   declare_env_globalr   r   r   ru   r   rX   r   r   r   r   )
r"   rG   r   r   env_settersr~   
envgv_namer   envgvenv_setters_inits
             r   _emit_envgvs_array"_ModuleCompiler._emit_envgvs_array1  s   
 ((E--e4J00IBJJr}}-Eu%	 ) 	
 #55

 6
	 LL++ gbmm$% 6
 	 	2==./0L\\--k.>.>@ vvtTl##
s   	AE
c                 2   U R                   (       a  [        R                  " [        R                  UR
                  U R                  U R                  UR
                  /5      n[        R                  " XU R                   5      nUR                  XXEU/5      $ g)z0
Emit call to "external" init function, if any.
N)
r9   r   FunctionTyper   _int32r   method_def_ptrenv_def_ptrr   call)	r"   rG   r   modobjr   	env_arrayenvgv_arrayr   r   s	            r   _emit_module_init_code&_ModuleCompiler._emit_module_init_codeM  s    
 &&??299$*KK1D1D$($4$4k6F6F$HID [0K0KLB<<\%0%2 3 3 r   )r>   r7   rW   r8   r6   rU   r9   rX   rV   r5   r;   r:   N)F)r*   r+   r,   r-   r.   r   LiteralStructTyper   
_int8_starr   r   r   PointerTyper   r   r   r#   rC   rH   r	   r   r   r   r   r   r   r   r   r   r/   r0   r   r   r2   r2   Q   s     (("--*,--*,))*,--*9 :M
 ^^M2N %%r}}')yy')}}')}}')yy	'2 3J
 ..,K-1"
 Q Qf/5
J @$.$8r   r2   c                   B   \ rS rSrS r\" \R                  \R                  5      r\" \R                  \R                  5      r	\" \R                  \R                  \\R                  5      r\" \R                  \R                  5      r\" \R                  5      r\R                  r\R"                  " \R$                  \\R&                  \R                  45      r\R"                  " \\\\R&                  \R,                  \	\\	\4	5      r\S 5       r\S 5       rS rSrg)ModuleCompileri]  c                 V    [         R                  " [         R                  " X5      5      $ r   )r   r   r   )retra   s     r   <lambda>ModuleCompiler.<lambda>_  s    "..1K"Lr   c                     [         R                  " [        R                  [         R                  " U R
                  5      [        R                  45      nSn[        R                  (       a  US-  nX4$ )zV
Return the signature and name of the Python C API function to
initialize the module.
PyModule_Create2	TraceRefs)r   r   r   _pyobject_head_pr   module_def_tyr   _trace_refs_)r"   r    re   s      r   module_create_definition'ModuleCompiler.module_create_definition  sX     OOB$7$7%'^^D4F4F%G%'YY%01	 "??KDr   c                 n    [         R                  " [        R                  S5      nUSU R                  -   4$ )zH
Return the name and signature of the module's initialization function.
r0   PyInit_)r   r   r   r  r5   )r"   r    s     r   module_init_definition%ModuleCompiler.module_init_definition  s0    
 OOB$7$7<	)d&6&6666r   c                    [         R                  " U/U R                  Q76 nSUl        U R                  R                  UU R                  5      n[         R                  R                  [        R                  [         R                  " U R                  S 5      [         R                  " [        R                  S 5      [         R                  " [        R                  S 5      45      n[        R                  " UUR                   S5      nXEl        SUl        U R%                  U5      n[         R                  R                  UU[         R                  " U R&                  S 5      [         R                  " [        R                  S5      U[         R                  " U R(                  S 5      [         R                  " U R*                  S 5      [         R                  " U R(                  S 5      [         R                  " U R,                  S 5      4	5      n[        R                  " XR                   S5      nXxl        SUl        [         R                  " U/U R.                  Q76 n	U	R1                  S5      n
[         R2                  " U
5      nU R                  R5                  U5      nUR7                  UU[         R                  " [        R8                  [:        R<                  5      45      nUR?                  [        R@                  " X5      5         URC                  [D        RG                  U	R                   RH                  RJ                  5      5        S S S 5        U RM                  XU5      nU RO                  XU5      nU RQ                  XUXnU5      nUb_  UR?                  [        RR                  " UU5      5         URC                  [         R                  " UR                   S 5      5        S S S 5        URC                  U5        U RT                  RW                  U	RX                  5        g ! , (       d  f       N= f! , (       d  f       NV= f)NrP   z.module_def_baserO   z.module_defEntry)-r   r   r  rg   r>   r   r5   r   r   r   _pyobject_head_init	m_init_ty_llvm_py_ssize_tr  r   r   r   r   r   
_char_star
inquiry_tytraverseproc_tyfreefunc_tyr  append_basic_block	IRBuilderget_python_apir   r   sysapi_versionif_thenis_nullr   r   r   pointeerb   r   r   r   is_not_nullr7   ru   re   )r"   rG   create_module_fnmod_name_constmod_def_base_initmod_def_baser   mod_def_initmod_defmod_init_fnr~   r   r   modr   r   r   s                    r   rH   #ModuleCompiler._emit_python_wrapper  s"    ;;{ST5R5RS#-  99+:>:J:JL KK66##[[.[[,,d3[[,,d3
 22;3D3I3I3EG $5 )..{;{{11[[$/[[,,b1[[$/[[--t4[[$/[[))40	
 --k;L;L.;=*$ kk+L0K0KL..w7,,u%++G4ll+#KK		3??CEF __W__W:;KK[%5%5%=%=%I%IJK < 00uM	--kEJ))+*6;P?!4!4Wc!BCBKK$78 D 	C 0 01 <; DCs   AP"21P3"
P03
Qr0   N)r*   r+   r,   r-   _ptr_funr   _int8r  visitproc_tyr  r   r  r  r  r   r  r   r   _pyobject_headr  module_def_base_tyr2   r   r  propertyr  r  rH   r/   r0   r   r   r   r   ]  s6   LH BHH//1L "((--/J rxx!22+!}}.O 288==*K "IJ --		
( ((**
	
M   7 7G2r   r   ))loggingr   r  llvmliter   llvmlite.bindingr   
numba.pyccr   r   numba.core.cgutilsr   numba.core.compilerr   r   numba.core.compiler_lockr	   numba.core.registryr
   numba.core.runtimer   
numba.corer   numba.core.environmentr   	getLoggerr*   logger__all__r   r   r   r   r   ONEr   r   objectr   r2   r   r0   r   r   <module>r@     s     	 
  $ ' 4 4 9 * (  5 
		8	$,	{{2==$'	{{299a kk"))QKK		37 !(HE& EIf IXb2_ b2r   