コード例 #1
0
ファイル: transforms.py プロジェクト: lizecillie/numba
    def _get_int_conversion_func(self, type, funcs_dict):
        type = promote_to_native(type)
        if type.itemsize <= long_.itemsize:
            types = [ulong, long_]
        else:
            assert type.itemsize > long_.itemsize
            types = [ulonglong, longlong]

        return funcs_dict[types[type.signed]]
コード例 #2
0
    def _get_int_conversion_func(self, type, funcs_dict):
        type = promote_to_native(type)
        if type.itemsize <= long_.itemsize:
            types = [ulong, long_]
        else:
            assert type.itemsize > long_.itemsize
            types = [ulonglong, longlong]

        return funcs_dict[types[type.signed]]
コード例 #3
0
ファイル: transforms.py プロジェクト: FrancescAlted/numba
    def object_to_int(self, node, dst_type):
        """
        Return node that converts the given node to the dst_type.
        This also performs overflow/underflow checking, and conversion to
        a Python int or long if necessary.

        PyLong_AsLong and friends do not do this (overflow/underflow checking
        is only for longs, and conversion to int|long depends on the Python
        version).
        """
        dst_type = promote_to_native(dst_type)
        assert dst_type in utility.object_to_numeric, (dst_type, utility.object_to_numeric)
        utility_func = utility.object_to_numeric[dst_type]
        result = function_util.external_call_func(self.context,
                                                  self.llvm_module,
                                                  utility_func,
                                                  args=[node])
        return result
コード例 #4
0
    def object_to_int(self, node, dst_type):
        """
        Return node that converts the given node to the dst_type.
        This also performs overflow/underflow checking, and conversion to
        a Python int or long if necessary.

        PyLong_AsLong and friends do not do this (overflow/underflow checking
        is only for longs, and conversion to int|long depends on the Python
        version).
        """
        dst_type = promote_to_native(dst_type)
        assert dst_type in utility.object_to_numeric
        utility_func = utility.object_to_numeric[dst_type]
        result = function_util.external_call_func(self.context,
                                                  self.llvm_module,
                                                  utility_func,
                                                  args=[node])
        return result
コード例 #5
0
ファイル: coerce.py プロジェクト: jgors/numba
    def lstr(self, types, fmt=None):
        "Get an llvm format string for the given types"
        typestrs = []
        result_types = []
        for type in types:
            if is_obj(type):
                type = object_
            elif type.is_int:
                type = promote_to_native(type)

            result_types.append(type)
            typestrs.append(self.type_to_buildvalue_str[type])

        str = "".join(typestrs)
        if fmt is not None:
            str = fmt % str

        if debug.debug_conversion:
            self.translator.puts("fmt: %s" % str)

        result = self._create_llvm_string(str)
        return result_types, result
コード例 #6
0
ファイル: coerce.py プロジェクト: lizecillie/numba
    def lstr(self, types, fmt=None):
        "Get an llvm format string for the given types"
        typestrs = []
        result_types = []
        for type in types:
            if is_obj(type):
                type = object_
            elif type.is_int:
                type = promote_to_native(type)

            result_types.append(type)
            typestrs.append(self.type_to_buildvalue_str[type])

        str = "".join(typestrs)
        if fmt is not None:
            str = fmt % str

        if debug_conversion:
            self.translator.puts("fmt: %s" % str)

        result = self._create_llvm_string(str)
        return result_types, result