Exemplo n.º 1
0
def get_member_value(builder, data, idx):
    if get_version('numba') >= (0, 54):
        assert data.opname == 'insertvalue', data.opname
        return builder.extract_value(data, [idx])
    else:
        assert data.opname == 'load', data.opname
        struct = data.operands[0]
        return builder.load(builder.gep(struct, [int32_t(0), int32_t(idx)]))
Exemplo n.º 2
0
"""Implement Omnisci Array type support
"""

__all__ = ['ArrayPointer', 'Array', 'OmnisciArrayType']

from rbc import typesystem
from rbc.utils import get_version
from .omnisci_buffer import (BufferPointer, Buffer, OmnisciBufferType,
                             omnisci_buffer_constructor)

if get_version('numba') >= (0, 49):
    from numba.core import extending, types
else:
    from numba import extending, types


class OmnisciArrayType(OmnisciBufferType):
    """Omnisci Array type for RBC typesystem.

    :code:`Omnisci Array<T>` is defined as follows (using C++ syntax)::

      template<typename T>
      struct Array {
        T* ptr;
        size_t sz;
        bool is_null;
      }
    """
    @property
    def buffer_extra_members(self):
        return ('bool is_null', )
Exemplo n.º 3
0
def nb_version():
    from rbc.utils import get_version
    return get_version('numba')
Exemplo n.º 4
0
def get_or_insert_function(module, fnty, name=None):
    if get_version('numba') >= (0, 54):
        fn = cgutils.get_or_insert_function(module, fnty, name=name)
    else:
        fn = module.get_or_insert_function(fnty, name=name)
    return fn
Exemplo n.º 5
0
    """
    Raised when the user defines a function with name
    in a blacklist. For more info, see:
    https://github.com/xnd-project/rbc/issues/32
    """
    pass


class ForbiddenIntrinsicError(Exception):
    """
    Raised when the user uses an intrinsic with name
    in a blacklist. For more info, see:
    https://github.com/xnd-project/rbc/issues/207
    """
    pass


if get_version('numba') < (0, 55):

    class NumbaTypeError(TypingError):
        pass

    class NumbaNotImplementedError(TypingError):
        pass

    class RequireLiteralValue(TypingError):
        pass
else:
    from numba.core.errors import NumbaTypeError, NumbaNotImplementedError, \
                                  RequireLiteralValue  # noqa: F401