[pypy-svn] r16224 - in pypy/dist/pypy: interpreter lib/_stablecompiler
tismer at codespeak.net
tismer at codespeak.net
Mon Aug 22 18:56:56 CEST 2005
Author: tismer
Date: Mon Aug 22 18:56:54 2005
New Revision: 16224
Added:
pypy/dist/pypy/lib/_stablecompiler/apphook.py (contents, props changed)
Modified:
pypy/dist/pypy/interpreter/pycompiler.py
Log:
changed pycompiler for the case of pparseapp:
always re-import the compiler from _stablecompiler.apphook
Thismake it possible to change the function
apphook.applevelcompile at any time in a compiled PyPy executable.
Reasoning: I want to use the compiled PyPy to run the regression tests,
but compiling with the applevelcompilermakes it useless, again.
Instead, we use a fake via calling a real CPython process to do this.
(coming next. First, I have to build a PyPy that has os.system)
Modified: pypy/dist/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/dist/pypy/interpreter/pycompiler.py (original)
+++ pypy/dist/pypy/interpreter/pycompiler.py Mon Aug 22 18:56:54 2005
@@ -240,28 +240,15 @@
PythonCompiler.__init__(self, space)
debug_print("importing the 'compiler' package at app-level...",
newline=False)
- self.w_applevelcompile = space.appexec([], r'''():
- from _stablecompiler.misc import set_filename
- from _stablecompiler.pycodegen import ModuleCodeGenerator
- from _stablecompiler.pycodegen import InteractiveCodeGenerator
- from _stablecompiler.pycodegen import ExpressionCodeGenerator
- from _stablecompiler.transformer import Transformer
-
- def applevelcompile(tuples, filename, mode):
- transformer = Transformer()
- tree = transformer.compile_node(tuples)
- set_filename(filename, tree)
- if mode == 'exec':
- codegenerator = ModuleCodeGenerator(tree)
- elif mode == 'single':
- codegenerator = InteractiveCodeGenerator(tree)
- else: # mode == 'eval':
- codegenerator = ExpressionCodeGenerator(tree)
- return codegenerator.getCode()
+ self._load_compiler()
+ debug_print(" done")
- return applevelcompile
+ def _load_compiler(self):
+ # doing this all the time, to allow patching
+ self.w_applevelcompile = self.space.appexec([], r'''():
+ from _stablecompiler import apphook
+ return apphook.applevelcompile
''')
- debug_print(" done")
def compile_parse_result(self, parse_result, filename, mode):
space = self.space
@@ -281,6 +268,7 @@
w_nested_tuples,
space.wrap(source_encoding)])
+ self._load_compiler()
w_code = space.call_function(self.w_applevelcompile,
w_nested_tuples,
space.wrap(filename),
Added: pypy/dist/pypy/lib/_stablecompiler/apphook.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lib/_stablecompiler/apphook.py Mon Aug 22 18:56:54 2005
@@ -0,0 +1,24 @@
+#
+# overridable part of applevel compiler
+# function applevelcompile can be patched at runtime
+#
+
+from _stablecompiler.misc import set_filename
+from _stablecompiler.pycodegen import ModuleCodeGenerator
+from _stablecompiler.pycodegen import InteractiveCodeGenerator
+from _stablecompiler.pycodegen import ExpressionCodeGenerator
+from _stablecompiler.transformer import Transformer
+
+def applevelcompile(tuples, filename, mode):
+ transformer = Transformer()
+ tree = transformer.compile_node(tuples)
+ set_filename(filename, tree)
+ if mode == 'exec':
+ codegenerator = ModuleCodeGenerator(tree)
+ elif mode == 'single':
+ codegenerator = InteractiveCodeGenerator(tree)
+ else: # mode == 'eval':
+ codegenerator = ExpressionCodeGenerator(tree)
+ return codegenerator.getCode()
+
+return applevelcompile
More information about the Pypy-commit
mailing list