Ejemplo n.º 1
0
 def test_patch_os(self):
     import os
     from pypy.translator.oosupport.support import patch_os, unpatch_os, NT_OS
     original_O_CREAT = os.O_CREAT
     olddefs = patch_os()
     assert os.O_CREAT == NT_OS['O_CREAT']
     unpatch_os(olddefs)
     assert os.O_CREAT == original_O_CREAT
Ejemplo n.º 2
0
def compile_function(func, annotation=[], graph=None, backendopt=True,
                     auto_raise_exc=False, exctrans=False,
                     annotatorpolicy=None, nowrap=False):
    olddefs = patch_os()
    gen = _build_gen(func, annotation, graph, backendopt, exctrans, annotatorpolicy, nowrap)
    gen.generate_source()
    exe_name = gen.build_exe()
    unpatch_os(olddefs) # restore original values
    return CliFunctionWrapper(exe_name, func.__name__, auto_raise_exc)
Ejemplo n.º 3
0
def compile_function(func, annotation=[], graph=None, backendopt=True,
                     auto_raise_exc=False, exctrans=False,
                     annotatorpolicy=None, nowrap=False):
    olddefs = patch_os()
    gen = _build_gen(func, annotation, graph, backendopt, exctrans, annotatorpolicy, nowrap)
    gen.generate_source()
    exe_name = gen.build_exe()
    unpatch_os(olddefs) # restore original values
    return CliFunctionWrapper(exe_name, func.__name__, auto_raise_exc)
Ejemplo n.º 4
0
 def task_compile_jvm(self):
     from pypy.translator.oosupport.support import unpatch_os
     from pypy.translator.jvm.test.runtest import JvmGeneratedSourceWrapper
     self.jvmsource.compile()
     self.c_entryp = JvmGeneratedSourceWrapper(self.jvmsource)
     # restore original os values
     if hasattr(self, 'old_cli_defs'):
         unpatch_os(self.old_cli_defs)
     self.log.info("Compiled JVM source")
     if self.standalone and self.exe_name:
         self.copy_jvm_jar()
Ejemplo n.º 5
0
 def task_compile_jvm(self):
     from pypy.translator.oosupport.support import unpatch_os
     from pypy.translator.jvm.test.runtest import JvmGeneratedSourceWrapper
     self.jvmsource.compile()
     self.c_entryp = JvmGeneratedSourceWrapper(self.jvmsource)
     # restore original os values
     if hasattr(self, 'old_cli_defs'):
         unpatch_os(self.old_cli_defs)
     self.log.info("Compiled JVM source")
     if self.standalone and self.exe_name:
         self.copy_jvm_jar()
Ejemplo n.º 6
0
 def task_compile_cli(self):
     from pypy.translator.oosupport.support import unpatch_os
     from pypy.translator.cli.test.runtest import CliFunctionWrapper
     filename = self.gen.build_exe()
     self.c_entryp = CliFunctionWrapper(filename)
     # restore original os values
     if hasattr(self, 'old_cli_defs'):
         unpatch_os(self.old_cli_defs)
     
     self.log.info("Compiled %s" % filename)
     if self.standalone and self.exe_name:
         self.copy_cli_exe()
Ejemplo n.º 7
0
 def task_compile_cli(self):
     from pypy.translator.oosupport.support import unpatch_os
     from pypy.translator.cli.test.runtest import CliFunctionWrapper
     filename = self.gen.build_exe()
     self.c_entryp = CliFunctionWrapper(filename)
     # restore original os values
     if hasattr(self, 'old_cli_defs'):
         unpatch_os(self.old_cli_defs)
     
     self.log.info("Compiled %s" % filename)
     if self.standalone and self.exe_name:
         self.copy_cli_exe()
Ejemplo n.º 8
0
 def compile(self, fn, args, ann=None, backendopt=False):
     if ann is None:
         ann = [lltype_to_annotation(typeOf(x)) for x in args]
     if self._func is fn and self._ann == ann:
         return JvmGeneratedSourceWrapper(self._jvm_src)
     else:
         self._func = fn
         self._ann = ann
         olddefs = patch_os()
         self._jvm_src = generate_source_for_function(fn, ann, backendopt)
         unpatch_os(olddefs)
         if not getoption('noasm'):
             self._jvm_src.compile()
         return JvmGeneratedSourceWrapper(self._jvm_src)
Ejemplo n.º 9
0
 def compile(self, fn, args, ann=None, backendopt=False):
     if ann is None:
         ann = [lltype_to_annotation(typeOf(x)) for x in args]
     if self._func is fn and self._ann == ann:
         return JvmGeneratedSourceWrapper(self._jvm_src)
     else:
         self._func = fn
         self._ann = ann
         olddefs = patch_os()
         self._jvm_src = generate_source_for_function(fn, ann, backendopt)
         unpatch_os(olddefs)
         if not getoption('noasm'):
             self._jvm_src.compile()
         return JvmGeneratedSourceWrapper(self._jvm_src)
Ejemplo n.º 10
0
    def post_translation_hook(self):
        from pypy.translator.oosupport.support import unpatch_os

        unpatch_os(self.olddefs)  # restore original values
Ejemplo n.º 11
0
 def post_translation_hook(self):
     from pypy.translator.oosupport.support import unpatch_os
     unpatch_os(self.olddefs)  # restore original values