NL idbUdZddlmZddlZddlmZddlmZmZm Z ddl m Z ddl m Z mZmZmZddlmZmZdd lmZmZdd lmZmZmZmZmZmZmZmZm Z dd l!m"Z"dd l#m$Z$m%Z%dd l&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWddlXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZmZddlmZddlmZddlmZddlmZmZmZmZmZmZddlmZmZddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZmZmZmZddlmZmZmZmZmZmZmZmZddlmZmZmZmZmZddlmZddlmZmZmZmZddlmZmZmZmZmZddlmZddlmZdd lmZee eTeTfZd!Zd"e d#zd"z zZd$ed%<hd&Zd$ed'<hd(Zd$ed)<Gd*d+Zd-d,Zy).zeA "low-level" IR builder class. See the docstring of class LowLevelIRBuilder for more information. ) annotationsN)Sequence)CallableFinalOptional)map_actuals_to_formals)ARG_POSARG_STAR ARG_STAR2ArgKind) op_methodsunary_op_methods)AnyType TypeOfAny) BITMAP_BITSFAST_ISINSTANCE_MAX_SUBCLASSES FAST_PREFIXIS_FREE_THREADEDMAX_LITERAL_SHORT_INT MAX_SHORT_INTMIN_LITERAL_SHORT_INT MIN_SHORT_INT PLATFORM_SIZE)Errors)ClassIRall_concrete_classes)FuncDecl FuncSignature). ERR_FALSE ERR_NEVERNAMESPACE_MODULENAMESPACE_STATICNAMESPACE_TYPEAssign AssignMulti BasicBlockBoxBranchCallCallCCast ComparisonOpExtendFloatFloatComparisonOpFloatNegFloatOpGetAttr GetElementPtrGotoIntegerIntOp KeepAlive LoadAddressLoadErrorValue LoadGlobal LoadLiteralLoadMem LoadStatic MethodCallOpPrimitiveDescription PrimitiveOpRaiseStandardErrorRegisterTruncateTupleGetTupleSetUnbox UnreachableValuefloat_comparison_op_to_idfloat_op_to_id int_op_to_id)/PyObject PySetObjectRArray RInstance RPrimitiveRTupleRTypeRUnionbit_rprimitivebitmap_rprimitivebool_rprimitivebytes_rprimitivec_int_rprimitivec_pointer_rprimitivec_pyssize_t_rprimitivec_size_t_rprimitivecheck_native_int_rangedict_rprimitivefloat_rprimitiveint_rprimitiveis_bool_or_bit_rprimitiveis_bytes_rprimitiveis_dict_rprimitiveis_fixed_width_rtypeis_float_rprimitiveis_frozenset_rprimitiveis_int16_rprimitiveis_int32_rprimitiveis_int64_rprimitiveis_int_rprimitiveis_list_rprimitiveis_none_rprimitiveis_object_rprimitiveis_set_rprimitiveis_short_int_rprimitiveis_str_rprimitive is_taggedis_tuple_rprimitiveis_uint8_rprimitivelist_rprimitivenone_rprimitiveobject_pointer_rprimitiveobject_rprimitiveoptional_value_typepointer_rprimitiveshort_int_rprimitivestr_rprimitive)concrete_arg_kind)CompilerOptions) bytes_compare) dict_build_op dict_copy dict_copy_op dict_new_opdict_ssize_t_size_opdict_update_in_display_op)err_occurred_opkeep_propagating_op) copysign_opint_to_float_op) generic_len_opgeneric_ssize_t_len_op py_call_oppy_call_with_kwargs_oppy_call_with_posargs_op py_getattr_oppy_method_call_oppy_vectorcall_method_oppy_vectorcall_op) int16_divide_op int16_mod_opint16_overflowint32_divide_op int32_mod_opint32_overflowint64_divide_op int64_mod_opint64_to_int_opint_to_int32_opint_to_int64_opssize_t_to_int_opuint8_overflow) list_build_oplist_extend_op list_items new_list_op)bool_op buf_init_itemdebug_print_opfast_isinstance_opnone_object_opnot_implemented_opset_immortal_opvar_object_size) ERR_NEG_INTCFunctionDescription binary_opsmethod_call_ops unary_ops) new_set_op)str_check_if_truestr_eqstr_ssize_t_size_opunicode_compare) list_tuple_opload_empty_tuple_constant_op new_tuple_opnew_tuple_with_length_opsequence_tuple_op)is_runtime_subtype) is_same_type) is_subtype rPY_VECTORCALL_ARGUMENTS_OFFSET>%=*=+=-=<<>>//=<<=>>=*%&+-^|&=//^=|=FIXED_WIDTH_INT_BINARY_OPS> <=r<>rr!=r==>=rrBOOL_BINARY_OPSceZdZdZdvdZdwdZdxdZdydZdzdZdzdZ dd d{d Z dd d|d Z d}d Z d~dZ ddZddZddZddZddd ddZ ddd ddZddZddZddZddZdd  ddZ ddZddZddZddZdd Zdd!Z dd"Z d dd$Z d dd%Z!dd&Z" dd'Z# dd(Z$d#d) dd*Z%d#d) dd+Z& d dd,Z' dd-Z(dd.Z)dd/Z*dd0Z+dd1Z,dd2Z-dd3Z.dd4Z/dd5Z0dd6Z1dd7Z2dd8Z3d#e4d9d#f dd:Z5dd;Z6dd<Z7dd=Z8dd>Z9dd?Z:ddd@Z;ddAZddDZ?ddEZ@ddFZAddGZBddHddIZCddJZDddKZEddLZFddMZGddNZHddOZIddPZJddQZKddR ddSZL ddTZMddUZNddVZO d ddWZP d ddXZQ d ddYZR d ddZZSddd[ZTdd\ZUdd]ZVdd^ZWdd_ZXdd`ZYddaZZ ddbZ[ddcZ\dddZ]ddeZ^ddfZ_ddgZ`ddhZadddiZbddjZcddkZdddlZeddmZf ddnZg d ddoZhddpZiddqZj ddrZkddsZlddtZmdduZny#)LowLevelIRBuilderaxA "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. cZ||_||_g|_g|_dg|_g|_yN)errorsoptionsargsblockserror_handlers keep_alives)selfrrs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/irbuild/ll_builder.py__init__zLowLevelIRBuilder.__init__s2  $& (* 8Add a basic block and make it the active one (target of adds).rN)rrr error_handlerrrblocks ractivate_blockz LowLevelIRBuilder.activate_block sE ;;;;r?-- --"11"5 5!rcH|j||j|y)z.Add goto a block and make it the active block.N)rrrs rgoto_and_activatez#LowLevelIRBuilder.goto_and_activate(s % E"rFstealc<|jt||y)Nr)rr7)rvaluesrs r keep_alivezLowLevelIRBuilder.keep_alive-s 6/0rborrowc<|jt|||S)Nr)rr<)rptr value_typers rload_memzLowLevelIRBuilder.load_mem0sxx C?@@rc:|jj|yr)rr)rhandlers rpush_error_handlerz$LowLevelIRBuilder.push_error_handler3s ""7+rc6|jjSr)rpoprs rpop_error_handlerz#LowLevelIRBuilder.pop_error_handler6s""&&((rc |jdS)zWReturn reference to the 'self' argument. This only works in a method. r)rrs rrzLowLevelIRBuilder.self9s yy|rc|jr:|jt|jjg|_yyr)rrr7copyrs rflush_keep_alivesz#LowLevelIRBuilder.flush_keep_alives@s8    HHYt//4467 8!D  rcvt|tr|j|}|jt|gdy)Nr) isinstancestrload_str primitive_opr)rtoprints r debug_printzLowLevelIRBuilder.debug_printEs. gs #mmG,G .7)R8rc |jjrlt|trBt |jr-|j t |jdz tS|j t|S|S)Nrrtype) type is_unboxedrr5rqrr;valuerwr')rsrcs rboxzLowLevelIRBuilder.boxLs[ 88  #w'Ichh,?xx CIINBS TUU88CH% %Jr can_borrow uncheckedc |jr|jt|||S|r|jj ||jt |||||S)N)rr')r!rrGrrr+)rr# target_typeliner&r's r unbox_or_castzLowLevelIRBuilder.unbox_or_castTsY  ! !88E#{D9: :  '',88Dk4 V_`a arr&c * |j}|jr|js|j|S|jr|jrt||st |t rdt |rYt|rN|j}t||s|jd|d|d|t |jdz |St|rt|r|j|||St|rt|r|j||St |rt|r|j|||St |t r\t |t rL|j"r@|j"r4|j$|j$k(r|j&|j&k(r|St)|r\t+|rQ|j-t.|t dt.t0j2}|j5t7||dSt)|r(t|r|j5t7||dSt |t rUt9|rJt+|r!t;t=|jdzSt;t=|jSt+|rt9|r|j?||St |t@rt |t@rtC|jDtC|jDk(rg} tGtC|jDD]e} d} t |tHr!|jJ| } t | tLs| } | tO|| } |j5| | jQ| g|j5tItS| |jDD cgc]\} } |jU| | |c} } |S|j|}|jW|||S|js |js tY||s|jW|||| S|r(tM|}|j5t[|||S|Scc} } w) aGenerate 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). zValue z is out of range for ""rFsignedNr,).r r!r$rrr5rord numeric_valuer]errorr"rjcoerce_int_to_fixed_widthcoerce_fixed_width_to_intcoerce_short_int_to_fixed_widthrQ is_native_intsize is_signedrarqint_oprWr6 LEFT_SHIFTrr-rer.float int_to_floatrRlentypesrangerFitemsrCrErzipcoercer+rr$)rr#r)r*forcer&src_typer"shiftedrivitemttmps rrCzLowLevelIRBuilder.coerceds&88   {'='=88C=   K$:$:DV kE 3(+H5(5))+-k5AJJw.D[MQRSUYZsyyA~{;;"8,1Ek1R55c;MM%h/4Ek4R55c4@@(27KK7X;;CdSS8Z0{J7**--MM[%5%55&&+*?*?? *84;9O++#S'!_*EuGWGWxxw E JKK*849Mk9ZxxsK FGGC).A+.NX& syyA~!677U399-..8$)<[)I((d338V,{F3'3{/@/@+AAs8>>23 %AA!#x0"yy|)$9 $Ay$S!, MM!$ %xx=@IZIZ=[\TQQ40\^b((3-C%%c;= =## (>(>z kH %%c;%T T ;'C HHVC% &J ]sRc ^ t|sJ|t|tsJ|t|}t t t }}}|j ||}|j t|||tj|j||j} | tjkrt t } } d| dzdz z} |js| dz} |j t|t| |jtj } |j t| | |tj|j| |jr| }nd}|j t|t||jtj"}|j t|| |tj|j| |j%t&|tdt&t(j*|}|j t-||}n`| tjkDr|j t/||d}n|}|j%||td|t(j*|}|j t1|||j3||j|t5|st7|r| tjk(r|j%t8|tdt8t(j:|}tt<}|j t1||t5|rt>}nt@}|jC||g|}|j t1|||j tE|g|j3|nt7|r1|jCtFg||j tIntK|r1|jCtLg||j tInCtO|r1|jCtPg||j tInJ||j||S)Nrrr1rTr/))rdrrQrCr&check_tagged_short_intrr(BOOLrr8r`r9r,r5r SLTSGEr:r[r6 RIGHT_SHIFTrDr-r$rrirhryXORrZrrcall_cr7rrHrgrrsr)rr#r)r*resfastslowendcheckr8fast2fast3 upper_boundcheck2 lower_boundcheck3rKrptr2conv_ops rr4z+LowLevelIRBuilder.coerce_int_to_fixed_widths#K0=+=0+z2?K?2{#$, jlCd++C6 tT6;;78 D! .%% %%<5Eq1 -K((q XXl3 SXX0NP\P`P`abF HHVFE4= >    &$$*l  XXl3 SXX0NP\P`P`abF HHVFE4= >    &++&12!! C((8C56Cn)))hhvc;tDE++k3;0GIZIZ\`aC S!" # D! { +  ,9L9L1L++"C4F)GTXC01D HHVD#& '";/))++gvt4C HHVC% & HHYu% & IIcN  - KKD 1 HH[] #  - KKD 1 HH[] #  - KKD 1 HH[] # %+ %5 C  rct|stdk(r8t|r-|j||t d|t j |SJ|j|tf)Nr)rirrhr:r5r6rQr )rr#r)r*s rr6z1LowLevelIRBuilder.coerce_short_int_to_fixed_widthsT { + Q #6{#C;;{CK1H%J[J[]ab b E"++c;5 ./ # G$ 45 t,- s# rct|jtr|jjjrl|jjj |rGt ||||}|jr|jj||j|St|jtr|j||j|||S|j|||S)z.Get a native or Python attribute of an object.r)rr rPclass_ir is_ext_classhas_attrr2 is_borrowedrrrrTunion_get_attr py_get_attr)robjattr result_typer*rrs rget_attrzLowLevelIRBuilder.get_attrxs sxx +!!..!!**40dD8B~~  '',88B<  & )&&sCHHdKN N##Ct4 4rcFdfd }j|||S)z0Get an attribute of an object with a union type.c,j|Sr)r{)r"ryr*rzrs r get_item_attrz7LowLevelIRBuilder.union_get_attr..get_item_attrs==k4@ @rr"rIreturnrI)decompose_union_helper)rrxrryrzr*r~s` ``` rrvz LowLevelIRBuilder.union_get_attrs+  A A**3{MSWXXrcV|j|}|jt||g|S)zuGet a Python attribute (slow). Prefer get_attr() which generates optimized code for native classes. )rrr)rrxryr*keys rrwzLowLevelIRBuilder.py_get_attrs+ mmD!  c DAArc|sjSj|d|ddD]'dfd }jdtfd|)S)zHFast path for isinstance() that checks against a list of native classes.rrNc*jSr)isinstance_native)rrr*rxrsrotherz2LowLevelIRBuilder.isinstance_helper..others--c8TBBrorcSrretsrz5LowLevelIRBuilder.isinstance_helper..#rrrI)falsershortcircuit_helperrW)rrx class_irsr*rrrrs`` ` @@risinstance_helperz#LowLevelIRBuilder.isinstance_helperso::< $$S)A,=!!"  \H C C**4+uVZ[C  \  rc|jt|td|}|j|td}|jt |g|S)Nob_typeTr)rr3rMr rwr7)rrxr*ob_type_addressrs rget_type_of_objz!LowLevelIRBuilder.get_type_of_objsH((=h 4#PQ--1B4-P C5!"rc||j||}|jt||tj|Sr)rrr,EQ)rrxtype_objr*typs r type_is_opzLowLevelIRBuilder.type_is_ops2""3-xx S(LOOTJKKrctt|}|t|tdzkDr(jtj |gS|sj Sj |d}j||ddD]'dfd }jdtfd|)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`. NrrcHjjSr)rget_native_type)cr*rxrsrrz2LowLevelIRBuilder.isinstance_native..others!sD,@,@,CTJJrrcSrrrsrrz5LowLevelIRBuilder.isinstance_native..rrr) rr>rrrrrrrrW) rrxrrr*concreterrrrs `` ` @@rrz#LowLevelIRBuilder.isinstance_natives(1  s8}/MPQ/QQ$$"S$*>*>x*H$I4 ::< '' 4ooc8T2!" \A K K**4+uVZ[C  \  rc 6 d}d}g}g}g} d} |D] \} } } | tk(r|tt|dk(r{t| jr|j t | g|} nGt | js2t| jts|j t| g|} | dfcSt|dk(r|ddtk(rt | jst| jtr| }nFt| jr|j t | g|}n|j t| g|}|d}|d}t|jrt}nt}||j ||g|fcS|j||}|j t|| g|| tk(r|kt|dk(rJt| jrt}nt}|j!g||j || g|fcS|j#|| |}|j%t&|| g|6| j)}| j+xr|}| j-xs| j)xr| xr|}|r-|r||j||}|r||j#|| |}|r||j/| |r;|9| J|j1| }|j/|| j/| | }t3}|r|r;| s9t5t6}|j9t;||j=||r t3n|}t3}|j9t?| ||t>j@|jC||rD|rB| r@t3t3}}|j9t?| ||t>jDnt3x}}|jG||r=|jC||sJ|jI|d| gd||jG||rW|r| rS|jC|| J|j1| }|sJ|jI|d|| gd||jG||rV|rT|rR|usJ|jC||j9t;||jK||jG||jC||} |s|r|sJ|s| r|sJ|rB||j!||}n-t |js|j t |g|}|r#|!t|dkDr|j#|| |}||fS) aConstruct *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.) Nrr1rr*rrzr* __setitem__)&r r>rkr rrrrrrRrr rcrrrr new_tuple _create_dictrSr is_optional is_positionalis_namedrrr&rCrWrr$rr(rkrrNrtranslate_special_method_calltrue)rrr*has_star has_star2 star_result star2_result star_values star2_keys star2_valuesseen_empty_regr"kindname star2_arg star2_valuestar2_fastpath_opnullable maybe_pos maybe_namedrnew_seen_empty_regrnskipkeep pos_block named_blocks r_construct_varargsz$LowLevelIRBuilder._construct_varargsssP%) %) $& "$ $& *.!%D 4 E4x&4yA~-ejj9$($5$5meWd$SE!4UZZ!@!JJJ%)$5$56G%RV$WE$d{*TaDGAJ),C/uzz:jU[>\*/K/ ;*.*;*;ME7TX*YK*.*;*;.>?0<-09-*D,=,=- }d-  #'"2"2;"EK!!.;2FM"'4yA~.ejj90<-09-#~~b$79J9J-w: $(#4#4Zt#TL 5 e7LSW X++- ..0=X "mmo\$2B2B2D2[2[R[  [%8&*&6&6{D&I "|';'+'8'8\SW'X !4&&u-<#7+++---C%%c* ''.&4" l!-5o-F*(:DJJL$!OP+4:<#D%> ""nn[$? ()9)9:"// }dS -#j/A2E,,ZtLLL((rNc d|j|||||}||S|td|Dr|jt|g|z|S|J|j t t ||||dd\}}|sJ||jt||g|S|jt|||g|S)zCall a Python function (non-native and slow). Use py_call_op or py_call_with_kwargs_op for Python function call. c3.K|] }|tk(ywrr .0rs r z,LowLevelIRBuilder.py_call..#JDGO#JTrr) _py_vector_callallrSrrlistrBrr) rfunction arg_valuesr* arg_kinds arg_namesresultpos_args_tuple kw_args_dicts rpy_callzLowLevelIRBuilder.py_calls%%h D)YW  M  #J #J J;;zH: +BDI I$$$'+'>'> ZI6 7X\(?( $ ~  ;;6>8RTXY Y{{1Hnl3[]abbrc |td|Dr|r=|Dcgc]}|j|t|}}|jt|d}nt dt }t ||} |j|} |jt||t | t| g|} |r|jt| Sycc}w)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. Nc3dK|](}|j xr|j *ywris_starrrs rrz4LowLevelIRBuilder._py_vector_call..2$ >B   9t'7'7'9#9 9$ .0T object_ptrr) rrCrw setup_rarrayr5rvnum_positional_args_vectorcall_keywordsrSrr\rr7) rrrr*rrarg coerced_argsarg_ptrnum_poskeywordsr"s rrz!LowLevelIRBuilder._py_vector_calls  $ FO$ ! U_`c C1BD I` `++,=|X\+]!!%>?)*i@G00;HKK 7GG5H$I8TE <01L# asC c|r<|Dcgc]}|| }}|r(|jtt|tSt dtScc}w)zReturn a reference to a tuple literal with keyword argument names. Return null pointer if there are no keyword arguments. r)rr;tuplerwr5)rrrkw_lists rrz&LowLevelIRBuilder._vectorcall_keywordssQ (1FT5EtFGFxx E'N.rrrr)_py_vector_method_callrrrSrrwr) rrx method_namerr*rrrmethod_name_regmethods rpy_method_callz LowLevelIRBuilder.py_method_calls,, j$ 9   M  #J #J J"mmK8O;;032H:2UW[\ \%%c;=F<< DIYb<c crc |td|Dr|j|}|g|zDcgc]}|j|t|} }|j t| d} t ||} |j |} |jt|| t| dztzt| g|} |jt| | Sycc}w)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. Nc3dK|](}|j xr|j *ywrrrs rrz;LowLevelIRBuilder._py_vector_method_call..6rrTrr)rrrCrwrrrrSrr5rr\rr7)rrxrrr*rrrrrrrrr"s rrz(LowLevelIRBuilder._py_vector_method_call(s  $ FO$ ! #mmK8OFIUZEW>A C!2D9L''(9.sgi445rFrrT)rur)rnum_bitmap_argsrrr|rrBrextendr r rrrdr r5rer.rr9rrprCrreversedr@r> error_overlaprrV)rrrrrr*rsig_argsrr sig_arg_kinds sig_arg_namesarg_kindconcrete_kindsformal_to_actualrrstar_arg_entrieslstrGstar_argr output_args output_argbase_argbitmaprs rrz+LowLevelIRBuilder.native_args_to_positionalgs:&88    !}H-56c6 6-56c6 6FOP(+H5PP1     5   %$9,h7 ;HCxx! ''X[(\ST$q'9Q<1)N(\]7388x#7H!:SXX%:I  ; #55 dX6 )$& ,h7 +HCxx8#x% Y&&I$*;*;BD*I '1!(CHH!5J(2!&sJ!%.t*T!UJA<SV$002!%!5!5h$!OJ!%Xsxx!FJ   z *+ +.%(# CAq3{#33"";q>2FA 0(; S88'')chh.D.D;!Cq1u .CC"aAq,A&BBFFA     wv/@A B C I76P)]sL>MM<M c |(td|Dr|j||||||St|z} t|jt r|jj js&|jj j| rg|jj jsF|jj jr|n| }|jj j|r|jj j|} |,|Jd|D cgc]} t }} |D cgc]} d}} n |Jd| jsJ|j|||| j|}|jt||||S|jj j!|rn|jt#|||} |j%| ||||St|jt&r"|j)||j||||||S|r|tgt+|zk(r|j-||||||} | r| S|j||||||Scc} wcc} w)z/Generate either a native or Python method call.Nc3<K|]}|jywr)rrs rrz4LowLevelIRBuilder.gen_method_call..s(ND(Nsz&arg_kinds not present but arg_names isz&arg_kinds present but arg_names is notrr,)anyrrrr rPrrrs has_method builtin_base method_declr bound_sigrrr>rtr2rrTunion_method_callr>r)rbaserrrzr*rrr& fast_namer_rrs rgen_method_callz!LowLevelIRBuilder.gen_method_calls`  S(NI(N%N&&tT:tYPYZ Z $& tyy) ,##00DII4F4F4Q4QR[4\II&&3399--::4 Dyy!!,,T2yy))55d;$$,V.VV,2< =Q =I =/9 :! :I :$0Z2ZZ0~~%~!;; 9dnnd xx 4z4 HII##,,T288GD$$=>||j$)y$ 6 *))diiz;iQZ  I'S_)DD77dJ Tj8F ""4z4IVV?!> :s 3 J Jc fxstdfd } j||| S)z8Generate a method call with a union type for the object.c 2j|Sr)r)r"rrrr*r return_rtypers rcall_union_itemz.call_union_items%''tZtY  rr)rwr) rrobj_typerrr r*rrr!s ` `````` rrz#LowLevelIRBuilder.union_method_calls6$8'8    **4<Z^__rc"tdtS)z0Load unboxed None value (type: none_rprimitive).r)r5rurs rnonezLowLevelIRBuilder.noneq/**rc"tdtS)z0Load unboxed True value (type: bool_rprimitive).rr5rWrs rrzLowLevelIRBuilder.truer%rc"tdtS)z1Load unboxed False value (type: bool_rprimitive).rr'rs rrzLowLevelIRBuilder.false#r%rct|jttjtjdS)z1Load Python None value (type: object_rprimitive).rr)rr8rr r#rs r none_objectzLowLevelIRBuilder.none_object's'xx N$7$79K9KRTUVVrc@|jttdS)z2Load Python True object (type: object_rprimitive).Py_Truerr:rwrs r true_objectzLowLevelIRBuilder.true_object+sxx #4i@AArc@|jttdS)z3Load Python False object (type: object_rprimitive).Py_Falser-rs r false_objectzLowLevelIRBuilder.false_object/sxx #4jABBrcz|tkDs |tkr|jt|tSt |S)z-Load a tagged (Python) integer literal value.)rrrr;r`r5rr"s rload_intzLowLevelIRBuilder.load_int3s3 ( (E4I,I88K~>? ?5> !rct|S)zLoad a float literal value.)r.r3s r load_floatzLowLevelIRBuilder.load_float:s U|rc@|jt|tS)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. )rr;r{r3s rrzLowLevelIRBuilder.load_str>s xx E>:;;rc@|jt|tS)zLoad a bytes literal value.)rr;rXr3s r load_byteszLowLevelIRBuilder.load_bytesFsxx E+;<==rc@|jt|tS)zLoad a complex literal value.)rr;rwr3s r load_complexzLowLevelIRBuilder.load_complexJsxx E+<=>>rrc |d|d}tt}}|jt|||||} |jt| ||tjd|j ||jt t j|||jt|j || S)Nzname "z" is not definedrTrare) r&rr=r(rkrrB NAME_ERRORrH) rr identifierr namespacer* error_msgok_block error_blockr"s rload_static_checkedz%LowLevelIRBuilder.load_static_checkedNs    ,<=I * jl+C[)RVWX {HfooDQR K( #$6$A$A9dST  H% rcL|jtt|tS)N)rA)rr=rwr!)rrs r load_modulezLowLevelIRBuilder.load_modulebsxx #4dFVWXXrcZ|jd|j}|j|S)zLoad native type object..)rrload_native_type_object)rclsfullnames rrz!LowLevelIRBuilder.get_native_typees,oo&az2++H55rcv|jdd\}}|jtt||tS)NrIr)rsplitrr=rwr#)rrLmodulers rrJz)LowLevelIRBuilder.load_native_type_objectjs1sA. xx #4dFNSTTrc x |j}|j}t|tr(t|tr|dvr|j||||S|dvr|j ||||}||S|dvr|j ||||St |rPt |rE|tvr=|tjvr|j||||S|j|||d|St|tr|dvr|j||||St|r||tvr|j!d}|dk7r t"|}nt$j&}t |r|j)|||}|}t|s t+|r|j-|||||St|t.ru|j-|||j)|||||S|tjvr>"b#9 ++,DtTlTXY>9B>>v rc|j}t|tsy|rtj|nt j|}|y|j j|sy|j j|}|s#t|jjdk7ry|rZt|jjdk7s7t|j|jjdjsy|r/ttj|jjry|r|gng}|j||||jj|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). Nrr1)r rrPr rerrrrrr>rrrrret_typer) rrgrhrr*rirrrs rrdzLowLevelIRBuilder.dunder_ops %+,0jnnR(6F6J6J26N  ~~((5~~))+6DHHMM*a/ S'1,Jtyy$((--XYJZJ_J_4` J1668I8IJv2##D+tTXX=N=NPTUUrctdt|}|jt||tj|}tdt|}|rt j nt j}|j||||}|S)zuCheck if a tagged integer is a short integer. Return the result of the check (value of type 'bit'). rr) r5r[r:r6ANDr,NEQrr`) rvalr*negatedint_tag bitwise_andzerorrXs rrMz(LowLevelIRBuilder.check_tagged_short_intsl !3T:kk"8#w SWX q0$7!(\  loo"";b$? rc |dk(r|jt||g|S|dk(rR|jt||g|}|jt||j tj |S|j t||g|}tdt|}|jt||tj |}ttt} } } t|| | tj} d| _ |j| |j| |j tg|} tdt |}|jt| |tj"|}t|| | tj} d| _ |j| |j| |j t$g||j'| |j| |dk(rtj ntj"}|jt|tdt||S)zCompare two stringsrrrFr)rrrr,rrrSrr5rYr&r(rNrtrrryrrrr)rlhsrhsrr*eqcompare_resulterror_constantcompare_error_checkexception_check propagate final_comparebranchcheck_error_resultnullop_types rcompare_stringsz!LowLevelIRBuilder.compare_stringss :$$Vc3Z> > 4Z""6C:t|jt||r|jn|j||St |jj dk(r`t |jj dk(r>|jt||r|jn|j||St |jj }ttt} } }t|D cgc] } t} } t|D cgc]} |jt|| | }} t|D cgc]} |jt|| | }} |r|| }}n| |}}tt |jj D]} | dk7r|j| | || }|| }|j||||}t!|js|j#t$|g|}| t |jj dz kr#t'||| | dzt&j(}nt'|||t&j(}||_|j||j||jt||j||j-| |j| |jt||j||j/| |Scc} wcc} wcc} w)zCompare two tuples item by itemrTFrr)rr rRrCrWr>r?rr$rrr&r@rErrmrarrr(rNrtrr)rryrzrr*equalrlength false_assign true_assignrnr check_blocksrG lhs_items rhs_items early_stopfinallhs_itemrhs_itemcomparers rrVz LowLevelIRBuilder.compare_tuples9s#((F+ 388V0LbsxxY\YaYaNbbLd /* sxx~~ #chhnn"5 5 HHVFEDJJLtyy{DQ RM sxx~~ ! #CHHNN(;q(@ HHVF5DIIKdjjlDQ RMSXX^^$)3z|Z\3k .3Fm< < >*+ AAv##LO4 |H |HnnXxTBG-W\\:++GgYE3sxx~~&**\!a%5H&++VUFKKH"FN HHV ! " L)  d34 # K(  T23 s# A=MMs3O#O!#O&c|j|d|gd|}t|js|jt|g|}|dk(r#|j |t dtd|}|S)N __contains__rTrrr)rrar rrr[r5rW)rinstrIrr*rTs rr\z-LowLevelIRBuilder.translate_instance_containsksh""4$tL(2##GcUD9C >&&sGA_,MsTXYC rc |dk(rtj}n3|dk(rtj}n|dk(rtj}nJ||j tt ||||S)Nrrr)r6rqORrRrrW)rrgrhrr*codes rr[z!LowLevelIRBuilder.bool_bitwise_opssX 999D 3Y88D 3Y99D " 5xxotT4FGGrcPtj|}|j||||Sr)r,rYr`)rrgrhrr*rjs rrZz$LowLevelIRBuilder.bool_comparison_op~s)''+!!$eT::rct|jtr|j|d||}||St j |g}|j ||g|}|s Jd|z|S)NUnsupported unary operation: %s)rr rPrdrrerf)rr"rr*rrlrs r_non_specialized_unary_opz+LowLevelIRBuilder._non_specialized_unary_opso ejj) ,^^E4T:F! #,==R#8 ++,DugtT=82==v r) likely_boolc|j}t|r0td||}|j|||tj |S|r"t |rtt}ttttf\}}} } t} |jt||jtj|} |jt| ||tj|j!||jt#||j%|j'| |j!||jt||j)tj|} |jt| | | tj|j!| |jt#||j+|j'| |j!| |j-|d|} |jt#|| |j'| |j!| |S|j-|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 rnot)r rar5r:r6rRrmrCrUr&rr,r.rr(rNrr$rrr1rr)rr"r*rrmaskrTr not_falserrrncmprss r unary_notzLowLevelIRBuilder.unary_notsjj $S )1c4(D;;sE4DA A /4>*C,6L*, V`Vb,b )E9dE,C((<t/?/?/A>%. . 3Y##E40 0 3Y??5$/ / 3Y$$UD1 1|#|j||j|-|j|d||gd|F||j|||}|jt||g|v||j|||}|S)Nrrr)rrrrSr)rkey_value_pairsr*rkeysrrr"s r make_dictzLowLevelIRBuilder.make_dicts# ) SJC>KK$MM%(22MC!..tVTBF 5T R! S$ >&&tVT:F rc2|jt|g|S)aThis 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 )rSrrrr*s rnew_list_op_with_lengthz)LowLevelIRBuilder.new_list_op_with_lengths{{;$77rc tt|t|g}t|tk\r|j t ||z|S|j t ||}|s|S|Dcgc]}|j|t|}}|jt|gt|}tt|D]-}|jt|t|t||g|/|jt|g|Scc}wr)r5r>r[!LIST_BUILDING_EXPANSION_THRESHOLDrSrrrCrwrrArr@rrr7) rrr*r result_listrIr ob_item_baserGs rrzLowLevelIRBuilder.new_list_op s&s6{4JDQR v;; ;;;}fvotD D kk+vt<  GMNt D"3T:NNxx [M:t LM s6{# A    ga9O.PRVWXRYZ\`   K=)*Os'D c0|jt||Sr)rr)rrr*s rrzLowLevelIRBuilder.new_set_op!s  VT::rrctt|t|}|jt |t ||jt |rt|St|S)z;Declare and initialize a new RArray, returning its address.) rCrOr>rr%rr8rvrZ)r item_typerrarrays rrzLowLevelIRBuilder.setup_rarray$sb 3v;78 UDL12xx Z1[` a  EY[` a  rct|}ttt} }}|dk(r||fn||f\} } |} |j| | | |j||j | ||} |j t || |j| |j||}|j |||}|j t |||j| |j| |S)Nand)rCr&add_bool_branchrrCrr$r)rr expr_typeleftrightr*r left_body right_body next_block true_body false_body left_value left_coerced right_value right_coerceds rrz%LowLevelIRBuilder.shortcircuit_helper.s)$,6L*, z: <>;Y 7YXbLc :V  ZJ? I&{{:y$?   -. * J'g  KDA   ./ * J' rc Zt|jr|}|St|jtr>t dt }|j ||tj|j}|St|jrBt d|j}|jt||tj}|St|jtr$|jt|g|j}|St|jt st|jt"rG|j%||j}t d}|j'||d|j}|St)|jt*rj|jj,j.rJ|jj,j1dr%|j3|dgt4|j}|St7|jr7|j9|t;dt<j|j}|St?|j}||jA||jCd|j}d}t)|t*r8|j,j1ds|j,jEdrd}|r|}|StGtH}tKtKtK} } }tM||| tLjN} |j| |jQ||jS|||j} |jU| } |jtW|| |jY| |jQ| |jtW|t dtH|jY| |jQ| |S|j[t\|g|j}|S)z_Return bool(value). The result type can be bit_rprimitive or bool_rprimitive. rr__bool__rrRFT)/rar rr`r5rzr`r,rrr*rdrrr{rSrrtr^ builtin_lenrmrrPrrrsrrrWrerar.r/rxrXr*is_method_finalrCrUr&r(rNrr+ bool_valuer$rrr)rr"rrwrr not_none always_truthyrrrWr remainingas_bools rrzLowLevelIRBuilder.bool_valuePsf %UZZ 0Fr q  N ;123D''t\5E5EuzzRFl k"%** -1ejj)DXXl5$ 8H8HIJFf e%**n 5[[!2UGUZZHFb a%**o 6, JJ; %%eUZZ8F1:D^^FD$ CFV S uzz9 - ##00 ##..z:))%RRWR\R\]FH G! ,((c F HHV !M.)4%..99$--==jI$(M (l ##FKK0!..unejjQ $$Ye<!rc g}ttt|t|jD]:}|j|}||}|j |||}|j |<|j *|jJ|j Dcgc]}|| }}d} |jut|j} tt|jt|D]5}||}|j ||j|}|j |7|jD]%} | \} } t| | |} |j | '|j}|tk(rt}|jt|j||j |j"|j$||| |j& }|j$r9|D]4}t)|tt*fr|j,j |6|jtk(rMt/|td|j |t.j0|}t2|_ |j||j4|}n'|jt7||j4}|}|rRt9|j:|s arg_typesrCrordering var_arg_typeextra_int_constantsr5 error_kindrr rr*c_function_name return_typestealsrurrr;rr,rPrtruncated_typerDrr rlr$)rdescrr*rzrorG formal_typer var_arg_idxrIrsrextra_int_constantrrcomprtruncates rrSzLowLevelIRBuilder.call_css3t9c$..&9:; A..+Kq'C++c;5C NN3   == $$$, ,,+/==9awqz9G9    (dnn-K3t~~.D : $1gkk#t'8'8$?s# $ ,, /DHC!(c4!8  NN- . /__  $"J $$             1!#'=>$$++C0 1 ??k )43C3CT(JLL\L\^bcD'DO HHTN    &Fxx1D1D EFHF 1&++{K!+. V[$4K[K[\ o:s K?cd}|D]}t|jt|k7r%tdt||jDsL|jr|s[|rM|j |j k7sJdj |||j |j kDs|}|}|r|j||||}|Sy)Nc3NK|]\}}t|j|ywrrr ractualformals rrz4LowLevelIRBuilder.matching_call_c..s$4BFF 6;;/#%Ambiguous: 1) {} 2) {})r>rrrBrupriorityformatrS) r candidatesrr*rzr&matchingrrs rmatching_call_cz!LowLevelIRBuilder.matching_call_cs15 $D4>>"c$i/FI$PTP^P^F_'':#,, =?Y?`?` $@=}}x'8'88#'#H $ [[4{CFMrc|jrt|j|j|j|j |j |j|j|j|j|j|j|j|j }|j||||Sg}tt!t#|t#|jD]>}|j|}||} |J|j%| ||} |j'| @|jJ|j J|jrJ|j)t+|||} |jr9|D]4} t-| t.t0fr|j2j'| 6|jt4k(rMt7| t/d|j|t6j8|} t:| _|j)| |j J| } |rRt=| j>|srCrrrArr5r;rrr,rPrrr rlr$) rrrr*rzc_descrorGrrrrrs rrzLowLevelIRBuilder.primitive_ops=   *   !!##$$    ((  F;;vtT{;K K s3t9c$..&9:; A..+Kq'C* **++c;5C NN3   }}$$$  (((+++++gt$?@    1!#'=>$$++C0 1 ??k )43C3CT(JLL\L\^bcD'DO HHTN""*** 1&++{K!+. V[$4K[K[\ rcd}|D]}t|jt|k7r%tdt||jDsL|jr|s[|rM|j |j k7sJdj |||j |j kDs|}|}|r|j||||Sy)Nc3NK|]\}}t|j|ywrrrs rrz:LowLevelIRBuilder.matching_primitive_op..ds)#FF6;;/rr)r*rz)r>rrrBrurrr)rrrr*rzr&rrs rrfz'LowLevelIRBuilder.matching_primitive_opXs15 $D4>>"c$i/'*$&?'':#,, =?Y?`?` $@=}}x'8'88#'#H $ $$Xt$K$X Xrc >|jt|||||S)aGenerate 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) )rr6)rr ryrzrr*s rr:zLowLevelIRBuilder.int_opus xxdCb$788rc t|}|tjtjfvrt |t r|j dk7s|j|t dtj|}tt}}|jt|||tjd|j||tjk(rd} nd} |jttj | ||jt#|j||tjk(r|j%|||S|jt||||S)aGenerate 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 '*') rTr=zfloat division by zeroz float modulo)rKr1r^MODrr.r"rar/rr&rr(rNrrBZERO_DIVISION_ERRORrH float_mod) rryrzrr*rjrerrokmsgs rrczLowLevelIRBuilder.float_opsr" W[['++. .sE*syyC/?''U3Z9J9M9MtT$, R3FKKdCD##C(GKK'2C(C+,>,R,RTWY]^_'##B' GKK >>#sD1 188GCeT:; ;rc|jt||tj|}tt}|jt ||t t t t f\}}}} |jt|tdtj|} |jt| ||tj|j||j|||} |jt| | |tj|j||j||d|} |jt || |jt| |j||j!t"td|g|} |jt || |jt| |j| |S)z/Perform x % y on floats using Python semantics.rr)rr1rrCr_r$r&r/r.rr(rNris_same_float_signsrcr4rr) rryrzr*modrTtrickyadjustcopysigndoneis_zero same_signsadjs rrzLowLevelIRBuilder.float_modshhwsCd;<'( S!")3z|Z\S]S_)_&$((,S%*>O>R>RTXYZ 66;;?@ F#--c3=   D&&++>? F#mmCc40 S!" d H% eCj#->E S!" d D! rc<|jt||||Sr)rr/rryrzrr*s rraz LowLevelIRBuilder.compare_floatssxx)#sB=>>rct|trt||j}|j |j||t j dS)zTHelper to add two native integers. The result has the type of lhs. rr)rintr5r r:r6ADDrryrzs rint_addzLowLevelIRBuilder.int_add? c3 #sxx(C{{388S#uyyr{BBrct|trt||j}|j |j||t j dS)zgHelper to subtract a native integer from another one. The result has the type of lhs. rr)rrr5r r:r6rrs rint_subzLowLevelIRBuilder.int_subrrct|trt||j}|j |j||t j dS)zYHelper to multiply two native integers. The result has the type of lhs. rr)rrr5r r:r6MULrs rint_mulzLowLevelIRBuilder.int_mulrrc\|j|||}|j|||}|tjk(rt|trQ|j dvrC|j s#|j|||tj|S|j||||St|rt}n^t|rt}nLt|rt}n:t|r(|j!||||j|||||SJ||j#|||g|S|tj$k(rt|trQ|j dvrC|j s#|j|||tj$|S|j'||||St|rt(}n^t|rt*}nLt|rt,}n:t|r(|j!||||j|||||SJ||j#|||g|S|j|||||S)aGenerate 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) )rr)rCr6r^rr5r"r9r:inline_fixed_width_dividerirrhrrgrrscheck_for_zero_divisionrSrinline_fixed_width_modrrr)rr ryrzrr*prims rr_z$LowLevelIRBuilder.fixed_width_int_opskk#tT*kk#tT* ?#w'CIIW,D~~;;tS#uyy$GG 99$S$OO"4(&$T*&$T*&$T*,,S$={{4c2t<<"d"u;;tc3Z6 6 ?#w'CIIW,D~~;;tS#uyy$GG 66tS#tLL"4(#$T*#$T*#$T*,,S$={{4c2t<<"d"u;;tc3Z6 6{{4c2t44rctt}}|j|td|d|}|jt |||tj |j ||jttjd||jt|j |y)Nrrz"integer division or modulo by zero) r&rmr5rr(rNrrBrrH)rrzr r*rrrs rr"z)LowLevelIRBuilder.check_for_zero_division s, R..ga&6dC b&++67 C   "668\^b   Brcnt|}|j|||tj|}|j t |||j ||||}ttt} } }|j t|| |tj|j||j|||tj|} |j t| |tj|} |j t| | | tj|j| |j||td|tj|} |j t || |j t!| |j| |S)Nr)rCr:r6r^rr$is_same_native_int_signsr&r(rNrrr,rr5rr4)rr ryrzr*rTdivrr r rmulmul_eqrs rr!z+LowLevelIRBuilder.inline_fixed_width_divide sAtnkk$S%))T: S!"224c4H )|Z\:<  D&&++>? F#kk$S%))T:,sC$GH ffkk:; F#kk$WQ%5uyy$G S!" d D! rc (t|}|j|||tj|}|j t |||j ||||}ttt} } }|j t|| |tj|j||j t|td|tj|} |j t| | | tj|j| |j|||tj|} |j t || |j t| |j| |SNr)rCr:r6rrr$r'r&r(rNrr,r5rrr4) rr ryrzr*rTr rr r rrrs rr#z(LowLevelIRBuilder.inline_fixed_width_mod+ s(tnkk$S%))T: S!"224c4H )|Z\:<  D&&++>? F#((<WQ-=|PTUV vv{{;< F#kk$S%))T: S!" d D! rc ,|jt|td|tj|}|jt|td|tj|}|jt||tj|Sr,)rr,r5rOr)rr abr*neg1neg2s rr'z*LowLevelIRBuilder.is_same_native_int_signs= slxx Q4(8,:J:JDQRxx Q4(8,:J:JDQRxx T4$GHHrc(|jt|tdtj|}|jt|tdtj|}|jt ||tj |S)Nr)rr/r.LTr,r)rr.r/r*r0r1s rr z%LowLevelIRBuilder.is_same_float_signsB sjxx)!U3Z9J9M9MtTUxx)!U3Z9J9M9MtTUxx T4$GHHrc<|jt||||Sr)rr,rs rr`zLowLevelIRBuilder.comparison_opG sxx S#r4899rc|j}d}t|st|s t|r|j t |g|}nt |s t|rR|jt|td}|j|t}|jt|gnGt|r|jt |g|}n#t#|r|jt$|g|}|<|r|St'dt|}|j)t*||t,j.|St1|t2r|rJ|j5|dgt6|}|j9|t6|}t;t;} } |j=|t'dd|} |j?| | | |jA| |jtCtBjDd||jtG|jA| |S|r|jtH|g|S|jtJ|g|S)zGenerate len(val). Return short_int_rprimitive by default. Return c_pyssize_t if use_pyssize_t is true (unshifted). Nusedr__len__rrz__len__() should return >= 0)&r rkrrrbrrrnrfrr3rNr r[r7rcrSrrprr5r:rzr6r;rrPrr`rCr&rmrrrB VALUE_ERRORrHrr) rrsr* use_pyssize_tr size_value elem_addressoffsetrrfailconds rrzLowLevelIRBuilder.builtin_lenJ s hh c "&9#&>BUVYBZ**?SE4HJ s #'>s'C88M#{F$KLL|5KLJ HHYu% &  $%9C5$GJ s #%83%FJ  !!!Q 6=F;;3ZIYIY[_` ` c9 %$ $$))#y"ndSF[[>F!|Z\B>>&'!*dDAD  r4 0    % HH"&224RTX  HH[] #    #M ;;5udC C;;~ud; ;rc|r4tt|t}|jt|g|z|S|jt g|Sr)r5r>r[rSrr)rrAr*r8s rrzLowLevelIRBuilder.new_tuple{ sC !#e*.DED;;|dVe^TB B;;;RF Frc2|jt|g|S)aThis 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 )rSrrs rnew_tuple_with_lengthz'LowLevelIRBuilder.new_tuple_with_length s{{3fXtDDrc2|jt|g|Sr)rr)rrr*s rr=zLowLevelIRBuilder.int_to_float s  1#t< else: result = 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 rT)rD)rArrPrr&rC enumerater>rrrrrrCrr$rrw)rrxrrz process_itemr* fast_items rest_itemsrI exit_blockrrG more_typesr true_block false_blockrotemptemp2s rrz(LowLevelIRBuilder.decompose_union_helper s6  KK (D$ *!!$'!!$'  (  \ +& , 1GAtS_q00>JJ++CE*4, K $$R[A##J/kk#tT2G(DKKk48E HHVFE* + IIj !##K0 1 kk#'8$dkKG(DKKk48E HHVFE* + IIj ! J' rcftj|g}|j||g|z|||}|S)arTranslate 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,)rrerf) rbase_regrrrzr*r&rlrs rrz/LowLevelIRBuilder.translate_special_method_call sG"$3#6#6tR#@ 11 $xj4&7{Wa2 rcb|j}|j}t|rt|r|j||||St|rt|r|j ||||St |}t |}d} |A|t ||r|j|rd} t ||r5|j|r$d} n!|t ||r|j|rd} | r|j||||St|tr||k(sy|j} | jd xs.| jd xs| jxs | j} | ry| jds|dk(rdnd} |j!||| |S|j#|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__rrQrR)r rprrbrrxr_never_equal_to_none_translate_fast_optional_eq_cmprrPrrrinherits_python is_augmentedrrXrr ) rrgrhexpr_opr*rirloptropt fast_opt_eqrrcmp_varies_at_runtimeidentity_ref_ops rrWz"LowLevelIRBuilder.translate_eq_cmp s   U #(9%(@''dGTB B u %*=e*D%%dD'4@ @"5)"5)  Lt$<AZAZ[_A`" D%(T-F-Ft-L"  D%(T-F-Ft-L" 77dGTR R5),%>> ((2 2 %++H55 %'' %$$  !""8,&-od8O''dOTJ J##D*W*=vudSSrc2t|xs t|S)z+Are the values of type never equal to None?)rprb)rrs rrYz&LowLevelIRBuilder._never_equal_to_none* s!%A) F#$))V,")T/$**,tyy{C HHVC% &$+tO9I9IB((<d.>.>.@"dKLC HHVC% & # J'$))V,&&""4DTUY"Z B > !> HHVC_ %\F#J((<d.>.>.@,//SWXYC HHVCV[[A B    '")T/$**,tyy{C HHVC% & IIcN    +&&""4DTUY"Z""4DTUY"Z B > !> HHVC_ % # C  rc|dk(rtjntj}|j|t|}|j|t|}|j t||||S)zCreate equality comparison operation between object identities Args: expr_op: either 'is' or 'is not' rQ)r,rrrrCrwr)rrgrhr]r*rryrzs rrXz!LowLevelIRBuilder.translate_is_opp s[ !(4\__\5E5Ekk$ 148kk$ 148xx S#r4899rct|}|dkDrVt|t}tt ||Dcgc] }|D]}| }}}|j t |g|z|S|j tg|Scc}}w)z9Create a dictionary(possibly empty) using keys and valuesr)r>r5r[rrBrSrr) rrrr*r8r:rJrGrAs rrzLowLevelIRBuilder._create_dict{ s4y !8 '.D EJ $Sv%6 7C1CAQCQCEC;;}zlU.BDI I;;{B5 5DsA>cx|jJd|jj||j|y)Nz-cannot generate errors in this compiler phase)rr3r)rrr*s rr3zLowLevelIRBuilder.error s4{{&W(WW& #t//6r)rz Errors | Nonerr}rNone)rrrrrrm)rr?rrI)rr&rrm)rr&rrm)r list[Value]rboolrrm)rrIr rSrrorrI)r BasicBlock | Nonerrm)rrp)rrC)rrm)rz str | Valuerrm)r#rIrrI) r#rIr)rSr*rr&ror'rorrI)F) r#rIr)rSr*rrDror&rorrI)r#rIr)rSr*rrrI)r#rIr*rrrI) rxrIryrrzrSr*rrrorrI) rxrIrrTryrrzrSr*rrrI)rxrIryrr*rrrI)rxrIrz list[ClassIR]r*rrrI)rxrIr*rrrI)rxrIrrIr*rrrI)rxrIrrrr*rrrI) rz+Sequence[tuple[Value, ArgKind, str | None]]r*rrrorrorz!tuple[Value | None, Value | None])NN) rrIrrnr*rrlist[ArgKind] | NonerSequence[str | None] | NonerrI) rrIrrnr*rrrqrrrr Value | None)rrrrrI)rxrIrrrrnr*rrrqrrrrrI)rxrIrrrrnr*rrrqrrrrrs)rrrSequence[Value]r list[ArgKind]rSequence[str | None]r*rrlist[Register] | NonerrI)rrtrrurrvrrr*rrrwrrn)NNF)rrIrrrrnrz RType | Noner*rrrqrlist[str | None] | Noner&rorrI)rrIr"rTrrrrnr rxr*rrrqrryrrIr)r"rrrI)r"r<rrI)r"rrrI)r"bytesrrI)r"complexrrI)rrSr@rr str | NonerArr*rrBr|rrI)rrrrI)rKrrrI)rLrrrI) rgrIrhrIrrr*rrrI) rgrIrhrsrrr*rrrs)rsrIr*rrtrorrI) ryrIrzrIrrr*rrrI)r) rrIrIrIrrr*rrrI)r"rIrrr*rrrI)r"rIr*rrrorrI)r"rIr*rrrI)rzSequence[DictEntry]r*rrrI)rrIr*rrrI)rrnr*rrrI)rrSrrtrrorrI) rrrrSrCallable[[], Value]rr}r*rrrIr)r"rIrr&rr&rrmr) rrrrnr*rrzrxrrI)NF) rzlist[CFunctionDescription]rrnr*rrzrxr&rorrs) rr@rrnr*rrzrxrrI) rzlist[PrimitiveDescription]rrnr*rrzrxr&rorrs) r rSryrIrzrIrrr*rrrI)ryrIrzrIr*rrrI) ryrIrzrIrrr*rrrI)ryrIrzz Value | intrrI) r rQryrIrzrIrrr*rrrI)rzrIr rSr*rrrm) r rSryrIrzrIr*rrrI) r rSr.rIr/rIr*rrrI)r.rIr/rIr*rrrI)rsrIr*rr9rorrI)rArnr*rrrI)rrIr*rrrI)rHrIr*rrrm) rxrIrrTrzrSrKzCallable[[Value], Value]r*rrrI)rUrIrrrrnrzrxr*rr&rorrs) rgrIrhrIr]rr*rrrs)rrSrro) rgrIrhrIr]rr*rrrI)rrnrrnr*rrrI)rrr*rrrm)o__name__ __module__ __qualname____doc__rrrrrrrr r rrrrr$r+rCr4r6r5rpr{rvrwrrrrrrrrrrrrrrr$rrr*r.r1r4r6rr9r;r"rErGrrJrmrdrMrrrVr\r[rZrrrrrrrrrrrrrrrSrrrfr:rcrrarrrr_r"r!r#r'r r`rrrAr=rHrrrWrYrZrXrr3rrrrrs +' # "# @E1INA,)" 9!b bb b  bb b* c!c cc c  cc cJRh=6p8W\55 #5275?B5OS5 5(YY!'Y/2YAFYNQY YB  L6i)9i)i)  i)  i) +i)`+/15 cc c c ( c / c cL+/15 $$ $ $ ( $ / $ $L -d dd d  d ( d/d d2' '' '  ' ( '/' 'b.2000! 0 ( 0  0+0 0<.2\\!\( \  \  \+\ \J+/-1 ;W;W;W ;W " ;W  ;W(;W+;W;W ;Wz``` `  ` # ``(`+` `2+++WBC"<>?#') $       (Y6 U pd VD "cHc 0d H;IN!BF @ @ @ C6 8*;PU  (7 HL      "  #     D?B=@%) J"JJ J " J  Jb%) .  "    B%) B"BB B " B  BR%) .  "    : 9<:0?CCC5555%*551655r )rrrrs rrr s=:G 7? qLG Nr)rrnrrqrr)r __future__rrFcollections.abcrtypingrrr mypy.argmapr mypy.nodesr r r r mypy.operatorsr r mypy.typesrr mypyc.commonrrrrrrrrr mypyc.errorsrmypyc.ir.class_irrrmypyc.ir.func_irrr mypyc.ir.opsrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKrLmypyc.ir.rtypesrMrNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmrnrorprqrrrsrtrurvrwrxryrzr{mypyc.irbuild.utilr| mypyc.optionsr}mypyc.primitives.bytes_opsr~mypyc.primitives.dict_opsrrrrrrmypyc.primitives.exc_opsrrmypyc.primitives.float_opsrrmypyc.primitives.generic_opsrrrrrrrrrmypyc.primitives.int_opsrrrrrrrrrrrrrmypyc.primitives.list_opsrrrrmypyc.primitives.misc_opsrrrrrrrrmypyc.primitives.registryrrrrrmypyc.primitives.set_opsrmypyc.primitives.str_opsrrrrmypyc.primitives.tuple_opsrrrrrmypyc.rt_subtypermypyc.sametyper mypyc.subtyperr DictEntryrr__annotations__rrrrrrrrs # $,,.<<7)    ;4////////////`0000000000000b1)4JC   ]\   0 0'$ (5/5( ) %'!)*ma.?!.C(DD%E0]\W&7W&7tLr