
    mi                      U d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZmZmZ dd	lmZmZ dd
lmZmZ ddlmZmZmZmZmZm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z( ddl)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZ ddl[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZ ddlmZmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZ ddlmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZ ddlmZmZmZmZmZ ddlmZ dd lmZ dd!lmZ ee	eW         eWf         Zd"Zd#e#d$z  d#z
  z  Zd%ed&<   h d'Zd%ed(<   h d)Zd%ed*<    G d+ d,          Zd4d3ZdS )5zeA "low-level" IR builder class.

See the docstring of class LowLevelIRBuilder for more information.

    )annotationsN)Sequence)CallableFinalOptionalcast)	TypeGuard)map_actuals_to_formals)ARG_POSARG_STAR	ARG_STAR2ArgKind)
op_methodsunary_op_methods)AnyType	TypeOfAny)	BITMAP_BITSFAST_ISINSTANCE_MAX_SUBCLASSESFAST_PREFIXIS_FREE_THREADEDMAX_LITERAL_SHORT_INTMAX_SHORT_INTMIN_LITERAL_SHORT_INTMIN_SHORT_INTPLATFORM_SIZE)Errors)ClassIRall_concrete_classes)FuncDeclFuncSignature).	ERR_FALSE	ERR_NEVERNAMESPACE_MODULENAMESPACE_STATICNAMESPACE_TYPEAssignAssignMulti
BasicBlockBoxBranchCallCallCCastComparisonOpExtendFloatFloatComparisonOpFloatNegFloatOpGetAttrGetElementPtrGotoIntegerIntOp	KeepAliveLoadAddressLoadErrorValue
LoadGlobalLoadLiteralLoadMem
LoadStatic
MethodCallOpPrimitiveDescriptionPrimitiveOpRaiseStandardErrorRegisterTruncateTupleGetTupleSetUnboxUnreachableValuefloat_comparison_op_to_idfloat_op_to_idint_op_to_id).PyObjectPySetObjectRArray	RInstance
RPrimitiveRTupleRTypeRUnionbit_rprimitivebitmap_rprimitivebool_rprimitivebytes_rprimitivec_int_rprimitivec_pointer_rprimitivec_pyssize_t_rprimitivec_size_t_rprimitivecheck_native_int_rangefloat_rprimitiveint_rprimitiveis_bool_or_bit_rprimitiveis_bytes_rprimitiveis_dict_rprimitiveis_fixed_width_rtypeis_float_rprimitiveis_frozenset_rprimitiveis_int16_rprimitiveis_int32_rprimitiveis_int64_rprimitiveis_int_rprimitiveis_list_rprimitiveis_none_rprimitiveis_object_rprimitiveis_optional_typeis_set_rprimitiveis_short_int_rprimitiveis_str_rprimitive	is_taggedis_tuple_rprimitiveis_uint8_rprimitivenone_rprimitiveobject_pointer_rprimitiveobject_rprimitiveoptional_value_typepointer_rprimitiveshort_int_rprimitivestr_rprimitiveconcrete_arg_kind)CompilerOptions)bytes_compare)dict_build_op	dict_copydict_copy_opdict_new_opdict_ssize_t_size_opdict_update_in_display_op)err_occurred_opkeep_propagating_op)copysign_opint_to_float_op)	generic_len_opgeneric_ssize_t_len_op
py_call_oppy_call_with_kwargs_oppy_call_with_posargs_oppy_getattr_oppy_method_call_oppy_vectorcall_method_oppy_vectorcall_op)int16_divide_opint16_mod_opint16_overflowint32_divide_opint32_mod_opint32_overflowint64_divide_opint64_mod_opint64_to_int_opint_to_int32_opint_to_int64_opssize_t_to_int_opuint8_overflow)list_build_oplist_extend_op
list_itemsnew_list_op)bool_opbuf_init_itemdebug_print_opfast_isinstance_opnone_object_opnot_implemented_opset_immortal_opvar_object_size)ERR_NEG_INTCFunctionDescription
binary_opsmethod_call_ops	unary_ops)
new_set_op)str_check_if_truestr_eqstr_eq_literalstr_ssize_t_size_opunicode_compare)list_tuple_opload_empty_tuple_constant_opnew_tuple_opnew_tuple_with_length_opsequence_tuple_op)is_runtime_subtype)is_same_type)
is_subtype
         r   PY_VECTORCALL_ARGUMENTS_OFFSET>   %=*=+=-=<<>>//=<<=>>=*%&+-^|&=//^=|=FIXED_WIDTH_INT_BINARY_OPS>   <=r   <>r   r   !=r   ==>=r   r   BOOL_BINARY_OPSc                     e Zd ZdZddZddZddZddZddZddZ	ddddZ
dddd#Zdd&Zdd'Zdd)Zdd*Zdd-Zdd/Zddd0d d6Z	 ddd7dd9Zdd:Zdd;Zdd<Zdd=ZddddAZddDZddEZddHZd	dIZd
dKZddNZddTZ	 	 ddd\Z 	 	 ddd^Z!dd_Z"ddaZ#ddbZ$dUdcddkZ%dUdcddnZ&	 	 	 dddsZ'ddvZ(ddwZ)ddxZ*ddyZ+ddzZ,dd{Z-dd|Z.dd~Z/ddZ0ddZ1ddZ2ddZ3dUe4ddUfddZ5ddZ6d dZ7d!dZ8d"dZ9d#dZ:dd$dZ;d%dZ<d%dZ=d&d%dZ>d'dZ?d"dZ@d"dZAd(dZBddd)dZCd*dZDd*dZEd*dZFd(dZGd+dZHd,dZId-dZJd-dZKddd.dZLd/dZMd0dZNd1dZO	 d2d3dZP	 	 d4d5dĄZQ	 d2d6dƄZR	 	 d4d7dȄZSd&d8dʄZTd%d˄ZUd9d̄ZVd:d̈́ZWd;dτZXd;dЄZYd;dфZZd<dӄZ[d=dԄZ\d>dՄZ]d>dքZ^d?dلZ_d@dڄZ`d:dۄZaddAd݄ZbdBd߄Zcd,dZddCdZedDdZfdEdZg	 ddFdZhdGdZidHdZjdIdZkdIdZldJdZmdKdZndUS (L  LowLevelIRBuilderax  A "low-level" IR builder class.

    LowLevelIRBuilder provides core abstractions we use for constructing
    IR as well as a number of higher-level ones (accessing attributes,
    calling functions and methods, and coercing between types, for
    example).

    The core principle of the low-level IR builder is that all of its
    facilities operate solely on the mypyc IR level and not the mypy AST
    level---it has *no knowledge* of mypy types or expressions.

    The mypyc.irbuilder.builder.IRBuilder class wraps an instance of this
    class and provides additional functionality to transform mypy AST nodes
    to IR.
    errorsErrors | Noneoptionsr   returnNonec                \    || _         || _        g | _        g | _        d g| _        g | _        d S N)r   r   argsblockserror_handlerskeep_alives)selfr   r   s      p/var/www/html/bestrading.cuttalo.com/scripts/kaggle-env/lib/python3.11/site-packages/mypyc/irbuild/ll_builder.py__init__zLowLevelIRBuilder.__init__  s8    $&	(*8<v )+    module_namestrmodule_pathc                "    || _         || _        dS )z,Set the name and path of the current module.N)r   r   )r   r   r   s      r   
set_modulezLowLevelIRBuilder.set_module  s    &&r   oprA   rK   c                    | j         d         j        r
J d            | j         d         j                            |           |S )z
Add an op.zCan't add to finished block)r   
terminatedopsappend)r   r   s     r   addzLowLevelIRBuilder.add  sB    ;r?-LL/LLLLB""2&&&	r   targetr(   c                r    | j         d         j        s$|                     t          |                     dS dS )zAdd goto to a basic block.r   N)r   r   r   r6   )r   r   s     r   gotozLowLevelIRBuilder.goto  s;    {2) 	#HHT&\\"""""	# 	#r   blockc                    | j         r| j         d         j        sJ | j        d         |_        | j                             |           dS )z>Add a basic block and make it the active one (target of adds).r   N)r   r   r   error_handlerr   r   r   s     r   activate_blockz LowLevelIRBuilder.activate_block!  sM    ; 	.;r?----"1"55!!!!!r   c                Z    |                      |           |                     |           dS )z.Add goto a block and make it the active block.N)r   r  r  s     r   goto_and_activatez#LowLevelIRBuilder.goto_and_activate)  s.    		%E"""""r   Fstealvalueslist[Value]r  boolc               N    |                      t          ||                     d S )Nr  )r   r9   )r   r	  r  s      r   
keep_alivezLowLevelIRBuilder.keep_alive.  s'    6///00000r   borrowptr
value_typerU   r  c               L    |                      t          |||                    S )Nr  )r   r>   )r   r  r  r  s       r   load_memzLowLevelIRBuilder.load_mem1  s#    xx
C???@@@r   handlerBasicBlock | Nonec                :    | j                             |           d S r   )r   r   )r   r  s     r   push_error_handlerz$LowLevelIRBuilder.push_error_handler4  s    ""7+++++r   c                4    | j                                         S r   )r   popr   s    r   pop_error_handlerz#LowLevelIRBuilder.pop_error_handler7  s    "&&(((r   rE   c                    | j         d         S )zWReturn reference to the 'self' argument.

        This only works in a method.
        r   )r   r  s    r   r   zLowLevelIRBuilder.self:  s    
 y|r   c                    | j         rB|                     t          | j                                                              g | _         d S d S r   )r   r   r9   copyr  s    r   flush_keep_alivesz#LowLevelIRBuilder.flush_keep_alivesA  sN     	"HHYt/446677888!D	" 	"r   toprintstr | Valuec                    t          |t                    r|                     |          }|                     t          |gd           d S )Nr   )
isinstancer   load_strprimitive_opr   )r   r   s     r   debug_printzLowLevelIRBuilder.debug_printF  sE    gs## 	-mmG,,G.7)R88888r   srcc                   |j         j        r|t          |t                    rEt	          |j                   r1|                     t          |j        dz	  t                              S |                     t          |                    S |S )Nr   rtype)
type
is_unboxedr#  r7   rs   r   r=   valuerx   r)   )r   r'  s     r   boxzLowLevelIRBuilder.boxM  sw    8 	#w'' VIch,?,? VxxCINBS T T TUUU88CHH%%%Jr   
can_borrow	uncheckedtarget_typelineintr0  r1  c          	         |j         r$|                     t          |||                    S |r| j                            |           |                     t          |||||                    S )N)r  r1  )r,  r   rI   r   r   r-   )r   r'  r2  r3  r0  r1  s         r   unbox_or_castzLowLevelIRBuilder.unbox_or_castU  ss     ! 	b88E#{D99::: - '',,,88Dk4
V_```aaar   r0  forcec          	     
    |j         }|j        r|j        s                     |          S |j        rk|j        rct          ||          sRt	          |t
                    rwt          |          rht          |          rY|                                }t          ||          s 
                    d| d| d           t          |j        dz	  |          S t          |          r&t          |          r                     ||          S t          |          r%t          |          r                     |          S t          |          r&t          |          r                     ||          S t	          |t                     rEt	          |t                     r0|j        r)|j        r"|j        |j        k    r|j        |j        k    r|S t)          |          rnt+          |          r_                     t.          |t          dt.                    t0          j                  }                     t7          ||d                    S t)          |          r4t          |          r%                     t7          ||d                    S t	          |t
                    rct9          |          rTt+          |          r$t;          t=          |j        dz                      S t;          t=          |j                            S t+          |          r%t9          |          r                     |          S t	          |t@                    r t	          |t@                    r
tC          |j"                  tC          |j"                  k    rg }	tG          tC          |j"                            D ]y}
d}t	          |tH                    r$|j%        |
         }t	          |tL                    s|}|%tO          ||
          }                     |           |	(                    |           z                     tI           fd	tS          |	|j"                  D                                 S                      |          } *                    ||          S |j        s|j        stW          ||          s *                    |||
          S |r4tM          |          }                     tY          ||                     |S |S )a  Generate a coercion/cast from one type to other (only if needed).

        For example, int -> object boxes the source int; int -> int emits nothing;
        object -> int unboxes the object. All conversions preserve object value.

        If force is true, always generate an op (even if it is just an assignment) so
        that the result will have exactly target_type as the type.

        Returns the register with the converted value (may be same as src).
        zValue z is out of range for ""r   Fsigned   Nc                D    g | ]\  }}                     ||          S  )coerce).0vtr3  r   s      r   
<listcomp>z,LowLevelIRBuilder.coerce.<locals>.<listcomp>  s-    \\\TQQ400\\\r   r7  )-r+  r,  r.  r   r#  r7   rq   re   numeric_valuer_   errorr-  rk   coerce_int_to_fixed_widthcoerce_fixed_width_to_intcoerce_short_int_to_fixed_widthrS   is_native_intsize	is_signedrb   rs   int_oprY   r8   
LEFT_SHIFTr   r/   rf   r0   floatint_to_floatrT   lentypesrangerH   itemsrE   rG   r   zipr6  r   r&   )r   r'  r2  r3  r8  r0  src_typer-  shiftedr	  irB  itemtmps   `  `          r   r@  zLowLevelIRBuilder.coercee  s0   & 8 	!{'= 	!88C==  C	>K$: C	>DVkE
 E
 C	> 3((<+H55< )55<
 ))++-k5AA [JJSSS[SSSUYZZZsyA~{;;;"8,, 31Ek1R1R 355c;MMM%h// 14Ek4R4R 155c4@@@(22 /7KK7X7X /;;CdSSS8Z00-{J77- *-  -	-
 M[%555&+*??? 
*844 #;9O9O #++#S'!_*E*EuGW  xxwE J J JKKK*844 9Mk9Z9Z xxsK F F FGGGC)) .A+.N.N X&& 8 syA~!6!6777U39--...8$$ )<[)I)I ((d3338V,,{F33 ''3{/@+A+AAA s8>2233 
% 
%AA!#x00 %"y|)$99 % $Ay$S!,,MM!$$$$xx\\\\\SIZ=[=[\\\^b    ((3--C%%c;===# 	(> 	zkH
 H
 	 %%c;%TTT 	;''CHHVC%%&&&J
r   c           	     
   t          |          s
J |            t          |t                    s
J |            t          |          }t	                      t	                      t	                      }}}|                     ||          }|                     t          |||t          j                             | 	                    |           |j
        }	|	t          j
        k     rt	                      t	                      }}
d|	dz  dz
  z  }|j        s|dz  }|                     t          |t          ||j                  t          j                            }|                     t          ||
|t          j                             | 	                    |
           |j        r| }nd}|                     t          |t          ||j                  t          j                            }|                     t          |||t          j                             | 	                    |           |                     t&          |t          dt&                    t(          j        |          }|                     t-          ||                    }ni|	t          j
        k    r&|                     t/          ||d                    }n|}|                     ||t          d|          t(          j        |          }|                     t1          ||                     |                     |           | 	                    |           t5          |          s!t7          |          r|	t          j
        k    r|                     t8          |t          dt8                    t(          j        |          }t          t<                    }|                     t1          ||                     t5          |          rt>          }nt@          }| !                    ||g|          }|                     t1          ||                     |                     tE          |g                     |                     |           nt7          |          r>| !                    tF          g |           |                     tI                                 ntK          |          r>| !                    tL          g |           |                     tI                                 nWtO          |          r>| !                    tP          g |           |                     tI                                 n
J |            | 	                    |           |S )Nr   r   r=  r   Tr;  ))re   r#  rS   rE   r(   check_tagged_short_intr   r*   BOOLr  rK  ra   rL  r.   r7   r+  SLTSGErM  r]   r8   RIGHT_SHIFTrF   r/   r&   r   rj   ri   rz   XORr\   r   r   call_cr9   r   rJ   rh   r   ru   r   )r   r'  r2  r3  resfastslowendcheckrK  fast2fast3upper_boundcheck2lower_boundcheck3rZ  r  ptr2conv_ops                       r   rG  z+LowLevelIRBuilder.coerce_int_to_fixed_width  s   #K00==+===+z22??K???{##$,,
jllCd++C66tT6;77888D!!!.%%%%<<5Eq1-K( !q XXl3SX0N0NP\P`aabbFHHVFE4==>>>&&&$  *lXXl3SX0N0NP\P`aabbFHHVFE4==>>>&&&++&122! C ((8C5566CCn)))hhvc;tDDDEE++k3;0G0GIZ\`aaCS!!"""		#D!!!{++ 	&,,	&159L1L1L ++"C4F)G)GTX C 011DHHVD#&&'''";// *))++gvt44CHHVC%%&&&HHYu%%&&&IIcNNNN -- 	&KKD111HH[]]#### -- 		&KKD111HH[]]#### -- 	&KKD111HH[]]####%+%%%C   
r   c                    t          |          st          dk    r@t          |          r1|                     ||t	          d|          t
          j        |          S J |j        |t          f            )N   r   )rj   r   ri   rM  r7   r8   r`  r+  )r   r'  r2  r3  s       r   rI  z1LowLevelIRBuilder.coerce_short_int_to_fixed_width  sk    {++ 	cQ#6{#C#C;;{CK1H1H%J[]abbb<sxm<<<<r   c           	        t          |j                  rt          dk    s(t          |j                  st	          |j                  ro|                     t          |t          |j        j                            }| 	                    t          |t          dt                    t          j        |          S |j        }t          |          s
J |            t          |t                     s
J |            t#          t                    }t%                      t%                      t%                      t%                      f\  }}}}	|                     t'          |t          t(          |          t&          j                            }
|                     t-          |
||t,          j                             |                     |           |                     t'          |t          t2          |          t&          j                            }|                     t-          |||t,          j                             |                     |           t7          |          rt8          }n.t          |          rt          dk    sJ t:          }n
J |            |                     ||g|          }|                     t?          ||                     |                      |	           |                     |           t          j!        |j!        k     r)|                     tE          |t                              }n|}| 	                    t          |t          d|j                  t          j        |          }|                     t?          ||                     |                      |	           |                     |	           |S )Nr   r;  r   rq  )#ri   r+  r   rh   ru   r   r/   r]   rL  rM  ra   r7   r8   rN  re   r#  rS   rE   r(   r.   r   SLEr*   r]  r  r   r_  rj   r   r   rb  r&   r   rK  rF   )r   r'  r3  extendedrV  rc  rd  rh  re  rf  c1c2ro  xrZ  ss                   r   rH  z+LowLevelIRBuilder.coerce_fixed_width_to_int&  s    **	/</A/A"38,, 0B"38,, 0B
 xxs,B38K] ^ ^ ^__H;;122    8#H--77x777(J//99999~&&!+z||Z\\:<<!WeT3XXl3x(H(H,JZ[[\\D$44555D!!!XXl3x(H(H,JZ[[\\E455666D!!!x(( 	#%GG ** 	# A%%%%'GG"("""KK#--Q   		#E"""..((8C)?@@AACCCKKWQ-A-A5CSUYZZQ   		#C   
r   c                   |j         j        |j        k    r:|j        rt          |j         |          s|j        st          |j         |          r|S t	          |          }t                      t                      t                      }}}|                     t          |||t          j                             | 	                    |           | 
                    |||          }|                     t          |||                     |                     |           | 	                    |           |                     t          |                    }	|                     t          ||	|                     |                     |           |S )z2Generate a coercion from a potentially null value.)r+  r,  r   r   rE   r(   r   r*   IS_ERRORr  r@  r&   r   r;   r  )
r   r'  r2  r3  r   validinvalidoutcoercedrF  s
             r   coerce_nullablez!LowLevelIRBuilder.coerce_nullable^  s\   8+"888# 9(:38[(Q(Q 9* 9/9#(K/P/P 9 J+&&(llJLL*,,wWeV_==>>>E"""++c;55..///		#G$$$4455t,,---s###r   objattrresult_typec                  t          |j        t                    ry|j        j        j        rh|j        j                            |          rIt          ||||          }|j        r| j        	                    |           | 
                    |          S t          |j        t                    r|                     ||j        |||          S |                     |||          S )z.Get a native or Python attribute of an object.r  )r#  r+  rR   class_iris_ext_classhas_attrr4   is_borrowedr   r   r   rV   union_get_attrpy_get_attr)r   r  r  r  r3  r  r   s          r   get_attrzLowLevelIRBuilder.get_attry  s    
 sx++	5!.	5 !**400	5
 dD888B ~ - '',,,88B<<&)) 	5&&sCHdKNNN##Ct444r   r*  rV   c                N     d fd}                      |||          S )z0Get an attribute of an object with a union type.r-  rK   r   c                4                         |           S r   )r  )r-  r  r3  r  r   s    r   get_item_attrz7LowLevelIRBuilder.union_get_attr.<locals>.get_item_attr  s    ==k4@@@r   r-  rK   r   rK   )decompose_union_helper)r   r  r*  r  r  r3  r  s   `  ``` r   r  z LowLevelIRBuilder.union_get_attr  s[    
	A 	A 	A 	A 	A 	A 	A 	A 	A **3{MSWXXXr   c                h    |                      |          }|                     t          ||g|          S )zuGet a Python attribute (slow).

        Prefer get_attr() which generates optimized code for native classes.
        )r$  r%  r   )r   r  r  r3  keys        r   r  zLowLevelIRBuilder.py_get_attr  s1    
 mmD!!  c
DAAAr   	class_irslist[ClassIR]c                     |s                                  S                      |d                   |dd         D ],d	 fd}                     dt          fd|          -S )
zHFast path for isinstance() that checks against a list of native classes.r   r   Nr   rK   c                 2                                    S r   )isinstance_native)r  r3  r  r   s   r   otherz2LowLevelIRBuilder.isinstance_helper.<locals>.other  s    --c8TBBBr   orc                      S r   r?  rets   r   <lambda>z5LowLevelIRBuilder.isinstance_helper.<locals>.<lambda>      # r   r   rK   )falser  shortcircuit_helperrY   )r   r  r  r3  r  r  r  s   `` ` @@r   isinstance_helperz#LowLevelIRBuilder.isinstance_helper  s     	 ::<<$$S)A,==!!"" 	\ 	\HC C C C C C C C C **4++++uVZ[[CC
r   c                    |                      t          |t          d|                    }|                     |t          d          }|                      t          |g                     |S )Nob_typeTr  )r   r5   rO   r  rx   r9   )r   r  r3  ob_type_addressr  s        r   get_type_of_objz!LowLevelIRBuilder.get_type_of_obj  sZ    ((=h	4#P#PQQ--1B4-PPC5!!"""r   type_objc                    |                      ||          }|                     t          ||t          j        |                    S r   )r  r   r.   EQ)r   r  r  r3  typs        r   
type_is_opzLowLevelIRBuilder.type_is_op  s9    ""3--xxS(LOTJJKKKr   r  r   c                    t          |          }|t          |          t          dz   k    r1                     t                               |          g          S |s                                 S                      |d                   }                     |          |dd         D ],d	 fd}                     dt          fd|          -S )
zFast isinstance() check for a native class.

        If there are three or fewer concrete (non-trait) classes among the class
        and all its children, use even faster type comparison checks `type(obj)
        is typ`.
        Nr   r   r   rK   c                 X                                                                  S r   )r  get_native_type)cr3  r  r   s   r   r  z2LowLevelIRBuilder.isinstance_native.<locals>.other  s'    sD,@,@,C,CTJJJr   r  c                      S r   r?  r  s   r   r  z5LowLevelIRBuilder.isinstance_native.<locals>.<lambda>  r  r   r  )
r   rQ  r   r%  r   r  r  r  r  rY   )	r   r  r  r3  concreter  r  r  r  s	   `` `   @@r   r  z#LowLevelIRBuilder.isinstance_native  s#    (11s8}}/MPQ/QQQ$$"S$*>*>x*H*H$I4    	 ::<<''44ooc8T22!"" 	\ 	\AK K K K K K K K K **4++++uVZ[[CC
r   r   +Sequence[tuple[Value, ArgKind, str | None]]has_star	has_star2!tuple[Value | None, Value | None]c          	        d}d}g }g }g }	d}
|D ]\  }}}|t           k    r|t          |          dk    rt          |j                  r|                     t
          |g|          }nKt          |j                  s7t          |j        t                    s|                     t          |g|          }|dfc S t          |          dk    r|d         d         t          k    rt          |j                  st          |j        t                    r|}nOt          |j                  r|                     t
          |g|          }n|                     t          |g|          }|d         }|d         }t          |j                  rt          }nt          }||                     ||g|          fc S |                     ||          }|                     t          ||g|           |t          k    r|}t          |          dk    rSt          |j                  rt          }nt          }|                     g |          |                     ||g|          fc S |                     ||	|          }|                     t&          ||g|           |                                }|                                o|}|                                p|                                o|o|}|r5|r||                     ||          }|r||                     ||	|          }|r||                    |           .|rG|E|J |                     |          }|                    |           |	                    |           w|
}t3                      }|r|rL|
sJt5          t6                    }|                     t;          ||                                 |                     |rt3                      n|}t3                      }|                     t?          |||t>          j                              | !                    |           |rP|rN|
rLt3                      t3                      }}|                     t?          |
||t>          j"                             n%t3                      x}}| #                    |           |rI| !                    |           |sJ | $                    |d|gd|           | #                    |           |rg|r|
rc| !                    |           |J |                     |          }|sJ | $                    |d||gd|           | #                    |           |rj|rh|rf||usJ | !                    |           |                     t;          || %                                |                     | #                    |           | !                    |           |}
|s|r|sJ |s|	r|sJ |rJ||                     ||          }n1t          |j                  s|                     t
          |g|          }|r,|*t          |          dk    r|                     ||	|          }||fS )	a  Construct *args and **kwargs from a collection of arguments

        This is pretty complicated, and almost all of the complication here stems from
        one of two things (but mostly the second):
          * The handling of ARG_STAR/ARG_STAR2. We want to create as much of the args/kwargs
            values in one go as we can, so we collect values until our hand is forced, and
            then we emit creation of the list/tuple, and expand it from there if needed.

          * Support potentially nullable argument values. This has very narrow applicability,
            as this will never be done by our compiled Python code, but is critically used
            by gen_glue_method when generating glue methods to mediate between the function
            signature of a parent class and its subclasses.

            For named-only arguments, this is quite simple: if it is
            null, don't put it in the dict.

            For positional-or-named arguments, things are much more complicated.
              * First, anything that was passed as a positional arg
                must be forwarded along as a positional arg. It *must
                not* be converted to a named arg. This is because mypy
                does not enforce that positional-or-named arguments
                have the same name in subclasses, and it is not
                uncommon for code to have different names in
                subclasses (a bunch of mypy's visitors do this, for
                example!). This is arguably a bug in both mypy and code doing
                this, and they ought to be using positional-only arguments, but
                positional-only arguments are new and ugly.

              * On the flip side, we're willing to accept the
                infelicity of sometimes turning an argument that was
                passed by keyword into a positional argument. It's wrong,
                but it's very marginal, and avoiding it would require passing
                a bitmask of which arguments were named with every function call,
                or something similar.
                (See some discussion of this in testComplicatedArgs)

            Thus, our strategy for positional-or-named arguments is to
            always pass them as positional, except in the one
            situation where we can not, and where we can be absolutely
            sure they were passed by name: when an *earlier*
            positional argument was missing its value.

            This means that if we have a method `f(self, x: int=..., y: object=...)`:
              * x and y present:      args=(x, y), kwargs={}
              * x present, y missing: args=(x,),   kwargs={}
              * x missing, y present: args=(),     kwargs={'y': y}

            To implement this, when we have multiple optional
            positional arguments, we maintain a flag in a register
            that tracks whether an argument has been missing, and for
            each such optional argument (except the first), we check
            the flag to determine whether to append the argument to
            the *args list or add it to the **kwargs dict. What a
            mess!

            This is what really makes everything here such a tangle;
            otherwise the *args and **kwargs code could be separated.

        The arguments has_star and has_star2 indicate whether the target function
        takes an ARG_STAR and ARG_STAR2 argument, respectively.
        (These will always be true when making a pycall, and be based
        on the actual target signature for a native call.)
        Nr   r=  r   r3  r   r  r3  __setitem__)&r   rQ  rl   r+  r%  r   rt   r#  rT   r   r   rd   r   r   r   r   	new_tuple_create_dictrb  r   is_optionalis_positionalis_namedr   r$  r(   rE   rY   r   r&   r  r*   rz  r  r]  r   translate_special_method_calltrue)r   r   r3  r  r  star_resultstar2_resultstar_values
star2_keysstar2_valuesseen_empty_regr-  kindname	star2_argstar2_valuestar2_fastpath_opnullable	maybe_posmaybe_namedr  new_seen_empty_regr}  skipkeep	pos_blocknamed_blocks                              r   _construct_varargsz$LowLevelIRBuilder._construct_varargs  sY   P %)%)
 $&"$
$&*.!% D	4 D	4E4x&4yyA~~-ej99 X$($5$5meWd$S$SEE!4UZ!@!@ X!JJ J X %)$5$56G%RV$W$WE$d{***TaDGAJ),C,C /uz:: ^jU[>\>\ ^*/KK/
;; ^*.*;*;ME7TX*Y*YKK*.*;*;<MPUwX\*]*]K$(G	&/l-k.>?? :0<--09-*D,=,=-}d- -     
 #'"2"2;"E"EK!!.;2FMMMM""'4yyA~~ .ej99 :0<--09-#~~b$779J9J-w: :      $(#4#4Zt#T#TL5e7LSWXXXX++-- ..00=X	"mmoo\$2B2B2D2D2[2[R[
  Y  J[%8&*&6&6{D&I&I" Y|';'+'8'8\SW'X'X  !4&&u--- <#7+++----C%%c*** ''... &4" ll . ! Q Q-5o-F-F*(:DJJLL$!O!OPPP+4=:<<<#D%<<DHHVE4vGGHHH''---
  ) ) )-7\\:<<{IHHVNKFKXXYYYY.8ll:IIIi((( #''	222&&&&66#XwDt 7    IIcNNN #	 #^ #''444+++----C''''66$mc5\tZ^ 7    IIcNNN #	 #.@ #s????''---HHV$6		TJJKKKIIcNNN##C(((!3;;;8;;; >L>Y>>> 	T ""nn[$??()9:: T"//}dSS 	M-#j//A2E2E,,ZtLLLL((r   Nfunction
arg_values	arg_kindslist[ArgKind] | None	arg_namesSequence[str | None] | Nonec           	        |                      |||||          }||S |t          d |D                       r |                     t          |g|z   |          S |J |                     t          t          |||                    |dd          \  }}|sJ ||                     t          ||g|          S |                     t          |||g|          S )zCall a Python function (non-native and slow).

        Use py_call_op or py_call_with_kwargs_op for Python function call.
        Nc              3  ,   K   | ]}|t           k    V  d S r   r   rA  r  s     r   	<genexpr>z,LowLevelIRBuilder.py_call.<locals>.<genexpr>  &      #J#JDGO#J#J#J#J#J#Jr   Tr  r  )	_py_vector_callallrb  r   r  listrU  r   r   )	r   r  r  r3  r  r  resultpos_args_tuplekw_args_dicts	            r   py_callzLowLevelIRBuilder.py_call  s    %%h
D)YWWM #J#J	#J#J#J J J;;zH:
+BDIII $$$'+'>'>ZI6677X\ (? (
 (
$ ;;6>8RTXYYY{{1Hnl3[]abbbr   Value | Nonec           	         |t          d |D                       r|r- fd|D             }                     t          |d          }nt          dt                    }t          ||          }                     |          }	                     t          ||t          |t                    |	g          }
|r" 
                    t          |                     |
S dS )zCall function using the vectorcall API if possible.

        Return the return value if successful. Return None if a non-vectorcall
        API should be used instead.
        Nc              3  j   K   | ].}|                                  o|                                 V  /d S r   is_starr  r  s     r   r  z4LowLevelIRBuilder._py_vector_call.<locals>.<genexpr>  R       $
 $
>B9t'7'7'9'9#9$
 $
 $
 $
 $
 $
r   c                H    g | ]}                     |t                    S r?  r@  rx   rA  argr3  r   s     r   rD  z5LowLevelIRBuilder._py_vector_call.<locals>.<listcomp>  s*    ```cC1BD I I```r   T
object_ptrr   )r  setup_rarrayrx   r7   rw   num_positional_args_vectorcall_keywordsrb  r   r^   r   r9   )r   r  r  r3  r  r  coerced_argsarg_ptrnum_poskeywordsr-  s   `  `       r   r  z!LowLevelIRBuilder._py_vector_call  s     $
 $
FO$
 $
 $
 !
 !
  @`````U_```++,=|X\+]]!!%>??)*i@@G00;;HKK 7GG5H$I$I8T E
  2 <00111Ltr   c                    |rCd |D             }|r5|                      t          t          |          t                              S t	          dt                    S )zReturn a reference to a tuple literal with keyword argument names.

        Return null pointer if there are no keyword arguments.
        c                    g | ]}||S r   r?  )rA  r  s     r   rD  z:LowLevelIRBuilder._vectorcall_keywords.<locals>.<listcomp>  s    FFFT5Et5E5E5Er   r   )r   r=   tuplerx   r7   )r   r  kw_lists      r   r  z&LowLevelIRBuilder._vectorcall_keywords  s]    
  	PFF	FFFG PxxE'NN<M N NOOOq+,,,r   method_namec                B   |                      ||||||          }||S |t          d |D                       r6|                     |          }|                     t          ||g|z   |          S |                     |||          }	|                     |	||||          S )z+Call a Python method (non-native and slow).Nc              3  ,   K   | ]}|t           k    V  d S r   r  r  s     r   r  z3LowLevelIRBuilder.py_method_call.<locals>.<genexpr>   r  r   r  r  )_py_vector_method_callr  r$  rb  r   r  r  )
r   r  r  r  r3  r  r  r  method_name_regmethods
             r   py_method_callz LowLevelIRBuilder.py_method_call  s     ,,j$	9
 
 M#J#J	#J#J#J J J"mmK88O;;032H:2UW[\\\ %%c;==F<<
DIYb<cccr   c           	         |t          d |D                       r̉                     |          } fd|g|z   D             }                     t          |d          }	t	          ||          }
                     |          }                     t          ||	t          |
dz   t          z  t                    |g          }                     t          |                     |S dS )zCall method using the vectorcall API if possible.

        Return the return value if successful. Return None if a non-vectorcall
        API should be used instead.
        Nc              3  j   K   | ].}|                                  o|                                 V  /d S r   r  r  s     r   r  z;LowLevelIRBuilder._py_vector_method_call.<locals>.<genexpr>7  r  r   c                H    g | ]}                     |t                    S r?  r  r  s     r   rD  z<LowLevelIRBuilder._py_vector_method_call.<locals>.<listcomp>;  s7       >AC!2D99  r   Tr  r   )r  r$  r  rx   r  r  rb  r   r7   r   r^   r   r9   )r   r  r  r  r3  r  r  r  r  r  r  r  r-  s   `   `        r   r  z(LowLevelIRBuilder._py_vector_method_call)  s%     $
 $
FO$
 $
 $
 !
 !
 #mmK88O    FIUZEW  L ''(9<TX'YYG)*i@@G00;;HKK'#Wq[,JJL_``	 	 	E HHY|,,---Ltr   bitmap_argsdeclr   Sequence[Value]list[ArgKind]Sequence[str | None]r  list[Register] | Nonec                   |                      ||||j        ||          }|                     t          |||                    S )a  Call a native function.

        If bitmap_args is given, they override the values of (some) of the bitmap
        arguments used to track the presence of values for certain arguments. By
        default, the values of the bitmap arguments are inferred from args.
        r
  )native_args_to_positionalsigr   r+   )r   r  r   r  r  r3  r  s          r   callzLowLevelIRBuilder.callR  sM    " --)Y$K . 
 
 xxT4..///r   r  r    c               n   |j         }|j        }|r|d|          }d |D             }	d |D             }
d D             }t          ||	|
d           }dx}}g }t          ||          D ]e\  }}|j                                        r#|                    fd|D                        |p|j        t          k    }|p|j        t          k    }f| 	                    ||||          \  }}g }t          ||          D ]>\  }}|j        t          k    r|sJ |}n|j        t          k    r|p| 
                    g g |          }n|sxt          |j                  rt          d	|j                  }nt          |j                  rt          d
          }n|                     t#          |j        d                    }ng|d	                  }|d	                                                  r|                     ||j        |          }n|                     ||j        |          }|                    |           @t-          t/          |                    D ]}|r/|t1          |          k     r|                    ||                    3d	}d	}t          ||          D ]g\  }}|j                                        rI|j        j        r=|t4          z  |cxk    r|dz   t4          z  k     rn n|r|d|t4          dz
  z  z  z  }|dz  }h|                    t          |t6                               |S )a  Prepare arguments for a native call.

        Given args/kinds/names and a target signature for a native call, map
        keyword arguments to their appropriate place in the argument list,
        fill in error values for unspecified default arguments,
        package arguments that will go into *args/**kwargs into a tuple/dict,
        and coerce arguments to the appropriate type.
        Nc                    g | ]	}|j         
S r?  )r  rA  r  s     r   rD  z?LowLevelIRBuilder.native_args_to_positional.<locals>.<listcomp>      666c666r   c                    g | ]	}|j         
S r?  )r  r  s     r   rD  z?LowLevelIRBuilder.native_args_to_positional.<locals>.<listcomp>  r  r   c                ,    g | ]}t          |          S r?  r}   )rA  arg_kinds     r   rD  z?LowLevelIRBuilder.native_args_to_positional.<locals>.<listcomp>  s!    PPP(+H55PPPr   c                4    t          t          j                  S r   )r   r   special_form)ns    r   r  z=LowLevelIRBuilder.native_args_to_positional.<locals>.<lambda>  s    gi455 r   Fc                >    g | ]}|         |         |         fS r?  r?  )rA  rX  r  r  r   s     r   rD  z?LowLevelIRBuilder.native_args_to_positional.<locals>.<listcomp>  s-    (\(\(\ST$q'9Q<1)N(\(\(\r   r  r           T)r  r   )r   num_bitmap_argsr
   rU  r  r  extendr   r   r  r  re   r+  r7   rf   r0   r   r;   r  r  r@  r   reversedrS  rQ  error_overlapr   rX   )r   r   r  r  r  r3  r  sig_argsr  sig_arg_kindssig_arg_namesconcrete_kindsformal_to_actualr  r  star_arg_entrieslstr  star_argr  output_args
output_argbase_argrX  bitmapr  s    ```                      r   r  z+LowLevelIRBuilder.native_args_to_positionalh  s   & 8 	%!}H66X66666X666PPiPPP155
 
  %$9,h77 	; 	;HCx!! ^ ''(\(\(\(\(\(\X[(\(\(\]]]738x#7H!:SX%:II"55dX 6 
 
) $&,h77 	+ 	+HCx8##%

Y&&&I$*;*;BD*I*I

 G'11 V!(CH!5!5JJ(22 V!&sJJ!%.t*T*T*T!U!UJJA<SV$0022 G!%!5!5h$!O!OJJ!%Xsx!F!FJz****%((## 	C 	CA q3{#3#333"";q>222FA 0(;;  S8'')) ch.D ;!CCCCq1u.CCCCCC C"aAq,A&BBFFAwv/@AABBBBr   baser  RType | Nonelist[str | None] | Nonec	           
        |3t          d |D                       r|                     ||||||          S t          |z   }	t          |j        t
                    rs|j        j        j        s |j        j                            |	          rB|j        j        j	        s0|j        j        j        r|n|	}|j        j                            |          r|j        j        
                    |          }
|%|
J d            d |D             }d |D             }n|
J d            |
j        sJ |                     ||||
j        |          }|                     t          ||||                    S |j        j                            |          r>|                     t!          |||                    }|                     |||||          S n;t          |j        t$                    r!|                     ||j        ||||||          S |r|t(          gt+          |          z  k    r|                     ||||||          }|r|S |                     ||||||          S )	z/Generate either a native or Python method call.Nc              3  >   K   | ]}|                                 V  d S r   )r  r  s     r   r  z4LowLevelIRBuilder.gen_method_call.<locals>.<genexpr>  s*      (N(ND(N(N(N(N(N(Nr   z&arg_kinds not present but arg_names isc                    g | ]	}t           
S r?  r  rA  _s     r   rD  z5LowLevelIRBuilder.gen_method_call.<locals>.<listcomp>  s     = = =Q = = =r   c                    g | ]}d S r   r?  r7  s     r   rD  z5LowLevelIRBuilder.gen_method_call.<locals>.<listcomp>  s     : : :! : : :r   z&arg_kinds present but arg_names is notr  r7  )anyr  r   r#  r+  rR   r  r  
has_methodbuiltin_basemethod_decl	bound_sigr  r   r@   r  r4   r  rV   union_method_callr   rQ  r  )r   r1  r  r  r  r3  r  r  r0  	fast_namer  r  r   s                r   gen_method_callz!LowLevelIRBuilder.gen_method_call  s     S(N(NI(N(N(N%N%N &&tT:tYPYZZZ  $&	ty),,	#0	48I4F4Q4QR[4\4\	 I&3	
  9-:I44	Dy!,,T22 y)55d;;$$,,.V,,, = =* = = =I : :z : : :II$002Z000 ~%%%!;;	9dnd 
 xx
4z4 H HIII#,,T22 88GD$$=$=>>||j$)y $    	6** 	))diz;iQZ  
  	I'S__)DDD77dJTj 8  F   ""4z4IVVVr   obj_typereturn_rtypec	                l     pt           d fd}	                     |||	          S )z8Generate a method call with a union type for the object.r-  rK   r   c           	     :                         |           S r   )rA  )r-  r  r  r  r3  r  rC  r   s    r   call_union_itemz<LowLevelIRBuilder.union_method_call.<locals>.call_union_item  s*    ''tZtY	  r   r  )rx   r  )
r   r1  rB  r  r  rC  r3  r  r  rF  s
   `  `````` r   r?  z#LowLevelIRBuilder.union_method_call  sq     $8'8	 	 	 	 	 	 	 	 	 	 	 	
 **4<Z^___r   c                ,    t          dt                    S )z0Load unboxed None value (type: none_rprimitive).r   )r7   rv   r  s    r   nonezLowLevelIRBuilder.none      q/***r   c                ,    t          dt                    S )z0Load unboxed True value (type: bool_rprimitive).r   r7   rY   r  s    r   r  zLowLevelIRBuilder.true   rI  r   c                ,    t          dt                    S )z1Load unboxed False value (type: bool_rprimitive).r   rK  r  s    r   r  zLowLevelIRBuilder.false$  rI  r   c                t    |                      t          t          j        t          j        d                    S )z1Load Python None value (type: object_rprimitive).r   r  )r   r:   r   r+  r'  r  s    r   none_objectzLowLevelIRBuilder.none_object(  s*    xxN$79KRTUUUVVVr   c                R    |                      t          t          d                    S )z2Load Python True object (type: object_rprimitive).Py_Truer   r<   rx   r  s    r   true_objectzLowLevelIRBuilder.true_object,  s    xx
#4i@@AAAr   c                R    |                      t          t          d                    S )z3Load Python False object (type: object_rprimitive).Py_FalserQ  r  s    r   false_objectzLowLevelIRBuilder.false_object0  s    xx
#4jAABBBr   r-  c                    |t           k    s|t          k     r(|                     t          |t                              S t          |          S )z-Load a tagged (Python) integer literal value.)r   r   r   r=   ra   r7   r   r-  s     r   load_intzLowLevelIRBuilder.load_int4  sA    (((E4I,I,I88K~>>???5>>!r   rO  c                     t          |          S )zLoad a float literal value.)r0   rW  s     r   
load_floatzLowLevelIRBuilder.load_float;  s    U||r   c                R    |                      t          |t                              S )zLoad a str literal value.

        This is useful for more than just str literals; for example, method calls
        also require a PyObject * form for the name of the method.
        )r   r=   r|   rW  s     r   r$  zLowLevelIRBuilder.load_str?  s      xxE>::;;;r   bytesc                R    |                      t          |t                              S )zLoad a bytes literal value.)r   r=   rZ   rW  s     r   
load_byteszLowLevelIRBuilder.load_bytesG  s    xxE+;<<===r   complexc                R    |                      t          |t                              S )zLoad a complex literal value.)r   r=   rx   rW  s     r   load_complexzLowLevelIRBuilder.load_complexK  s    xxE+<==>>>r   r   r  
identifier
str | None	namespace	error_msgc           	        |d| d}t                      t                      }}|                     t          |||||                    }	|                     t          |	||t          j        d                     |                     |           |                     t          t          j        ||                     |                     t                                 |                     |           |	S )Nzname "z" is not definedr  Trare)	r(   r   r?   r*   rz  r  rD   
NAME_ERRORrJ   )
r   r  rb  r   rd  r3  re  ok_blockerror_blockr-  s
             r   load_static_checkedz%LowLevelIRBuilder.load_static_checkedO  s     ====I *jll+C[)RVWWWXX{HfoDQQQRRRK(((#$6$A9dSSTTTH%%%r   c                `    |                      t          t          |t                              S )N)rd  )r   r?   rx   r#   )r   r  s     r   load_modulezLowLevelIRBuilder.load_modulec  s%    xx
#4dFVWWWXXXr   clsc                N    |j          d|j         }|                     |          S )zLoad native type object..)r   r  load_native_type_object)r   ro  fullnames      r   r  z!LowLevelIRBuilder.get_native_typef  s-    o2222++H555r   rs  c                    |                     dd          \  }}|                     t          t          ||t                              S )Nrq  r   )rsplitr   r?   rx   r%   )r   rs  moduler  s       r   rr  z)LowLevelIRBuilder.load_native_type_objectk  s:    sA..xx
#4dFNSSTTTr   lregrregc           	     |   |j         }|j         }t          |t                    r1t          |t                    r|dv r|                     ||||          S |dv r|                     ||||          }||S |dv r|                     ||||          S t          |          r\t          |          rM|t          v rD|t          j	        v r| 
                    ||||          S |                     |||d         |          S t          |t                    r|dv r|                     ||||          S t          |          r|t          v r|                    d          }|dk    rt"          |         }nt$          j        }t          |          r|                     |||          }|}t          |          st+          |          r|                     |||||          S t          |t.                    r.|                     |||                     |||          ||          S n|t          j	        v rt1          |          r|                     |||          }n&t          |          r|                     |||          }t          j	        |         }t          |j                   r|                     ||||          S t          |t.                    r-|                     ||                     |||          ||          S nt          |          r|t          v r|                    d          }|dk    rt"          |         }nt$          j        }t          |t.                    r.|                     ||                     |||          |||          S t+          |          r|                     |||||          S t          |          r0|                     |||          }|                     |||||          S n|t          j	        v rt1          |          r|                     |||          }n&t          |          r|                     |||          }t          j	        |         }t          |t.                    r-|                     |                     |||          |||          S t          |j                   r|                     ||||          S t7          |          st7          |          rtt          |t.                    r/t9          t;          |                                                    }nt          |t.                    r/t9          t;          |                                                    }nUt1          |j                   r|                     ||          }n*t1          |j                   r|                     ||          }t7          |j                   rt7          |j                   ro|t@          v r#| !                    ||t@          |         |          S |"                    d          r|dd         }	n|}	|	tF          v r| $                    |||	|          S | %                    ||||          }
|
r|
S tM          j'        |g           }| (                    |||g|          }|sJ d	|z              |S )
zPerform a binary operation.

        Generate specialized operations based on operand types, with a fallback
        to generic operations.
        )r   r   N)isis notr   )innot in=r   r   z Unsupported binary operation: %s))r+  r#  rT   compare_tuplestranslate_eq_cmptranslate_is_oprb   r   r.   
signed_opsbool_comparison_opbool_bitwise_oprR   translate_instance_containsre   r   removesuffixrN   r8   DIVr@  rs   fixed_width_int_opr7   rk   rG  comparison_oprf   r0   rO  rE  rP  rL   compare_floatsendswithrM   float_op	dunder_opr   getmatching_primitive_op)r   rw  rx  r   r3  ltyper*  r-  op_idbase_opr  primitive_ops_candidatesr   s                r   	binary_opzLowLevelIRBuilder.binary_opq  s    		 eV$$ 	=E6)B)B 	=r\GYGY&&tT2t<<< ))$b$??E  !!!''dB===%e,,	E)%00	E o%%\,,,..tT2tDDD++D$1tDDDeY'' 	JB2B,B,B33D$DIII&& 3	G///__S))::(,EE!IE,U33 ";;tUD99D!E'.. S)E2B2B S225$eTRRRdG,, 22tT[[ud%C%CUD   |...$U++ :99$tLLDD.u55 :;;tUD99D$/3'	22 G--dD%FFFdG,, a--dDKKeT4R4RTY[_```!%(( 	G///__S))::(,EE!IEdG,, 22t{{4==tUD   U## S225$eTRRR,U33 S;;tUD99D225$eTRRRS |...$U++ :99$tLLDD.u55 :;;tUD99D$/3dG,, a--dkk$t.L.LdTY[_```'	22 G--dD%FFFu%% 	D)<U)C)C 	D$(( 5U4#5#5#7#78899D'** 5U4#5#5#7#78899"49-- 5((t44"49-- 5((t44"49-- D2Edi2P2P D222..tT;TUW;XZ^___;;s## ! "gGG Gn,,==tWdCCCNN4r488	 	#->"b#9#9 ++,DtTlTXYY>>9B>>>>r   c                   |j         }t          |t                    sdS |rt          j        |          nt          j        |          }|dS |j                            |          sdS |j                            |          }|st          |j
        j                  dk    rdS |rIt          |j
        j                  dk    s*t          |j         |j
        j        d         j                   sdS |r&t          t          j         |j
        j                  rdS |r|gng }|                     ||||j
        j        |          S )a[  
        Dispatch a dunder method if applicable.

        For example for `a + b` it will use `a.__add__(b)` which can lead to higher performance
        due to the fact that the method could be already compiled and optimized instead of going
        all the way through `PyNumber_Add(a, b)` python api (making a jump into the python DL).
        Nr   r=  )r+  r#  rR   r   r  r   r  r;  r=  rQ  r  r   r   r   ret_typerA  )	r   rw  rx  r   r3  r  r  r  r   s	            r   r  zLowLevelIRBuilder.dunder_op  sC    	%++ 	4,0NjnR(((6F6J26N6N4~((55 	4~))+66 	DHM**a//4 	S''1,,Jty$(-XYJZJ_4`4`,4 	J168IJJ 	 4%vv2##D+tTX=NPTUUUr   valnegatedc                   t          dt          |          }|                     t          ||t          j        |          }t          dt          |          }|rt
          j        nt
          j        }|                     ||||          }|S )zuCheck if a tagged integer is a short integer.

        Return the result of the check (value of type 'bit').
        r   r   )	r7   r]   rM  r8   ANDr.   NEQr  r  )	r   r  r3  r  int_tagbitwise_andzeror   rg  s	            r   r\  z(LowLevelIRBuilder.check_tagged_short_int  sw    
 !3T::kk"8#w	SWXXq0$77!(=\lo"";b$??r   lhsrhsc           	        |dk    rd}dd} ||          rJ ||          r8|j         |j         k    r|                                 n|                                 S ||}}d}n ||          rd}|rot          t          t          t
          |          j                   }t          t          |          t          |          }| 	                    t          |||g|          S | 	                    t          ||g|          S |d	k    rY|                     ||d|          }	|                     t          |	|                                 t          j        |                    S |                     t"          ||g|          }
t          d
t$          |          }|                     t          |
|t          j        |                    }t'                      t'                      t'                      }}}t)          |||t(          j                  }d|_        |                     |           |                     |           |                     t0          g |          }t          dt2          |          }|                     t          ||t          j        |                    }t)          |||t(          j                  }d|_        |                     |           |                     |           |                     t6          g |           |                     |           |                     |           |dk    rt          j        nt          j        }|                     t          |
t          dt$                    ||                    S )zCompare two stringsr   Fr-  rK   r   TypeGuard[LoadLiteral]c                T    t          | t                    ot          | j                  S r   )r#  r=   rr   r+  )r-  s    r   is_string_literalz<LowLevelIRBuilder.compare_strings.<locals>.is_string_literal  s"    !%55W:KEJ:W:WWr   Tr   r   r   )r-  rK   r   r  )r-  r  r  r   r   r=   r7   rQ  r]   r%  r   r   compare_stringsr   r.   r  rb  r   r[   r(   r*   r]  r  r  r   rz   r  r   r   )r   r  r  r   r3  literal_fastpathr  literal_stringliteral_lengtheqcompare_resulterror_constantcompare_error_checkexception_check	propagatefinal_comparebranchcheck_error_resultnullop_types                       r   r  z!LowLevelIRBuilder.compare_strings  s:   ::$X X X X ! %% 	($$S)) S*-)sy*@*@499;;;djjllR S#'  ""3'' (#'  [!%c4S+A+A+G!H!H!(^)<)<>TVZ![![((#sN9SUYZZZ$$Vc3Z>>>4ZZ%%c3d;;B88LTZZ\\<?DQQRRR
 _sCj$GG %5t<<"hh$OO
 
 5?LL*,,PZP\P\M+_mV[YYO,,,![["dCCq,d33"hh+T<3CTJJ
 
 +Yv{SSI&&&'T222		-   M***%'4ZZ,//\5Exx^WQ@P5Q5QSZ\`aabbbr   c           	         |                      t          ||g|          }|dk    rt          j        nt          j        }|                     t          |t          dt                    ||                    S )Nr   r   )rb  r   r.   r  r  r   r7   r[   )r   r  r  r   r3  r  r  s          r   compare_byteszLowLevelIRBuilder.compare_bytesM  s^    ]S#JEE%'4ZZ,//\5Exx^WQ@P5Q5QSZ\`aabbbr   c                    t          j        t                    rt          j        t                    sJ j        j        f            |dk    rdnd}t          t                    }t          j        j                  t          j        j                  k    rN                     t          ||r 	                                n 
                                                     |S t          j        j                  dk    rkt          j        j                  dk    rN                     t          ||r 
                                n 	                                                     |S t          j        j                  }t                      t                      t                      }
}	}d t          |          D             } fdt          |          D             } fdt          |          D             }|r||	}}n|	|}}t          t          j        j                            D ]}|dk    r                     ||                    ||         }||         }                     |||          }t          |j                  s                     t"          |g          }|t          j        j                  dz
  k     r&t%          ||||dz            t$          j                  }nt%          |||t$          j                  }||_                             |                                |                                t          | 	                                                                          |
                                |	                                t          | 
                                                                          |
           |S )	zCompare two tuples item by itemr   TFr   c                *    g | ]}t                      S r?  )r(   r7  s     r   rD  z4LowLevelIRBuilder.compare_tuples.<locals>.<listcomp>b  s    <<<
<<<r   c           	     X    g | ]&}                     t          |                    'S r?  r   rG   )rA  rX  r  r3  r   s     r   rD  z4LowLevelIRBuilder.compare_tuples.<locals>.<listcomp>c  1    MMM!TXXhsAt4455MMMr   c           	     X    g | ]&}                     t          |                    'S r?  r  )rA  rX  r3  r  r   s     r   rD  z4LowLevelIRBuilder.compare_tuples.<locals>.<listcomp>d  r  r   r   )r#  r+  rT   rE   rY   rQ  rR  r   r&   r  r  r(   rS  r  r  rb   r%  r   r*   r]  r  r   r  )r   r  r  r   r3  equalr  lengthfalse_assigntrue_assignr}  check_blocks	lhs_items	rhs_items
early_stopfinalrX  lhs_itemrhs_itemcomparer  s   ``` `                r   r  z LowLevelIRBuilder.compare_tuplesR  sw    #(F++b
38V0L0LbbsxY\YaNbbbbd

/**sx~#chn"5"555HHVFE$JDJJLLLtyy{{DQQRRRMsx~!##CHN(;(;q(@(@HHVF5$JDIIKKKdjjllDQQRRRMSX^$$)3z||Z\\3k<<eFmm<<<MMMMMMuV}}MMM	MMMMMMuV}}MMM	 	: ,kJJ +\Js38>**++ 	 	AAvv##LO444 |H |HnnXxTBBG -W\:: F++GgYEE3sx~&&***\!a%5H&+VVUFKHH"FNHHVL)))

d33444		#K(((		T22333s###r   instrY  c                    |                      |d|gd |          }t          |j                  s|                     t          |g|          }|dk    r,|                     |t          dt                    d|          }|S )N__contains__r}  r   r)  r   )rA  rb   r+  r%  r   r  r7   rY   )r   r  rY  r   r3  rc  s         r   r  z-LowLevelIRBuilder.translate_instance_contains  s    ""4$tLL(22 	:##GcUD99C>>&&sGA_,M,M,MsTXYYC
r   c           	         |dk    rt           j        }n0|dk    rt           j        }n|dk    rt           j        }n
J |            |                     t          t
          ||||                    S )Nr   r   r   )r8   r  ORra  r   rY   )r   rw  rx  r   r3  codes         r   r  z!LowLevelIRBuilder.bool_bitwise_op  sh    999DD3YY8DD3YY9DD"xxotT4FFGGGr   c                V    t           j        |         }|                     ||||          S r   )r.   r  r  )r   rw  rx  r   r3  r  s         r   r  z$LowLevelIRBuilder.bool_comparison_op  s)    '+!!$eT:::r   c                    t          |j        t                    r|                     |d ||          }||S t	          j        |g           }|                     ||g|          }|sJ d|z              |S )NUnsupported unary operation: %s)r#  r+  rR   r  r   r  r  )r   r-  r   r3  r  r  r   s          r   _non_specialized_unary_opz+LowLevelIRBuilder._non_specialized_unary_op  s    ej),, 	^^E4T::F!#,=R#8#8 ++,DugtTT==82====r   )likely_boolr  c          	        |j         }t          |          r4t          d||          }|                     |||t          j        |          S t          |          st          |          r%|                     |t          d          d|          S t          |          sBt          |          s3t          |          s$t          |          st          |t                    r+|                     |          }|                     ||          S t#          |          rt%          |          }|sJ t          |          sCt          |          s4t          |          s%t          |          st          |t                    rt'          t(                    }|                     t-          ||                                 t,          j        |                    }	t3                      t3                      t3                      }}}
|                     t5          |	|
|t4          j                             |                     |
           |                     t;          ||                                                      |                     |           |                     |           |                     |                      |||dd          |          }|                     t;          ||                     |                     |           |                     |           |S |rtC          |          rt'          t(                    }t3                      t3                      t3                      t3                      f\  }}}}t3                      }|                     t-          || "                                t,          j        |                    }	|                     t5          |	||t4          j                             |                     |           |                     t;          || #                                                     |                     |           |                     |           |                     t-          || $                                t,          j        |                    }	|                     t5          |	||t4          j                             |                     |           |                     t;          ||                                                      |                     |           |                     |           | %                    |d|          }|                     t;          ||                     |                     |           |                     |           |S | %                    |d|          S )zPerform unary 'not'.

        Args:
            likely_bool: The operand is likely a bool value, even if the type is something
                more general, so specialize for bool values
        r   r   r   Tr/  not)&r+  rb   r7   rM  r8   ra  rs   re   r  rr   rl   rt   rd   r#  rR   
bool_value	unary_notro   ry   rE   rW   r   r.   rN  r  r(   r*   r]  r  r&   r  r   r6  rn   rR  r  rU  r  )r   r-  r3  r  r  maskbool_val	value_typrc  cmprH  not_noner}  r  r  	not_falser  r  s                     r   r  zLowLevelIRBuilder.unary_not  s    j$S)) 	B1c4((D;;sE4DAAAS>> 	A1#66 	A>>%T4@@@c""	2!#&&	2 #3''	2 "#&&		2
 #y))	2 u--H>>(D111C   	+C00I!),,%i00 'y11 &i00	
 i33 ~..hh|E43C3C3E3E|X\]]^^&0llJLL*,,hT8V[AABBB##D)))TYY[[11222		###H---nn&&ui$Z^&__  S))***		###C(((
 	/44 	>**C,6LL*,,
V`VbVb,b)E9dE,,C((<t/?/?/A/A<?TXYYZZCHHVC	6;??@@@&&&HHVC..///IIcNNN	***((<t/@/@/B/BLOUYZZ[[CHHVCufk::;;;%%%HHVC--...IIcNNN&&&00tDDCHHVC%%&&&IIcNNN$$$J--eUDAAAr   c                   |j         }t          |t                    r$t          |                                 ||          S t          |t                    rt	          |j         |          S t          |          r1|                     |t          d|          |t          j	        |          S t          |          r#|                     t          ||                    S |                     |d|          S )zPerform unary '-'.r   r   )r+  r#  r7   rE  r0   r-  re   rM  r8   SUBrf   r   r2   r  r   r-  r3  r  s       r   unary_minuszLowLevelIRBuilder.unary_minus  s    jeW%% 		3E//1113===u%% 	3%+t,,,!#&& 	3;;sGAsOOUEItLLL %% 	388HUD11222--eS$???r   c                    |j         }t          |          s-t          |          st          |          st	          |          r|S |                     |d|          S )zPerform unary '+'.r   )r+  rs   rf   rb   re   r  r  s       r   
unary_pluszLowLevelIRBuilder.unary_plus  sj    jcNN	"3''	 )--	 $C((		 L--eS$???r   c                N   |j         }t          |          ry|j        r1|                     ||t	          d|          t
          j        |          S d|j        dz  z  dz
  }|                     ||t	          ||          t
          j        |          S |                     |d|          S )zPerform unary '~'.r   r   r   ~)	r+  re   rL  rM  r7   r8   ra  rK  r  )r   r-  r3  r  r  s        r   unary_invertzLowLevelIRBuilder.unary_invert	  s    j$$ 	T} T{{3wr3/?/?DQQQ chl+q0{{3wtS/A/A59dSSS--eS$???r   c                   |dk    r|                      ||          S |dk    r|                     ||          S |dk    r|                     ||          S |dk    r|                     ||          S t	          d|z            )zPerform a unary operation.r  r   r   r  r  )r  r  r  r  RuntimeError)r   r-  r   r3  s       r   unary_opzLowLevelIRBuilder.unary_op  s    ;;>>%...3YY##E40003YY??5$///3YY$$UD111<rABBBr   key_value_pairsSequence[DictEntry]c                \   d }g }g }|D ]\  }}|J|+|                     |           |                     |           4|                     |d||gd |           Q||                     |||          }|                     t          ||g|           ||                     |||          }|S )Nr  r  r  )r   r  r  rb  r   )r   r  r3  r  keysr	  r  r-  s           r   	make_dictzLowLevelIRBuilder.make_dict"  s    # ) 	S 	SJC>KK$$$MM%(((22MC<TPT 3    
 >!..tVTBBF5TRRRR>&&tVT::Fr   r  c                <    |                      t          |g|          S )a  This function returns an uninitialized list.

        If the length is non-zero, the caller must initialize the list, before
        it can be made visible to user code -- otherwise the list object is broken.
        You might need further initialization with `new_list_set_item_op` op.

        Args:
            length: desired length of the new list. The rtype should be
                    c_pyssize_t_rprimitive
            line: line number
        )rb  r   r   r  r3  s      r   new_list_op_with_lengthz)LowLevelIRBuilder.new_list_op_with_length=  s     {{;$777r   c           	     f    t          t          |          t                    g}t          |          t          k    r                     t
          ||z             S                      t          |          }|s|S  fd|D             }                     t          |gt                              }t          t          |                    D ]:}                     t          |t          |t                    ||         g           ;                     t          |g                     |S )Nc                H    g | ]}                     |t                    S r?  r  )rA  rY  r3  r   s     r   rD  z1LowLevelIRBuilder.new_list_op.<locals>.<listcomp>W  s*    NNNtD"3T::NNNr   )r7   rQ  r]   !LIST_BUILDING_EXPANSION_THRESHOLDrb  r   r   r   rC   r   rS  r%  r   r9   )r   r	  r3  r  result_listr   ob_item_baserX  s   ` `     r   r   zLowLevelIRBuilder.new_list_opK  s*   &s6{{4JDQQRv;;;;;;;}fvotDDD kk+vt<< 	NNNNNvNNNxx[M:t L LMMs6{{## 	 	Aga9O.P.PRVWXRYZ\`    	K=))***r   c                :    |                      t          ||          S r   )r%  r   )r   r	  r3  s      r   r   zLowLevelIRBuilder.new_set_op`  s      VT:::r   r  	item_typer  c                  t          t          |t          |                              }|                     t	          |t          |                               |                     t          |rt          nt          |                    S )z;Declare and initialize a new RArray, returning its address.)	rE   rQ   rQ  r   r'   r  r:   rw   r\   )r   r  r	  r  arrays        r   r  zLowLevelIRBuilder.setup_rarrayc  ss     	3v;;7788UDLL11222xxZY11EY[`aa
 
 	
r   	expr_typeleftCallable[[], Value]rightc                   t          |          }t                      t                      t                      }	}}|dk    r||fn||f\  }
} |            }|                     ||
|           |                     |           |                     |||          }|                     t          ||                     |                     |	           |                     |            |            }|                     |||          }|                     t          ||                     |                     |	           |                     |	           |S )Nand)rE   r(   add_bool_branchr  r@  r   r&   r   )r   r   r  r  r  r3  r   	left_body
right_body
next_block	true_body
false_body
left_valueleft_coercedright_valueright_coerceds                   r   r  z%LowLevelIRBuilder.shortcircuit_helperm  sC    )$$,6LL*,,
z:	 <>;;Y 7 7YXbLc	:TVV
ZJ???I&&&{{:y$??--...		*J'''eggKDAA..///		*J'''r   c           	        t          |j                  r|}nEt          |j        t                    r>t	          dt
                    }|                     ||t          j        |j	                  }nt          |j                  rEt	          d|j                  }|                     t          ||t          j                            }nt          |j                  r$|                     t          |g|j	                  }n\t          |j                  s(t!          |j                  st#          |j                  rI|                     ||j	                  }t	          d          }|                     ||d|j	                  }nt)          |j        t*                    rU|j        j        j        rD|j        j                            d          r%|                     |dg t4          |j	                  }nht7          |j                  r6|                     |t;          d          t<          j        |j	                  }nt?          |j                  }||                      || !                                d|j	                  }d}t)          |t*                    r6|j                            d          s|j        "                    d          rd}|r|}ntG          tH                    }tK                      tK                      tK                      }
}	}tM          |||	tL          j'                  }|                     |           | (                    |           | )                    |||j	                  }| *                    |          }|                     tW          ||                     | ,                    |
           | (                    |	           |                     tW          |t	          dtH                                         | ,                    |
           | (                    |
           n"| -                    t\          |g|j	                  }|S )	z_Return bool(value).

        The result type can be bit_rprimitive or bool_rprimitive.
        r   r   __bool__r   Nr{  FT)/rb   r+  r   ra   r7   r{   r  r.   r  r3  re   r   rr   rb  r   rl   rd   rt   builtin_lenr  r#  rR   r  r  r;  rA  rY   rf   r  r0   r1   ry   r  rN  is_method_finalrE   rW   r(   r*   r]  r  r6  r  r&   r   r%  r   )r   r-  r  r  r  r  r  always_truthyr  r  rf  r  	remainingas_bools                 r   r  zLowLevelIRBuilder.bool_value  s   
 %UZ00 ;	IFF
N;; 9	I1233D''t\5EuzRRFF!%*-- 6	I1ej))DXXl5$8HIIJJFFuz** 3	I[[!2UGUZHHFFuz**1	I!%*--1	I #5:..1	I
 %%eUZ88F1::D^^FD$
CCFFuz9--)	I
#0)	I 
#..z::)	I ))%RRWR\]]FF ,, "	I((c

<M<QSXS]^^FF,UZ88J%//t7G7G7I7I8UZU_`` %j)44 -%.99"  -$-==jII- )-  -%FF &n55F'1||Z\\:<<%D#HdE6;GGFHHV$$$''--- !% 2 25*ej Q QI"ooi88GHHVFG44555IIcNNN''...HHVFGA~,F,FGGHHHIIcNNN'',,,,**7UGUZHHr   r  r  c                   t          |j                  }|F|                     |          }|                     t	          |||t          j                             d S |                     ||                                 d|j                  }t	          |||t          j                  }|                     |           d}t          |t                    r6|j                            d          s|j                            d          rd}|sbt                      |_        |                     |j                   |                     |||j                  }	|                     |	||           d S d S )Nr{  Fr  T)ry   r+  r  r   r*   r]  r  rN  r3  r#  rR   r  r;  r  r(   r  r  r6  r   )
r   r-  r  r  opt_value_typer  is_noner  r  r  s
             r   r   z!LowLevelIRBuilder.add_bool_branch  sc   ,UZ88!//JHHVJeV[AABBBBB **5$2B2B2D2DhPUPZ[[GGT5&+>>FHHV!M.)44 )%.99  )$-==jII) %)M  =(ll##FK000 !..unejQQ	$$Ye<<<<<= =r   descr   c                   g t          t          t          |          t          |j                                      D ]C}|j        |         }||         }|                     |||          }                    |           D|j        |j        J fd|j        D             d}|j        t          |j                  }t          t          |j                  t          |                    D ];}||         }|                     ||j        |          }                    |           <|j        D ]-}	|	\  }
}t          |
||          }                    |           .|j
        }|t          k    rt          }|                     t          |j        |j        |j        |j        ||||j        |j        |j                            }|j        r;D ]8}t-          |t          t.          f          s| j                            |           9|j
        t          k    rQt3          |t          d|j        |          t2          j        |          }t6          |_
        |                     |           |j        |}n*|                     t;          ||j                            }|}|rWt=          |j        |          sBtA          |          r| !                                }n|                     ||||j                  }|S )zHCall function using C/native calling convention (not a Python callable).Nc                     g | ]
}|         S r?  r?  )rA  rX  r~  s     r   rD  z,LowLevelIRBuilder.call_c.<locals>.<listcomp>   s    999awqz999r   r   is_purereturns_nullcapsuler   r7  )"rS  minrQ  	arg_typesr@  r   orderingvar_arg_typeextra_int_constantsr7   
error_kindr   r"   r   r,   c_function_namereturn_typestealsr  r  r  r  r#  r=   r   r.   r_  r!   truncated_typerF   r   r+  rm   rH  )r   r  r   r3  r  rX  formal_typer  var_arg_idxrY  r  r  extra_int_constantr   r   compr  truncater~  s                     @r   rb  zLowLevelIRBuilder.call_c  s    s3t99c$.&9&9::;; 	  	 A.+Kq'C++c;55CNN3=$$,,,99994=999G(dn--K3t~..D		:: $ $1gkk#t'8$??s####, 	/ 	/DHC!(c4!8!8NN-...._
$$"J$  !.  
 
  	1  1 1!#'=>> 1$++C000?k))43CT(J(JLL\^bccD'DOHHTNNN&FFxx1D E EFFHF 	]1&+{KK 	]!+.. ] V[$4K[\\r   
candidateslist[CFunctionDescription]c                   d }|D ]}t          |j                  t          |          k    r(t          d t          ||j                  D                       rN|j        r|rE|rA|j        |j        k    sJ d                    ||                      |j        |j        k    r|}|}|r|                     ||||          }|S d S )Nc              3  F   K   | ]\  }}t          |j        |          V  d S r   r   r+  rA  actualformals      r   r  z4LowLevelIRBuilder.matching_call_c.<locals>.<genexpr>G  sC        4BFF
6;//     r   Ambiguous:
1) {}
2) {})rQ  r  r  rU  r  priorityformatrb  )	r   r*  r   r3  r  r0  matchingr  r   s	            r   matching_call_cz!LowLevelIRBuilder.matching_call_c;  s    15 	$ 	$D4>""c$ii//  FI$PTP^F_F_     
$'
$+5
$  $#,===?Y?`?` $@ @=== }x'888#'#H 	[[4{CCFMtr   rB   c                   |j         r}t          |j        |j        |j        |j        |j        |j         |j        |j        |j	        |j
        |j        |j        |j        d|j                  }|                     ||||          S g }t!          t#          t%          |          t%          |j                                      D ]G}|j        |         }||         }	|J |                     |	||          }	|                    |	           H|j
        J |j        J |j        rJ |                     t-          |||                    }
|j	        r;|D ]8}	t/          |	t0          t2          f          s| j                            |	           9|j        t6          k    rQt9          |
t1          d|j        |          t8          j        |          }t<          |_        |                     |           |j        J |
}|rWt?          |j         |          sBtC          |          r| "                                }n|                     ||||j	                  }|S )zAdd a primitive op.Fr  )r  Nr  r   r7  )#r!  r   r  r  r"  r  r$  r   r#  r  r  r  r3  r  r  rb  rS  r  rQ  r@  r   r   rC   r#  r7   r=   r   r   r.   r_  r!   r   r+  rm   rH  )r   r  r   r3  r  c_descr~  rX  r%  r  r   r(  r  s                r   r%  zLowLevelIRBuilder.primitive_opW  si     	L *	 !#$ ("  F" ;;vtT{;KKK
 s3t99c$.&9&9::;; 	  	 A.+Kq'C***++c;55CNN3}$$$ (((+++++gt$???@@ 	1  1 1!#'=>> 1$++C000?k))43CT(J(JLL\^bccD'DOHHTNNN"*** 	]1&+{KK 	]!+.. ] V[$4K[\\r   list[PrimitiveDescription]c                   d }|D ]}t          |j                  t          |          k    r(|j        r| j        j        s<t          d t          ||j                  D                       rN|j        r|rE|rA|j        |j        k    sJ d	                    ||                      |j        |j        k    r|}|}|r| 
                    ||||          S d S )Nc              3  F   K   | ]\  }}t          |j        |          V  d S r   r.  r/  s      r   r  z:LowLevelIRBuilder.matching_primitive_op.<locals>.<genexpr>  sH         #FF 6;//     r   r2  )r3  r  )rQ  r  experimentalr   experimental_featuresr  rU  r  r3  r4  r%  )r   r*  r   r3  r  r0  r5  r  s           r   r  z'LowLevelIRBuilder.matching_primitive_op  s,    15 	$ 	$D4>""c$ii//  )K    '*$&?&?     $ '	$ ,6	$
  $#,===?Y?`?` $@ @=== }x'888#'#H 	Y$$Xt$K$XXXtr   r+  c           	     N    |                      t          |||||                    S )a  Generate a native integer binary op.

        Use native/C semantics, which sometimes differ from Python
        semantics.

        Args:
            type: Either int64_rprimitive or int32_rprimitive
            op: IntOp.* constant (e.g. IntOp.ADD)
        )r   r8   )r   r+  r  r  r   r3  s         r   rM  zLowLevelIRBuilder.int_op  s&     xxdCb$77888r   c           	     @   t           |         }|t          j        t          j        fv r+t	          |t
                    r|j        dk    s
|                     |t          d          t          j	        |          }t                      t                      }}|                     t          |||t          j        d                     |                     |           |t          j        k    rd}	nd}	|                     t          t          j        |	|                     |                     t#                                 |                     |           |t          j        k    r|                     |||          S |                     t          ||||                    S )a  Generate a native float binary arithmetic operation.

        This follows Python semantics (e.g. raise exception on division by zero).
        Add a FloatOp directly if you want low-level semantics.

        Args:
            op: Binary operator (e.g. '+' or '*')
        r   Trg  zfloat division by zerozfloat modulo)rM   r3   r  MODr#  r0   r-  r  r1   r  r(   r   r*   r]  r  rD   ZERO_DIVISION_ERRORrJ   	float_mod)
r   r  r  r   r3  r  r  errokmsgs
             r   r  zLowLevelIRBuilder.float_op  sZ    r"W['+...sE** (syC/?/?''U3ZZ9J9MtTT$,,
R3FKdCCCDDD##C(((GK''2CC(C+,>,RTWY]^^___'''##B'''GK>>#sD11188GCeT::;;;r   c                   |                      t          ||t          j        |                    }t          t                    }|                      t          ||                     t                      t                      t                      t                      f\  }}}}	|                      t          |t          d          t          j	        |                    }
|                      t          |
||t          j                             |                     |           |                     |||          }|                      t          ||	|t          j                             |                     |           |                     ||d|          }|                      t          ||                     |                      t          |	                     |                     |           |                     t"          t          d          |g|          }|                      t          ||                     |                      t          |	                     |                     |	           |S )z/Perform x % y on floats using Python semantics.r   r   )r   r3   r@  rE   r`   r&   r(   r1   r0   r  r*   r]  r  is_same_float_signsr  r6   r%  r   )r   r  r  r3  modrc  trickyadjustcopysigndoneis_zero
same_signsadjs                r   rB  zLowLevelIRBuilder.float_mod  s   hhwsCd;;<<'((S!!""")3z||Z\\S]S_S_)_&$((,S%**>O>RTXYYZZ66;??@@@F###--c3==

D&&+>>???F###mmCc400S!!"""dH%%% eCjj#->EES!!"""dD!!!
r   c                L    |                      t          ||||                    S r   )r   r1   r   r  r  r   r3  s        r   r  z LowLevelIRBuilder.compare_floats  s#    xx)#sB==>>>r   Value | intc                    t          |t                    rt          ||j                  }|                     |j        ||t
          j        d          S )zTHelper to add two native integers.

        The result has the type of lhs.
        r   r  )r#  r4  r7   r+  rM  r8   ADDr   r  r  s      r   int_addzLowLevelIRBuilder.int_add 	  G    
 c3 	)#sx((C{{38S#uyr{BBBr   c                    t          |t                    rt          ||j                  }|                     |j        ||t
          j        d          S )zgHelper to subtract a native integer from another one.

        The result has the type of lhs.
        r   r  )r#  r4  r7   r+  rM  r8   r  rU  s      r   int_subzLowLevelIRBuilder.int_sub		  rW  r   c                    t          |t                    rt          ||j                  }|                     |j        ||t
          j        d          S )zYHelper to multiply two native integers.

        The result has the type of lhs.
        r   r  )r#  r4  r7   r+  rM  r8   MULrU  s      r   int_mulzLowLevelIRBuilder.int_mul	  rW  r   rS   c                   |                      |||          }|                      |||          }|t          j        k    rt          |t                    rK|j        dvrB|j        s#|                     |||t          j        |          S |                     ||||          S t          |          rt          }nwt          |          rt          }n`t          |          rt          }nIt          |          r0|                     |||           |                     |||||          S J |            |                     |||g|          S |t          j        k    rt          |t                    rK|j        dvrB|j        s#|                     |||t          j        |          S |                     ||||          S t          |          rt(          }nwt          |          rt*          }n`t          |          rt,          }nIt          |          r0|                     |||           |                     |||||          S J |            |                     |||g|          S |                     |||||          S )a  Generate a binary op using Python fixed-width integer semantics.

        These may differ in overflow/rounding behavior from native/C ops.

        Args:
            type: Either int64_rprimitive or int32_rprimitive
            op: IntOp.* constant (e.g. IntOp.ADD)
        )r   r   )r@  r8   r  r#  r7   r-  rL  rM  inline_fixed_width_dividerj   r   ri   r   rh   r   ru   check_for_zero_divisionrb  r@  inline_fixed_width_modr   r   r   )r   r+  r  r  r   r3  prims          r   r  z$LowLevelIRBuilder.fixed_width_int_op	  s    kk#tT**kk#tT**??#w'' PCIW,D,D~ P;;tS#uy$GGG  99$S$OOO"4(( 
#&$T** #&$T** #&$T** #,,S$==={{4c2t<<<"d""";;tc3Z666??#w'' MCIW,D,D~ M;;tS#uy$GGG  66tS#tLLL"4(( 
##$T** ##$T** ##$T** #,,S$==={{4c2t<<<"d""";;tc3Z666{{4c2t444r   c                   t                      t                      }}|                     |t          d|          d|          }|                     t	          |||t          j                             |                     |           |                     t          t          j        d|                     |                     t                                 |                     |           d S )Nr   r   z"integer division or modulo by zero)
r(   r  r7   r   r*   r]  r  rD   rA  rJ   )r   r  r+  r3  rC  rD  rM  s          r   r_  z)LowLevelIRBuilder.check_for_zero_divisionR	  s    ,,
R..ga&6&6dCCb&+66777C   "68\^b 	
 	
 	

 	Br   c                   t          |          }|                     |||t          j        |          }|                     t          ||                     |                     ||||          }t                      t                      t                      }
}	}|                     t          ||
|t          j	                             | 
                    |           |                     |||t          j        |          }|                     t          ||t          j        |                    }|                     t          ||
|	t          j	                             | 
                    |	           |                     ||t          d|          t          j        |          }|                     t          ||                     |                     t!          |
                     | 
                    |
           |S )Nr   )rE   rM  r8   r  r   r&   is_same_native_int_signsr(   r*   r]  r  r[  r.   r  r7   r  r6   )r   r+  r  r  r3  rc  divrN  rI  rJ  rL  mulmul_eqrO  s                 r   r^  z+LowLevelIRBuilder.inline_fixed_width_divide_	  s   tnnkk$S%)T::S!!"""224c4HH
)||Z\\:<<
D&&+>>???F###kk$S%)T::,sC$GGHHffk::;;;F###kk$WQ%5%5uy$GGS!!"""dD!!!
r   c           	        t          |          }|                     |||t          j        |          }|                     t          ||                     |                     ||||          }t                      t                      t                      }
}	}|                     t          ||
|t          j	                             | 
                    |           |                     t          |t          d|          t          j        |                    }|                     t          ||
|	t          j	                             | 
                    |	           |                     |||t          j        |          }|                     t          ||                     |                     t          |
                     | 
                    |
           |S Nr   )rE   rM  r8   r@  r   r&   rd  r(   r*   r]  r  r.   r7   r  rT  r6   )r   r+  r  r  r3  rc  rH  rN  rI  rJ  rL  rM  rO  s                r   r`  z(LowLevelIRBuilder.inline_fixed_width_modr	  sv   tnnkk$S%)T::S!!"""224c4HH
)||Z\\:<<
D&&+>>???F###((<WQ-=-=|PTUUVVvv{;;<<<F###kk$S%)T::S!!"""dD!!!
r   abc           	     T   |                      t          |t          d|          t          j        |                    }|                      t          |t          d|          t          j        |                    }|                      t          ||t          j        |                    S ri  )r   r.   r7   r^  r  )r   r+  rj  rk  r3  neg1neg2s          r   rd  z*LowLevelIRBuilder.is_same_native_int_signs	  s|    xxQ4(8(8,:JDQQRRxxQ4(8(8,:JDQQRRxxT4$GGHHHr   c                P   |                      t          |t          d          t          j        |                    }|                      t          |t          d          t          j        |                    }|                      t	          ||t          j        |                    S )Nr   )r   r1   r0   LTr.   r  )r   rj  rk  r3  rm  rn  s         r   rG  z%LowLevelIRBuilder.is_same_float_signs	  sx    xx)!U3ZZ9J9MtTTUUxx)!U3ZZ9J9MtTTUUxxT4$GGHHHr   c                L    |                      t          ||||                    S r   )r   r.   rQ  s        r   r  zLowLevelIRBuilder.comparison_op	  s"    xxS#r488999r   use_pyssize_tc                   |j         }d}t          |          st          |          st          |          r|                     t
          |g|          }nt          |          st          |          rh|                     t          |t          d                    }|                     |t                    }|                     t          |g                     nYt          |          r|                     t           |g|          }n,t#          |          r|                     t$          |g|          }|B|r|S t'          dt          |          }|                     t*          ||t,          j        |          S t1          |t2                    r|rJ |                     |dg t6          |          }|                     |t6          |          }t;                      t;                      }
}	|                     |t'          d          d|          }|                     ||	|
           |                      |
           |                     tC          tB          j"        d|                     |                     tG                                 |                      |	           |S |r|                     tH          |g|          S |                     tJ          |g|          S )zGenerate len(val).

        Return short_int_rprimitive by default.
        Return c_pyssize_t if use_pyssize_t is true (unshifted).
        Nusedr   __len__r   r   z__len__() should return >= 0)&r+  rl   rt   rc   r%  r   rp   rg   r   r5   rP   r  r]   r9   rd   rb  r   rr   r   r7   rM  r{   r8   rN  r#  rR   rA  ra   r@  r(   r  r   r  rD   VALUE_ERRORrJ   r   r   )r   r  r3  rr  r  
size_valueelem_addressoffsetr  rD  failconds               r   r  zLowLevelIRBuilder.builtin_len	  s    h
c"" 		G&9#&>&> 		GBUVYBZBZ 		G**?SE4HHJJs## 	G'>s'C'C 	G88M#{F$K$KLLL|5KLLJHHYu%%&&&&$$ 	G%9C5$GGJJs## 	G%83%FFJ! "!!Q 6==F;;3ZIY[_```c9%% 	$$$$))#y"ndSSF[[>>F!||Z\\B>>&'!**dDAAD  r4000%%%HH"&24RTX   
 HH[]]######M  	<;;5udCCC;;~ud;;;r   rT  c                    |rBt          t          |          t                    }|                     t          |g|z   |          S |                     t
          g |          S r   )r7   rQ  r]   rb  r   r   )r   rT  r3  rK  s       r   r  zLowLevelIRBuilder.new_tuple	  sT     	G!#e**.DEED;;|dVe^TBBB;;;RFFFr   c                <    |                      t          |g|          S )a  This function returns an uninitialized tuple.

        If the length is non-zero, the caller must initialize the tuple, before
        it can be made visible to user code -- otherwise the tuple object is broken.
        You might need further initialization with `new_tuple_set_item_op` op.

        Args:
            length: desired length of the new tuple. The rtype should be
                    c_pyssize_t_rprimitive
            line: line number
        )rb  r   r  s      r   new_tuple_with_lengthz'LowLevelIRBuilder.new_tuple_with_length	  s     {{3fXtDDDr   r  c                <    |                      t          |g|          S r   )r%  r   )r   r  r3  s      r   rP  zLowLevelIRBuilder.int_to_float	  s      1#t<<<r   rB  c                v    t           r/t          j        dk    r!|                     t          |g|           dS dS dS )zFMake an object immortal on free-threaded builds (to avoid contention).)      N)r   sysversion_infor%  r   )r   rB  r3  s      r   set_immortal_if_free_threadedz/LowLevelIRBuilder.set_immortal_if_free_threaded	  sG     	: 0G ; ;osD99999	: 	: ; ;r   process_itemCallable[[Value], Value]c                4   g }g }|j         D ]B}t          |t                    r|                    |           -|                    |           Ct	                      }	t          |          }
t          |          D ]\  }}|t          |          dz
  k     p|}|rd|                     ||j	        |          }t	                      t	                      }}| 
                    |||           |                     |           |                     |||          } ||          }|                     |||          }|                     t          |
|                     |                     |	           |r|                     |           |rx|                     |t           |d          } ||          }|                     |||          }|                     t          |
|                     |                     |	           |                     |	           |
S )al  Generate isinstance() + specialized operations for union items.

        Say, for Union[A, B] generate ops resembling this (pseudocode):

            if isinstance(obj, A):
                result = <result of process_item(cast(A, obj)>
            else:
                result = <result of process_item(cast(B, obj)>

        Args:
            obj: value with a union type
            rtype: the union type
            result_type: result of the operation
            process_item: callback to generate op for a single union item (arg is coerced
                to union item type)
            line: line number
        r   T)r8  )rT  r#  rR   r   r(   rE   	enumeraterQ  r  r  r   r  r@  r   r&   r   rx   )r   r  r*  r  r  r3  
fast_items
rest_itemsrY  
exit_blockr  rX  
more_typesr   
true_blockfalse_blockr~  temptemp2s                      r   r  z(LowLevelIRBuilder.decompose_union_helper	  s   6 

K 	( 	(D$	** (!!$'''' !!$''''\\
+&& ,, 	1 	1GAtS__q00>JJ 0++CEE*4,,
K
$$R[AAA##J///kk#tT22G<((DKKk488EHHVFE**+++IIj!!! 1##K000 	" kk#'8$dkKKG<((DKKk488EHHVFE**+++IIj!!!J'''r   base_regc                l    t          j        |g           }|                     ||g|z   |||          }|S )ar  Translate a method call which is handled nongenerically.

        These are special in the sense that we have code generated specifically for them.
        They tend to be method calls which have equivalents in C that are more direct
        than calling with the PyObject api.

        Return None if no translation found; otherwise return the target register.
        r7  )r   r  r  )	r   r  r  r   r  r3  r0  r  r%  s	            r   r  z/LowLevelIRBuilder.translate_special_method_call 
  sL    " $3#6tR#@#@ 11$xj4&7{Wa 2 
 
 r   expr_opc                   |j         }|j         }t          |          r't          |          r|                     ||||          S t          |          r't          |          r|                     ||||          S t          |          }t          |          }d}	|Q|'t          ||          r|                     |          rd}	t          ||          r|                     |          rd}	n)|'t          ||          r|                     |          rd}	|	r|                     ||||          S t          |t                    r||k    sdS |j        }
|
                    d           p#|
                    d           p|
j        p|
j        }|rdS |
                    d          s"|dk    rdnd}|                     ||||          S |                     |t$          |         |g||          S )	zAdd an equality comparison operation.

        Note that this doesn't cover all possible types.

        Args:
            expr_op: either '==' or '!='
        FNT__eq____ne__r   rz  r{  )r+  rr   r  rc   r  ry   r   _never_equal_to_none_translate_fast_optional_eq_cmpr#  rR   r  r  inherits_pythonis_augmentedr;  r  rA  r   )r   rw  rx  r  r3  r  r*  loptroptfast_opt_eqr  cmp_varies_at_runtimeidentity_ref_ops                r   r  z"LowLevelIRBuilder.translate_eq_cmp7
  sI    		U## 	C(9%(@(@ 	C''dGTBBBu%% 	A*=e*D*D 	A%%dD'4@@@"5))"5)) Lt$<$<AZAZ[_A`A`"D%(( #T-F-Ft-L-L #"D%(( #T-F-Ft-L-L #" 	S77dGTRRR5),, 	%4>
 ((222 %++H555%'% $	 	 ! 	 4""8,, 	K&-oodd8O''dOTJJJ##D*W*=vudSSSr   c                >    t          |          pt          |          S )z+Are the values of type never equal to None?)rr   rc   )r   r  s     r   r  z&LowLevelIRBuilder._never_equal_to_noneq
  s      !%%A)<S)A)AAr   c           
     d   t          |j        t                    s||}}t          |j                  }|sJ t	          t
                    }|                     t          ||                                 t          j	        |                    }t                      }t                      }	t                      }
|                     t          |||	t          j                             |                     |           t          |j        t                    sR|dk    r|                                 n|                                 }|                     t!          ||                     nx|dk    rt          j	        nt          j        }|                     t          ||                                 ||                    }|                     t!          ||                     |                     |
           |                     |	           t          |j        t                    sY|                     |                     |||dd          |||          }|J |                     t!          ||                     nt                      }t                      }|                     t          ||                                 t          j	        |                    }|                     t          |||t          j                             |                     |           |dk    r|                                 n|                                 }|                     t!          ||                     |                     |
           |                     |           |                     |                     |||dd          |                     |||dd          ||          }|J |                     t!          ||                     |                     |
           |                     |
           |S )z}Generate eq/ne fast path between 'X | None' and ('X | None' or X).

        Assume 'X' never compares equal to None.
        r   Tr/  )r#  r+  rV   ry   rE   rY   r   r.   rN  r  r(   r*   r]  r  r  r  r&   r  r   r  r6  )r   rw  rx  r  r3  r  rc  r  l_none
l_not_noner}  r  r   r  r_none
r_not_nones                   r   r  z1LowLevelIRBuilder._translate_fast_optional_eq_cmpv
  s    $)V,, 	$t$D'	22	'' hh|D$*:*:*<*<lotTTUU\\
llVZ==>>>F###$)V,, 	'")T//$**,,,tyy{{CHHVC%%&&&&$+tOO9IB((<d.>.>.@.@"dKKLLCHHVC%%&&&		#J'''$)V,, 	&&&""4DTUY"ZZ	 B >>>HHVC__%%%%\\F#J((<d.>.>.@.@,/SWXXYYCHHVCV[AABBB'''")T//$**,,,tyy{{CHHVC%%&&&IIcNNN
+++&&""4DTUY"ZZ""4DTUY"ZZ	 B >>>HHVC__%%%		#C   
r   c                    |dk    rt           j        nt           j        }|                     |t          |          }|                     |t          |          }|                     t          ||||                    S )zCreate equality comparison operation between object identities

        Args:
            expr_op: either 'is' or 'is not'
        rz  )r.   r  r  r@  rx   r   )r   rw  rx  r  r3  r   r  r  s           r   r  z!LowLevelIRBuilder.translate_is_op
  sf     !(4\__\5Ekk$ 1488kk$ 1488xxS#r488999r   r  c                   t          |          }|dk    r\t          |t                    }d t          t	          ||                    D             }|                     t          |g|z   |          S |                     t          g |          S )z9Create a dictionary(possibly empty) using keys and valuesr   c                    g | ]	}|D ]}|
S r?  r?  )rA  rC  rX  s      r   rD  z2LowLevelIRBuilder._create_dict.<locals>.<listcomp>
  s%    CCC1CCAQCCCCr   )rQ  r7   r]   r  rU  rb  r   r   )r   r  r	  r3  rK  rw  rT  s          r   r  zLowLevelIRBuilder._create_dict
  s     4yy!88 '.D E EJCCSv%6%6 7 7CCCE;;}zlU.BDIII;;{B555r   rE  c                j    | j         
J d            | j                             || j        |           d S )Nz-cannot generate errors in this compiler phase)r   rF  r   )r   rE  r3  s      r   rF  zLowLevelIRBuilder.error
  s<    {&&(W&&&#t/66666r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   rA   r   rK   )r   r(   r   r   )r   r(   r   r   )r	  r
  r  r  r   r   )r  rK   r  rU   r  r  r   rK   )r  r  r   r   )r   r  )r   rE   )r   r   )r   r!  r   r   )r'  rK   r   rK   )r'  rK   r2  rU   r3  r4  r0  r  r1  r  r   rK   )F)r'  rK   r2  rU   r3  r4  r8  r  r0  r  r   rK   )r'  rK   r2  rU   r3  r4  r   rK   )r'  rK   r3  r4  r   rK   )r  rK   r  r   r  rU   r3  r4  r  r  r   rK   )r  rK   r*  rV   r  r   r  rU   r3  r4  r   rK   )r  rK   r  r   r3  r4  r   rK   )r  rK   r  r  r3  r4  r   rK   )r  rK   r3  r4  r   rK   )r  rK   r  rK   r3  r4  r   rK   )r  rK   r  r   r3  r4  r   rK   )
r   r  r3  r4  r  r  r  r  r   r  )NN)r  rK   r  r
  r3  r4  r  r  r  r  r   rK   )r  rK   r  r
  r3  r4  r  r  r  r  r   r  )r  r  r   rK   )r  rK   r  r   r  r
  r3  r4  r  r  r  r  r   rK   )r  rK   r  r   r  r
  r3  r4  r  r  r  r  r   r  )r  r   r   r  r  r  r  r  r3  r4  r  r  r   rK   )r   r  r  r  r  r  r  r    r3  r4  r  r  r   r
  )NNF)r1  rK   r  r   r  r
  r  r2  r3  r4  r  r  r  r3  r0  r  r   rK   )r1  rK   rB  rV   r  r   r  r
  rC  r2  r3  r4  r  r  r  r3  r   rK   r  )r-  r4  r   rK   )r-  rO  r   rK   )r-  r   r   rK   )r-  r\  r   rK   )r-  r_  r   rK   )r  rU   rb  r   r   rc  rd  r   r3  r4  re  rc  r   rK   )r  r   r   rK   )ro  r   r   rK   )rs  r   r   rK   )
rw  rK   rx  rK   r   r   r3  r4  r   rK   )
rw  rK   rx  r  r   r   r3  r4  r   r  )r  rK   r3  r4  r  r  r   rK   )
r  rK   r  rK   r   r   r3  r4  r   rK   )r   )
r  rK   rY  rK   r   r   r3  r4  r   rK   )r-  rK   r   r   r3  r4  r   rK   )r-  rK   r3  r4  r  r  r   rK   )r-  rK   r3  r4  r   rK   )r  r  r3  r4  r   rK   )r  rK   r3  r4  r   rK   )r	  r
  r3  r4  r   rK   )r  rU   r	  r  r  r  r   rK   )r   r   r  rU   r  r  r  r  r3  r4  r   rK   r  )r-  rK   r  r(   r  r(   r   r   r   )
r  r   r   r
  r3  r4  r  r2  r   rK   )NF)r*  r+  r   r
  r3  r4  r  r2  r0  r  r   r  )
r  rB   r   r
  r3  r4  r  r2  r   rK   )r*  r9  r   r
  r3  r4  r  r2  r0  r  r   r  )r+  rU   r  rK   r  rK   r   r4  r3  r4  r   rK   )r  rK   r  rK   r3  r4  r   rK   )
r  rK   r  rK   r   r4  r3  r4  r   rK   )r  rK   r  rR  r   rK   )r+  rS   r  rK   r  rK   r   r4  r3  r4  r   rK   )r  rK   r+  rU   r3  r4  r   r   )
r+  rU   r  rK   r  rK   r3  r4  r   rK   )
r+  rU   rj  rK   rk  rK   r3  r4  r   rK   )rj  rK   rk  rK   r3  r4  r   rK   )r  rK   r3  r4  rr  r  r   rK   )rT  r
  r3  r4  r   rK   )r  rK   r3  r4  r   rK   )rB  rK   r3  r4  r   r   )r  rK   r*  rV   r  rU   r  r  r3  r4  r   rK   )r  rK   r  r   r   r
  r  r2  r3  r4  r0  r  r   r  )
rw  rK   rx  rK   r  r   r3  r4  r   r  )r  rU   r   r  )
rw  rK   rx  rK   r  r   r3  r4  r   rK   )r  r
  r	  r
  r3  r4  r   rK   )rE  r   r3  r4  r   r   )o__name__
__module____qualname____doc__r   r   r   r   r  r  r  r  r  r  r   r  r&  r.  r6  r@  rG  rI  rH  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rA  r?  rH  r  r  rN  rR  rU  rX  rZ  r$  r^  ra  r$   rl  rn  r  rr  r  r  r\  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r  r  r  r   rb  r6  r%  r  rM  r  rB  r  rV  rY  r\  r  r_  r^  r`  rd  rG  r  r  r  r~  rP  r  r  r  r  r  r  r  r  rF  r?  r   r   r   r      s[
         	+ 	+ 	+ 	+' ' ' '   # # # #
" " " "# # # #
 @E 1 1 1 1 1 1 IN A A A A A A, , , ,) ) ) )   " " " "
9 9 9 9    !b b b b b b* c !c c c c c cJR R R Rh= = = =6 6 6 6p   8 W\5 5 5 5 5 5(Y Y Y YB B B B      L L L L   6i) i) i) i)` +/15c c c c cL +/15$ $ $ $ $L	- 	- 	- 	-d d d d2' ' ' 'b .20 0 0 0 0 0< .2\ \ \ \ \ \J +/-1 ;W ;W ;W ;W ;Wz` ` ` `2+ + + ++ + + ++ + + +W W W WB B B BC C C C" " " "   < < < <> > > >? ? ? ? #') $    (Y Y Y Y6 6 6 6
U U U Up p p pd V  V  V  VD
 
 
 
 
:c :c :c :cxc c c c
0 0 0 0 0d   	H 	H 	H 	H; ; ; ;    IN GB GB GB GB GB GBR@ @ @ @
@ 
@ 
@ 
@@ @ @ @
C 
C 
C 
C   68 8 8 8   *; ; ; ; PU
 
 
 
 
 
       DA A A AF= = = =@ %)L L L L Lf %)     B %)D D D D DV %)     >
9 
9 
9 
9 
9< < < <:   0? ? ? ?C C C CC C C CC C C C55 55 55 55n          &   $I I I I
I I I I
: : : :/< /< /< /< /<bG G G GE E E E= = = =: : : := = = =L !    .8T 8T 8T 8TtB B B B
? ? ? ?B	: 	: 	: 	:
6 
6 
6 
67 7 7 7 7 7r   r   r  r
  r  r  r   r4  c                V    |t          |           S d}|D ]}|t          k    r|dz  }|S )Nr   r   )rQ  r   )r  r  r  r  s       r   r  r  
  s@    :G  7??qLGNr   )r  r
  r  r  r   r4  )r  
__future__r   r  collections.abcr   typingr   r   r   r   typing_extensionsr	   mypy.argmapr
   
mypy.nodesr   r   r   r   mypy.operatorsr   r   
mypy.typesr   r   mypyc.commonr   r   r   r   r   r   r   r   r   mypyc.errorsr   mypyc.ir.class_irr   r   mypyc.ir.func_irr   r    mypyc.ir.opsr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   mypyc.ir.rtypesrO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   mypyc.irbuild.utilr~   mypyc.optionsr   mypyc.primitives.bytes_opsr   mypyc.primitives.dict_opsr   r   r   r   r   r   mypyc.primitives.exc_opsr   r   mypyc.primitives.float_opsr   r   mypyc.primitives.generic_opsr   r   r   r   r   r   r   r   r   mypyc.primitives.int_opsr   r   r   r   r   r   r   r   r   r   r   r   r   mypyc.primitives.list_opsr   r   r   r   mypyc.primitives.misc_opsr   r   r   r   r   r   r   r   mypyc.primitives.registryr   r   r   r   r   mypyc.primitives.set_opsr   mypyc.primitives.str_opsr   r   r   r   r   mypyc.primitives.tuple_opsr   r   r   r   r   mypyc.rt_subtyper   mypyc.sametyper   mypyc.subtyper   r  	DictEntryr  r   __annotations__r   r   r   r  r?  r   r   <module>r     s	     # " " " " " 



 $ $ $ $ $ $ 2 2 2 2 2 2 2 2 2 2 2 2 ' ' ' ' ' ' . . . . . . < < < < < < < < < < < < 7 7 7 7 7 7 7 7 ) ) ) ) ) ) ) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        ; ; ; ; ; ; ; ; 4 4 4 4 4 4 4 4/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /`/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /` 1 0 0 0 0 0 ) ) ) ) ) ) 4 4 4 4 4 4                J I I I I I I I C C C C C C C C
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
                              ] \ \ \ \ \ \ \ \ \ \ \	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	              0 / / / / /                           0 / / / / / ' ' ' ' ' ' $ $ $ $ $ $(5/5()	 %' ! )*ma.?!.C(D  D D D D% % %     0 ]\\ \ \ \ \]'7 ]'7 ]'7 ]'7 ]'7 ]'7 ]'7 ]'7@O     r   