NL i'dZddlmZddlmZmZmZmZmZm Z m Z m Z ddl m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZddl m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:Gdd Z;y ) z>Maintain a mapping from mypy concepts to IR/compiled concepts.) annotations)ARG_STAR ARG_STAR2GDEFArgKindFuncDefRefExpr SymbolNodeTypeInfo)AnyType CallableTypeInstance LiteralTypeNoneTyp Overloaded PartialType TupleTypeType TypedDictTypeTypeTypeTypeVarLikeType UnboundTypeUninhabitedType UnionTypefind_unpack_in_listget_proper_type)ClassIR)FuncDecl FuncSignature RuntimeArg)KNOWN_NATIVE_TYPES RInstanceRTupleRTypeRUnionbool_rprimitivebytes_rprimitivedict_rprimitivefloat_rprimitivefrozenset_rprimitiveint16_rprimitiveint32_rprimitiveint64_rprimitiveint_rprimitivelist_rprimitivenone_rprimitiveobject_rprimitiverange_rprimitiveset_rprimitivestr_rprimitivetuple_rprimitiveuint8_rprimitivecHeZdZdZd dZd dZd dZd dZddZddZ ddZ y )MapperaKeep track of mappings from mypy concepts to IR concepts. For example, we keep track of how the mypy TypeInfos of compiled classes map to class IR objects. This state is shared across all modules being compiled in all compilation groups. cZ||_i|_i|_t|_i|_yN) group_map type_to_ir func_to_declsetsymbol_fullnamesfdef_to_generator)selfr;s Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/irbuild/mapper.py__init__zMapper.__init__?s*"358:*-%9;c |tSt|}t|tr|jj ret |jjdk(sJ|jj|j|jjdS|jjdk(rtS|jjdk(rtS|jjdk(rtS|jjdk(rtS|jjdk(rtS|jjdk(rtSt!d |jj"Drt$S|jjd k(rt&S|jjd k(rt(S|jjd k(rt*S|jjd k(rt,S|j|j.vrKt1|j.|j}|jj2rt5|tgS|S|jjdk(rt6S|jjdk(rt8S|jjdk(rt:S|jjdk(rt<S|jjt>vrt>|jjStSt|t@rp|jBjjd k(rGtE|jF2tI|jFDcgc]}|j|c}St*St|tJrtSt|tLrtNSt|tPrz'Mapper.type_to_rtype..`sMS\\_4Msz builtins.setzbuiltins.frozensetzbuiltins.tuplezbuiltins.rangezmypy_extensions.i64zmypy_extensions.i32zmypy_extensions.i16zmypy_extensions.u8zunexpected type %s)6r1r isinstancertype is_newtypelenbases type_to_rtyperHr.r)r&r4r'r/anymror(r3r*r5r2r<r" is_protocolr%r-r,r+r6r!rpartial_fallbackritemsr#r rr0rmake_simplified_unionr rr upper_boundrvarrrrfallbackrr)rAtypinsttitems rBrQzMapper.type_to_rtypeGs  ;$ $c" c8 $xx""388>>*a/??/))#((..*;<<xx  N2%%""&66''""o5&&""n4%%""&66''""o5&&M MM&&""n4%%""&::++""&66''""&66''T__, !:;88''!4):";<<K""&;;''""&;;''""&;;''""&::''""&88)#((*;*;<<(( Y '$$))226FF' 2:ciiHt11!4HII'' \ *$ $ W %" " Y '//VYV_V_0`d1C1CD1I0`a a W %$ $ X &$ $ _ -%%coo6 6 [ )77<<+ ++%%cggll3 3 Z ($ $ ] +" " [ )%%cll3 3 o{; <$ $ 7*T#Y66uAI1as ;U9Uc`|tk(rtS|tk(rtS|j |Sr:)rr5rr(rQ)rAr[kinds rB get_arg_rtypezMapper.get_arg_rtypes/ 8 # # Y " "%%c* *rDc t|jtrt|jj|jj Dcgc]\}}|j ||}}}|jjDcgc]}|du}}|js |jr%|jst|j|}n|j|jj}nu|jD cgc]} t  }} |jD cgc]} | j"}} |j$dk(xrt'|j(} | rt*}nt }t-|dr.|jD cgc]} | j.j$} } n|jDcgc]}|xsd } }t| |j ||D cgc]\} }}}t1| |||}}}} }|s|j$dvrt }t3||Scc}}wcc}wcc} wcc} wcc} wcc}wcc}}}} w)NrC arguments)__eq____ne____lt____gt____le____ge__)rLrMr zip arg_types arg_kindsra arg_names is_coroutine is_generator is_decoratedr"r@rQret_typercr1pos_onlynameboolinfor0hasattrvariabler r)rAfdefstrict_dunders_typingr[r`rlrt arg_pos_onlysret_argis_init_methodrnarg_namearg_kindarg_type arg_pos_onlyargss rB fdef_to_sigzMapper.fdef_to_sigs dii ."%TYY%8%8$)):M:M!NC""3-I7;ii6I6IJdTT\JMJ!!T%6%6@Q@Q't'='=d'CD((););<59NNCq*CIC59^^DcS\\DMD!YY*4HdiiN%' 4 %6:nnEs**EIE04??I??B4>>9m?  :(Hl x8\ B  % yyXX'T3''iKDD"F? s*H# H) H.$H3H86 H="I c||jvS)z*Is the given module one compiled by mypyc?)r;)rAmodules rBis_native_modulezMapper.is_native_modules''rDc|jyd|jjvrI|jjjdd}|j|xs||jvSy)NF.rT)noderH rpartitionrr?)rAexprrts rBis_native_ref_exprzMapper.is_native_ref_exprsd 99  $))$$ $99%%005a8D((.O$$:O:O2O OrDcN|j|xr|jtk(Sr:)rr`r)rArs rBis_native_module_ref_exprz Mapper.is_native_module_ref_exprs!&&t,Bd1BBrDN)r;zdict[str, str | None]returnNone)r[z Type | Nonerr$)r[rr`rrr$)ryrrzrurr)rstrrru)rr rru) __name__ __module__ __qualname____doc__rCrQrarrrrrDrBr8r85s.<_7B+6(p(CrDr8N)rsdD"aaa&&@@4@C@CrD