[pypy-svn] r23604 - pypy/dist/pypy/translator

pedronis at codespeak.net pedronis at codespeak.net
Wed Feb 22 23:23:45 CET 2006


Author: pedronis
Date: Wed Feb 22 23:23:41 2006
New Revision: 23604

Modified:
   pypy/dist/pypy/translator/translator.py
Log:
translator.Translator is not used anymore and was not fixed.




Modified: pypy/dist/pypy/translator/translator.py
==============================================================================
--- pypy/dist/pypy/translator/translator.py	(original)
+++ pypy/dist/pypy/translator/translator.py	Wed Feb 22 23:23:41 2006
@@ -128,228 +128,3 @@
             result.append(graph)
     assert len(result) == 1
     return result[0]
-
-# _______________________________________________________________
-
-class Translator(TranslationContext):
-
-    def __init__(self, func, **flowing_flags):
-        super(Translator, self).__init__(**flowing_flags)
-        self.entrypoint = func
-
-    def __getstate__(self):
-        # try to produce things a bit more ordered
-        XXX
-        return self.entrypoint, self.functions, self.__dict__
-
-    def __setstate__(self, args):
-        XXX
-        assert len(args) == 3
-        self.__dict__.update(args[2])
-        assert args[0] is self.entrypoint and args[1] is self.functions
-
-    def gv(self):
-        """Shows the control flow graph -- requires 'dot' and 'gv'."""
-        import os
-        from pypy.translator.tool.make_dot import make_dot, make_dot_graphs
-        graphs = []
-        for graph in self.graphs:
-            graphs.append((graph.name, graph))
-        dest = make_dot_graphs(self.entrypoint.__name__, graphs)
-        os.system('gv %s' % str(dest))
-
-    def simplify(self, passes=True):
-        """Simplifies all the control flow graphs."""
-        for graph in self.graphs:
-            simplify_graph(graph, passes)
-            
-    def annotate(self, input_args_types, policy=None):
-        """annotate(self, input_arg_types) -> Annotator
-
-        Provides type information of arguments. Returns annotator.
-        """
-        annotator = self.buildannotator(policy)
-        annotator.build_types(self.entrypoint, input_args_types)
-        return annotator
-
-    def specialize(self, **flags):
-        rtyper = self.buildrtyper(
-            type_system=flags.pop("type_system", "lltype"))
-        rtyper.specialize(**flags)
-
-    def backend_optimizations(self, **kwds):
-        from pypy.translator.backendopt.all import backend_optimizations
-        backend_optimizations(self, **kwds)
-
-    def source(self):
-        """Returns original Python source.
-        
-        Returns <interactive> for functions written during the
-        interactive session.
-        """
-        FIX_ME
-        return self.entrypointgraph.source
-
-    def pyrex(self, input_arg_types=None, func=None):
-        """pyrex(self[, input_arg_types][, func]) -> Pyrex translation
-
-        Returns Pyrex translation. If input_arg_types is provided,
-        returns type annotated translation. Subsequent calls are
-        not affected by this.
-        """
-        FIX_ME
-        from pypy.translator.pyrex.genpyrex import GenPyrex
-        return self.generatecode(GenPyrex, input_arg_types, func)
-
-    def cl(self, input_arg_types=None, func=None):
-        """cl(self[, input_arg_types][, func]) -> Common Lisp translation
-        
-        Returns Common Lisp translation. If input_arg_types is provided,
-        returns type annotated translation. Subsequent calls are
-        not affected by this.
-        """
-        FIX_ME
-        from pypy.translator.gencl import GenCL
-        return self.generatecode(GenCL, input_arg_types, func)
-
-    def c(self):
-        """c(self) -> C (CPython) translation
-        
-        Returns C (CPython) translation.
-        """
-        FIX_ME
-        from pypy.translator.c import genc
-        from cStringIO import StringIO
-        f = StringIO()
-        database, ignored = genc.translator2database(self)
-        genc.gen_readable_parts_of_main_c_file(f, database)
-        return f.getvalue()
-
-    def llvm(self):
-        """llvm(self) -> LLVM translation
-        
-        Returns LLVM translation.
-        """
-        FIX_ME
-        from pypy.translator.llvm.genllvm import GenLLVM
-        if self.annotator is None:
-            raise ValueError, "function has to be annotated."
-        gen = GenLLVM(self)
-        filename = gen.gen_llvm_source()
-        f = open(str(filename), "r")
-        result = f.read()
-        f.close()
-        return result
-    
-    def generatecode(self, gencls, input_arg_types, func):
-        if input_arg_types is None:
-            ann = self.annotator
-        else:
-            from pypy.annotation.annrpython import RPythonAnnotator
-            ann = RPythonAnnotator(self)
-        if func is None:
-            codes = [self.generatecode1(gencls, input_arg_types,
-                                        self.entrypoint, ann)]
-            for func in self.functions:
-                if func is not self.entrypoint:
-                    code = self.generatecode1(gencls, None, func, ann,
-                                              public=False)
-                    codes.append(code)
-        else:
-            codes = [self.generatecode1(gencls, input_arg_types, func, ann)]
-        code = self.generateglobaldecl(gencls, func, ann)
-        if code:
-            codes.insert(0, code)
-        return '\n\n#_________________\n\n'.join(codes)
-
-    def generatecode1(self, gencls, input_arg_types, func, ann, public=True):
-        graph = self.getflowgraph(func)
-        g = gencls(graph)
-        g.by_the_way_the_function_was = func   # XXX
-        if input_arg_types is not None:
-            ann.build_types(graph, input_arg_types, func)
-        if ann is not None:
-            g.setannotator(ann)
-        return g.emitcode(public)
-
-    def generateglobaldecl(self, gencls, func, ann):
-        graph = self.getflowgraph(func)
-        g = gencls(graph)
-        if ann is not None:
-            g.setannotator(ann)
-        return g.globaldeclarations()
-
-    def pyrexcompile(self):
-        """Returns compiled function, compiled using Pyrex.
-        """
-        FIX_ME
-        from pypy.translator.tool.cbuild import make_module_from_pyxstring
-        from pypy.tool.udir import udir
-        name = self.entrypoint.func_name
-        pyxcode = self.pyrex()
-        mod = make_module_from_pyxstring(name, udir, pyxcode)
-        return getattr(mod, name)
-
-    def compile(self, compiler='c', **kw):
-        compiler += 'compile'
-        if hasattr(self, compiler):
-            compiler = getattr(self,compiler)
-            return compiler(**kw)
-        else:
-            raise NotImplementedError, "Compiler not known", compiler
-    
-    def ccompile(self, really_compile=True, standalone=False, gcpolicy=None):
-        """Returns compiled function (living in a new C-extension module), 
-           compiled using the C generator.
-        """
-        FIX_ME
-        cbuilder = self.cbuilder(standalone=standalone, gcpolicy=gcpolicy)
-        c_source_filename = cbuilder.generate_source()
-        if not really_compile: 
-            return c_source_filename
-        cbuilder.compile()
-        if standalone:
-            return cbuilder.executable_name
-        cbuilder.import_module()    
-        return cbuilder.get_entry_point()
-
-    def cbuilder(self, standalone=False, gcpolicy=None, thread_enabled=False):
-        FIX_ME
-        from pypy.translator.c import genc
-        if standalone:
-            return genc.CStandaloneBuilder(self, gcpolicy=gcpolicy, thread_enabled=thread_enabled)
-        else:
-            return genc.CExtModuleBuilder(self, gcpolicy=gcpolicy, thread_enabled=thread_enabled)
-
-    def llvmcompile(self, really_compile=True, standalone=False, optimize=True, exe_name=None, gcpolicy=None):
-        """llvmcompile(self, really_compile=True, standalone=False, optimize=True) -> LLVM translation
-        
-        Returns LLVM translation with or without optimization.
-        """
-        FIX_ME
-        from pypy.translator.llvm import genllvm
-        if self.annotator is None:
-            raise ValueError, "function has to be annotated."
-        if standalone:
-            if not exe_name:
-                exe_name = self.entrypoint.__name__
-        else:
-            exe_name = None
-        return genllvm.genllvm(self, really_compile=really_compile, standalone=standalone, optimize=optimize, exe_name=exe_name, gcpolicy=gcpolicy)
-
-    def asmcompile(self, processor='virt'):
-        FIX_ME
-        from pypy.translator.asm import genasm
-        assert processor in ['ppc', 'virt', 'virtfinite']
-        assert self.rtyper is not None, 'must specialize'
-        graph = graphof(self, self.entrypoint)
-        return genasm.genasm(graph, processor)
-
-    def call(self, *args):
-        """Calls underlying Python function."""
-        return self.entrypoint(*args)
-
-    def dis(self):
-        """Disassembles underlying Python function to bytecodes."""
-        from dis import dis
-        dis(self.entrypoint)



More information about the Pypy-commit mailing list