§
    X-Phy/  ã                  ó´  — U d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 dZded<    G d	„ d
e¦  «        Z G d„ de¦  «        Zi Zded<   i Zded<   i Zded<   i Zded<   i Zded<   	 	 	 	 	 	 	 	 d<d=d/„Z	 	 	 	 	 	 	 d>d?d0„Z	 	 	 	 	 	 	 	 	 d@dAd3„Z	 	 	 	 	 	 dBdd4œdCd5„Z	 	 	 	 	 	 	 	 dDdEd6„Z	 	 	 	 	 	 	 dFdGd8„ZdHd;„ZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#ZdS )Ia;  Utilities for defining primitive ops.

Most of the ops can be automatically generated by matching against AST
nodes and types. For example, a func_op is automatically generated when
a specific function is called with the specific positional argument
count and argument types.

Example op definition:

list_len_op = func_op(name='builtins.len',
                      arg_types=[list_rprimitive],
                      result_type=short_int_rprimitive,
                      error_kind=ERR_NEVER,
                      emit=emit_len)

This op is automatically generated for calls to len() with a single
list argument. The result type is short_int_rprimitive, and this
never raises an exception (ERR_NEVER). The function emit_len is used
to generate C for this op.  The op can also be manually generated using
"list_len_op". Ops that are only generated automatically don't need to
be assigned to a module attribute.

Ops defined with custom_op are only explicitly generated in
mypyc.irbuild and won't be generated automatically. They are always
assigned to a module attribute, as otherwise they won't be accessible.

The actual ops are defined in other submodules of this package, grouped
by category.

Most operations have fallback implementations that apply to all possible
arguments and types. For example, there are generic implementations of
arbitrary function and method calls, and binary operators. These generic
implementations are typically slower than specialized ones, but we tend
to rely on them for infrequently used ops. It's impractical to have
optimized implementations of all ops.
é    )Úannotations)ÚFinalÚ
NamedTuple)ÚPrimitiveDescriptionÚStealsDescription)ÚRTypeé
   r   ÚERR_NEG_INTc                  ó’   — e Zd ZU ded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   dS )ÚCFunctionDescriptionÚstrÚnameúlist[RType]Ú	arg_typesr   Úreturn_typeúRType | NoneÚvar_arg_typeÚtruncated_typeÚc_function_nameÚintÚ
error_kindr   ÚstealsÚboolÚis_borrowedúlist[int] | NoneÚorderingzlist[tuple[int, RType]]Úextra_int_constantsÚpriorityÚis_pureN©Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© ó    úY/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mypyc/primitives/registry.pyr   r   2   s    € € € € € € Ø€I€IIØÐÐÑØÐÐÑØÐÐÑØ Ð Ð Ñ ØÐÐÑØ€O€OOØÐÐÑØÐÐÑØÐÐÑØ0Ð0Ð0Ñ0Ø€M€MMØ€M€MM€M€Mr&   r   c                  ó.   — e Zd ZU ded<   ded<   ded<   dS )ÚLoadAddressDescriptionr   r   r   ÚtypeÚsrcNr    r%   r&   r'   r)   r)   C   s+   € € € € € € Ø€I€IIØ€K€KKØ€H€HH€H€Hr&   r)   z%dict[str, list[PrimitiveDescription]]Úmethod_call_opsÚfunction_opsÚ
binary_opsÚ	unary_opszdict[str, tuple[RType, str]]Úbuiltin_namesNFé   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   úlist[tuple[int, RType]] | Noner   r   r   r   r   r   Úreturnr   c                ó¦   — |€g }t                                | g ¦  «        }t          | |||||||	|
||||¬¦  «        }|                     |¦  «         |S )a.  Define a c function call op that replaces a method call.

    This will be automatically generated by matching against the AST.

    Args:
        name: short name of the method (for example, 'append')
        arg_types: argument types; the receiver is always the first argument
        return_type: type of the return value. Use void_rtype to represent void.
        c_function_name: name of the C function to call
        error_kind: how errors are represented in the result (one of ERR_*)
        var_arg_type: type of all variable arguments
        truncated_type: type to truncated to(See Truncate for info)
                        if it's defined both return_type and it should be non-referenced
                        integer types or bool type
        ordering: optional ordering of the arguments, if defined,
                  reorders the arguments accordingly.
                  should never be used together with var_arg_type.
                  all the other arguments(such as arg_types) are in the order
                  accepted by the python syntax(before reordering)
        extra_int_constants: optional extra integer constants as the last arguments to a C call
        steals: description of arguments that this steals (ref count wise)
        is_borrowed: if True, returned value is borrowed (no need to decrease refcount)
        priority: if multiple ops match, the one with the highest priority is picked
        is_pure: if True, declare that the C function has no side effects, takes immutable
                 arguments, and never raises an exception
    N©r   )r,   Ú
setdefaultr   Úappend)r   r   r   r   r   r   r   r   r   r   r   r   r   ÚopsÚdescs                  r'   Ú	method_opr:   X   sz   € ðR Ð"Ø ÐÝ
×
$Ò
$ T¨2Ñ
.Ô
.€CÝØØØØØØØØØØØØØðñ ô €Dð ‡J‚JˆtÑÔÐØ€Kr&   c                ó¦   — |€g }t                                | g ¦  «        }t          | |||||||	|
|||d¬¦  «        }|                     |¦  «         |S )a-  Define a C function call op that replaces a function call.

    This will be automatically generated by matching against the AST.

    Most arguments are similar to method_op().

    Args:
        name: full name of the function
        arg_types: positional argument types for which this applies
    NF©
r   r   r   r   r   r   r   r   r   r   )r-   r6   r   r7   )r   r   r   r   r   r   r   r   r   r   r   r   r8   r9   s                 r'   Úfunction_opr=   —   sy   € ð0 Ð"Ø ÐÝ
×
!Ò
! $¨Ñ
+Ô
+€CÝØØØØ!Ø%Ø'ØØØØØ/ØØðñ ô €Dð ‡J‚JˆtÑÔÐØ€Kr&   ú
str | NoneÚprimitive_namec                óÂ   — |€|€J ‚||J ‚|	€g }	t                                | g ¦  «        }t          |p| |||||||
|||	|d¬¦  «        }|                     |¦  «         |S )zàDefine a c function call op for a binary operation.

    This will be automatically generated by matching against the AST.

    Most arguments are similar to method_op(), but exactly two argument types
    are expected.
    NF©r   r   r   r   r   r   r   r   r   r   r   r   r   )r.   r6   r   r7   )r   r   r   r   r   r?   r   r   r   r   r   r   r   r8   r9   s                  r'   Ú	binary_oprB   Å   s    € ð, Ð&¨.Ð*DÐ*DÐ*DØÐ+°Ð0JÐ0JÐ0JØÐ"Ø ÐÝ
×
Ò
  bÑ
)Ô
)€CÝØÐ#˜tØØØ!Ø%Ø'ØØØØØ/ØØðñ ô €Dð ‡J‚JˆtÑÔÐØ€Kr&   r5   c
               óB   — |€g }t          d| |||||||	||d|
¬¦  «        S )z‚Create a one-off CallC op that can't be automatically generated from the AST.

    Most arguments are similar to method_op().
    Nz<custom>r   r5   )r   )r   r   r   r   r   r   r   r   r   r   r   s              r'   Ú	custom_oprD   ó   sN   € ð$ Ð"Ø ÐÝØØØØØØØØØØØØ	Øðñ ô ð r&   c                óB   — |€g }t          | |||||||	|
||d|¬¦  «        S )z‚Define a primitive op that can't be automatically generated based on the AST.

    Most arguments are similar to method_op().
    Nr   rA   )r   )r   r   r   r   r   r   r   r   r   r   r   r   s               r'   Úcustom_primitive_oprF     sN   € ð$ Ð"Ø ÐÝØØØØ!Ø%Ø'ØØØØØ/ØØðñ ô ð r&   Úarg_typec                ó¨   — |€g }t                                | g ¦  «        }t          | |g|d|||||	|||
|¬¦  «        }|                     |¦  «         |S )zØDefine a primitive op for an unary operation.

    This will be automatically generated by matching against the AST.

    Most arguments are similar to method_op(), but exactly one argument type
    is expected.
    Nr<   )r/   r6   r   r7   )r   rG   r   r   r   r   r   r   r   r   r   r   r8   r9   s                 r'   Úunary_oprI   =  s{   € ð* Ð"Ø ÐÝ
×
Ò
˜t RÑ
(Ô
(€CÝØØ	ˆ
ØØØ%Ø'ØØØØØ/ØØðñ ô €Dð ‡J‚JˆtÑÔÐØ€Kr&   r*   r+   c                óh   — | t           vsJ d| z  ¦   «         ‚||ft           | <   t          | ||¦  «        S )Nzalready defined: %s)r0   r)   )r   r*   r+   s      r'   Úload_address_oprK   h  sA   € Ø•}Ð$Ð$Ð$Ð&;¸dÑ&BÑ$Ô$Ð$Ø ˜+…M$ÑÝ! $¨¨cÑ2Ô2Ð2r&   )NNNNFFr1   F)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r   r   r3   r   )NNNNFFr1   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r3   r   )	NNNNNNFFr1   )r   r   r   r   r   r   r   r   r   r>   r?   r>   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r3   r   )NNNNFF)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r3   r   )NNNNNFFF)r   r   r   r   r   r   r   r   r   r>   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r3   r   )NNNFFr1   F)r   r   rG   r   r   r   r   r   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r   r   r3   r   )r   r   r*   r   r+   r   r3   r)   )$Ú__doc__Ú
__future__r   Útypingr   r   Úmypyc.ir.opsr   r   Úmypyc.ir.rtypesr   r
   r$   r   r)   r,   r-   r.   r/   r0   r:   r=   rB   rD   rF   rI   rK   Úmypyc.primitives.bytes_opsÚmypycÚmypyc.primitives.dict_opsÚmypyc.primitives.float_opsÚmypyc.primitives.int_opsÚmypyc.primitives.list_opsÚmypyc.primitives.misc_opsÚmypyc.primitives.str_opsÚmypyc.primitives.tuple_opsr%   r&   r'   ú<module>rZ      sé  ðð#ð #ð #ðJ #Ð "Ð "Ð "Ð "Ð "à $Ð $Ð $Ð $Ð $Ð $Ð $Ð $à @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø !Ð !Ð !Ð !Ð !Ð !ð €Ð Ð Ð Ñ ðð ð ð ð ˜:ñ ô ð ð"ð ð ð ð ˜Zñ ô ð ð :<€Ð ;Ð ;Ð ;Ñ ;ð 79€Ð 8Ð 8Ð 8Ñ 8ð 57€
Ð 6Ð 6Ð 6Ñ 6ð 46€	Ð 5Ð 5Ð 5Ñ 5à.0€Ð 0Ð 0Ð 0Ñ 0ð "&Ø#'Ø!%Ø:>Ø %ØØØð<ð <ð <ð <ð <ðJ "&Ø#'Ø!%Ø:>Ø %ØØð+ð +ð +ð +ð +ðf #'Ø!%Ø!%Ø#'Ø!%Ø:>Ø %ØØð+ð +ð +ð +ð +ðf "&Ø#'Ø!%Ø:>Ø %Øð"ð ð"ð "ð "ð "ð "ð "ðT #'Ø!%Ø#'Ø!%Ø:>Ø %ØØð"ð "ð "ð "ð "ðV $(Ø!%Ø:>Ø %ØØØð(ð (ð (ð (ð (ðV3ð 3ð 3ð 3ð "Ð !Ð !Ð !Ø  Ð  Ð  Ð  Ø !Ð !Ð !Ð !Ø Ð Ð Ð Ø  Ð  Ð  Ð  Ø  Ð  Ð  Ð  Ø Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !r&   