
    i                        d 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mZ  G d	 d
          ZddZeeef         ZdS )z'Intermediate representation of modules.    )annotations)JsonDict)ClassIR)Capsule
Dependency	SourceDep)FuncDeclFuncIR)	DeserMaps)RTypedeserialize_typec                  :    e Zd ZdZddZddZedd            ZdS )ModuleIRz(Intermediate representation of a module.fullnamestrimports	list[str]	functionslist[FuncIR]classeslist[ClassIR]final_nameslist[tuple[str, RType]]type_var_namesreturnNonec                    || _         |                                | _        || _        || _        || _        || _        t                      | _        d S N)	r   copyr   r   r   r   r   setdependencies)selfr   r   r   r   r   r   s          Q/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypyc/ir/module_ir.py__init__zModuleIR.__init__   sL     !||~~"& --0UU    r   c                   g }t          | j        d           D ]g}t          |t                    r|                    d|j        d           5t          |t                    r|                    d|j        d           h| j        | j	        d | j
        D             d | j        D             d	 | j        D             |d
S )Nc                H    t          |           j        t          |           fS r   )type__name__r   )ds    r#   <lambda>z$ModuleIR.serialize.<locals>.<lambda>(   s    DGG<LcRSff;U r%   )keyr   )r(   namer   )r(   pathc                6    g | ]}|                                 S  	serialize).0fs     r#   
<listcomp>z&ModuleIR.serialize.<locals>.<listcomp>1   s     @@@A!++--@@@r%   c                6    g | ]}|                                 S r0   r1   )r3   cs     r#   r5   z&ModuleIR.serialize.<locals>.<listcomp>2   s     <<<!<<<r%   c                @    g | ]\  }}||                                 fS r0   r1   )r3   kts      r#   r5   z&ModuleIR.serialize.<locals>.<listcomp>3   s)    LLL41aQ.LLLr%   )r   r   r   r   r   r!   )sortedr!   
isinstancer   appendr-   r   r.   r   r   r   r   r   )r"   serialized_depsdeps      r#   r2   zModuleIR.serialize%   s    $+1U1UVVV 	P 	PC#w'' P&&	38'L'LMMMMC++ P&&SX'N'NOOO |@@@@@<<t|<<<LL4;KLLL+
 
 	
r%   datactxr   c           	        t          |d         |d         fd|d         D             fd|d         D             fd|d         D             g           }t                      }|d	         D ]k}|d
         dk    r)|                    t          |d                              7|d
         dk    r(|                    t	          |d                              l||_        |S )Nr   r   c                N    g | ]!}j         t          j        |                   "S r0   )r   r	   get_id_from_json)r3   r4   rA   s     r#   r5   z(ModuleIR.deserialize.<locals>.<listcomp><   s+    TTTQS]84Q778TTTr%   r   c                :    g | ]}t          j        |          S r0   )r   deserialize)r3   r7   rA   s     r#   r5   z(ModuleIR.deserialize.<locals>.<listcomp>=   s&    BBBQW C((BBBr%   r   c                :    g | ]\  }}|t          |          fS r0   )r   )r3   r9   r:   rA   s      r#   r5   z(ModuleIR.deserialize.<locals>.<listcomp>>   s-    KKKtq!a!!S))*KKKr%   r   r!   r(   r   r-   r   r.   )r   r    addr   r   r!   )clsr@   rA   moduledepsdep_dicts     `   r#   rF   zModuleIR.deserialize7   s   OTTTT${BSTTTBBBB$y/BBBKKKKtM7JKKK
 
 !$^, 	6 	6H9,,&!1223333&![008F#344555"r%   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   )r@   r   rA   r   r   r   )r)   
__module____qualname____doc__r$   r2   classmethodrF   r0   r%   r#   r   r      sb        223 3 3 3*
 
 
 
$    [  r%   r   r@   dict[str, JsonDict]rA   r   r   dict[str, ModuleIR]c                   |                                  D ]X}|d         D ]M}t          |d         |d                   }|j        j        vsJ d|j        z              |j        |j        <   NY|                                  D ]`}|d         D ]U}t	          j        |          }|j        j        j        vsJ d|j        j        z              |j        |j        j        <   Vafd| 	                                D             S )aG  Deserialize a collection of modules.

    The modules can contain dependencies on each other.

    Arguments:
        data: A dict containing the modules to deserialize.
        ctx: The deserialization maps to use and to populate.
             They are populated with information from the deserialized
             modules and as a precondition must have been populated by
             deserializing any dependencies of the modules being deserialized
             (outside of dependencies between the modules themselves).

    Returns a map containing the deserialized modules.
    r   r-   module_namezClass %s already in mapr   zMethod %s already in mapc                N    i | ]!\  }}|t                               |          "S r0   )r   rF   )r3   r9   vrA   s      r#   
<dictcomp>z'deserialize_modules.<locals>.<dictcomp>n   s/    EEE1Ax##As++EEEr%   )
valuesr   r   r   r
   rF   declidr   items)r@   rA   modrI   irmethodfuncs    `     r#   deserialize_modulesr`   N   s.    {{}} * *y> 	* 	*CVc-&899B;ck1113Lr{3Z111')CK$$	*
 {{}} / / +& 	/ 	/F%fc22D9<s}444*TY-?? 544 +/CM$),''	/ FEEE

EEEEr%   N)r@   rQ   rA   r   r   rR   )rO   
__future__r   mypyc.commonr   mypyc.ir.class_irr   mypyc.ir.depsr   r   r   mypyc.ir.func_irr	   r
   mypyc.ir.opsr   mypyc.ir.rtypesr   r   r   r`   dictr   	ModuleIRsr0   r%   r#   <module>rj      s    - - " " " " " " ! ! ! ! ! ! % % % % % % 8 8 8 8 8 8 8 8 8 8 - - - - - - - - " " " " " " 3 3 3 3 3 3 3 3> > > > > > > >B F  F  F  FJ h			r%   