Esempio n. 1
0
def _compile(context, func, ret_type=None, arg_types=None, **kwds):
    """
    Compile a numba annotated function.

        - decompile function into a Python ast
        - run type inference using the given input types
        - compile the function to LLVM
    """
    ast = _get_ast(func)
    func_signature = minitypes.FunctionType(return_type=ret_type,
                                            args=arg_types)
    func_signature, symtab, ast = type_inference._infer_types(
        context, func, ast, func_signature)

    func_name = naming.specialized_mangle(func.__name__, func_signature.args)

    t = translate.LLVMCodeGenerator(context,
                                    func,
                                    ast,
                                    func_signature=func_signature,
                                    func_name=func_name,
                                    symtab=symtab,
                                    **kwds)
    t.translate()

    return func_signature, t.lfunc, t.get_ctypes_func(kwds.get('llvm', True))
Esempio n. 2
0
def infer(func, arg_types):
    sig = minitypes.FunctionType(return_type=None, args=arg_types)
    ast = functions._get_ast(func)

    sig, symtab, ast = ast_type_inference._infer_types(
                                decorators.context, func, ast, sig)
    return sig, symtab
Esempio n. 3
0
def infer(func, arg_types):
    sig = minitypes.FunctionType(return_type=None, args=arg_types)
    ast = functions._get_ast(func)

    sig, symtab, ast = ast_type_inference._infer_types(decorators.context,
                                                       func, ast, sig)
    return sig, symtab
Esempio n. 4
0
def _compile(context, func, ret_type=None, arg_types=None, **kwds):
    """
    Compile a numba annotated function.

        - decompile function into a Python ast
        - run type inference using the given input types
        - compile the function to LLVM
    """
    ast = _get_ast(func)
    func_signature = minitypes.FunctionType(return_type=ret_type,
                                            args=arg_types)
    func_signature, symtab, ast = type_inference._infer_types(
                            context, func, ast, func_signature)

    func_name = naming.specialized_mangle(func.__name__, func_signature.args)

    t = translate.LLVMCodeGenerator(
        context, func, ast, func_signature=func_signature,
        func_name=func_name, symtab=symtab, **kwds)
    t.translate()

    return func_signature, t.lfunc, t.get_ctypes_func(kwds.get('llvm', True))
Esempio n. 5
0
def _infer_types(context, func, ret_type=None, arg_types=None):
    ast = _get_ast(func)
    func_signature = minitypes.FunctionType(return_type=ret_type,
                                            args=arg_types)
    return type_inference._infer_types(context, func, ast, func_signature)