
    \j                        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
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	HeaderDep	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          V/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/mypyc/ir/module_ir.py__init__zModuleIR.__init__   sL     !||~~"& --0UU    r   c                "   g }t          | j        d           D ]}t          |t                    r|                    d|j        d           5t          |t                    r,d|j        |j        |j	        d}|                    |           vt          |t                    r+d|j        |j        |j	        d}|                    |           | 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)   pathinclude_dirsinternalr   c                6    g | ]}|                                 S  	serialize).0fs     r$   
<listcomp>z&ModuleIR.serialize.<locals>.<listcomp>?   s     @@@A!++--@@@r&   c                6    g | ]}|                                 S r3   r4   )r6   cs     r$   r8   z&ModuleIR.serialize.<locals>.<listcomp>@   s     <<<!<<<r&   c                @    g | ]\  }}||                                 fS r3   r4   )r6   kts      r$   r8   z&ModuleIR.serialize.<locals>.<listcomp>A   s)    LLL41aQ.LLLr&   )r   r   r   r   r   r"   )sortedr"   
isinstancer   appendr.   r	   r/   r0   r1   r   r   r   r   r   r   )r#   serialized_depsdep
source_dep
header_deps        r$   r5   zModuleIR.serialize%   sG   $+1U1UVVV 	3 	3C#w'' 3&&	38'L'LMMMMC++ 3'H$'$4 #	( (
  &&z2222C++ 3'H$'$4 #	( (
  &&z222 |@@@@@<<t|<<<LL4;KLLL+
 
 	
r&   datactxr   c           	     l   t          |d         |d         fd|d         D             fd|d         D             fd|d         D             g           }t                      }|d	         D ]}|d
         dk    r)|                    t          |d                              7|d
         dk    r8|                    t	          |d         |d         |d                              {|d
         dk    r7|                    t          |d         |d         |d                              ||_        |S )Nr   r   c                N    g | ]!}j         t          j        |                   "S r3   )r   r
   get_id_from_json)r6   r7   rF   s     r$   r8   z(ModuleIR.deserialize.<locals>.<listcomp>J   s+    TTTQS]84Q778TTTr&   r   c                :    g | ]}t          j        |          S r3   )r   deserialize)r6   r:   rF   s     r$   r8   z(ModuleIR.deserialize.<locals>.<listcomp>K   s&    BBBQW C((BBBr&   r   c                :    g | ]\  }}|t          |          fS r3   )r   )r6   r<   r=   rF   s      r$   r8   z(ModuleIR.deserialize.<locals>.<listcomp>L   s-    KKKtq!a!!S))*KKKr&   r   r"   r)   r   r.   r	   r/   r0   r1   )r0   r1   r   )r   r!   addr   r	   r   r"   )clsrE   rF   moduledepsdep_dicts     `   r$   rK   zModuleIR.deserializeE   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
 
 !$^, 	 	H9,,&!1223333&![00 (%-n%=!)*!5      &![00 (%-n%=!)*!5     #r&   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   )rE   r   rF   r   r   r   )r*   
__module____qualname____doc__r%   r5   classmethodrK   r3   r&   r$   r   r      sc        223 3 3 3*
 
 
 
@ ! ! ! [! ! !r&   r   rE   dict[str, JsonDict]rF   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 r3   )r   rK   )r6   r<   vrF   s      r$   
<dictcomp>z'deserialize_modules.<locals>.<dictcomp>   s/    EEE1Ax##As++EEEr&   )
valuesr   r   r   r   rK   declidr   items)rE   rF   modrN   irmethodfuncs    `     r$   deserialize_modulesre   j   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)rE   rV   rF   r   r   rW   )rT   
__future__r   mypyc.commonr   mypyc.ir.class_irr   mypyc.ir.depsr   r   r   r	   mypyc.ir.func_irr
   r   mypyc.ir.opsr   mypyc.ir.rtypesr   r   r   re   dictr   	ModuleIRsr3   r&   r$   <module>ro      s   - - " " " " " " ! ! ! ! ! ! % % % % % % C C C C C C C C C C C C - - - - - - - - " " " " " " 3 3 3 3 3 3 3 3Z Z Z Z Z Z Z Zz F  F  F  FJ h			r&   