o
    7ft ć                   @  s  U d Z ddlmZ ddlmZmZmZmZm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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*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZS ddlTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{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 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  ddl”m¢Z¢m£Z£m¤Z¤m„Z„m¦Z¦m§Z§mØZØm©Z©mŖZŖm«Z«m¬Z¬m­Z­m®Z®mÆZÆ ddl°m±Z±m²Z²m³Z³ ddl“mµZµm¶Z¶m·Z· ddløm¹Z¹mŗZŗm»Z»m¼Z¼m½Z½ ddl¾mæZæ ddlĄmĮZĮmĀZĀmĆZĆ ddlÄmÅZÅmĘZĘmĒZĒ ddlČmÉZÉ ddlŹmĖZĖ ddlĢmĶZĶ eeeP ePf ZĪd ZĻd!ed" d! > ZŠd#eŃd$< h d%£ZŅd#eŃd&< h d'£ZÓd#eŃd(< G d)d* d*ZŌd4d1d2ZÕd3S )5aŖ  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 IR level and not the AST
level---it has *no knowledge* of mypy types or expressions.
é    )Śannotations)ŚCallableŚFinalŚOptionalŚSequenceŚTuple)Śmap_actuals_to_formals)ŚARG_POSŚARG_STARŚ	ARG_STAR2ŚArgKind)Ś
op_methods)ŚAnyTypeŚ	TypeOfAny)	ŚBITMAP_BITSŚFAST_ISINSTANCE_MAX_SUBCLASSESŚMAX_LITERAL_SHORT_INTŚMAX_SHORT_INTŚMIN_LITERAL_SHORT_INTŚMIN_SHORT_INTŚPLATFORM_SIZEŚuse_method_vectorcallŚuse_vectorcall)Ś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ŚLoadLiteralŚLoadMemŚ
LoadStaticŚ
MethodCallŚOpŚRaiseStandardErrorŚRegisterŚSetMemŚTruncateŚTupleGetŚTupleSetŚUnboxŚUnreachableŚValueŚfloat_comparison_op_to_idŚfloat_op_to_idŚint_op_to_id)0ŚPyListObjectŚPyObjectŚPySetObjectŚPyVarObjectŚ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Śdict_rprimitiveŚfloat_rprimitiveŚint_rprimitiveŚis_bit_rprimitiveŚis_bool_rprimitiveŚis_bytes_rprimitiveŚis_dict_rprimitiveŚis_fixed_width_rtypeŚis_float_rprimitiveŚis_int16_rprimitiveŚis_int32_rprimitiveŚis_int64_rprimitiveŚis_int_rprimitiveŚis_list_rprimitiveŚis_none_rprimitiveŚis_set_rprimitiveŚis_short_int_rprimitiveŚis_str_rprimitiveŚ	is_taggedŚis_tuple_rprimitiveŚis_uint8_rprimitiveŚlist_rprimitiveŚnone_rprimitiveŚobject_pointer_rprimitiveŚobject_rprimitiveŚoptional_value_typeŚpointer_rprimitiveŚshort_int_rprimitiveŚstr_rprimitive)ŚMapper©Śconcrete_arg_kind)ŚCompilerOptions)Śbytes_compare)Śdict_build_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_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_comparison_op_mappingŚint_to_int32_opŚint_to_int64_opŚssize_t_to_int_opŚuint8_overflow)Ślist_build_opŚlist_extend_opŚnew_list_op)Śbool_opŚfast_isinstance_opŚnone_object_op)ŚERR_NEG_INTŚCFunctionDescriptionŚ
binary_opsŚmethod_call_opsŚ	unary_ops)Ś
new_set_op)Śstr_check_if_trueŚstr_ssize_t_size_opŚunicode_compare)Ślist_tuple_opŚnew_tuple_opŚnew_tuple_with_length_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                   @  s  e Zd Zd5ddZd6ddZd7ddZd8ddZd9ddZd9ddZdd d:d%d&Z	d;d)d*Z
d<d+d,Zd=d.d/Zd>d0d1Zd?d3d4Zdd5d@d;d<Z	dAdd5dBd>d?ZdCd@dAZdCdBdCZdDdDdEZdCdFdGZddHdEdMdNZdFdQdRZdGdSdTZdHdWdXZdIdYdZZdJd\d]ZdKd`daZdLdgdhZ	i	idMdNdpdqZ	i	idMdOdsdtZdPdudvZdQdxdyZ dRdzd{Z!did|dSddZ"did|dTddZ#	i	i	dUdVddZ$dWddZ%dXddZ&dXddZ'dXddZ(dXddZ)dYddZ*dZd d”Z+d[d¢d£Z,d\d„d¦Z-d]dØd©Z.die/dŖdifd^d°d±Z0d_d²d³Z1d`dµd¶Z2dadød¹Z3dbd¼d½Z4dAdcdĄdĮZ5dddÄdÅZ6dedČdÉZ7dddŹdĖZ8dddĢdĶZ9dfdddĪdĻZ:dgdŅdÓZ;dbdŌdÕZ<dbdÖd×Z=dhdŲdŁZ>didŪdÜZ?djdßdąZ@dkdādćZAdldädåZBdldędēZCddčdmdėdģZDdndńdņZEdodódōZFdpdõdöZG	idqdrdłdśZH	i	dsdtdżdžZIdfdud dZJddddZKdvddZLdwddZMdxd	d
ZNdyddZOdzddZPdzddZQd{ddZRd|ddZSdwddZTdAd}ddZUd~ddZVdkdd ZWdd"d#ZXdd&d'ZY	dAdd)d*ZZdd+d,Z[dd-d.Z\dd0d1Z]dd3d4Z^diS (  ŚLowLevelIRBuilderŚcurrent_moduleŚstrŚerrorsr   Śmapperrz   Śoptionsr}   ŚreturnŚNonec                 C  s6   || _ || _|| _|| _g | _g | _d g| _g | _d S ©N)rÓ   rÕ   rÖ   r×   ŚargsŚblocksŚerror_handlersŚkeep_alives)ŚselfrÓ   rÕ   rÖ   r×   © rą   śQ/home/ertert/spirit/venv/lib/python3.10/site-packages/mypyc/irbuild/ll_builder.pyŚ__init__ß   s   
zLowLevelIRBuilder.__init__Śmodule_nameŚmodule_pathc                 C  s   || _ || _dS )z,Set the name and path of the current module.N)rć   rä   )rß   rć   rä   rą   rą   rį   Ś
set_moduleī   s   
zLowLevelIRBuilder.set_moduleŚopr=   rF   c                 C  s*   | 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ę   rą   rą   rį   Śaddõ   s   zLowLevelIRBuilder.addŚtargetr%   c                 C  s"   | j d js|  t|” dS dS )zAdd goto to a basic block.rē   N)rÜ   rč   rė   r3   )rß   rģ   rą   rą   rį   Śgotoū   s   ’zLowLevelIRBuilder.gotoŚblockc                 C  s2   | 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ī   rą   rą   rį   Śactivate_block   s   z LowLevelIRBuilder.activate_blockc                 C  s   |   |” |  |” dS )z.Add goto a block and make it the active block.N)rķ   rń   rš   rą   rą   rį   Śgoto_and_activate  s   
z#LowLevelIRBuilder.goto_and_activateF©ŚstealŚvaluesślist[Value]rō   Śboolc                C  s   |   t||d” d S )Nró   )rė   r6   )rß   rõ   rō   rą   rą   rį   Ś
keep_alive  ó   zLowLevelIRBuilder.keep_aliveŚhandlerśBasicBlock | Nonec                 C  s   | j  |” d S rŚ   )rŻ   rź   )rß   rś   rą   rą   rį   Śpush_error_handler  ó   z$LowLevelIRBuilder.push_error_handlerc                 C  s
   | j  ” S rŚ   )rŻ   Śpop©rß   rą   rą   rį   Śpop_error_handler  s   
z#LowLevelIRBuilder.pop_error_handlerr?   c                 C  s
   | j d S )zWReturn reference to the 'self' argument.

        This only works in a method.
        r   )rŪ   r’   rą   rą   rį   rß     s   
zLowLevelIRBuilder.selfc                 C  s(   | j r|  t| j  ” ” g | _ d S d S rŚ   )rŽ   rė   r6   Ścopyr’   rą   rą   rį   Śflush_keep_alives  s   
žz#LowLevelIRBuilder.flush_keep_alivesŚsrcc                 C  sF   |j jr!t|trt|j r|  t|jd? td”S |  t	|”S |S )Nr³   ©Śrtype)
ŚtypeŚ
is_unboxedŚ
isinstancer4   ro   rė   r9   Śvalueru   r&   )rß   r  rą   rą   rį   Śbox$  s
   zLowLevelIRBuilder.box©Ś
can_borrowŚtarget_typerR   ŚlineŚintr  c                C  s>   |j r|  t|||”S |r| j |” |  t||||d”S )N©Śborrow)r  rė   rD   rŽ   rź   r*   )rß   r  r  r  r  rą   rą   rį   Śunbox_or_cast,  s
   zLowLevelIRBuilder.unbox_or_castŚforcec                  s  |j }|jr|js |”S |jra|jrat||sat|trGt|rGt|rG| ” }t	||s? 
d| d| d ” t|jd? |S t|rVt|rV || ”S t|rdt|rd | ”S t|rst|rs || ”S t|trt|tr|jr|jr|j|jkr|j|jkr|S t|st|r³t|r³ t|tdttj”} t||dd”S t|s»t|rÉt|rÉ t||dd”S t|tręt|ręt|rßtt|jd S tt|jS t|rōt|rō  | ”S t|t!rUt|t!rUt"|j#t"|j#krUg }	t$t"|j#D ],}
d}t|t%r+|j&|
 }t|t's+|}|du r:t(||
} |” |	 )|” q t% fd	d
t*|	|j#D  ”S  |”} +|| ”S |jsi|jsot,||sxj+|| |dS |rt'|} t-||” |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                   s   g | ]\}}  || ”qS rą   )Ścoerce)Ś.0ŚvŚt©r  rß   rą   rį   Ś
<listcomp>  ó    z,LowLevelIRBuilder.coerce.<locals>.<listcomp>r  ).r  r  r
  rÆ   r  r4   rm   rd   Śnumeric_valuer\   Śerrorr	  ri   Ścoerce_int_to_fixed_widthŚcoerce_fixed_width_to_intŚcoerce_short_int_to_fixed_widthrP   Śis_native_intŚsizeŚ	is_signedra   r`   ro   Śint_oprV   r5   Ś
LEFT_SHIFTrė   r,   re   r-   ŚfloatŚint_to_floatrQ   ŚlenŚtypesŚrangerC   Śitemsr?   rB   rź   Śzipr  r±   r#   )rß   r  r  r  r  r  Śsrc_typer	  Śshiftedrõ   Śir  ŚitemŚtmprą   r  rį   r  6  sŖ   
’’žż
’žżü’’’’ž’ž



’’
’zLowLevelIRBuilder.coercec                 C  sä  t |sJ |t|tsJ t|}t t t }}}|  ||”}|  t|||tj” |  	|” |j
}	|	tj
k r­t t }
}d|	d d > }|jsR|d9 }|  t|t||jtj”}|  t||
|tj” |  	|
” |jrw| }nd}|  t|t||jtj”}|  t|||tj” |  	|” |  t|tdttj|”}|  t||”}n|	tj
kr½|  t||dd”}n|}|  ||td|tj|”}|  t||” |  |” |  	|” t|sķt|r.|	tj
kr.|  t|tdttj|”}tt}|  t||” t|rt}nt }|  !||g|”}|  t||” |  t"|g” |  |” n=t|rA|  !t#g |” |  t$ ” n*t%|rT|  !t&g |” |  t$ ” nt'|rg|  !t(g |” |  t$ ” nJ ||  	|” |S )Nr³   r“   r  r   Tr  ))rd   r  rP   r?   r%   Ścheck_tagged_short_intrė   r'   ŚBOOLrń   r%  r_   r&  r+   r4   r  ŚSLTŚSGEr'  rZ   r5   ŚRIGHT_SHIFTrA   r,   r#   rķ   rh   rg   rw   ŚXORrY   r   r   Ścall_cr6   r   rE   rf   r   rq   r   )rß   r  r  r  ŚresŚfastŚslowŚendŚcheckr%  Śfast2Śfast3Śupper_boundŚcheck2Ślower_boundŚcheck3r4  ŚptrŚptr2Śconv_oprą   rą   rį   r!    s   



ū


’’




z+LowLevelIRBuilder.coerce_int_to_fixed_widthc                 C  s0   t |r|  ||td|tj|”S J |j|f©Nr³   )rh   r'  r4   r5   r9  r  )rß   r  r  r  rą   rą   rį   r#  ó  s   z1LowLevelIRBuilder.coerce_short_int_to_fixed_widthc                 C  sŽ  t |jr	tdkst|jst|jr,|  t|t|jjd”}|  	t
|tdttj|”S t|js3J t|jts;J |j}tt
}t t t t f\}}}}	|  t|tt|tj”}
|  t|
||tj” |  |” |  t|tt|tj”}|  t|||tj” |  |” t|rt}nt |rtdksJ t}nJ ||  ||g|”}|  t||” |   |	” |  |” t
j!|j!k rĖ|  t"|t”}n|}|  	t
|td|jtj|”}|  t||” |   |	” |  |	” |S )Nr“   r  r³   é   )#rg   r  r   rf   rq   rė   r,   rZ   r&  r'  r_   r4   r5   r(  rd   r  rP   r?   r%   r+   r   ŚSLEr'   r6  rń   r   r8  rh   r   r   r;  r#   rķ   r%  rA   )rß   r  r  Śextendedr0  r<  r=  rA  r>  r?  Śc1Śc2rI  Śxr4  Śsrą   rą   rį   r"  ł  sX   ’’žū





z+LowLevelIRBuilder.coerce_fixed_width_to_intc           
      C  sÖ   |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±   r?   r%   rė   r'   ŚIS_ERRORrń   r  r#   rķ   r8   rņ   )
rß   r  r  r  rģ   ŚvalidŚinvalidŚoutŚcoercedr   rą   rą   rį   Ścoerce_nullable0  s,   ’
’ž
ž



z!LowLevelIRBuilder.coerce_nullabler  ŚobjŚattrŚresult_typer  c                C  s~   t |jtr(|jjjr(|jj |”r(t||||d}|jr#| j 	|” |  
|”S t |jtr8|  ||j|||”S |  |||”S )z.Get a native or Python attribute of an object.r  )r  r  rO   Śclass_irŚis_ext_classŚhas_attrr1   Śis_borrowedrŽ   rź   rė   rS   Śunion_get_attrŚpy_get_attr)rß   rX  rY  rZ  r  r  rę   rą   rą   rį   Śget_attrK  s   
’žż
zLowLevelIRBuilder.get_attrr  rS   c                   s&   d fdd}  |||”S )z0Get an attribute of an object with a union type.r	  rF   rŲ   c                   s     |  ”S rŚ   )ra  ©r	  ©rY  r  rZ  rß   rą   rį   Śget_item_attrd  rż   z7LowLevelIRBuilder.union_get_attr.<locals>.get_item_attrN©r	  rF   rŲ   rF   )Śdecompose_union_helper)rß   rX  r  rY  rZ  r  rd  rą   rc  rį   r_  _  s   z LowLevelIRBuilder.union_get_attrc                 C  s   |   |”}|  t||g|”S )zuGet a Python attribute (slow).

        Prefer get_attr() which generates optimized code for native classes.
        )Śload_strr;  r   )rß   rX  rY  r  Śkeyrą   rą   rį   r`  i  s   
zLowLevelIRBuilder.py_get_attrŚ	class_irsślist[ClassIR]c                   sb   |s  ” S  |d ”|dd D ] d fdd} dtfd	d
|”qS )zHFast path for isinstance() that checks against a list of native classes.r   r³   NrŲ   rF   c                     s      ”S rŚ   )Śisinstance_nativerą   )r[  r  rX  rß   rą   rį   Śotherz  ó   z2LowLevelIRBuilder.isinstance_helper.<locals>.otherŚorc                     ó    S rŚ   rą   rą   ©Śretrą   rį   Ś<lambda>}  ó    z5LowLevelIRBuilder.isinstance_helper.<locals>.<lambda>©rŲ   rF   )Śfalserk  Śshortcircuit_helperrV   )rß   rX  ri  r  rl  rą   )r[  r  rX  rq  rß   rį   Śisinstance_helpers  s   z#LowLevelIRBuilder.isinstance_helperc                 C  s8   |   t|td|”}|   tt|”}|   t|g” |S )NŚob_type)rė   r2   rK   r:   ru   r6   )rß   rX  r  Śob_type_addressrx  rą   rą   rį   Śget_type_of_obj  s   z!LowLevelIRBuilder.get_type_of_objŚtype_objc                 C  s"   |   ||”}|  t||tj|”S rŚ   )rz  rė   r+   ŚEQ)rß   rX  r{  r  Śtyprą   rą   rį   Ś
type_is_op  s   zLowLevelIRBuilder.type_is_opr[  r   c                   s¤   t |}|du st|td kr t |”g”S |s" ” S  |d ”} |”|dd D ] d fdd} dt	fd	d
|”q6S )zēFast 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Ų   rF   c                     s       ””S rŚ   )r~  Śget_native_typerą   )Ścr  rX  rß   rą   rį   rl    ó   z2LowLevelIRBuilder.isinstance_native.<locals>.otherrn  c                     ro  rŚ   rą   rą   rp  rą   rį   rr    rs  z5LowLevelIRBuilder.isinstance_native.<locals>.<lambda>rt  )
r   r+  r   r;  r”   r  ru  r~  rv  rV   )rß   rX  r[  r  Śconcreter{  rl  rą   )r  r  rX  rq  rß   rį   rk    s   z#LowLevelIRBuilder.isinstance_nativerŪ   ś+Sequence[tuple[Value, ArgKind, str | None]]Śhas_starŚ	has_star2ś!tuple[Value | None, Value | None]c                C  s`  d}d}g }g }g }	d}
|D ]`\}}}|t kr,|du r"|  ||”}|  t||g|” q|tkrF|du r;|  ||	|”}| jt||g|d q| ” }| ” oO|}| 	” p[| ” o[|o[|}|rw|rj|du rj|  ||”}|rw|du rw|  ||	|”}|r|du r| 
|” q|r|du r|dusJ |  |”}| 
|” |	 
|” q|
}t }|rÓ|r¹|
s¹tt}|  t||  ” |” |r¾t n|}t }|  t|||tj” |  |” |rģ|rģ|
rģt t }}|  t|
||tj” n
t  }}|  |” |r|  |” |sJ | j|d|gd|d |  |” |rC|r|
rC|  |” |dus(J |  |”}|s2J | j|d||gd|d |  |” |rh|rh|rh||usSJ |  |” |  t||  ” |” |  |” |  |” |}
q|sv|r{|s{J |s|	r|sJ |r|du r|  ||”}n|  t|g|”}|r¬|du 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.)
        N©r  rź   ©rZ  r  Ś__setitem__)r
   r   r;  r   r   Ś_create_dictr   Śis_optionalŚis_positionalŚis_namedrź   rg  r%   r?   rV   rė   r#   ru  r'   rR  rń   r6  rķ   Śtranslate_special_method_callŚtrueŚ	new_tupler¬   )rß   rŪ   r  r  r  Śstar_resultŚstar2_resultŚstar_valuesŚ
star2_keysŚstar2_valuesŚseen_empty_regr	  ŚkindŚnameŚnullableŚ	maybe_posŚmaybe_namedrh  Śnew_seen_empty_regrU  ŚskipŚkeepŚ	pos_blockŚnamed_blockrą   rą   rį   Ś_construct_varargs£  s   H








’



’




z$LowLevelIRBuilder._construct_varargsNŚfunctionŚ
arg_valuesŚ	arg_kindsślist[ArgKind] | NoneŚ	arg_namesśSequence[str | None] | Nonec           	      C  s¦   t | jjr|  |||||”}|dur|S |du s"tdd |D r,|  t|g| |”S |dus2J | jtt	||||ddd\}}|rG|sIJ |  t
|||g|”S )zCall a Python function (non-native and slow).

        Use py_call_op or py_call_with_kwargs_op for Python function call.
        Nc                 s  ó    | ]}|t kV  qd S rŚ   ©r	   ©r  r  rą   rą   rį   Ś	<genexpr>u  ó    z,LowLevelIRBuilder.py_call.<locals>.<genexpr>T©r  r  )r   r×   Ścapi_versionŚ_py_vector_callŚallr;  r   r”  Ślistr/  r   )	rß   r¢  r£  r  r¤  r¦  ŚresultŚpos_args_tupleŚkw_args_dictrą   rą   rį   Śpy_callb  s   
’zLowLevelIRBuilder.py_callśValue | Nonec                   s   |du st dd |D rJ|r" fdd|D }jt|dd}ntdt}t||} |”}	 t||t|t	|	g ”}
|rH 
t|” |
S dS )	z°Call 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                 s  ó$    | ]}|  ”  o| ”  V  qd S rŚ   ©Śis_starr  rŖ  rą   rą   rį   r«    ó    
’z4LowLevelIRBuilder._py_vector_call.<locals>.<genexpr>c                   ó   g | ]	}  |t ”qS rą   ©r  ru   ©r  Śargr  rą   rį   r    ó    z5LowLevelIRBuilder._py_vector_call.<locals>.<listcomp>T©Ś
object_ptrr   )r°  Śsetup_rarrayru   r4   rt   Śnum_positional_argsŚ_vectorcall_keywordsr;  r   r[   rė   r6   )rß   r¢  r£  r  r¤  r¦  Ścoerced_argsŚarg_ptrŚnum_posŚkeywordsr	  rą   r  rį   rÆ    s$   ’


żz!LowLevelIRBuilder._py_vector_callc                 C  s4   |rdd |D }|r|   tt|t”S tdtS )zReturn a reference to a tuple literal with keyword argument names.

        Return null pointer if there are no keyword arguments.
        c                 S  s   g | ]}|d ur|qS rŚ   rą   )r  r  rą   rą   rį   r  ®  s    z:LowLevelIRBuilder._vectorcall_keywords.<locals>.<listcomp>r   )rė   r9   Śtupleru   r4   )rß   r¦  Śkw_listrą   rą   rį   rÄ  Ø  s
   
z&LowLevelIRBuilder._vectorcall_keywordsŚmethod_namec           
      C  s   t | jjr|  ||||||”}|dur|S |du s#tdd |D r3|  |”}|  t||g| |”S |  |||”}	| j	|	||||dS )z+Call a Python method (non-native and slow).Nc                 s  rØ  rŚ   r©  rŖ  rą   rą   rį   r«  Å  r¬  z3LowLevelIRBuilder.py_method_call.<locals>.<genexpr>©r¤  r¦  )
r   r×   r®  Ś_py_vector_method_callr°  rg  r;  r   r`  rµ  )
rß   rX  rĖ  r£  r  r¤  r¦  r²  Śmethod_name_regŚmethodrą   rą   rį   Śpy_method_call³  s   
’
z LowLevelIRBuilder.py_method_callc                   s   |du st dd |D rL |”} fdd|g| D }jt|dd}	t||}
 |”} t||	t|
d t	B t
|g ”} t|” |S dS )	z®Call 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                 s  r·  rŚ   rø  rŖ  rą   rą   rį   r«  Ü  rŗ  z;LowLevelIRBuilder._py_vector_method_call.<locals>.<genexpr>c                   r»  rą   r¼  r½  r  rą   rį   r  ą  s    ’z<LowLevelIRBuilder._py_vector_method_call.<locals>.<listcomp>TrĄ  r³   )r°  rg  rĀ  ru   rĆ  rÄ  r;  r   r4   rµ   r[   rė   r6   )rß   rX  rĖ  r£  r  r¤  r¦  rĪ  rÅ  rĘ  rĒ  rČ  r	  rą   r  rį   rĶ  Ī  s,   ’
’

üųz(LowLevelIRBuilder._py_vector_method_call©Śbitmap_argsŚdeclr   śSequence[Value]ślist[ArgKind]śSequence[str | None]rŅ  ślist[Register] | Nonec                C  s*   | j ||||j||d}|  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¦  r  rŅ  rą   rą   rį   Ścall÷  s   ’zLowLevelIRBuilder.callrŁ  r   c                  sl  |j }|j}|r|d|  }dd |D }	dd |D }
dd  D }t||	|
dd }d }}g }t||D ]%\}}|j ” rP|  fd	d|D ” |pV|jtk}|p]|jtk}q9| j	||||d
\}}g }t||D ]c\}}|jtkr|s~J |}nN|jtkr|sJ |}nB|s°t
|jrtd|j}n4t|jr„td}n*|  t|jdd”}n|d  } |d   ” rĒ|  ||j|”}n|  ||j|”}| |” qqtt|D ]X}|rķ|t|k rķ| || ” qŪd}d}t||D ]4\}}|j ” r*|jjr*|t |  kr|d t k r&n n|r&|d|td @ > O }|d7 }qö| t|t” qŪ|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                 S  ó   g | ]}|j qS rą   )r  r½  rą   rą   rį   r  %  ó    z?LowLevelIRBuilder.native_args_to_positional.<locals>.<listcomp>c                 S  rŪ  rą   )r  r½  rą   rą   rį   r  &  rÜ  c                 S  s   g | ]}t |qS rą   r{   )r  Śarg_kindrą   rą   rį   r  (  ó    c                 S  s
   t tjS rŚ   )r   r   Śspecial_form)Śnrą   rą   rį   rr  .  s   
 z=LowLevelIRBuilder.native_args_to_positional.<locals>.<lambda>Fc                   s"   g | ]}|  | | fqS rą   rą   ©r  r2  ©r¤  r¦  rŪ   rą   rį   r  6  s   " r­  r   ē        T)r^  r³   )rŪ   Śnum_bitmap_argsr   r/  r  r¹  Śextendr
   r   r”  rd   r  r4   re   r-   rė   r8   r  rW  r  rź   Śreversedr-  r+  Śerror_overlapr   rU   )rß   rŪ   r¤  r¦  rŁ  r  rŅ  Śsig_argsrą  Śsig_arg_kindsŚsig_arg_namesŚconcrete_kindsŚformal_to_actualr  r  Śstar_arg_entriesŚlstr¾  Śstar_argŚ	star2_argŚoutput_argsŚ
output_argŚbase_argr2  Śbitmapr  rą   rā  rį   rŲ    st   ū	

’




(z+LowLevelIRBuilder.native_args_to_positionalŚbaser  śRType | Noneślist[str | None] | Nonec	              
   C  s  |durt dd |D r|  ||||j||”S t|jtr|jjjr|jjjs|jj 	|”rr|jj 
|”}	|du rQ|du sBJ ddd |D }dd |D }n|dusYJ d|	js^J |  ||||	j|”}|  t||||”S |jj |”r|  t|||”}
| j|
||||d	S nt|jtr |  ||j||||||”S |r«|tgt| krŗ| j||||||d
}|rŗ|S |  ||||||”S )z/Generate either a native or Python method call.Nc                 s  s    | ]}|  ” V  qd S rŚ   )r¹  rŖ  rą   rą   rį   r«  y  r¬  z4LowLevelIRBuilder.gen_method_call.<locals>.<genexpr>z&arg_kinds not present but arg_names isc                 S  s   g | ]}t qS rą   r©  ©r  Ś_rą   rą   rį   r    ó    z5LowLevelIRBuilder.gen_method_call.<locals>.<listcomp>c                 S  s   g | ]}d qS rŚ   rą   rų  rą   rą   rį   r    rś  z&arg_kinds present but arg_names is notrĢ  r  )ŚanyrŠ  r  r  r  rO   r[  r\  Śbuiltin_baseŚ
has_methodŚmethod_declŚ	bound_sigrŲ  rė   r<   r]  r1   rµ  rS   Śunion_method_callr	   r+  r  )rß   rõ  r  r£  rZ  r  r¤  r¦  r  rÓ  r¢  rģ   rą   rą   rį   Śgen_method_calll  sJ   
’žż
’
’ž’’z!LowLevelIRBuilder.gen_method_callŚobj_typeŚreturn_rtypec	           
        s4   pt d fdd}	 |||	”S )z8Generate a method call with a union type for the object.r	  rF   rŲ   c              	     s     |  ”S rŚ   )r  rb  ©r¤  r¦  r£  r  r  r  rß   rą   rį   Ścall_union_item·  s   ’z<LowLevelIRBuilder.union_method_call.<locals>.call_union_itemNre  )ru   rf  )
rß   rõ  r  r  r£  r  r  r¤  r¦  r  rą   r  rį   r   §  s   z#LowLevelIRBuilder.union_method_callc                 C  ó
   t dtS )z0Load unboxed None value (type: none_rprimitive).r³   )r4   rs   r’   rą   rą   rį   ŚnoneĄ  ó   
zLowLevelIRBuilder.nonec                 C  r  )z0Load unboxed True value (type: bool_rprimitive).r³   ©r4   rV   r’   rą   rą   rį   r  Ä  r  zLowLevelIRBuilder.truec                 C  r  )z1Load unboxed False value (type: bool_rprimitive).r   r	  r’   rą   rą   rį   ru  Č  r  zLowLevelIRBuilder.falsec                 C  s   |   ttjtjdd”S )z1Load Python None value (type: object_rprimitive).rē   r  )rė   r7   r¢   r  r  r’   rą   rą   rį   Śnone_objectĢ  s   zLowLevelIRBuilder.none_objectr	  c                 C  s(   |t ks|tk r|  t|t”S t|S )z-Load a tagged (Python) integer literal value.)r   r   rė   r9   r_   r4   ©rß   r	  rą   rą   rį   Śload_intŠ  s   zLowLevelIRBuilder.load_intr)  c                 C  s   t |S )zLoad a float literal value.)r-   r  rą   rą   rį   Ś
load_float×  s   zLowLevelIRBuilder.load_floatc                 C  ó   |   t|t”S )zøLoad 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ė   r9   ry   r  rą   rą   rį   rg  Ū  s   zLowLevelIRBuilder.load_strŚbytesc                 C  r  )zLoad a bytes literal value.)rė   r9   rW   r  rą   rą   rį   Ś
load_bytesć  ó   zLowLevelIRBuilder.load_bytesŚcomplexc                 C  r  )zLoad a complex literal value.)rė   r9   ru   r  rą   rą   rį   Śload_complexē  r  zLowLevelIRBuilder.load_complexrē   r}  Ś
identifierś
str | NoneŚ	namespaceŚ	error_msgc           
   	   C  s   |d u r
d| d}t  t  }}|  t|||||d”}	|  t|	||tjdd” |  |” |  ttj||” |  t ” |  |” |	S )Nzname "z" is not definedr  T©Śrare)	r%   rė   r;   r'   rR  rń   r>   Ś
NAME_ERRORrE   )
rß   r}  r  rć   r  r  r  Śok_blockŚerror_blockr	  rą   rą   rį   Śload_static_checkedė  s   	

z%LowLevelIRBuilder.load_static_checkedc                 C  s   |   tt|td”S )N)r  )rė   r;   ru   r    )rß   r  rą   rą   rį   Śload_module’  r  zLowLevelIRBuilder.load_moduleŚclsc                 C  s   |j  d|j }|  |”S )zLoad native type object.Ś.)rć   r  Śload_native_type_object)rß   r  Śfullnamerą   rą   rį   r    s   
z!LowLevelIRBuilder.get_native_typer"  c                 C  s$   |  dd”\}}|  tt||t”S )Nr   r³   )Śrsplitrė   r;   ru   r"   )rß   r"  Śmoduler  rą   rą   rį   r!    s   z)LowLevelIRBuilder.load_native_type_objectŚlregŚrregc              	   C  s  |j }|j }t|trt|tr|dv r|  ||||”S |dv r.|  ||||”}|dur.|S |dv r:|  ||||”S t|rNt|rN|dv rN|  ||||”S t|rbt|rb|dv rb|  	||||”S t
|rvt
|rv|tv rv|  ||||”S t|rt|r|tv r|tjv r|  ||||”S |  |||d |”S t|trŖ|dv rŖ|  ||||”S t|rM|tv r| d”ræ|dd }|dkrČt| }ntj}t|sÓt|rÜ|  |||”}|}t|sät
|rķ|  |||||”S t|tr|  |||  |||”||”S nõ|tjv rLt|r|   |||”}nt|st|r&|  |||”}tj| }t|j r9|  !||||”S t|trL|  !||  |||”||”S nŖt|r÷|tv r­| d”rc|dd }|dkrmt| }ntj}t|tr|  ||  |||”|||”S t
|r|  |||||”S t|st|r¬|  |||”}|  |||||”S nJ|tjv r÷t|rĄ|   |||”}nt|sŹt|rŃ|  |||”}tj| }t|tré|  !|  |||”|||”S t|j r÷|  !||||”S |dv r6tj| }t
|rt"||r|  |t#|”}|  !||||”S t
|r5t"||r5|  |t#|”}|  !||||”S nB||  v rBtv rxn n4t
|r^t"||r^|  |t$|”}|  ||||”S t
|rxt"||rx|  |t$|”}|  ||||”S t%|st%|ršt|trt&t'| (” }n(t|tr t&t'| (” }nt|j r­|  )||”}nt|j r¹|  )||”}t%|j ršt%|j rš|t*v rŌ|  +||t*| |”S | d”rį|dd }	n|}	|	t,v rš|  -|||	|”S t. /|g ”}
|  0|
||g|”}|sJ d	| |S )
zPerform 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)1r  r  rQ   Ścompare_tuplesŚtranslate_eq_cmpŚtranslate_is_oprn   Ścompare_stringsrb   Ścompare_bytesro   r   Ścompare_taggedra   rŃ   r+   Ś
signed_opsŚbool_comparison_opŚbool_bitwise_oprO   Śtranslate_instance_containsrd   rŹ   ŚendswithrI   r5   ŚDIVr`   r  Śfixed_width_int_opr4   ri   r!  Ścomparison_opr±   r_   rx   re   r-   r)  r  r*  rG   Ścompare_floatsrH   Śfloat_opr„   ŚgetŚmatching_call_c)rß   r%  r&  rę   r  Śltyper  r	  Śop_idŚbase_opŚcall_c_ops_candidatesrģ   rą   rą   rį   Ś	binary_op  sä   




’’





’
ž





zLowLevelIRBuilder.binary_opŚvalŚnegatedc           	      C  sP   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   )	r4   rZ   r'  r5   ŚANDr+   ŚNEQr|  r:  )	rß   rD  r  rE  Śint_tagŚbitwise_andŚzerorę   r@  rą   rą   rį   r5    s   z(LowLevelIRBuilder.check_tagged_short_intŚlhsŚrhsc                 C  sF  t |jrt |jr|  ||t| d |”S t| \}}}}tt}	t t t }
}}|  ||”}|dv r:|}n|  ||”}|  t	||t
j|”}|  t||
|tj” |  |
” |  ||||”}|  t|	||” |  |” |  |” |r|||g}n||g}|  |||”}|r|  |d|”}n|}|  t|	||” |  |” |	S )zACompare two tagged integers using given operator (value context).r   r'  Śnot)rm   r  r:  r   r?   rV   r%   r5  r'  rT   r5   rF  rė   r'   r6  rń   r#   rķ   r;  Śunary_oprņ   )rß   rK  rL  rę   r  Śop_typeŚc_func_descŚnegate_resultŚswap_opr²  Śshort_int_blockŚ	int_blockrU  Ś	check_lhsr@  Ś	check_rhsŚeqrŪ   rŚ  Ścall_resultrą   rą   rį   r2    s4   




z LowLevelIRBuilder.compare_taggedr  ru  c                 C  sŗ  |dv }t |jrt |js|r7t |jst |jr7|  ||t| d |”}|  ”  |  t|||tj” dS t| \}	}
}}t t }}| j	||dd}|sUt |jre|  ”  |  t|||tj” n*t }|  t|||tj” |  
|” | j	||dd}|  ”  |  t|||tj” |  
|” |r||g}n||g}|  |
||”}|r“|  t|||tj” n|  ”  |  t|||tj” |  
|” |  |||	|”}|  t|||tj” dS )a~  Compare two tagged integers using given operator (conditional context).

        Assume lhs and rhs are tagged integers.

        Args:
            lhs: Left operand
            rhs: Right operand
            op: Operation, one of '==', '!=', '<', '<=', '>', '<='
            true: Branch target if comparison is true
            false: Branch target if comparison is false
        r'  r   NT)rE  )rm   r  r:  r   r  rė   r'   r6  r%   r5  rń   r;  )rß   rK  rL  rę   r  ru  r  Śis_eqr@  rO  rP  rQ  rR  rT  rS  rU  Ś	rhs_blockrV  rŪ   rŚ  rW  rą   rą   rį   Ścompare_tagged_conditionĄ  sH   ’’’



z*LowLevelIRBuilder.compare_tagged_conditionc                 C  s  |   t||g|”}tdt|}|  t||tj|”}t t t }}	}
t|||
tj	}d|_
|  |” |  |” |   tg |”}tdt|}|  t||tj|”}t||	|
tj	}d|_
|  |” |  |	” |   tg |” |  |
” |  |
” |dkrtjntj}|  t|tdt||”S )zCompare two stringsrē   Fr   rĻ   )r;  r«   r4   rX   rė   r+   r|  r%   r'   r6  rE  rń   r   rw   rG  r   rķ   )rß   rK  rL  rę   r  Ścompare_resultŚerror_constantŚcompare_error_checkŚexception_checkŚ	propagateŚfinal_compareŚbranchŚcheck_error_resultŚnullrO  rą   rą   rį   r0  ö  s0   ’

’



z!LowLevelIRBuilder.compare_stringsc                 C  s@   |   t||g|”}|dkrtjntj}|  t|tdt||”S )NrĻ   r³   )r;  r~   r+   r|  rG  rė   r4   rX   )rß   rK  rL  rę   r  r\  rO  rą   rą   rį   r1    s   zLowLevelIRBuilder.compare_bytesc                   s  t  jtrt jtsJ |dkrdnd}tt}t jjdkr=tjjdkr= t||r4 	” n 
” ” |S t jj}t t t }}	}
dd t|D } fddt|D }fddt|D }|ry||	}}n|	|}}tt jjD ]Q}|dkr || ” || }|| } |||”}t|js° t|g”}|t jjd	 k rĒt||||d	  tj}nt|||tj}||_ |” q |”  t| 
” ”  |
”  |	”  t| 	” ”  |
” |S )
zCompare two tuples item by itemrĻ   TFr   c                 S  s   g | ]}t  qS rą   )r%   rų  rą   rą   rį   r  "  rÜ  z4LowLevelIRBuilder.compare_tuples.<locals>.<listcomp>c                   s   g | ]}  t |”qS rą   ©rė   rB   rį  )rK  r  rß   rą   rį   r  #  r  c                   s   g | ]}  t| ”qS rą   re  rį  )r  rL  rß   rą   rį   r  $  r  r³   )r  r  rQ   r?   rV   r+  r,  rė   r#   r  ru  r%   r-  rń   rC  ra   r;  r    r'   r6  rE  rķ   rņ   )rß   rK  rL  rę   r  Śequalr²  ŚlengthŚfalse_assignŚtrue_assignrU  Ścheck_blocksŚ	lhs_itemsŚ	rhs_itemsŚ
early_stopŚfinalr2  Ślhs_itemŚrhs_itemŚcomparerb  rą   )rK  r  rL  rß   rį   r-    sD    "





z LowLevelIRBuilder.compare_tuplesŚinstr3  c                 C  sR   |   |d|gd |”}t|js|  t|g|”}|dkr'|  |tdtdd|”}|S )NŚ__contains__r+  r³   r  rÄ   )r  ra   r  r;  r    r5  r4   rV   )rß   rr  r3  rę   r  r<  rą   rą   rį   r6  D  s   
z-LowLevelIRBuilder.translate_instance_containsc                 C  sN   |dkrt j}n|dkrt j}n|dkrt j}nJ ||  t t||||”S )NrĮ   rÅ   rÄ   )r5   rF  ŚORr:  rė   rV   )rß   r%  r&  rę   r  Ścoderą   rą   rį   r5  L  s   z!LowLevelIRBuilder.bool_bitwise_opc                 C  s   t j| }|  ||||”S rŚ   )r+   r3  r:  )rß   r%  r&  rę   r  r@  rą   rą   rį   r4  W  s   
z$LowLevelIRBuilder.bool_comparison_opc                 C  s$   t d|j|}|  |j||tj|”S rJ  )r4   r  r'  r5   r:  )rß   r	  r  Śmaskrą   rą   rį   Ś	unary_not[  s   zLowLevelIRBuilder.unary_notŚexpr_opc           
      C  sŌ  |j }t|st|r|dkr|  ||”S |dkr|S t|r`|dkr0|  |td||tj|”S |dkrZ|j	rD|  ||td|tj
|”S d|jd > d }|  ||t||tj
|”S |dkr`|S t|rv|dkrp|  t||”S |dkrv|S t|tr|j}t|r|dL }t| ||jS t|r|dkr|S t|tr„t|j |jS t|trŅ|dkr±d	}n|dkrød
}n	|dkræd}nd}|rŅ|j |”rŅ|  ||g d |”S t |g ”}|  ||g|”}	|	sčJ d| |	S )NrM  rĀ   rĆ   r   ś~rē   r³   r“   Ś__neg__Ś__pos__Ś
__invert__Ś zUnsupported unary operation: %s)r  ra   r`   rw  rd   r'  r4   r5   ŚSUBr&  r:  r%  re   rė   r/   r  r	  rm   r  ro   r-   rO   r[  rż  r  r§   r=  r>  )
rß   r	  rx  r  r}  rv  ŚnumrĻ  rB  rģ   rą   rą   rį   rN  _  sX   


zLowLevelIRBuilder.unary_opŚkey_value_pairsśSequence[DictEntry]c                 C  s   d }g }g }|D ]9\}}|d ur,|d u r|  |” |  |” q| j|d||gd |d q|d u r7|  |||”}| jt||g|d q|d u rM|  |||”}|S )Nr  r  r  )rź   r  r  r;  r   )rß   r  r  r²  Śkeysrõ   rh  r	  rą   rą   rį   Ś	make_dict  s$   

’zLowLevelIRBuilder.make_dictrg  c                 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
        )r;  r   ©rß   rg  r  rą   rą   rį   Śnew_list_op_with_lengthÆ  ó   z)LowLevelIRBuilder.new_list_op_with_lengthc              	     sō   t t|t g}t|tkr t||  ”S  t| ”}|s#|S  fdd|D } t|t	d ”} t
t| ”}tt|D ])}|dkrO|}	nt t| t }
 tt||
tj ”}	 tt|	||  ” qF t|g” |S )Nc                   r»  rą   r¼  )r  r3  r  rą   rį   r  É  ræ  z1LowLevelIRBuilder.new_list_op.<locals>.<listcomp>Śob_itemr   )r4   r+  rZ   Ś!LIST_BUILDING_EXPANSION_THRESHOLDr;  r   r   rė   r2   rJ   r:   rw   r-  r   r5   ŚADDr@   ru   r6   )rß   rõ   r  rg  Śresult_listrŪ   Śob_item_ptrŚob_item_baser2  Śitem_addressŚoffsetrą   r  rį   r   ½  s&   ’zLowLevelIRBuilder.new_list_opc                 C  s   |   t||”S rŚ   )r;  rØ   )rß   rõ   r  rą   rą   rį   rØ   Ų  rm  zLowLevelIRBuilder.new_set_oprĄ  Ś	item_typerĮ  c                C  sD   t t|t|}|  t|t|” |  t|rt|”S t|”S )z;Declare and initialize a new RArray, returning its address.)	r?   rN   r+  rė   r$   r±  r7   rt   rY   )rß   r  rõ   rĮ  Śarrayrą   rą   rį   rĀ  Ū  s   ’’zLowLevelIRBuilder.setup_rarrayŚ	expr_typeŚleftśCallable[[], Value]Śrightc                 C  sĘ   t |}t t t }}}	|dkr||fn||f\}
}| }|  ||
|” |  |” |  |||”}|  t||” |  |	” |  |” | }|  |||”}|  t||” |  |	” |  |	” |S )NŚand)r?   r%   Śadd_bool_branchrń   r  rė   r#   rķ   )rß   rę   r  r  r  r  rģ   Ś	left_bodyŚ
right_bodyŚ
next_blockŚ	true_bodyŚ
false_bodyŚ
left_valueŚleft_coercedŚright_valueŚright_coercedrą   rą   rį   rv  å  s    	




z%LowLevelIRBuilder.shortcircuit_helperc                 C  sd  t |js
t|jr|}|S t|jtr%tdt}|  ||tj	|j
”}|S t|jr<td|j}|  t||tj	”}|S t|jtrM|  t|g|j
”}|S t|jtsYt|jtro|  ||j
”}td}|  ||d|j
”}|S t|jtr|jjjr|jj d”r|  |dg t|j
”}|S t|jr |  |tdtj	|j
”}|S t |j}|dur'|  !||  "” d|j
”}d}t|trŹ|j d”sŹ|j #d”rŹd}|rŠ|}|S t$t%}t& t& t& }}	}
t'|||	t'j(}|  |” |  )|” |  *|||j
”}|  +|”}|  t,||” |  -|
” |  )|	” |  t,|tdt%” |  -|
” |  )|
” |S |  t.|g|j
”}|S )	z_Return bool(value).

        The result type can be bit_rprimitive or bool_rprimitive.
        r   rĪ   Ś__bool__rć  Nr)  FT)/ra   r  r`   rÆ   r_   r4   rx   r:  r+   rG  r  rd   rė   r°   ry   r;  r©   rr   r]   Śbuiltin_lenrC  r  rO   r[  r\  rż  r  rV   re   r;  r-   r.   rv   r/  r
  Śis_method_finalr?   rT   r%   r'   r6  rń   r  Ś
bool_valuer#   rķ   r    )rß   r	  r²  rJ  rg  Ś
value_typeŚnot_noneŚalways_truthyr  ru  r?  rb  Ś	remainingŚas_boolrą   rą   rį   r¤    s|   9Č
6
Ė3Ī1Š’+
×’žż$
Ż"
ą

’
žļ






’zLowLevelIRBuilder.bool_valuec           
      C  sĪ   t |j}|d u r|  |”}|  t|||tj” d S |  ||  ” d|j”}t|||tj}|  |” d}t	|t
rH|j d”sH|j d”rHd}|set |_|  |j” |  |||j”}	|  |	||” d S d S )Nr)  Fr”  T)rv   r  r¤  rė   r'   r6  r/  r
  r  r  rO   r[  rż  r£  r%   r  rń   r  r  )
rß   r	  r  ru  Śopt_value_typer¤  Śis_nonerb  r§  rØ  rą   rą   rį   r  H  s*   



’
žłz!LowLevelIRBuilder.add_bool_branchŚdescr¤   c                   sģ  g  t tt|t|jD ]}|j| }|| }|  |||”}  |” q|jdur<|jdu s2J  fdd|jD  d}|jdurft|j}t t|jt|D ]}|| }|  ||j|”}  |” qR|jD ]}	|	\}
}t	|
||}  |” qi|j
}|tkrt}|  t|j |j|j|j|||”}|jr« D ]}t|t	tfsŖ| j |” q|j
tkrÅt|t	d|j|tj|}t|_
|  |” |jdu rĶ|}n|  t||j”}|}|rōt|j|sōt|rź|  ” }|S | j||||jd}|S )zHCall function using C/native calling convention (not a Python callable).Nc                   s   g | ]} | qS rą   rą   rį  ©rV  rą   rį   r  v  rŽ  z,LowLevelIRBuilder.call_c.<locals>.<listcomp>rē   r   r  )r-  Śminr+  Ś	arg_typesr  rź   ŚorderingŚvar_arg_typeŚextra_int_constantsr4   Ś
error_kindr£   r   rė   r)   Śc_function_nameŚreturn_typeŚstealsr^  r  r9   rŽ   r+   r8  r   Śtruncated_typerA   rÆ   r  rk   r  )rß   r¬  rŪ   r  rZ  r2  Śformal_typer¾  Śvar_arg_idxr3  rD  r}  Śextra_int_constantr³  rģ   Ścompr²  Śtruncaterą   r­  rį   r;  c  sl   	




ų’


’zLowLevelIRBuilder.call_cŚ
candidatesślist[CFunctionDescription]c           	      C  s   d }|D ]9}t |jt |krqtdd t||jD r=|jr"|r=|r;|j|jks2J d ||”|j|jkr:|}q|}q|rJ|  ||||”}|S d S )Nc                 s  s     | ]\}}t |j|V  qd S rŚ   )r±   r  )r  ŚactualŚformalrą   rą   rį   r«  ŗ  s    
’z4LowLevelIRBuilder.matching_call_c.<locals>.<genexpr>zAmbiguous:
1) {}
2) {})r+  rÆ  r°  r/  r^  ŚpriorityŚformatr;  )	rß   r½  rŪ   r  rZ  r  Śmatchingr¬  rģ   rą   rą   rį   r>  ®  s0   
’žž’z!LowLevelIRBuilder.matching_call_cr  c                 C  s   |   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ė   r5   )rß   r  rK  rL  rę   r  rą   rą   rį   r'  Ź  s   
zLowLevelIRBuilder.int_opc           
   	   C  sŽ   t | }|tjtjfv rYt|tr|jdksY|  |tdtj	|”}t
 t
 }}|  t|||tjdd” |  |” |tjkrBd}	nd}	|  ttj|	|” |  t ” |  |” |tjkre|  |||”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ć  Tr  zfloat division by zerozfloat modulo)rH   r0   r8  ŚMODr  r-   r	  r;  r.   r|  r%   rė   r'   r6  rń   r>   ŚZERO_DIVISION_ERRORrE   Ś	float_mod)
rß   rK  rL  rę   r  r@  r  ŚerrŚokŚmsgrą   rą   rį   r<  Ö  s    	



zLowLevelIRBuilder.float_opc                 C  s,  |   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ė   r0   rÄ  r?   r^   r#   r%   r.   r-   r|  r'   r6  rń   Śis_same_float_signsr<  r3   r;  r   )rß   rK  rL  r  Śmodr<  ŚtrickyŚadjustŚcopysignŚdoneŚis_zeroŚ
same_signsŚadjrą   rą   rį   rĘ  ó  s&   



zLowLevelIRBuilder.float_modc                 C  ó   |   t||||”S rŚ   )rė   r.   ©rß   rK  rL  rę   r  rą   rą   rį   r;    r  z LowLevelIRBuilder.compare_floatsrP   c                 C  s  |   |||”}|   |||”}|tjkrht|tr2|jdvr2|js*|  |||tj|”S |  ||||”S t	|r9t
}n&t|r@t}nt|rGt}nt|r[|  |||” |  |||||”S J ||  |||g|”S |tjkrĀt|tr|jdvr|js|  |||tj|”S |  ||||”S t	|rt}n&t|rt}nt|r”t}nt|rµ|  |||” |  |||||”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  r5   r8  r  r4   r	  r&  r'  Śinline_fixed_width_dividerh   r   rg   r   rf   r   rq   Ścheck_for_zero_divisionr;  rÄ  Śinline_fixed_width_modr   r   r   )rß   r  rK  rL  rę   r  Śprimrą   rą   rį   r9    sF   

z$LowLevelIRBuilder.fixed_width_int_opc                 C  sr   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%   rC  r4   rė   r'   r6  rń   r>   rÅ  rE   )rß   rL  r  r  rĒ  rČ  rŠ  rą   rą   rį   rÖ  E  s   
’’z)LowLevelIRBuilder.check_for_zero_divisionc                 C  s  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 rJ  )r?   r'  r5   r8  rė   r#   Śis_same_native_int_signsr%   r'   r6  rń   ŚMULr+   r|  r4   r~  r3   )rß   r  rK  rL  r  r<  ŚdivrŃ  rĢ  rĶ  rĻ  ŚmulŚmul_eqrŅ  rą   rą   rį   rÕ  R  s    


z+LowLevelIRBuilder.inline_fixed_width_dividec                 C  sī   t |}|  |||tj|”}|  t||” |  ||||”}t t t }}	}
|  t||
|tj	” |  
|” |  t|td|tj|”}|  t||
|	tj	” |  
|	” |  |||tj|”}|  t||” |  t|
” |  
|
” |S ©Nr   )r?   r'  r5   rÄ  rė   r#   rŁ  r%   r'   r6  rń   r+   r4   r|  r  r3   )rß   r  rK  rL  r  r<  rĖ  rŃ  rĢ  rĶ  rĻ  rŠ  rŅ  rą   rą   rį   r×  e  s   


z(LowLevelIRBuilder.inline_fixed_width_modŚaŚbc                 C  sN   |   t|td|tj|”}|   t|td|tj|”}|   t||tj|”S rŽ  )rė   r+   r4   r7  r|  )rß   r  rß  rą  r  Śneg1Śneg2rą   rą   rį   rŁ  w  s   z*LowLevelIRBuilder.is_same_native_int_signsc                 C  sJ   |   t|tdtj|”}|   t|tdtj|”}|   t||tj|”S )Nrć  )rė   r.   r-   ŚLTr+   r|  )rß   rß  rą  r  rį  rā  rą   rą   rį   rŹ  |  s   z%LowLevelIRBuilder.is_same_float_signsc                 C  rÓ  rŚ   )rė   r+   rŌ  rą   rą   rį   r:    r  zLowLevelIRBuilder.comparison_opŚuse_pyssize_tc                 C  sØ  |j }d}t|st|st|r+|  t|td”}|  tt|”}|  t	|g” n7t
|rI|  t|td”}|  tt|”}|  t	|g” nt|rV|  t|g|”}nt|rb|  t|g|”}|durz|rj|S tdt|}|  t||tj|”S t|trĀ|rJ |  |dg t|”}|  |t|”}t t }	}
|  |tdd|	|
|” |  |
” |  ttjd|” |  t  ” |  |	” |S |rĢ|  t!|g|”S |  t"|g|”S )	zGenerate len(val).

        Return short_int_rprimitive by default.
        Return c_pyssize_t if use_pyssize_t is true (unshifted).
        NŚob_sizeŚusedr³   Ś__len__r   rŠ   z__len__() should return >= 0)#r  rj   rp   rb   rė   r2   rM   r:   rZ   r6   rl   rL   rc   r;  r   rn   rŖ   r4   r'  rx   r5   r(  r  rO   r  r_   r  r%   r[  rń   r>   ŚVALUE_ERRORrE   r   r   )rß   rD  r  rä  r}  Ś
size_valueŚelem_addressr  rg  rČ  Śfailrą   rą   rį   r¢    sJ   

’’
zLowLevelIRBuilder.builtin_lenr.  c                 C  s"   t t|t}|  t|g| |”S rŚ   )r4   r+  rZ   r;  r­   )rß   r.  r  r%  rą   rą   rį   r  ¶  s   zLowLevelIRBuilder.new_tuplec                 C  r  )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
        )r;  r®   r  rą   rą   rį   Śnew_tuple_with_lengthŗ  r  z'LowLevelIRBuilder.new_tuple_with_lengthrą  c                 C  r  rŚ   )r;  r   )rß   rą  r  rą   rą   rį   r*  Č  rż   zLowLevelIRBuilder.int_to_floatŚprocess_itemśCallable[[Value], Value]c                 C  sB  g }g }|j D ]}t|tr| |” q| |” qt }	t|}
t|D ]Q\}}|t|d k p2|}|rP|  ||j	|”}t t }}|  
|||” |  |” |  |||”}||}|  |||”}|  t|
|” |  |	” |rv|  |” q%|r| j|t|d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)r  )r.  r  rO   rź   r%   r?   Ś	enumerater+  rk  r[  r  rń   r  rė   r#   rķ   ru   )rß   rX  r  rZ  rķ  r  Ś
fast_itemsŚ
rest_itemsr3  Ś
exit_blockr²  r2  Ś
more_typesrę   Ś
true_blockŚfalse_blockrV  ŚtempŚtemp2rą   rą   rį   rf  Ķ  s>   






z(LowLevelIRBuilder.decompose_union_helperŚbase_regc           	      C  s*   t  |g ”}| j||g| |||d}|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.
        r  )r¦   r=  r>  )	rß   rų  r  rŪ   rZ  r  r  rB  Ś	call_c_oprą   rą   rį   r  	  s
   ’z/LowLevelIRBuilder.translate_special_method_callc           
      C  s   |j }|j }t|tr||ksdS |j}| d” p%| d” p%|jp%|j}|r*dS | d”s?|dkr5dnd}	|  |||	|”S |  	|t
| |g||”S )zeAdd a equality comparison operation.

        Args:
            expr_op: either '==' or '!='
        NŚ__eq__Ś__ne__rĻ   r(  r)  )r  r  rO   r[  r£  Śinherits_pythonŚis_augmentedrż  r/  r  r   )
rß   r%  r&  rx  r  r?  r  r[  Ścmp_varies_at_runtimeŚidentity_ref_oprą   rą   rį   r.  #	  s$   
’žü
z"LowLevelIRBuilder.translate_eq_cmpc                 C  sD   |dkrt jnt j}|  |t|”}|  |t|”}|  t ||||”S )zCreate equality comparison operation between object identities

        Args:
            expr_op: either 'is' or 'is not'
        r(  )r+   r|  rG  r  ru   rė   )rß   r%  r&  rx  r  rę   rK  rL  rą   rą   rį   r/  E	  s   z!LowLevelIRBuilder.translate_is_opr  c                 C  sT   t |}|dkr#t|t}dd tt||D }|  t|g| |”S |  tg |”S )z9Create a dictionary(possibly empty) using keys and valuesr   c                 S  s   g | ]	}|D ]}|qqS rą   rą   )r  r  r2  rą   rą   rį   r  W	  ræ  z2LowLevelIRBuilder._create_dict.<locals>.<listcomp>)r+  r4   rZ   r±  r/  r;  r   r   )rß   r  rõ   r  r%  ré  r.  rą   rą   rį   r  P	  s   
zLowLevelIRBuilder._create_dictrÉ  c                 C  s   | j  || j|” d S rŚ   )rÕ   r   rä   )rß   rÉ  r  rą   rą   rį   r   \	  rł   zLowLevelIRBuilder.error)
rÓ   rŌ   rÕ   r   rÖ   rz   r×   r}   rŲ   rŁ   )rć   rŌ   rä   rŌ   rŲ   rŁ   )rę   r=   rŲ   rF   )rģ   r%   rŲ   rŁ   )rī   r%   rŲ   rŁ   )rõ   rö   rō   r÷   rŲ   rŁ   )rś   rū   rŲ   rŁ   )rŲ   rū   )rŲ   r?   )rŲ   rŁ   )r  rF   rŲ   rF   )
r  rF   r  rR   r  r  r  r÷   rŲ   rF   )F)r  rF   r  rR   r  r  r  r÷   r  r÷   rŲ   rF   )r  rF   r  rR   r  r  rŲ   rF   )r  rF   r  r  rŲ   rF   )rX  rF   rY  rŌ   rZ  rR   r  r  r  r÷   rŲ   rF   )rX  rF   r  rS   rY  rŌ   rZ  rR   r  r  rŲ   rF   )rX  rF   rY  rŌ   r  r  rŲ   rF   )rX  rF   ri  rj  r  r  rŲ   rF   )rX  rF   r  r  rŲ   rF   )rX  rF   r{  rF   r  r  rŲ   rF   )rX  rF   r[  r   r  r  rŲ   rF   )
rŪ   r  r  r  r  r÷   r  r÷   rŲ   r  )NN)r¢  rF   r£  rö   r  r  r¤  r„  r¦  r§  rŲ   rF   )r¢  rF   r£  rö   r  r  r¤  r„  r¦  r§  rŲ   r¶  )r¦  r§  rŲ   rF   )rX  rF   rĖ  rŌ   r£  rö   r  r  r¤  r„  r¦  r§  rŲ   rF   )rX  rF   rĖ  rŌ   r£  rö   r  r  r¤  r„  r¦  r§  rŲ   r¶  )rÓ  r   rŪ   rŌ  r¤  rÕ  r¦  rÖ  r  r  rŅ  r×  rŲ   rF   )rŪ   rŌ  r¤  rÕ  r¦  rÖ  rŁ  r   r  r  rŅ  r×  rŲ   rö   )NNF)rõ  rF   r  rŌ   r£  rö   rZ  rö  r  r  r¤  r„  r¦  r÷  r  r÷   rŲ   rF   )rõ  rF   r  rS   r  rŌ   r£  rö   r  rö  r  r  r¤  r„  r¦  r÷  rŲ   rF   rt  )r	  r  rŲ   rF   )r	  r)  rŲ   rF   )r	  rŌ   rŲ   rF   )r	  r  rŲ   rF   )r	  r  rŲ   rF   )r}  rR   r  rŌ   rć   r  r  rŌ   r  r  r  r  rŲ   rF   )r  rŌ   rŲ   rF   )r  r   rŲ   rF   )r"  rŌ   rŲ   rF   )
r%  rF   r&  rF   rę   rŌ   r  r  rŲ   rF   )rD  rF   r  r  rE  r÷   rŲ   rF   )
rK  rF   rL  rF   rę   rŌ   r  r  rŲ   rF   )rK  rF   rL  rF   rę   rŌ   r  r%   ru  r%   r  r  rŲ   rŁ   )rē   )
rr  rF   r3  rF   rę   rŌ   r  r  rŲ   rF   )r	  rF   r  r  rŲ   rF   )r	  rF   rx  rŌ   r  r  rŲ   rF   )r  r  r  r  rŲ   rF   )rg  rF   r  r  rŲ   rF   )rõ   rö   r  r  rŲ   rF   )r  rR   rõ   rŌ  rĮ  r÷   rŲ   rF   )rę   rŌ   r  rR   r  r  r  r  r  r  rŲ   rF   re  )r	  rF   r  r%   ru  r%   rŲ   rŁ   rŚ   )
r¬  r¤   rŪ   rö   r  r  rZ  rö  rŲ   rF   )NF)r½  r¾  rŪ   rö   r  r  rZ  rö  r  r÷   rŲ   r¶  )r  rR   rK  rF   rL  rF   rę   r  r  r  rŲ   rF   )rK  rF   rL  rF   r  r  rŲ   rF   )
rK  rF   rL  rF   rę   r  r  r  rŲ   rF   )r  rP   rK  rF   rL  rF   rę   r  r  r  rŲ   rF   )rL  rF   r  rR   r  r  rŲ   rŁ   )
r  rR   rK  rF   rL  rF   r  r  rŲ   rF   )
r  rR   rß  rF   rą  rF   r  r  rŲ   rF   )rß  rF   rą  rF   r  r  rŲ   rF   )rD  rF   r  r  rä  r÷   rŲ   rF   )r.  rö   r  r  rŲ   rF   )rą  rF   r  r  rŲ   rF   )rX  rF   r  rS   rZ  rR   rķ  rī  r  r  rŲ   rF   )rų  rF   r  rŌ   rŪ   rö   rZ  rö  r  r  r  r÷   rŲ   r¶  )
r%  rF   r&  rF   rx  rŌ   r  r  rŲ   r¶  )
r%  rF   r&  rF   rx  rŌ   r  r  rŲ   rF   )r  rö   rõ   rö   r  r  rŲ   rF   )rÉ  rŌ   r  r  rŲ   rŁ   )_Ś__name__Ś
__module__Ś__qualname__rā   rå   rė   rķ   rń   rņ   rų   rü   r   rß   r  r
  r  r  r!  r#  r"  rW  ra  r_  r`  rw  rz  r~  rk  r”  rµ  rÆ  rÄ  rŠ  rĶ  rŚ  rŲ  r  r   r  r  ru  r
  r  r  rg  r  r  r!   r  r  r  r!  rC  r5  r2  r[  r0  r1  r-  r6  r5  r4  rw  rN  r  r  r   rØ   rĀ  rv  r¤  r  r;  r>  r'  r<  rĘ  r;  r9  rÖ  rÕ  r×  rŁ  rŹ  r:  r¢  r  rģ  r*  rf  r  r.  r/  r  r   rą   rą   rą   rį   rŅ   Ž   sź    	’ūłiT7’

 Eś%ś&1ųųf÷;ł #6.5’
"A ūPś72Fł"rŅ   r£  rö   r¤  r„  rŲ   r  c                 C  s2   |d u rt | S d}|D ]
}|tkr|d7 }q|S )Nr   r³   )r+  r	   )r£  r¤  rĒ  r  rą   rą   rį   rĆ  `	  s   rĆ  N)r£  rö   r¤  r„  rŲ   r  )ÖŚ__doc__Ś
__future__r   Śtypingr   r   r   r   r   Śmypy.argmapr   Ś
mypy.nodesr	   r
   r   r   Śmypy.operatorsr   Ś
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,   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   Śmypyc.ir.rtypesrJ   rK   rL   rM   rN   rO   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   Śmypyc.irbuild.mapperrz   Śmypyc.irbuild.utilr|   Śmypyc.optionsr}   Śmypyc.primitives.bytes_opsr~   Śmypyc.primitives.dict_opsr   r   r   r   Śmypyc.primitives.exc_opsr   r   Śmypyc.primitives.float_opsr   r   Śmypyc.primitives.generic_opsr   r   r   r   r   r   r   r   Śmypyc.primitives.int_opsr   r   r   r   r   r   r   r   r   r   r   r   r   r   Śmypyc.primitives.list_opsr   r   r   Śmypyc.primitives.misc_opsr    r”   r¢   Śmypyc.primitives.registryr£   r¤   r„   r¦   r§   Śmypyc.primitives.set_opsrØ   Śmypyc.primitives.str_opsr©   rŖ   r«   Śmypyc.primitives.tuple_opsr¬   r­   r®   Śmypyc.rt_subtyperÆ   Śmypyc.sametyper°   Śmypyc.subtyper±   Ś	DictEntryr  rµ   Ś__annotations__rŹ   rŃ   rŅ   rĆ  rą   rą   rą   rį   Ś<module>   sn    
,øČ.2(@
                 