
    i                        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mZmZmZ ddZddZddZddZdS )    )annotations)ClassIR)
Dependency)FuncIR)AssignCallCPrimitiveOp)RStructRTupleRTypeRUnionRVecfnr   returnset[Dependency] | Nonec                   d}t          | |          }| j        D ]}|j        D ]}t          |t                    r
J d            t          |t
                    r6|j        /|j        D ]'}|t                      }|                    |           (t          |j
        |          }t          |t                    rt          |j        j
        |          }|S )a  Find implicit dependencies that need to be imported.

    Using primitives or types defined in librt submodules such as "librt.base64"
    requires dependency imports (e.g., capsule imports).

    Note that a module can depend on a librt module even if it doesn't explicitly
    import it, for example via re-exported names or via return types of functions
    defined in other modules.
    NzLowered IR is expected)find_type_dependenciesblocksops
isinstancer	   r   dependenciessetaddcollect_type_depstyper   dest)r   depsblockopdeps        Z/root/projects/qq-shell/venv/lib64/python3.11/site-packages/mypyc/analysis/capsule_deps.pyfind_implicit_op_dependenciesr"   
   s     $(D!"d++D 
= 
=) 		= 		=B!"k22LL4LLLL"e$$ ")D? " "C|"uuHHSMMMM$RWd33D"f%% =(t<<		= K    r   c                    | j         j        j        D ]}t          |j        |          }t          | j         j        j        |          }|S )zFind dependencies from RTypes in function signatures.

    Some RTypes (e.g., those for librt types) have associated dependencies
    that need to be imported when the type is used.
    )declsigargsr   r   ret_type)r   r   args      r!   r   r   &   sH     w{ 1 1 400RW[1488DKr#   clr   c                v    d}| j         D ].}|j                                        D ]}t          ||          }/|S )z-Find dependencies from class attribute types.N)mro
attributesvaluesr   )r*   r   base	attr_types       r!   find_class_dependenciesr1   4   sP    #'D 6 6//11 	6 	6I$Y55DD	6Kr#   typr   c                   | j         /| j         D ]'}|t                      }|                    |           (t          | t                    r| j        D ]}t          ||          }nt          | t                    r| j        D ]}t          ||          }nZt          | t                    r| j        D ]}t          ||          }n*t          | t                    rt          | j        |          }|S )zHCollect dependencies from an RType, recursively checking compound types.)r   r   r   r   r   itemsr   r   typesr
   r   	item_type)r2   r   r    items       r!   r   r   =   s   
## 	 	C|uuHHSMMMM#v 
6I 	1 	1D$T400DD	1	C	 	  6I 	1 	1D$T400DD	1	C	!	! 6I 	1 	1D$T400DD	1	C		 6 55Kr#   N)r   r   r   r   )r   r   r   r   r   r   )r*   r   r   r   )r2   r   r   r   r   r   )
__future__r   mypyc.ir.class_irr   mypyc.ir.depsr   mypyc.ir.func_irr   mypyc.ir.opsr   r   r	   mypyc.ir.rtypesr
   r   r   r   r   r"   r   r1   r    r#   r!   <module>r?      s    " " " " " " % % % % % % $ $ $ $ $ $ # # # # # # 3 3 3 3 3 3 3 3 3 3 @ @ @ @ @ @ @ @ @ @ @ @ @ @   8           r#   