[pypy-svn] r20456 - pypy/branch/somepbc-refactoring/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Wed Nov 30 21:26:17 CET 2005


Author: arigo
Date: Wed Nov 30 21:26:17 2005
New Revision: 20456

Modified:
   pypy/branch/somepbc-refactoring/pypy/interpreter/pycompiler.py
Log:
Minor reorganization of our AbstractCompiler subclasses.


Modified: pypy/branch/somepbc-refactoring/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/interpreter/pycompiler.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/interpreter/pycompiler.py	Wed Nov 30 21:26:17 2005
@@ -97,7 +97,18 @@
     return flag_names
 
 
-class CPythonCompiler(AbstractCompiler):
+class PyCodeCompiler(AbstractCompiler):
+    """Base class for compilers producing PyCode objects."""
+
+    def getcodeflags(self, code):
+        from pypy.interpreter.pycode import PyCode
+        if isinstance(code, PyCode):
+            return code.co_flags & compiler_flags
+        else:
+            return 0
+
+
+class CPythonCompiler(PyCodeCompiler):
     """Faked implementation of a compiler, using the underlying compile()."""
 
     def compile(self, source, filename, mode, flags):
@@ -133,13 +144,6 @@
         return PyCode(space)._from_code(c)
     compile._annspecialcase_ = "override:cpy_compile"
 
-    def getcodeflags(self, code):
-        from pypy.interpreter.pycode import PyCode
-        if isinstance(code, PyCode):
-            return code.co_flags & compiler_flags
-        else:
-            return 0
-
     def _warn_explicit(self, message, category, filename, lineno,
                        module=None, registry=None):
         if hasattr(category, '__bases__') and \
@@ -185,7 +189,7 @@
 
 
 ########
-class PythonAstCompiler(CPythonCompiler):
+class PythonAstCompiler(PyCodeCompiler):
     """Uses the stdlib's python implementation of compiler
 
     XXX: This class should override the baseclass implementation of



More information about the Pypy-commit mailing list