NL ihzUdZddlmZddlmZddlmZddlmZm Z ddl m Z ddl m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZdd lmZdd l m!Z!m"Z"m#Z#dd l$m%Z%m&Z&m'Z'm(Z(dd l)m*Z*dd l+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;mZ>m?Z?ddl@mAZAddlBmCZCmDZDmEZEmFZFmGZGddlHmIZIddlJmKZKdZLdeMd< d6dZNd7dZOd8dZPd9dZQ d:dZR d; dd ZUd?d!ZVd@d"ZW dAd#ZX dBd$ZY dCd%ZZ dDd&Z[ dEd'Z\ dEd(Z]dFd)Z^dGd*Z_ dAd+Z`eaeefZbGd,d-e Zc dHd.ZdGd/d0eZeGd1d2e Zf dId3Zg dJd4Zhy5)KaPrepare for IR transform. This needs to run after type checking and before generating IR. For example, construct partially initialized FuncIR and ClassIR objects for all functions and classes. This allows us to bind references to functions and classes before we've generated full IR for functions or classes. The actual IR transform will then populate all the missing bits, such as function bodies (basic blocks). Also build a mapping from mypy TypeInfos to ClassIR objects. ) annotations) defaultdict)Iterable)Final NamedTuple)Graph)ARG_STAR ARG_STAR2CallExprClassDef Decorator ExpressionFuncDef MemberExprMypyFileNameExprOverloadedFuncDefRefExpr SymbolNodeTypeInfoVar)refers_to_fullname)TraverserVisitor)InstanceTypeget_proper_type) FAST_PREFIXPROPSET_PREFIX SELF_NAMEget_id_from_name) catch_errors)Errors)ClassIR)FUNC_CLASSMETHOD FUNC_NORMALFUNC_STATICMETHODFuncDecl FuncSignature RuntimeArg) DeserMaps) RInstanceRTypedict_rprimitivenone_rprimitiveobject_pointer_rprimitiveobject_rprimitivetuple_rprimitive)Mapper) get_func_defget_mypyc_attrs is_dataclassis_extension_classis_trait)CompilerOptions) is_same_type__mypyc_generator_helper__rGENERATOR_HELPER_NAMEc g}|D]M}|jDcgc]}t|ts|} }|j| D cgc]} || fc} O|D]<\}} t | j |j t| | jj| jj} t|j| || _ | jr)| jjj| _|j"sd| _| |j&| j<|j(j+| j | jj,xr"t/| jj0dkD| _?|D]\}} t3|j| j45|j&| jjr%t7|j|j | |||n$t9|j|j | |||ddd|D]M\}} |j&| j} | js,t;| j| |j |O|D]+}t=|D]} t?|j d| ||-|D]\}} |j&| j} | j@D]} | jBddD]}| |j@vstE| j@| |j@| r9| jjF| jH}|J|jrdnd}|jKd| d|d|j d |j|j4ycc}wcc} w#1swY$xYw) N) is_abstractis_final_classrtraitclassz Type of "z%" is incompatible with definition in z "")&defs isinstancer extendr#namefullnamer7infor=is_finalr6path is_ext_classdeletable_attributescopy deletable global_optschildren type_to_irsymbol_fullnamesaddis_enumlen enum_membersr!lineprepare_class_defprepare_non_ext_class_def#prepare_implicit_property_accessorsget_module_func_defsprepare_func_def attributesmror9namesnodeerror)mappermodulesgraphtypesoptionserrorsclassesmoduler`module_classescdefclass_irfuncattrbase_irkinds [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/irbuild/prepare.pybuild_type_maprrMsdGD+1;;U4*T8:T$UU>B4BCD  Q  II OO TN --99--  !36;;f M  !%!?!?!D!D!FH "" $H '/$))$##H$5$5699,,PTYY5K5K1Lq1P!Q&   &++tyy 1   +88!&++vffV]^)KK$    ^ $$TYY/  / 8V__V\ ]^K(0 KD V__dD&' J KK  $$TYY/'' D#<<+ 7---'(;(;D(A7CUCUVZC[\#yyt499#///*1*:*:w 'v.--1F"W\\N!E"KK II   cVB0  sN)N) N. ?A-N33N= cT|j|jdz|jzk(S)N.)rGrF)r`ris rqis_from_modulerus# ==FOOc1DII= ==c|D]}|jjD]}t|jtst |j|s5|j |jj}||j|j<|jj|jj|j|j|j<|D]c}t|D]S}t|j|j|j }|j"|j$|j|<Uey)z>Populate a Mapper with deserialized IR from a list of modules.N)r_valuesrDr`rrurhrGrQrRrSctor func_to_declr[r rFrW functionsdecl)rbrc deser_ctxrir`irrmfunc_ids rq load_type_maprs9LL'') 9D$))X.>$))V3T&&tyy'9'9:/1!!$)),''++DII,>,>?13##DII.  99J(0 JD&tyy$--KG(1(;(;G(D(I(IF   % JJrvc#K|jjD]V}t|jtt t fs)t|j|s@t|jXyw)z?Collect all of the (non-method) functions declared in a module.N) r_rxrDr`rr rrur3)rir`s rqr[r[s\ ##%* dii'96G!H In IIvO tyy) )*sAA7A7A7ct|||||jrtn|jrtnt }|j ||j}t|j||||}||j|<|SN) create_generator_class_if_neededis_classr$ is_staticr&r% fdef_to_sigstrict_dunders_typingr'rFrz) module_name class_namefdefrbrfrpsigr|s rqr\r\sv%[*dFK == #'>>{   T7#@#@ AC DIIz;T BD $F Krvc  |js |jrdjd|j|fDdz|z}t ||dd}d|_||j |<tttttdttdttdttd ttd tft}tt|||d }||j|j<y y ) zIf function is a generator/async function, declare a generator class. Each generator and async function gets a dedicated class that implements the generator protocol with generated methods. _c3&K|] }|s| ywr).0xs rq z3create_generator_class_if_needed..s@aa@s_genT) is_generatedr>typevalue tracebackarg stop_iter_ptr)internalN) is_coroutine is_generatorjoinrFr#reuse_freed_instancefdef_to_generatorr(r)rr0r/r'r; method_decls) rrrrb name_suffixrFcir helper_sighelper_fn_decls rqrrs D--xx@DIIz#:@@6IKWdKd4P#' ),  &"9&786#457$56;(9:5"34?,EF    " !4j4 1?,,-/.rvcTt|tr1t||j||||j|j<yt|t rVt||j|j ||}|js||j|j<nt|jdtry|jdjdk(r]t|jz|_d|_ d|jjd_ ||jt|jz<|j jr`|j jsJd|jdd|_|jj"|j$|j<yyy)NrsetterTr?z.Expected return type annotation for property '')rDrr\rFrr rm decoratorsrris_prop_setterrargspos_only is_propertyris_prop_getterret_typeproperty_types)r~rrkrbr`rfr|s rqprepare_method_defrsJ$ %5 D&'&  " D) $ TYY 67S)-BOODII & *J 7DOOABOONTYY6 7 99 99>> `%STXT]T]S^^_#` `>"&D +/88+<+t#d | Dr,| dj$r|jd||j| D cgc]} | j$s| c} |_g} g}|j D]} | |jvr| jdk7rd|_(|j| }|j$s|j+|| j+|| j,j.s |j0rd|_|j$sd nd}t!||kDr |||_| |_||_t7|||||||t9||||| D]*} | j:| j:j+|,t=|rd|_yycc} wcc} w)zPopulate the interface-level information in a class IR. This includes attribute and method declarations, and the MRO, among other things, but method bodies are generated in a later pass. allow_interpreted_subclassesT serializablezbuiltins.BaseExceptionPyBaseExceptionObjectz builtins.dict PyDictObject builtins.z3Inheriting from most builtin types is unimplementedzEPotential workaround: @mypy_extensions.mypyc_attr(native_class=False)zVhttps://mypyc.readthedocs.io/en/stable/native_classes.html#defining-non-native-classesr?c36K|]}|j ywr)r7)rcs rqrz$prepare_class_def..s<!**n> H#AD#H H>99((T9W-W#11$))..A ;;:#;#; +2tZM*2tZM&0 d#  GY#7 8 r;fdii Q  #4 5yy$$2499= $ Y*2{D&$PWXYLL!KTSWS\S\]yy~~LLLdTXT]T]'r;fdiinnV]^G#_J  rvc pt}|jD]E}|jjD]&\}}|j |t ||||||(G|j ddD]F}|js|jjD]\}}||vs t ||||||HyNr?)setrr]rrS,add_property_methods_for_attribute_if_neededr^r7)rHr~rrbconcrete_attributesrrFrs rqrZrZs%  $ 5 5 7  D*  # #D ) 8b$ K   qr  ==$(OO$9$9$;  j22@b$ K rvc|jddD]}||jvs|j|}|jj|}|?|j} t | t r'| j|jvrt||||t | tr(t| rt||||t|||||js|jst||||t||||y)zAdd getter and/or setter for attribute if defined as property in a base class. Only add declarations. The body IR will be synthesized later during irbuild. r?N)r^rQr_rr`rDr rFrrrrrr7r) rHr~ attr_namerrrbrronr`s rqrrs O 6$$ $''-G y)Ay66D$ *tyy/O&r9j+ND"349XY]9^&r9j+N&r9j+N!!j&>&>&r9j+N&r9j+N!Orvctdt|d}t|g|}t||j||t }d|_d|_||j|<||j|<y)NselfTr) r)r+r(r'rFr%rimplicitrr)r~rrrself_argrr|s rqrrsg&)B-$?H  J /C Irww S+ FDDDM!%BOOI#-Bi rvctdt|d}td|d}t||gt}t|z}t ||j ||t}d|_d|_ ||j|<y)NrTrr) r)r+r(r.rr'rFr%rrr) r~rrrr value_argr setter_namer|s rqrr!sr&)B-$?H7J>I 9- ?C 9,K K+sK HDDDM#'BOOK rvcbt|j|jz }t|j|jz }||k7rytd|D]V}|j|}|j|}|j|jk7ry|j |j k7sVyy)NFr?T)rUrnum_bitmap_argsrangerrp)init_signew_sig num_init_args num_new_argsidxinit_argnew_args rqcheck_matching_argsr.s &)A)AAMw||$w'>'>>L $Q &==%,,s# ==GLL ( ==GLL ( rvc j|jdj}d}|jjd}|r3|jr'|jj ds |j}t |t tfr t|}|js|jst |trz|j|d}d}t |tr|j|d} t|| }|jj|j} | %| jr|jdj r|jjdk7s|sLt#|j$dt'dt(t*t'dt,t.g|j0}t3|j$|j4z } t#|j$d | t7|} t9|j:d|| |_|j<|j>|j<yyyy) N__init____new__rTrrrkwargsr?) rHr`rrGrrDr rr3r7rrrrrQrKrr(rr)r1r r-r rrUrr+r'rFryrz) rkr~rrb init_nodenew_node new_symbolr args_matchr defining_irlast_argctor_sigs rqrr@s *%**I"&Hy)J j))*2E2E2P2PQ\2]??(Y(9:;) ;;r:i3Q%%i6 h (((48G,Xw?J''++INN; #"//99Z(99''+<<$MM!$v'7Bx)D !! Hx}}%(@(@@ q!:IbMJ499dKB)+DII&?4R;rvc j|j}|j}|jjD] }t |j t tfrt||||j |nt |j tr|j jr^t|j s|jd||j|j jD]} t|||| |n#t|||t|j |t!||||j | t#fd|j$Dr|jd||jyy)Nrc3pK|]-}|jvxrj|j/ywr)rQrK)rrrbs rqrz,prepare_non_ext_class_def..s6 `PS3&## # K(9(9#(>(K(K K `s36z>"%.."5"5"7 .0 -1 !"56" *1v}U U  Iz *~~"4>>!#4#=#=#B#BC(H-}}:9dKK rvc|jdk(rVt|jtr<|jj}t|t rt |j|Sy)Nregister)rFrDexprrr`r r8rm)rBr,r`s rqr;r;sH yyJ:dii#Byy~~ dI &!$))]; ; rvN)rbr2rclist[MypyFile]rdrrezdict[Expression, Type]rfr8rgr"r4r5)r`rrirr4bool)rbr2rcrCr}r*r4r5)rirr4zIterable[FuncDef]) rrr str | Nonerrrbr2rfr8r4r')) rrrrErrrbr2rrr4r5)r~r#rrrkr rbr2r`zFuncDef | Decoratorrfr8r4r5)r~r#rrrkr rbr2r`zSymbolNode | Nonerfr8r4r5)rrr4rD)rrr4rD)rJrrrrkr rgr"rbr2rfr8r4r5)rkr r~r#rJrrrrgr"rbr2rfr8r4r5) rHrr~r#rrrbr2r4r5)rHrr~r#rrrr,rrrbr2r4r5) r~r#rrrr,rrr4r5)rr(rr(r4rD) rkr r~r#rrrbr2r4r5)rcrCrgr"r4r)r>rrmrr4RegisteredImpl | None)rBrr,rr4rG)i__doc__ __future__r collectionsrcollections.abcrtypingrr mypy.buildr mypy.nodesr r r r r rrrrrrrrrr mypy.semanalrmypy.traverserr mypy.typesrrr mypyc.commonrrrr mypyc.crashr! mypyc.errorsr"mypyc.ir.class_irr#mypyc.ir.func_irr$r%r&r'r(r) mypyc.ir.opsr*mypyc.ir.rtypesr+r,r-r.r/r0r1mypyc.irbuild.mapperr2mypyc.irbuild.utilr3r4r5r6r7 mypyc.optionsr8mypyc.sametyper9r;rrrrurr[r\rrrrrrXrrZrrrrrrYtupleRegisterImplInforrrr8r*r;rrvrqr_se ##$$",+66QQ$%#(*';u;J J J J " J  J  J JZ> J *       *ac??",?4;?EK?Z]? ?D=== =  =  =  = =D              <$ [ [[ [  [  [  [ [|1 11 1 1  1  11 1h .1;A &O OOO O  O  O O> . . .-2 .AD .  . ( ( (-2 (AD (  ($-1`              B7*+33 Z Z%+ZZE%,E%PZ !(@ %-rv