NL idZddlmZddlmZmZmZmZddlm Z ddl m Z m Z m Z mZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZmZdd lmZmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ededefZ2eee2ge2fejfdZ4e4 ddZ5ddZ6y)a?Transform a mypy AST to the IR form (Intermediate Representation). For example, consider a function like this: def f(x: int) -> int: return x * 2 + 1 It would be translated to something that conceptually looks like this: r0 = 2 r1 = 1 r2 = x * r0 :: int r3 = r2 + r1 :: int return r3 This module deals with the module-level IR transformation logic and putting it all together. The actual IR is implemented in mypyc.ir. For the core of the IR transform implementation, look at build_ir() below, mypyc.irbuild.builder, and mypyc.irbuild.visitor. ) annotations)AnyCallableTypeVarcast)Graph)ClassDef ExpressionFuncDefMypyFile)state)Type)analyze_always_defined_attrs)TOP_LEVEL_NAME)Errors)FuncDeclFuncIR FuncSignature)ModuleIR ModuleIRs)none_rprimitive) IRBuilder)Mapper)PreBuildVisitor)build_type_map create_generator_class_if_needed"find_singledispatch_register_impls)IRBuilderVisitor)compute_vtable)CompilerOptionsF.)boundTc <t||||||t||}i}|jdkDr|Sg}|D]:} t|| |j|} | j | | j D]<} t| tsd| j} t| jd| || >t} t| j||||| | ||j }|| _t!|| t#| jt%|j&|j(|j*|j,|j.}||| j<|j1|j*=t3||D]}|j4st7||S)zBuild basic IR for a set of modules that have been type-checked by mypy. The returned IR is not complete and requires additional transformations, such as the insertion of refcount handling. r___N) name_suffix)rr num_errorsrdecorators_to_removeaccept nested_funcs isinstancer linerfullnamerrsingledispatch_implsbuildertransform_mypy_filerlistimports functionsclasses final_namestype_var_namesextendr is_ext_classr)modulesgraphtypesmapperoptionserrorssingledispatch_inforesult class_irsmodulepbvfdefsuffixvisitorr. module_ircirs X/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/mypyc/irbuild/main.pybuild_irrI7s67E5'6Bbuiltins)traceback_name)r, set_modulepathdefsr*r r; type_to_irinfor3appendenter gen_importr(maybe_add_implicit_returnleaverrrrr module_namer2) r.mypyfilenoder3clsirargs_blocksret_typesigfunc_irs rHr/r/sC--  x(((--8 ( LD(1KtLGL# ^^ & &sxx 0r"# MM* z2& t %%'$+==? D!VXq O ,Cw':':C@ ! G  W%7Ms E%E%N)r8zlist[MypyFile]r9rr:zdict[Expression, Type]r;rr<r r=rreturnr)r.rr\r rfNone)7__doc__ __future__rrLrrrr mypy.buildr mypy.nodesr r r r mypy.stater mypy.typesrmypyc.analysis.attrdefinedr mypyc.commonr mypyc.errorsrmypyc.ir.func_irrrrmypyc.ir.module_irrrmypyc.ir.rtypesrmypyc.irbuild.builderrmypyc.irbuild.mapperrmypyc.irbuild.prebuildvisitorrmypyc.irbuild.preparerrrmypyc.irbuild.visitorrmypyc.irbuild.vtabler mypyc.optionsr r!strict_optional_setstrict_optional_decrIr/rJrHr~s,#//>>C'<<2++'9 3/) CxS)*8QCF+-FU-F-Ft-LMI I I "I  I  I  IIIX%&rJ