o
    qi                     @   s   G d d de ZdS )c                   @   s   e Zd ZdZd#ddZdd Zdd Zd	d
 Zdd Ze	dd Z
e	dd Ze	dd Ze	dd Ze	dd Ze	dd Ze	dd Ze	dd Ze	dd Ze	dd  Ze	d!d" ZdS )$Argumentz
    Function argument.

    An argument must have a C type and a name.

    :ivar c_type: the type of the argument in C
    :type c_type: :class:`peachpy.c.types.Type`

    :ivar name: the name of the argument
    :type name: str
    Nc                 C   sJ  ddl m} t||stdt| || _|du rddl}ddl}| d \}}}}}}|du r6t	d|d 
 }|d|}	|	r|	d}|drY|dd }|dsN|d	sc|d
rl|dtd	  }|dsv|dr|dtd  }|dr|dd }|ds|st	dddlm}
 |
| || _dS )a  
        :param peachpy.c.types.Type c_type: the type of the argument in C.
            When Go function is generated, the type is automatically converted to similar Go type.
            Note that the ``short``, ``int``, ``long``, and ``long long`` types do not have an equivalents in Go.
            In particular, C's ``int`` type is not an equivalent of Go's ``int`` type. To get Go's ``int`` and ``uint``
            types use ``ptrdiff_t`` and ``size_t`` correspondingly.

        :param str name: the name of the argument. If the name is not provided explicitly, PeachPy tries to parse it
            from the caller code. The name must follow the C rules for identifiers:

            - It can contain only Latin letters, digits, and underscore symbol
            - It can not start with a digit
            - It can not start with double underscore (these names are reserved for PeachPy)
            - Name must be unique among the function arguments
            )Typez%s is not a C typeN   zFArgument name is not specified and the caller context is not availablez.(?:\w+\.)*(\w+)\s*=\s*(?:\w+\.)*Argument\(.+\)_Zargumentr   argZArgzBArgument name is not specified and can not be parsed from the code)Name)peachpy.c.typesr   
isinstance	TypeErrorstrc_typeinspectrestack
ValueErrorstripmatchgroup
startswithendswithlenpeachpy.namer   
check_namename)selfr   r   r   r   r   r   Zcaller_linessource_liner   r    r   M/home/app/PyTorch/test/pytorch/third_party/python-peachpy/peachpy/function.py__init__   s:   







zArgument.__init__c                 C   s   t | jd | j S )N )r   r   r   r   r   r   r   __str__A   s   zArgument.__str__c                 C   s   t | S N)r   r!   r   r   r   __repr__D   s   zArgument.__repr__c                 C   s"   t |to| j|jko| j|jkS r#   r
   r   r   r   r   otherr   r   r   __eq__G   s   "zArgument.__eq__c                 C   s$   t |t p| j|jkp| j|jkS r#   r%   r&   r   r   r   __ne__J   s   $zArgument.__ne__c                 C      | j jS r#   )r   is_floating_pointr!   r   r   r   r+   M      zArgument.is_floating_pointc                 C   r*   r#   )r   is_codeunitr!   r   r   r   r-   Q   r,   zArgument.is_codeunitc                 C   r*   r#   )r   
is_integerr!   r   r   r   r.   U   r,   zArgument.is_integerc                 C   r*   r#   )r   is_unsigned_integerr!   r   r   r   r/   Y   r,   zArgument.is_unsigned_integerc                 C   r*   r#   )r   is_signed_integerr!   r   r   r   r0   ]   r,   zArgument.is_signed_integerc                 C   r*   r#   )r   is_size_integerr!   r   r   r   r1   a   r,   zArgument.is_size_integerc                 C   r*   r#   )r   is_pointer_integerr!   r   r   r   r2   e   r,   zArgument.is_pointer_integerc                 C   r*   r#   )r   
is_pointerr!   r   r   r   r3   i   r,   zArgument.is_pointerc                 C   r*   r#   )r   	is_vectorr!   r   r   r   r4   m   r,   zArgument.is_vectorc                 C   r*   r#   )r   is_maskr!   r   r   r   r5   q   r,   zArgument.is_maskc                 C   r*   r#   )r   sizer!   r   r   r   r6   u   r,   zArgument.sizer#   )__name__
__module____qualname____doc__r   r"   r$   r(   r)   propertyr+   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r   r   r   r      s:    
0









r   N)objectr   r   r   r   r   <module>   s   