o
    "jG
                     @   sP   d dl mZmZ d dlmZ ddlmZ ddlmZ dZ	g Z
G dd deZd	S )
    )ast_to_source_codeis_paddle_api)gast   )BaseTransformer)
is_builtinzpdb.set_tracec                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )CallTransformerzE
    This class transforms function calls into Static Graph Ast.
    c                 C   s
   || _ d S N)root)selfr
    r   f/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddle/jit/dy2static/call_transformer.py__init__   s   
zCallTransformer.__init__c                 C   sl   t |tjsJ t|rdS t|j }zh d}td| d}||v }|o*| W S  ty5   Y dS w )a8  
        Determines whether a function needs to be transformed by `convert_call`.
        It doesn't need to be transformed when a function satisfies the following conditions:
          1. It's a api of paddle
          2. It's a python builtin function not include `len`, `zip`, `range` and `enumerate`
        T>   ziprange	enumeratelenprintzis_builtin()F)	
isinstancer   Callr   r   funcstripeval	Exception)r   nodefunc_strZneed_convert_builtin_func_listr   Zneed_convertr   r   r   _no_need_convert_call"   s   z%CallTransformer._no_need_convert_callc                 C   s   |  | j d S r	   )visitr
   )r   r   r   r   	transform<   s   zCallTransformer.transformc                 C   sZ   |  | | |r|S t|j }t|v r|S d| d}t|jd j	}||_|S )Nz
_jst.Call(r   r   )
generic_visitr   r   r   r   PDB_SETr   parsebodyvalue)r   r   r   Znew_func_strZnew_func_astr   r   r   
visit_Call?   s   

zCallTransformer.visit_CallN)__name__
__module____qualname____doc__r   r   r   r%   r   r   r   r   r      s    r   N)Zpaddle.jit.dy2static.utilsr   r   Zpaddle.utilsr   Zbase_transformerr   utilsr   r!   __all__r   r   r   r   r   <module>   s   