U
    ºmœdÍ;  ã                   @   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	appendingZinternalÚprivateÚ	dllimportÚ	dllexportZexternal_weakÚghostÚcommonZlinker_privateZlinker_private_weak© r%   r%   úO/home/sam/Atlas/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   Ú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	   Ú
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_TypeIsPointerr.   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)r2   Ú
ValueErrorÚformatr*   r	   r,   ÚLLVMPY_GetElementTyper.   r%   r%   r&   Úelement_type?   s    zTypeRef.element_typec                 C   s   t  t j | ¡¡S ©N)r	   r+   r,   ÚLLVMPY_PrintTyper.   r%   r%   r&   Ú__str__I   s    zTypeRef.__str__N)	r   r   r   Ú__doc__Úpropertyr0   r2   r6   r9   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 r7   )Ú_kindÚ_parentsr	   Ú	ObjectRefÚ__init__)r/   ÚptrÚkindÚparentsr%   r%   r&   r@   Q   s    zValueRef.__init__c              
   C   s6   t  ¡ �$}t j | |¡ t|ƒW  5 Q R £ S Q R X d S r7   )r	   ÚOutputStringr,   ÚLLVMPY_PrintValueToStringÚstr)r/   Zoutstrr%   r%   r&   r9   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>   Úgetr.   r%   r%   r&   rG   [   s    zValueRef.modulec                 C   s   | j  d¡S )zT
        The function this argument or basic block value was obtained from.
        ÚfunctionrH   r.   r%   r%   r&   rJ   b   s    zValueRef.functionc                 C   s   | j  d¡S )zE
        The block this instruction value was obtained from.
        ÚblockrH   r.   r%   r%   r&   rK   i   s    zValueRef.blockc                 C   s   | j  d¡S )zG
        The instruction this operand value was obtained from.
        ÚinstructionrH   r.   r%   r%   r&   rL   p   s    zValueRef.instructionc                 C   s
   | j dkS )NÚglobal©r=   r.   r%   r%   r&   Ú	is_globalw   s    zValueRef.is_globalc                 C   s
   | j dkS )NrJ   rN   r.   r%   r%   r&   Úis_function{   s    zValueRef.is_functionc                 C   s
   | j dkS )NrK   rN   r.   r%   r%   r&   Úis_block   s    zValueRef.is_blockc                 C   s
   | j dkS )NÚargumentrN   r.   r%   r%   r&   Úis_argumentƒ   s    zValueRef.is_argumentc                 C   s
   | j dkS )NrL   rN   r.   r%   r%   r&   Úis_instruction‡   s    zValueRef.is_instructionc                 C   s
   | j dkS )NÚoperandrN   r.   r%   r%   r&   Ú
is_operand‹   s    zValueRef.is_operandc                 C   s   t tj | ¡ƒS r7   )r
   r	   r,   ÚLLVMPY_GetValueNamer.   r%   r%   r&   r0   �   s    zValueRef.namec                 C   s   t j | t|ƒ¡ d S r7   )r	   r,   ÚLLVMPY_SetValueNamer   )r/   Úvalr%   r%   r&   r0   “   s    c                 C   s   t tj | ¡ƒS r7   )r   r	   r,   ÚLLVMPY_GetLinkager.   r%   r%   r&   Úlinkage—   s    zValueRef.linkagec                 C   s$   t |tƒst| }tj | |¡ d S r7   )Ú
isinstancer   r	   r,   ÚLLVMPY_SetLinkage©r/   Úvaluer%   r%   r&   r[   ›   s    
c                 C   s   t tj | ¡ƒS r7   )r'   r	   r,   ÚLLVMPY_GetVisibilityr.   r%   r%   r&   Ú
visibility¡   s    zValueRef.visibilityc                 C   s$   t |tƒst| }tj | |¡ d S r7   )r\   r'   r	   r,   ÚLLVMPY_SetVisibilityr^   r%   r%   r&   ra   ¥   s    
c                 C   s   t tj | ¡ƒS r7   )r)   r	   r,   ÚLLVMPY_GetDLLStorageClassr.   r%   r%   r&   Ústorage_class«   s    zValueRef.storage_classc                 C   s$   t |tƒst| }tj | |¡ d S r7   )r\   r)   r	   r,   ÚLLVMPY_SetDLLStorageClassr^   r%   r%   r&   rd   ¯   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)rP   r3   r=   rF   r	   r,   Ú"LLVMPY_GetEnumAttributeKindForNamer   Úlenr4   ÚLLVMPY_AddFunctionAttr)r/   Ú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_TypeOfr.   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)rO   rP   r3   r=   r	   r,   ÚLLVMPY_IsDeclarationr.   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r tj 	| ¡}t|ƒ}n6| j
r†tj | ¡}t|ƒ}n| jr tj | ¡}t|ƒ}|S )z
        Return an iterator over this value's attributes.
        The iterator will yield a string for each attribute.
        r%   ÚcallZinvoke)ÚiterrP   r	   r,   ÚLLVMPY_FunctionAttributesIterÚ_AttributeListIteratorrT   ÚopcodeÚLLVMPY_CallInstAttributesIterÚLLVMPY_InvokeInstAttributesIterrO   ÚLLVMPY_GlobalAttributesIterÚ_AttributeSetIteratorrS   ÚLLVMPY_ArgumentAttributesIter)r/   Ú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.
        rf   ©rJ   )
rP   r3   r=   r	   r,   ÚLLVMPY_FunctionBlocksIterr>   ÚcopyÚupdateÚ_BlocksIterator©r/   r|   rC   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.
        rf   r~   )
rP   r3   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)rK   )
rQ   r3   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)rL   )
rT   r3   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‹   )rT   r3   r=   r	   r+   r,   ÚLLVMPY_GetOpcodeNamer.   r%   r%   r&   ru   '  s
    ÿzValueRef.opcodeN)r   r   r   r:   r@   r9   r;   rG   rJ   rK   rL   rO   rP   rQ   rS   rT   rV   r0   Úsetterr[   ra   rd   rl   rn   rp   r}   r„   r‡   rŠ   rŽ   ru   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	   r?   r@   r>   rB   ÚNotImplementedErrorrn   r   )r/   rA   rC   r%   r%   r&   r@   4  s    

ÿz_ValueIterator.__init__c                 C   s$   |   ¡ }|rt|| j| jƒS t‚d S r7   )Ú_nextr<   rB   r>   ÚStopIteration©r/   Zvpr%   r%   r&   Ú__next__<  s    z_ValueIterator.__next__c                 C   s   | S r7   r%   r.   r%   r%   r&   Ú__iter__E  s    z_ValueIterator.__iter__)r   r   r   rB   r@   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 r7   )r“   r”   r•   r%   r%   r&   r–   K  s    z_AttributeIterator.__next__c                 C   s   | S r7   r%   r.   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 )rt   c                 C   s   | j  | ¡ d S r7   )Ú_capiÚLLVMPY_DisposeAttributeListIterr.   r%   r%   r&   Ú_disposeZ  s    z_AttributeListIterator._disposec                 C   s   t  t j | ¡¡S r7   )r	   Ú	ret_bytesr,   ÚLLVMPY_AttributeListIterNextr.   r%   r%   r&   r“   ]  s    z_AttributeListIterator._nextN©r   r   r   rœ   r“   r%   r%   r%   r&   rt   X  s   rt   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ry   c                 C   s   | j  | ¡ d S r7   )rš   ÚLLVMPY_DisposeAttributeSetIterr.   r%   r%   r&   rœ   c  s    z_AttributeSetIterator._disposec                 C   s   t  t j | ¡¡S r7   )r	   r�   r,   ÚLLVMPY_AttributeSetIterNextr.   r%   r%   r&   r“   f  s    z_AttributeSetIterator._nextNrŸ   r%   r%   r%   r&   ry   a  s   ry   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r‚   rK   c                 C   s   | j  | ¡ d S r7   )rš   ÚLLVMPY_DisposeBlocksIterr.   r%   r%   r&   rœ   n  s    z_BlocksIterator._disposec                 C   s   t j | ¡S r7   )r	   r,   ÚLLVMPY_BlocksIterNextr.   r%   r%   r&   r“   q  s    z_BlocksIterator._nextN©r   r   r   rB   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†   rR   c                 C   s   | j  | ¡ d S r7   )rš   ZLLVMPY_DisposeArgumentsIterr.   r%   r%   r&   rœ   y  s    z_ArgumentsIterator._disposec                 C   s   t j | ¡S r7   )r	   r,   ÚLLVMPY_ArgumentsIterNextr.   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‰   rL   c                 C   s   | j  | ¡ d S r7   )rš   ÚLLVMPY_DisposeInstructionsIterr.   r%   r%   r&   rœ   „  s    z_InstructionsIterator._disposec                 C   s   t j | ¡S r7   )r	   r,   ÚLLVMPY_InstructionsIterNextr.   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�   rU   c                 C   s   | j  | ¡ d S r7   )rš   ÚLLVMPY_DisposeOperandsIterr.   r%   r%   r&   rœ   �  s    z_OperandsIterator._disposec                 C   s   t j | ¡S r7   )r	   r,   ÚLLVMPY_OperandsIterNextr.   r%   r%   r&   r“   ’  s    z_OperandsIterator._nextNr¤   r%   r%   r%   r&   r�   ‹  s   r�   )PÚctypesr   r   r   r   r   r   r   ÚenumZllvmlite.bindingr	   Zllvmlite.binding.commonr
   r   ÚIntEnumr   r'   r)   r?   r*   r<   r‘   r™   rt   ry   r‚   r†   r‰   r�   ZLLVMValueRefr,   rE   ZargtypesZLLVMPY_GetGlobalParentZLLVMModuleRefÚrestyperW   rX   rm   ZLLVMTypeRefr8   r1   r5   r-   rZ   r]   r`   rb   rc   re   rg   ri   ro   rs   ZLLVMAttributeListIteratorrv   rw   rx   ZLLVMAttributeSetIteratorrz   r   ZLLVMBlocksIteratorr…   ZLLVMArgumentsIteratorrˆ   ZLLVMInstructionsIteratorrŒ   ZLLVMOperandsIteratorr›   r    r¢   r¦   r¨   rž   r¡   r£   r¥   r§   r©   r�   r%   r%   r%   r&   Ú<module>   s®   $ c		þ









ÿ


