o
    iI                     @   s>  d dl mZmZmZmZ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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#j0_%eej#j0_(ej"gej#j1_%eej#j1_(ej"egej#j2_%ej"gej#j3_%eej#j3_(ej"egej#j4_%ej"gej#j5_%eej#j5_(ej"egej#j6_%eegej#j7_%eej#j7_(ej"egej#j8_%ej"gej#j9_%e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j?ej#j>_(ej"gej#j@_%ej?ej#j@_(ej"gej#jA_%ejBej#jA_(ej"gej#jC_%ejDej#jC_(ej"gej#jE_%ejFej#jE_(ej"gej#jG_%ejHej#jG_(ej;gej#jI_%ej?gej#jJ_%ejBgej#jK_%ejFgej#jL_%ejHgej#jM_%ej;gej#jN_%eej#jN_(ej?gej#jO_%eej#jO_(ejBgej#jP_%ej"ej#jP_(ejDgej#jQ_%ej"ej#jQ_(ejFgej#jR_%ej"ej#jR_(ejHgej#jS_%ej"ej#jS_(ej"gej#jT_%eej#jT_(ej"gej#jU_%e
ej#jU_(ej"gej#jV_%eej#jV_(ej"ee
gej#jW_%ee	ej#jW_(ej"gej#jX_%eej#jX_(ej"ee
gej#jY_%eej#jY_(dS )!    )POINTERbyrefcastc_char_pc_doublec_intc_size_tc_uintc_uint64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)   e/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/llvmlite/binding/value.pyr   	   s$    r   c                   @      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,          r,   c                   @   r+   )StorageClassr   r   r   N)r!   r"   r#   r-   r%   r&   r)   r)   r)   r*   r/   '   r.   r/   c                   @   st   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ZdZdZdZdZdZdZdZdZdS )	ValueKindr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r                               N)r!   r"   r#   argumentZbasic_blockZ
memory_useZ
memory_defZ
memory_phifunctionZglobal_aliasZglobal_ifuncZglobal_variableZblock_addressZconstant_exprZconstant_arrayZconstant_structZconstant_vectorZundef_valueZconstant_aggregate_zeroZconstant_data_arrayZconstant_data_vectorconstant_intconstant_fpZconstant_pointer_nullZconstant_token_noneZmetadata_as_valueZ
inline_asminstructionZpoison_valuer)   r)   r)   r*   r0   /   s6    r0   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      t t j| S )z
        Get type name
        )r   
ret_stringlibLLVMPY_GetTypeNameselfr)   r)   r*   nameU   s   zTypeRef.namec                 C      t j| S )z=
        Returns true is the type is a pointer type.
        )r   rB   LLVMPY_TypeIsPointerrD   r)   r)   r*   
is_pointer\      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)rI   
ValueErrorformatr?   r   rB   LLVMPY_GetElementTyperD   r)   r)   r*   element_typec   s   zTypeRef.element_typec                 C   r@   N)r   rA   rB   LLVMPY_PrintTyperD   r)   r)   r*   __str__m      zTypeRef.__str__N)	r!   r"   r#   __doc__propertyrF   rI   rN   rQ   r)   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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d0d1 Zed2d3 Zed4d5 Zed6d7 Zed8d9 Zed:d; Z d@d=d>Z!d?S )AValueRefz&A weak reference to a LLVM value.
    c                 C   s   || _ || _tj| | d S rO   )_kind_parentsr   	ObjectRef__init__)rE   ptrkindparentsr)   r)   r*   rY   u   s   zValueRef.__init__c                 C   sB   t  }t j| | t|W  d    S 1 sw   Y  d S rO   )r   OutputStringrB   LLVMPY_PrintValueToStringstr)rE   Zoutstrr)   r)   r*   rQ   z   s   
$zValueRef.__str__c                 C      | j dS )zV
        The module this function or global variable value was obtained from.
        modulerW   getrD   r)   r)   r*   ra      rJ   zValueRef.modulec                 C   r`   )zT
        The function this argument or basic block value was obtained from.
        r;   rb   rD   r)   r)   r*   r;      rJ   zValueRef.functionc                 C   r`   )zE
        The block this instruction value was obtained from.
        blockrb   rD   r)   r)   r*   rd      rJ   zValueRef.blockc                 C   r`   )zG
        The instruction this operand value was obtained from.
        r>   rb   rD   r)   r)   r*   r>      rJ   zValueRef.instructionc                 C   
   | j dkS )NglobalrV   rD   r)   r)   r*   	is_global      
zValueRef.is_globalc                 C   re   )Nr;   rg   rD   r)   r)   r*   is_function   ri   zValueRef.is_functionc                 C   re   )Nrd   rg   rD   r)   r)   r*   is_block   ri   zValueRef.is_blockc                 C   re   )Nr:   rg   rD   r)   r)   r*   is_argument   ri   zValueRef.is_argumentc                 C   re   )Nr>   rg   rD   r)   r)   r*   is_instruction   ri   zValueRef.is_instructionc                 C   re   )Noperandrg   rD   r)   r)   r*   
is_operand   ri   zValueRef.is_operandc                 C      t tj| S rO   )boolr   rB   LLVMPY_IsConstantrD   r)   r)   r*   is_constant      zValueRef.is_constantc                 C   rp   rO   )r0   r   rB   LLVMPY_GetValueKindrD   r)   r)   r*   
value_kind   rt   zValueRef.value_kindc                 C   rp   rO   )r   r   rB   LLVMPY_GetValueNamerD   r)   r)   r*   rF      rt   zValueRef.namec                 C   s   t j| t| d S rO   )r   rB   LLVMPY_SetValueNamer   )rE   valr)   r)   r*   rF      s   c                 C   rp   rO   )r   r   rB   LLVMPY_GetLinkagerD   r)   r)   r*   linkage   rt   zValueRef.linkagec                 C   $   t |ts	t| }tj| | d S rO   )
isinstancer   r   rB   LLVMPY_SetLinkagerE   valuer)   r)   r*   r{         
c                 C   rp   rO   )r,   r   rB   LLVMPY_GetVisibilityrD   r)   r)   r*   
visibility   rt   zValueRef.visibilityc                 C   r|   rO   )r}   r,   r   rB   LLVMPY_SetVisibilityr   r)   r)   r*   r      r   c                 C   rp   rO   )r/   r   rB   LLVMPY_GetDLLStorageClassrD   r)   r)   r*   storage_class   rt   zValueRef.storage_classc                 C   r|   rO   )r}   r/   r   rB   LLVMPY_SetDLLStorageClassr   r)   r)   r*   r      r   c                 C   s\   | j std| jf t|}tjt|t|}|dkr%t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)rj   rK   rV   r_   r   rB   "LLVMPY_GetEnumAttributeKindForNamer   lenrL   LLVMPY_AddFunctionAttr)rE   attrattrnameZattrvalr)   r)   r*   add_function_attribute   s   zValueRef.add_function_attributec                 C   rp   )z)
        This value's LLVM type.
        )r?   r   rB   LLVMPY_TypeOfrD   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)rh   rj   rK   rV   r   rB   LLVMPY_IsDeclarationrD   r)   r)   r*   is_declaration   s
   zValueRef.is_declarationc                 C   s   t d}| jrtj| }t|}|S | jr8| jdkr'tj| }t|}|S | jdkr6tj	| }t|}|S | j
rGtj| }t|}|S | jrTtj| }t|}|S )z
        Return an iterator over this value's attributes.
        The iterator will yield a string for each attribute.
        r)   callZinvoke)iterrj   r   rB   LLVMPY_FunctionAttributesIter_AttributeListIteratorrm   opcodeLLVMPY_CallInstAttributesIterLLVMPY_InvokeInstAttributesIterrh   LLVMPY_GlobalAttributesIter_AttributeSetIteratorrl   LLVMPY_ArgumentAttributesIter)rE   itritr)   r)   r*   
attributes  s,   


zValueRef.attributesc                 C   B   | 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.
        r   r;   )
rj   rK   rV   r   rB   LLVMPY_FunctionBlocksIterrW   copyupdate_BlocksIteratorrE   r   r\   r)   r)   r*   blocks     

zValueRef.blocksc                 C   r   )z
        Return an iterator over this function's arguments.
        The iterator will yield a ValueRef for each argument.
        r   r   )
rj   rK   rV   r   rB   LLVMPY_FunctionArgumentsIterrW   r   r   _ArgumentsIteratorr   r)   r)   r*   	arguments+  r   zValueRef.argumentsc                 C   r   )z
        Return an iterator over this block's instructions.
        The iterator will yield a ValueRef for each instruction.
        zexpected block value, got %s)rd   )
rk   rK   rV   r   rB   LLVMPY_BlockInstructionsIterrW   r   r   _InstructionsIteratorr   r)   r)   r*   instructions8  r   zValueRef.instructionsc                 C   r   )z
        Return an iterator over this instruction's operands.
        The iterator will yield a ValueRef for each operand.
        "expected instruction value, got %s)r>   )
rm   rK   rV   r   rB   LLVMPY_InstructionOperandsIterrW   r   r   _OperandsIteratorr   r)   r)   r*   operandsE  s   

zValueRef.operandsc                 C   s(   | j std| jf ttj| S )Nr   )rm   rK   rV   r   rA   rB   LLVMPY_GetOpcodeNamerD   r)   r)   r*   r   S  s
   zValueRef.opcodeFc           	      C   s   | j std| jf | jtjkr@td}tj	| }tj
| t|}tt|tt| j}tj||jr;d|dS d|dS | jtjkrctd}tj| t|}|jra|satdt|  |S t| S )a  
        Return the constant value, either as a literal (when supported)
        or as a string.

        Parameters
        -----------
        signed_int : bool
            if True and the constant is an integer, returns a signed version
        round_fp : bool
            if True and the constant is a floating point value, rounds the
            result upon accuracy loss (e.g., when querying an fp128 value).
            By default, raises an exception on accuracy loss
        zexpected constant value, got %sFlittlebig)signedz:Accuracy loss encountered in conversion of constant value )rs   rK   rV   rv   r0   r<   r   r   rB   LLVMPY_GetConstantIntNumWordsLLVMPY_GetConstantIntRawValuer   bytesr   r   r
   contentsint
from_bytesr   r=   LLVMPY_GetConstantFPValuer_   )	rE   Z
signed_intZround_fpZlittle_endianwordsrZ   ZasbytesZaccuracy_lossr   r)   r)   r*   get_constant_valueZ  s@   
zValueRef.get_constant_valueN)FF)"r!   r"   r#   rS   rY   rQ   rT   ra   r;   rd   r>   rh   rj   rk   rl   rm   ro   rs   rv   rF   setterr{   r   r   r   r   r   r   r   r   r   r   r   r   r)   r)   r)   r*   rU   q   s|    




























rU   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 u rtdt| jf d S )Nz%s must specify kind attribute)r   rX   rY   rW   r[   NotImplementedErrorr   r!   )rE   rZ   r\   r)   r)   r*   rY     s   

z_ValueIterator.__init__c                 C   s    |   }|rt|| j| jS trO   )_nextrU   r[   rW   StopIterationrE   Zvpr)   r)   r*   __next__  s   z_ValueIterator.__next__c                 C      | S rO   r)   rD   r)   r)   r*   __iter__     z_ValueIterator.__iter__)r!   r"   r#   r[   rY   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rO   )r   r   r   r)   r)   r*   r     s   z_AttributeIterator.__next__c                 C   r   rO   r)   rD   r)   r)   r*   r     r   z_AttributeIterator.__iter__N)r!   r"   r#   r   r   r   r)   r)   r)   r*   r     s    r   c                   @      e Zd Zdd Zdd ZdS )r   c                 C      | j |  d S rO   )_capiLLVMPY_DisposeAttributeListIterrD   r)   r)   r*   _dispose     z_AttributeListIterator._disposec                 C   r@   rO   )r   	ret_bytesrB   LLVMPY_AttributeListIterNextrD   r)   r)   r*   r     rR   z_AttributeListIterator._nextNr!   r"   r#   r   r   r)   r)   r)   r*   r         r   c                   @   r   )r   c                 C   r   rO   )r   LLVMPY_DisposeAttributeSetIterrD   r)   r)   r*   r     r   z_AttributeSetIterator._disposec                 C   r@   rO   )r   r   rB   LLVMPY_AttributeSetIterNextrD   r)   r)   r*   r     rR   z_AttributeSetIterator._nextNr   r)   r)   r)   r*   r     r   r   c                   @       e Zd ZdZdd Zdd ZdS )r   rd   c                 C   r   rO   )r   LLVMPY_DisposeBlocksIterrD   r)   r)   r*   r     r   z_BlocksIterator._disposec                 C   rG   rO   )r   rB   LLVMPY_BlocksIterNextrD   r)   r)   r*   r        z_BlocksIterator._nextNr!   r"   r#   r[   r   r   r)   r)   r)   r*   r         r   c                   @   r   )r   r:   c                 C   r   rO   )r   ZLLVMPY_DisposeArgumentsIterrD   r)   r)   r*   r     r   z_ArgumentsIterator._disposec                 C   rG   rO   )r   rB   LLVMPY_ArgumentsIterNextrD   r)   r)   r*   r     r   z_ArgumentsIterator._nextNr   r)   r)   r)   r*   r     r   r   c                   @   r   )r   r>   c                 C   r   rO   )r   LLVMPY_DisposeInstructionsIterrD   r)   r)   r*   r     r   z_InstructionsIterator._disposec                 C   rG   rO   )r   rB   LLVMPY_InstructionsIterNextrD   r)   r)   r*   r     r   z_InstructionsIterator._nextNr   r)   r)   r)   r*   r     r   r   c                   @   r   )r   rn   c                 C   r   rO   )r   LLVMPY_DisposeOperandsIterrD   r)   r)   r*   r     r   z_OperandsIterator._disposec                 C   rG   rO   )r   rB   LLVMPY_OperandsIterNextrD   r)   r)   r*   r     r   z_OperandsIterator._nextNr   r)   r)   r)   r*   r     r   r   )Zctypesr   r   r   r   r   r   r   r	   r
   r   r   enumZllvmlite.bindingr   Zllvmlite.binding.commonr   r   IntEnumr   r,   r/   r0   rX   r?   rU   r   r   r   r   r   r   r   r   ZLLVMValueRefrB   r^   argtypesZLLVMPY_GetGlobalParentZLLVMModuleRefrestyperw   rx   r   ZLLVMTypeRefrP   rH   rM   rC   rz   r~   r   r   r   r   r   r   r   r   ZLLVMAttributeListIteratorr   r   r   ZLLVMAttributeSetIteratorr   r   ZLLVMBlocksIteratorr   ZLLVMArgumentsIteratorr   ZLLVMInstructionsIteratorr   ZLLVMOperandsIteratorr   r   r   r   r   r   r   r   r   r   r   r   rr   ru   r   r   r   r)   r)   r)   r*   <module>   s   4 #  		


















