o
    ÕtBh’  ã                   @  sˆ   d 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mZ G d	d
„ d
ƒZddd„Zeeef ZdS )z'Intermediate representation of modules.é    )Úannotations)ÚDict)ÚJsonDict)ÚClassIR)ÚFuncDeclÚFuncIR)Ú	DeserMaps)ÚRTypeÚdeserialize_typec                   @  s2   e Zd ZdZddd„Zddd„Zed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]]ÚreturnÚNonec                 C  s*   || _ |d d … | _|| _|| _|| _d S )N©r   r   r   r   r   )Úselfr   r   r   r   r   © r   úi/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/mypyc/ir/module_ir.pyÚ__init__   s
   
zModuleIR.__init__r   c                 C  s8   | j | jdd„ | jD ƒdd„ | jD ƒdd„ | jD ƒdœS )Nc                 S  ó   g | ]}|  ¡ ‘qS r   ©Ú	serialize©Ú.0Úfr   r   r   Ú
<listcomp>#   ó    z&ModuleIR.serialize.<locals>.<listcomp>c                 S  r   r   r   ©r!   Úcr   r   r   r#   $   r$   c                 S  s   g | ]
\}}||  ¡ f‘qS r   r   ©r!   ÚkÚtr   r   r   r#   %   ó    r   r   )r   r   r   r   r      s   ûzModuleIR.serializeÚdataÚctxr   c                   sN   t |d |d ‡ fdd„|d D ƒ‡ fdd„|d D ƒ‡ fdd„|d	 D ƒƒS )
Nr   r   c                   s   g | ]
}ˆ j t |¡ ‘qS r   )r   r   Úget_id_from_jsonr    ©r,   r   r   r#   -   r*   z(ModuleIR.deserialize.<locals>.<listcomp>r   c                   s   g | ]}t  |ˆ ¡‘qS r   )r   Údeserializer%   r.   r   r   r#   .   s    r   c                   s   g | ]\}}|t |ˆ ƒf‘qS r   )r
   r'   r.   r   r   r#   /   ó    r   )r   )Úclsr+   r,   r   r.   r   r/   (   s   ûzModuleIR.deserializeN)r   r   r   r   r   r   r   r   r   r   r   r   )r   r   )r+   r   r,   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úclassmethodr/   r   r   r   r   r      s    

	r   r+   údict[str, JsonDict]r,   r   r   údict[str, ModuleIR]c                   s¾   |   ¡ D ]%}|d D ]}t|d |d ƒ}|jˆ jvs"J d|j ƒ‚|ˆ j|j< q
q|   ¡ D ]%}|d D ]}t |ˆ ¡}|jjˆ jvsKJ d|jj ƒ‚|ˆ j|jj< q4q.‡ fd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   ÚnameÚmodule_namezClass %s already in mapr   zMethod %s already in mapc                   s   i | ]\}}|t  |ˆ ¡“qS r   )r   r/   )r!   r(   Úvr.   r   r   Ú
<dictcomp>S   r0   z'deserialize_modules.<locals>.<dictcomp>)
Úvaluesr   r   r   r   r/   ÚdeclÚidr   Úitems)r+   r,   Úmodr1   ÚirÚmethodÚfuncr   r.   r   Údeserialize_modules3   s   ý
ÿûrE   N)r+   r7   r,   r   r   r8   )r5   Ú
__future__r   Útypingr   Úmypyc.commonr   Úmypyc.ir.class_irr   Úmypyc.ir.func_irr   r   Úmypyc.ir.opsr   Úmypyc.ir.rtypesr	   r
   r   rE   r   Ú	ModuleIRsr   r   r   r   Ú<module>   s    
%%