[pypy-svn] r7480 - in pypy/trunk/src: goal pypy/interpreter pypy/translator

arigo at codespeak.net arigo at codespeak.net
Sat Nov 20 09:24:45 CET 2004


Author: arigo
Date: Sat Nov 20 09:24:44 2004
New Revision: 7480

Modified:
   pypy/trunk/src/goal/translate_pypy.py
   pypy/trunk/src/pypy/interpreter/extmodule.py
   pypy/trunk/src/pypy/translator/genc.py
Log:
Trying  'translate_pypy.py -no-a'  to generate the C code from *all*
functions without doing the annotation phase at all.


Modified: pypy/trunk/src/goal/translate_pypy.py
==============================================================================
--- pypy/trunk/src/goal/translate_pypy.py	(original)
+++ pypy/trunk/src/goal/translate_pypy.py	Sat Nov 20 09:24:44 2004
@@ -5,6 +5,7 @@
 Command-line options for translate_pypy:
 
    -text    Don't start the Pygame viewer
+   -no-a    Don't infer annotations, just translate everything
    -no-c    Don't generate the C code
    -c       Generate the C code, but don't compile it
    -o       Generate and compile the C code, but don't run it
@@ -41,8 +42,10 @@
     # caches (as far as analyzing the entry_point is concerned) 
     entry_point() 
     t = Translator(entry_point, verbose=True, simplifying=True)
-    a = t.annotate([])
-    a.simplify()
+    if not options['-no-a']:
+        a = t.annotate([])
+        a.simplify()
+        t.frozen = True   # cannot freeze if we don't have annotations
 
     if options['--mark-some-objects']:
         find_someobjects(a)
@@ -105,6 +108,7 @@
                '-c':    False,
                '-o':    False,
                '--mark-some-objects': False,
+               '-no-a': False,
                }
     for arg in sys.argv[1:]:
         if arg in ('-h', '--help'):
@@ -172,7 +176,6 @@
 
     try:
         analyse()
-        t.frozen = True
         print '-'*60
         if options['-no-c']:
             print 'Not generating C code.'

Modified: pypy/trunk/src/pypy/interpreter/extmodule.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/extmodule.py	(original)
+++ pypy/trunk/src/pypy/interpreter/extmodule.py	Sat Nov 20 09:24:44 2004
@@ -92,6 +92,13 @@
                         space.delitem(w_builtins, w_name)
         del self.__saved_hooks
 
+        # Don't keep a reference to __builtins__ in self.__dict__
+        # (it might have been put there by exec/eval/execfile)
+        try:
+            del self.__dict__['__builtins__']
+        except KeyError:
+            pass
+
     def interplevelexec(self, w_codestring):
         "'exec' a string at interp-level."
         codestring = self.space.unwrap(w_codestring)

Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py	(original)
+++ pypy/trunk/src/pypy/translator/genc.py	Sat Nov 20 09:24:44 2004
@@ -347,6 +347,8 @@
         return name
 
     def nameof_dict(self, dic):
+        assert dic is not __builtins__
+        assert '__builtins__' not in dic, 'It seems to be a globals dict'
         name = self.uniquename('g%ddict' % len(dic))
         def initdict():
             for k in dic:



More information about the Pypy-commit mailing list