Ejemplo n.º 1
0
def create_extension(env, py_class, flags):
    """
    Compile an extension class given the NumbaEnvironment and the Python
    class that contains the functions that are to be compiled.
    """
    flags.pop('llvm_module', None)

    # ext_type = etypes.jit_exttype(py_class)
    ext_type = typesystem.jit_exttype(py_class)

    extension_compiler = JitExtensionCompiler(
        env, py_class, dict(vars(py_class)), ext_type, flags,
        signatures.JitMethodMaker(),
        compileclass.AttributesInheriter(),
        compileclass.Filterer(),
        JitAttributeBuilder(),
        virtual.StaticVTabBuilder(),
        compileclass.MethodWrapperBuilder())

    extension_compiler.init()
    extension_compiler.infer()
    extension_compiler.finalize_tables()
    extension_compiler.validate()
    extension_type = extension_compiler.compile()

    return extension_type
Ejemplo n.º 2
0
def create_extension(env, py_class, flags, argtypes):
    """
    Create a partial environment to compile specialized versions of the
    extension class in.

    Inovked when calling the wrapped class to compile a specialized
    new extension type.
    """
    # TODO: Remove argtypes! Partial environment!

    flags.pop('llvm_module', None)

    ext_type = etypes.autojit_exttype(py_class)

    class_dict = dict(utils.get_class_dict(py_class))

    extension_compiler = AutojitExtensionCompiler(
        env, py_class, class_dict, ext_type, flags,
        signatures.AutojitMethodMaker(argtypes),
        compileclass.AttributesInheriter(), AutojitMethodFilter(),
        AutojitAttributeBuilder(), virtual.HashBasedVTabBuilder(),
        AutojitMethodWrapperBuilder())

    extension_compiler.init()
    # return extension_compiler

    # def compile_class(extension_compiler, argtypes):
    extension_compiler.infer()
    extension_compiler.finalize_tables()
    extension_compiler.validate()
    extension_type = extension_compiler.compile()

    return extension_type