
    X-Phz                       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 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) ddl*m+Z+ ddl,m-Z- ddl.m/Z/  ededef                   Z0 eee0ge0f          ej1        d                    Z2e2d/d'            Z3d0d-Z4d.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MypyFile)state)Type)analyze_always_defined_attrs)TOP_LEVEL_NAME)Errors)FuncDeclFuncIRFuncSignature)ModuleIR	ModuleIRs)none_rprimitive)	IRBuilder)Mapper)PreBuildVisitor)build_type_map"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          | |          }i }g }| D ]}	t          ||	|j        |          }
|	                    |
           t                      }t          |	j        |||||
|||j        	  	        }||_	        t          ||	           t          |	j        t          |j                  |j        |j        |j        |j                  }|||	j        <   |                    |j                   t'          |           |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   r   r   decorators_to_removeacceptr   r   fullname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visitorr/   	module_ircirs                  R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypyc/irbuild/main.pybuild_irrB   3   se    67E5'6BBB<WfMMF I * *ff.A.VX]^^c #$$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  )
isinstancer	   ).0nodes     rA   
<listcomp>z'transform_mypy_file.<locals>.<listcomp>   s'    LLLD(1K1KLtLLLrC   z<module>builtins)traceback_name)r-   
set_modulepathdefsr&   
type_to_irinfor4   appendenter
gen_importr,   maybe_add_implicit_returnleaver   r   r   r   r   module_namer3   )r/   rD   r4   clsirrM   args_blocksret_typesigfunc_irs               rA   r0   r0   u   sb    --- 	x((-888LLLLLG  # #^&sx0r""""MM* z2&&&   t%%''' $+==?? D!VXq
O
,
,Cw':C@@!	  G W%%%%%rC   N)r!   r"   r#   r   r$   r%   r&   r   r'   r   r(   r   r)   r   )r/   r   rD   r   r)   rE   )5__doc__
__future__r   rG   r   r   r   r   
mypy.buildr   
mypy.nodesr	   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   mypyc.irbuild.visitorr   mypyc.irbuild.vtabler   mypyc.optionsr   r   strict_optional_setstrict_optional_decrB   r0   rJ   rC   rA   <module>rz      s'   , # " " " " " / / / / / / / / / / / /       5 5 5 5 5 5 5 5 5 5             C C C C C C ' ' ' ' ' '       < < < < < < < < < < 2 2 2 2 2 2 2 2 + + + + + + + + + + + + ' ' ' ' ' ' 9 9 9 9 9 9 T T T T T T T T 2 2 2 2 2 2 / / / / / / ) ) ) ) ) ) GCxS)***d8QCF+-FU-Ft-L-LMM  > > > >B%& %& %& %& %& %&rC   