U
    |e;                     @   s  d dl mZ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G dd de
jZG dd de
jZG dd deZG dd deZG dd deZG dd deZG dd deZG dd de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j0_ ee
jj0_#e
jege
jj1_ eege
jj2_ ee
jj2_#e
jege
jj3_ e
jge
jj4_ ee
jj4_#e
jge
jj5_ e
j6e
jj5_#e
jge
jj7_ e
j6e
jj7_#e
jge
jj8_ e
j6e
jj8_#e
jge
jj9_ e
j:e
jj9_#e
jge
jj;_ e
j:e
jj;_#e
jge
jj<_ e
j=e
jj<_#e
jge
jj>_ e
j?e
jj>_#e
jge
jj@_ e
jAe
jj@_#e
jge
jjB_ e
jCe
jjB_#e
j6ge
jjD_ e
j:ge
jjE_ e
j=ge
jjF_ e
jAge
jjG_ e
jCge
jjH_ e
j6ge
jjI_ ee
jjI_#e
j:ge
jjJ_ ee
jjJ_#e
j=ge
jjK_ e
je
jjK_#e
j?ge
jjL_ e
je
jjL_#e
jAge
jjM_ e
je
jjM_#e
jCge
jjN_ e
je
jjN_#e
jge
jjO_ ee
jjO_#dS )    )POINTERc_char_pc_intc_size_tc_uintc_boolc_void_pN)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                           	   
                     N)__name__
__module____qualname__ZexternalZavailable_externallyZlinkonce_anyZlinkonce_odrZlinkonce_odr_autohideZweak_anyZweak_odrZ	appendinginternalprivate	dllimport	dllexportZexternal_weakZghostcommonZlinker_privateZlinker_private_weak r%   r%   S/var/www/website-v5/atlas_env/lib/python3.8/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   defaulthidden	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	   
ret_string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_TypeIsPointerr0   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)r4   
ValueErrorformatr,   r	   r.   LLVMPY_GetElementTyper0   r%   r%   r&   element_type?   s    zTypeRef.element_typec                 C   s   t t j| S N)r	   r-   r.   LLVMPY_PrintTyper0   r%   r%   r&   __str__I   s    zTypeRef.__str__N)	r   r   r   __doc__propertyr2   r4   r8   r;   r%   r%   r%   r&   r,   .   s   


	r,   c                   @   sh  e Zd Z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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ed,d- Zed.d/ Zed0d1 Zed2d3 Zed4d5 Zed6d7 Zd8S )9ValueRefz&A weak reference to a LLVM value.
    c                 C   s   || _ || _tj| | d S r9   )_kind_parentsr	   	ObjectRef__init__)r1   ptrkindparentsr%   r%   r&   rB   Q   s    zValueRef.__init__c              
   C   s6   t  $}t j| | t|W  5 Q R  S Q R X d S r9   )r	   OutputStringr.   LLVMPY_PrintValueToStringstr)r1   outstrr%   r%   r&   r;   V   s    
zValueRef.__str__c                 C   s   | j dS )zV
        The module this function or global variable value was obtained from.
        moduler@   getr0   r%   r%   r&   rJ   [   s    zValueRef.modulec                 C   s   | j dS )zT
        The function this argument or basic block value was obtained from.
        functionrK   r0   r%   r%   r&   rM   b   s    zValueRef.functionc                 C   s   | j dS )zE
        The block this instruction value was obtained from.
        blockrK   r0   r%   r%   r&   rN   i   s    zValueRef.blockc                 C   s   | j dS )zG
        The instruction this operand value was obtained from.
        instructionrK   r0   r%   r%   r&   rO   p   s    zValueRef.instructionc                 C   s
   | j dkS )Nglobalr?   r0   r%   r%   r&   	is_globalw   s    zValueRef.is_globalc                 C   s
   | j dkS )NrM   rQ   r0   r%   r%   r&   is_function{   s    zValueRef.is_functionc                 C   s
   | j dkS )NrN   rQ   r0   r%   r%   r&   is_block   s    zValueRef.is_blockc                 C   s
   | j dkS )NargumentrQ   r0   r%   r%   r&   is_argument   s    zValueRef.is_argumentc                 C   s
   | j dkS )NrO   rQ   r0   r%   r%   r&   is_instruction   s    zValueRef.is_instructionc                 C   s
   | j dkS )NoperandrQ   r0   r%   r%   r&   
is_operand   s    zValueRef.is_operandc                 C   s   t tj| S r9   )r
   r	   r.   LLVMPY_GetValueNamer0   r%   r%   r&   r2      s    zValueRef.namec                 C   s   t j| t| d S r9   )r	   r.   LLVMPY_SetValueNamer   )r1   valr%   r%   r&   r2      s    c                 C   s   t tj| S r9   )r   r	   r.   LLVMPY_GetLinkager0   r%   r%   r&   linkage   s    zValueRef.linkagec                 C   s$   t |tst| }tj| | d S r9   )
isinstancer   r	   r.   LLVMPY_SetLinkager1   valuer%   r%   r&   r^      s    
c                 C   s   t tj| S r9   )r'   r	   r.   LLVMPY_GetVisibilityr0   r%   r%   r&   
visibility   s    zValueRef.visibilityc                 C   s$   t |tst| }tj| | d S r9   )r_   r'   r	   r.   LLVMPY_SetVisibilityra   r%   r%   r&   rd      s    
c                 C   s   t tj| S r9   )r+   r	   r.   LLVMPY_GetDLLStorageClassr0   r%   r%   r&   storage_class   s    zValueRef.storage_classc                 C   s$   t |tst| }tj| | d S r9   )r_   r+   r	   r.   LLVMPY_SetDLLStorageClassra   r%   r%   r&   rg      s    
c                 C   s\   | j std| jf t|}tjt|t|}|dkrJtd	|tj
| | dS )z{Only works on function value

        Parameters
        -----------
        attr : str
            attribute name
        expected function value, got %sr   zno such attribute {!r}N)rS   r5   r?   rH   r	   r.   "LLVMPY_GetEnumAttributeKindForNamer   lenr6   LLVMPY_AddFunctionAttr)r1   attr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_TypeOfr0   r%   r%   r&   type   s    zValueRef.typec                 C   s(   | j s| jstd| jf tj| S )zb
        Whether this value (presumably global) is defined in the current
        module.
        z)expected global or function value, got %s)rR   rS   r5   r?   r	   r.   LLVMPY_IsDeclarationr0   r%   r%   r&   is_declaration   s
    zValueRef.is_declarationc                 C   s   t d}| jr$tj| }t|}n|| jrj| jdkrJtj| }t|}q| jdkrtj	| }t|}n6| j
rtj| }t|}n| jrtj| }t|}|S )z
        Return an iterator over this value's attributes.
        The iterator will yield a string for each attribute.
        r%   callZinvoke)iterrS   r	   r.   LLVMPY_FunctionAttributesIter_AttributeListIteratorrW   opcodeLLVMPY_CallInstAttributesIterLLVMPY_InvokeInstAttributesIterrR   LLVMPY_GlobalAttributesIter_AttributeSetIteratorrV   LLVMPY_ArgumentAttributesIter)r1   itritr%   r%   r&   
attributes   s$    





zValueRef.attributesc                 C   sB   | j std| jf tj| }| j }|j| d t	||S )z|
        Return an iterator over this function's blocks.
        The iterator will yield a ValueRef for each block.
        ri   rM   )
rS   r5   r?   r	   r.   LLVMPY_FunctionBlocksIterr@   copyupdate_BlocksIteratorr1   r   rE   r%   r%   r&   blocks   s    
zValueRef.blocksc                 C   sB   | j std| jf tj| }| j }|j| d t	||S )z
        Return an iterator over this function's arguments.
        The iterator will yield a ValueRef for each argument.
        ri   r   )
rS   r5   r?   r	   r.   LLVMPY_FunctionArgumentsIterr@   r   r   _ArgumentsIteratorr   r%   r%   r&   	arguments   s    
zValueRef.argumentsc                 C   sB   | j std| jf tj| }| j }|j| d t	||S )z
        Return an iterator over this block's instructions.
        The iterator will yield a ValueRef for each instruction.
        zexpected block value, got %s)rN   )
rT   r5   r?   r	   r.   LLVMPY_BlockInstructionsIterr@   r   r   _InstructionsIteratorr   r%   r%   r&   instructions  s    
zValueRef.instructionsc                 C   sB   | j std| jf tj| }| j }|j| d t	||S )z
        Return an iterator over this instruction's operands.
        The iterator will yield a ValueRef for each operand.
        "expected instruction value, got %s)rO   )
rW   r5   r?   r	   r.   LLVMPY_InstructionOperandsIterr@   r   r   _OperandsIteratorr   r%   r%   r&   operands  s    
zValueRef.operandsc                 C   s(   | j std| jf ttj| S )Nr   )rW   r5   r?   r	   r-   r.   LLVMPY_GetOpcodeNamer0   r%   r%   r&   rx   '  s
    zValueRef.opcodeN)r   r   r   r<   rB   r;   r=   rJ   rM   rN   rO   rR   rS   rT   rV   rW   rY   r2   setterr^   rd   rg   ro   rq   rs   r   r   r   r   r   rx   r%   r%   r%   r&   r>   M   sp   

























r>   c                   @   s,   e Zd ZdZdd Zdd ZeZdd ZdS )_ValueIteratorNc                 C   s6   t j| | || _| jd kr2tdt| jf d S )Nz%s must specify kind attribute)r	   rA   rB   r@   rD   NotImplementedErrorrq   r   )r1   rC   rE   r%   r%   r&   rB   4  s    

z_ValueIterator.__init__c                 C   s$   |   }|rt|| j| jS td S r9   )_nextr>   rD   r@   StopIterationr1   vpr%   r%   r&   __next__<  s    z_ValueIterator.__next__c                 C   s   | S r9   r%   r0   r%   r%   r&   __iter__E  s    z_ValueIterator.__iter__)r   r   r   rD   rB   r   nextr   r%   r%   r%   r&   r   /  s
   r   c                   @   s    e Zd Zdd ZeZdd ZdS )_AttributeIteratorc                 C   s   |   }|r|S td S r9   )r   r   r   r%   r%   r&   r   K  s    z_AttributeIterator.__next__c                 C   s   | S r9   r%   r0   r%   r%   r&   r   T  s    z_AttributeIterator.__iter__N)r   r   r   r   r   r   r%   r%   r%   r&   r   I  s   r   c                   @   s   e Zd Zdd Zdd ZdS )rw   c                 C   s   | j |  d S r9   )_capiLLVMPY_DisposeAttributeListIterr0   r%   r%   r&   _disposeZ  s    z_AttributeListIterator._disposec                 C   s   t t j| S r9   )r	   	ret_bytesr.   LLVMPY_AttributeListIterNextr0   r%   r%   r&   r   ]  s    z_AttributeListIterator._nextNr   r   r   r   r   r%   r%   r%   r&   rw   X  s   rw   c                   @   s   e Zd Zdd Zdd ZdS )r|   c                 C   s   | j |  d S r9   )r   LLVMPY_DisposeAttributeSetIterr0   r%   r%   r&   r   c  s    z_AttributeSetIterator._disposec                 C   s   t t j| S r9   )r	   r   r.   LLVMPY_AttributeSetIterNextr0   r%   r%   r&   r   f  s    z_AttributeSetIterator._nextNr   r%   r%   r%   r&   r|   a  s   r|   c                   @   s    e Zd ZdZdd Zdd ZdS )r   rN   c                 C   s   | j |  d S r9   )r   LLVMPY_DisposeBlocksIterr0   r%   r%   r&   r   n  s    z_BlocksIterator._disposec                 C   s   t j| S r9   )r	   r.   LLVMPY_BlocksIterNextr0   r%   r%   r&   r   q  s    z_BlocksIterator._nextNr   r   r   rD   r   r   r%   r%   r%   r&   r   j  s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )r   rU   c                 C   s   | j |  d S r9   )r   ZLLVMPY_DisposeArgumentsIterr0   r%   r%   r&   r   y  s    z_ArgumentsIterator._disposec                 C   s   t j| S r9   )r	   r.   LLVMPY_ArgumentsIterNextr0   r%   r%   r&   r   |  s    z_ArgumentsIterator._nextNr   r%   r%   r%   r&   r   u  s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )r   rO   c                 C   s   | j |  d S r9   )r   LLVMPY_DisposeInstructionsIterr0   r%   r%   r&   r     s    z_InstructionsIterator._disposec                 C   s   t j| S r9   )r	   r.   LLVMPY_InstructionsIterNextr0   r%   r%   r&   r     s    z_InstructionsIterator._nextNr   r%   r%   r%   r&   r     s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )r   rX   c                 C   s   | j |  d S r9   )r   LLVMPY_DisposeOperandsIterr0   r%   r%   r&   r     s    z_OperandsIterator._disposec                 C   s   t j| S r9   )r	   r.   LLVMPY_OperandsIterNextr0   r%   r%   r&   r     s    z_OperandsIterator._nextNr   r%   r%   r%   r&   r     s   r   )Pctypesr   r   r   r   r   r   r   enumllvmlite.bindingr	   llvmlite.binding.commonr
   r   IntEnumr   r'   r+   rA   r,   r>   r   r   rw   r|   r   r   r   r   LLVMValueRefr.   rG   argtypesZLLVMPY_GetGlobalParentLLVMModuleRefrestyperZ   r[   rp   LLVMTypeRefr:   r3   r7   r/   r]   r`   rc   re   rf   rh   rj   rl   rr   rv   LLVMAttributeListIteratorry   rz   r{   LLVMAttributeSetIteratorr}   r   LLVMBlocksIteratorr   LLVMArgumentsIteratorr   LLVMInstructionsIteratorr   LLVMOperandsIteratorr   r   r   r   r   r   r   r   r   r   r   r   r%   r%   r%   r&   <module>   s   $ c		












