
    mi$                       d 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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 ddlmZmZmZ ddl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. ddl/m0Z0 ddl1m2Z2  ededef                   Z3 eee3ge3f          ej4        d                    Z5e5d/d'            Z6d0d-Z7d.S )1a?  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)AnyCallableTypeVarcast)Graph)ClassDef
ExpressionFuncDefMypyFile)state)Type)analyze_always_defined_attrs)TOP_LEVEL_NAME)Errors)FuncDeclFuncIRFuncSignature)ModuleIR	ModuleIRs)none_rprimitive)	IRBuilder)Mapper)PreBuildVisitor)#adjust_generator_classes_of_methodsbuild_type_mapcreate_generator_class_for_func"find_singledispatch_register_impls)IRBuilderVisitor)compute_vtable)CompilerOptionsF.)boundTmoduleslist[MypyFile]graphr   typesdict[Expression, Type]mapperr   optionsr!   errorsr   returnr   c                :   t          || ||||           t          |           t          | |          }i }|j        dk    r|S g }| D ](}	t	          ||	|j        |          }
|	                    |
           |
j        D ]H}t          |t                    r1d|j
         }|j        s|j        rt          |	j        d|||           It                      }t!          |	j        |||||
|||j        	  	        }||_        t'          ||	           t)          |	j        t+          |j                  |j        |j        |j        |j                  }|||	j        <   |                    |j                   *t9          |           |D ]}|j        rt=          |           |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)r   r   r   
num_errorsr   decorators_to_removeacceptnested_funcs
isinstancer   lineis_coroutineis_generatorr   fullnamer   r   singledispatch_implsbuildertransform_mypy_filer   listimports	functionsclassesfinal_namestype_var_namesextendr   is_ext_classr    )r$   r&   r'   r)   r*   r+   singledispatch_inforesult	class_irsmodulepbvfdefsuffixvisitorr:   	module_ircirs                    j/var/www/html/bestrading.cuttalo.com/scripts/kaggle-env/lib/python3.11/site-packages/mypyc/irbuild/main.pybuild_irrO   8   s    67E5'6BBB'///<WfMMF1 I )* )*ff.A.VX]^^c $ 	 	D$(( *ty**$ (9 3tV   
 #$$O4

 

 " 	GV,,,O!!O"
 
	 #,v)))) +++      	 3M    r:   r   mypyfiler   Nonec                   |j         dv rdS |                     |j         |j                   d |j        D             }|D ]3}| j        j        |j                 }| j                            |           4| 	                    d           | 
                    dd           |j        D ]}|                     |           |                                  |                                 \  }}}}	}t          g t                    }
t!          t#          t$          d| j        |
          ||d          }| j                            |           dS )z Generate IR for a single module.)typingabcNc                <    g | ]}t          |t                    |S  )r4   r	   ).0nodes     rN   
<listcomp>z'transform_mypy_file.<locals>.<listcomp>   s'    LLLD(1K1KLtLLLrP   z<module>builtins)traceback_name)r8   
set_modulepathdefsr)   
type_to_irinfor?   appendenter
gen_importr2   maybe_add_implicit_returnleaver   r   r   r   r   module_namer>   )r:   rQ   r?   clsirrY   args_blocksret_typesigfunc_irs               rN   r;   r;      sb    --- 	x((-888LLLLLG  # #^&sx0r""""MM* z2&&&   t%%''' $+==?? D!VXq
O
,
,Cw':C@@!	  G W%%%%%rP   N)r$   r%   r&   r   r'   r(   r)   r   r*   r!   r+   r   r,   r   )r:   r   rQ   r   r,   rR   )8__doc__
__future__r   rT   r   r   r   r   
mypy.buildr   
mypy.nodesr	   r
   r   r   
mypy.stater   
mypy.typesr   mypyc.analysis.attrdefinedr   mypyc.commonr   mypyc.errorsr   mypyc.ir.func_irr   r   r   mypyc.ir.module_irr   r   mypyc.ir.rtypesr   mypyc.irbuild.builderr   mypyc.irbuild.mapperr   mypyc.irbuild.prebuildvisitorr   mypyc.irbuild.preparer   r   r   r   mypyc.irbuild.visitorr   mypyc.irbuild.vtabler    mypyc.optionsr!   r"   strict_optional_setstrict_optional_decrO   r;   rW   rP   rN   <module>r      sW   , # " " " " " / / / / / / / / / / / /       > > > > > > > > > > > >             C C C C C C ' ' ' ' ' '       < < < < < < < < < < 2 2 2 2 2 2 2 2 + + + + + + + + + + + + ' ' ' ' ' ' 9 9 9 9 9 9            3 2 2 2 2 2 / / / / / / ) ) ) ) ) ) GCxS)***d8QCF+-FU-Ft-L-LMM  K K K K\%& %& %& %& %& %&rP   