[pypy-svn] r15273 - in pypy/dist/pypy: interpreter objspace/std
arigo at codespeak.net
arigo at codespeak.net
Thu Jul 28 18:38:21 CEST 2005
Author: arigo
Date: Thu Jul 28 18:38:17 2005
New Revision: 15273
Modified:
pypy/dist/pypy/interpreter/baseobjspace.py
pypy/dist/pypy/interpreter/pycompiler.py
pypy/dist/pypy/objspace/std/objspace.py
Log:
Added a 'space.default_compiler' so that when we have several
ExecutionContexts they share the same compiler by default.
This is needed right now to allow --compiler=pyparseapp to patch
the 'default_compiler' after initialization.
Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py (original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py Thu Jul 28 18:38:17 2005
@@ -226,13 +226,19 @@
def createcompiler(self):
"Factory function creating a compiler object."
# XXX simple selection logic for now
- if self.options.compiler in ('pyparse', 'pyparseapp'):
- return PythonCompiler(self)
- elif self.options.compiler == 'cpython':
- return CPythonCompiler(self)
- else:
- raise ValueError('unknown --compiler option value: %r' % (
- self.options.compiler,))
+ try:
+ return self.default_compiler
+ except AttributeError:
+ if (self.options.compiler == 'pyparse' or
+ self.options.compiler == 'pyparseapp'):
+ compiler = PythonCompiler(self)
+ elif self.options.compiler == 'cpython':
+ compiler = CPythonCompiler(self)
+ else:
+ raise ValueError('unknown --compiler option value: %r' % (
+ self.options.compiler,))
+ self.default_compiler = compiler
+ return compiler
# Following is a friendly interface to common object space operations
# that can be defined in term of more primitive ones. Subclasses
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Thu Jul 28 18:38:17 2005
@@ -274,13 +274,10 @@
w_nested_tuples,
space.wrap(source_encoding)])
- from pypy.interpreter.error import debug_print
- debug_print("app-level compiling...", newline=False)
w_code = space.call_function(self.w_applevelcompile,
w_nested_tuples,
space.wrap(filename),
space.wrap(mode))
- debug_print(" done")
return w_code
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Thu Jul 28 18:38:17 2005
@@ -108,7 +108,8 @@
# XXX hack!: patch the compiler after initialization is complete
if self.options.compiler == 'pyparseapp':
from pypy.interpreter.pycompiler import PythonCompilerApp
- self.getexecutioncontext().compiler = PythonCompilerApp(self)
+ self.default_compiler = PythonCompilerApp(self)
+ self.getexecutioncontext().compiler = self.default_compiler
def enable_old_style_classes_as_default_metaclass(self):
self.setitem(self.builtin.w_dict, self.wrap('__metaclass__'), self.w_classobj)
More information about the Pypy-commit
mailing list