B
    Ꮚ\                 @   s,  d dl mZmZmZmZmZmZ d dlZddlm	Z	 ddl
mZmZ G dd dejZG dd	 d	ejZG d
d dejZG dd de	jZG dd de	jZe	jeege	jj_e	jge	jj_e	je	jj_e	jge	jj_ee	jj_e	jege	jj_e	jge	jj_e	je	jj_e	jge	jj_ee	jj_e	jge	jj _ee	jj _e	jge	jj!_e	je	jj!_e	jge	jj"_ee	jj"_e	jge	jj#_ee	jj#_e	jege	jj$_e	jge	jj%_ee	jj%_e	jege	jj&_e	jge	jj'_ee	jj'_e	jege	jj(_eege	jj)_ee	jj)_e	jege	jj*_e	jge	jj+_ee	jj+_dS )    )POINTERc_char_pc_intc_size_tc_uintc_boolN   )ffi)_decode_string_encode_stringc               @   sP   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdS )Linkager   r                        	   
                     N)__name__
__module____qualname__ZexternalZavailable_externallyZlinkonce_anyZlinkonce_odrZlinkonce_odr_autohideZweak_anyZweak_odrZ	appendingZinternalZprivate	dllimport	dllexportZexternal_weakZghostcommonZlinker_privateZlinker_private_weak r"   r"   5lib/python3.7/site-packages/llvmlite/binding/value.pyr      s"   r   c               @   s   e Zd ZdZdZdZdS )
Visibilityr   r   r   N)r   r   r   defaultZhiddenZ	protectedr"   r"   r"   r#   r$      s   r$   c               @   s   e Zd ZdZdZdZdS )StorageClassr   r   r   N)r   r   r   r%   r   r    r"   r"   r"   r#   r&   &   s   r&   c               @   s<   e Zd ZdZedd Zedd Zedd Zdd	 Zd
S )TypeRefz$A weak reference to a LLVM type
    c             C   s   t tj| S )z
        Get type name
        )r
   r	   libLLVMPY_GetTypeName)selfr"   r"   r#   name1   s    zTypeRef.namec             C   s   t j| S )z=
        Returns true is the type is a pointer type.
        )r	   r(   LLVMPY_TypeIsPointer)r*   r"   r"   r#   
is_pointer8   s    zTypeRef.is_pointerc             C   s$   | j std| ttj| S )zh
        Returns the pointed-to type. When the type is not a pointer,
        raises exception.
        zType {} is not a pointer)r-   
ValueErrorformatr'   r	   r(   LLVMPY_GetElementType)r*   r"   r"   r#   element_type?   s    zTypeRef.element_typec             C   s   t tj| S )N)r
   r	   r(   LLVMPY_PrintType)r*   r"   r"   r#   __str__I   s    zTypeRef.__str__N)	r   r   r   __doc__propertyr+   r-   r1   r3   r"   r"   r"   r#   r'   .   s
   
r'   c               @   s   e Zd ZdZdd Zdd Zedd Zedd	 Zej	d
d	 Zedd Z
e
j	dd Z
edd Zej	dd Zedd Zej	dd Zdd Zedd Zedd ZdS )ValueRefz&A weak reference to a LLVM value.
    c             C   s   || _ tj| | d S )N)_moduler	   	ObjectRef__init__)r*   Zptrmoduler"   r"   r#   r9   Q   s    zValueRef.__init__c          	   C   s*   t  }t j| | t|S Q R X d S )N)r	   ZOutputStringr(   LLVMPY_PrintValueToStringstr)r*   Zoutstrr"   r"   r#   r3   U   s    
zValueRef.__str__c             C   s   | j S )z:
        The module this value was obtained from.
        )r7   )r*   r"   r"   r#   r:   Z   s    zValueRef.modulec             C   s   t tj| S )N)r
   r	   r(   LLVMPY_GetValueName)r*   r"   r"   r#   r+   a   s    zValueRef.namec             C   s   t j| t| d S )N)r	   r(   LLVMPY_SetValueNamer   )r*   valr"   r"   r#   r+   e   s    c             C   s   t tj| S )N)r   r	   r(   LLVMPY_GetLinkage)r*   r"   r"   r#   linkagei   s    zValueRef.linkagec             C   s$   t |tst| }tj| | d S )N)
isinstancer   r	   r(   LLVMPY_SetLinkage)r*   valuer"   r"   r#   rA   m   s    
c             C   s   t tj| S )N)r$   r	   r(   LLVMPY_GetVisibility)r*   r"   r"   r#   
visibilitys   s    zValueRef.visibilityc             C   s$   t |tst| }tj| | d S )N)rB   r$   r	   r(   LLVMPY_SetVisibility)r*   rD   r"   r"   r#   rF   w   s    
c             C   s   t tj| S )N)r&   r	   r(   LLVMPY_GetDLLStorageClass)r*   r"   r"   r#   storage_class}   s    zValueRef.storage_classc             C   s$   t |tst| }tj| | d S )N)rB   r&   r	   r(   LLVMPY_SetDLLStorageClass)r*   rD   r"   r"   r#   rI      s    
c             C   sF   t |}tjt|t|}|dkr4td|tj| | dS )z{Only works on function value

        Parameters
        -----------
        attr : str
            attribute name
        r   zno such attribute {!r}N)	r<   r	   r(   "LLVMPY_GetEnumAttributeKindForNamer   lenr.   r/   LLVMPY_AddFunctionAttr)r*   attrZattrnameZattrvalr"   r"   r#   add_function_attribute   s    zValueRef.add_function_attributec             C   s   t tj| S )z)
        This value's LLVM type.
        )r'   r	   r(   LLVMPY_TypeOf)r*   r"   r"   r#   type   s    zValueRef.typec             C   s   t j| S )zb
        Whether this value (presumably global) is defined in the current
        module.
        )r	   r(   LLVMPY_IsDeclaration)r*   r"   r"   r#   is_declaration   s    zValueRef.is_declarationN)r   r   r   r4   r9   r3   r5   r:   r+   setterrA   rF   rI   rO   rQ   rS   r"   r"   r"   r#   r6   M   s   r6   ),Zctypesr   r   r   r   r   r   enum r	   r!   r
   r   IntEnumr   r$   r&   r8   r'   r6   ZLLVMValueRefr(   r;   ZargtypesZLLVMPY_GetGlobalParentZLLVMModuleRefZrestyper=   r>   rP   ZLLVMTypeRefr2   r,   r0   r)   r@   rC   rE   rG   rH   rJ   rK   rM   rR   r"   r"   r"   r#   <module>   sN    ]







