Example #1
0
 def run_pipeline(self, func):
     func_sig = minitypes.FunctionType(minitypes.void, [])
     source = inspect.getsource(func)
     astree = ast.parse(source)
     with environment.TranslationContext(self.env, func, astree, func_sig):
         pipeline_callable = self.env.get_or_add_pipeline(
             'const_folding', pipeline.ConstFolding)
         astree = pipeline.AST3to2()(astree, self.env)
         ret_val = pipeline_callable(astree, self.env)
     return ret_val
Example #2
0
 def _iexport(func):
     if backend == 'bytecode':
         raise NotImplementedError(
             'Bytecode translation has been removed for exported functions.'
         )
     else:
         name = function_signature.name
         llvm_module = _lc.Module.new('export_%s' % name)
         if not hasattr(func, 'live_objects'):
             func.live_objects = []
         func._is_numba_func = True
         func_ast = functions._get_ast(func)
         # FIXME: Hacked "mangled_name" into the translation
         # environment.  Should do something else.  See comment in
         # codegen.translate.LLVMCodeGenerator.__init__().
         with environment.TranslationContext(env,
                                             func,
                                             func_ast,
                                             function_signature,
                                             name=name,
                                             llvm_module=llvm_module,
                                             mangled_name=name,
                                             link=False,
                                             wrap=False,
                                             is_pycc=True) as func_env:
             pipeline = env.get_pipeline()
             func_ast.pipeline = pipeline
             pipeline(func_ast, env)
             exports_env = env.exports
             exports_env.function_signature_map[name] = function_signature
             exports_env.function_module_map[name] = llvm_module
             if not exports_env.wrap_exports:
                 exports_env.function_wrapper_map[name] = None
             else:
                 wrapper_tup = llvmwrapper.build_wrapper_module(env)
                 exports_env.function_wrapper_map[name] = wrapper_tup
     return func