[pypy-svn] r8517 - in pypy/dist/pypy: annotation translator

mwh at codespeak.net mwh at codespeak.net
Mon Jan 24 12:14:43 CET 2005


Author: mwh
Date: Mon Jan 24 12:14:43 2005
New Revision: 8517

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/translator/annrpython.py
Log:
move detection and discarding of 'inappropriate' *calls up a level
(from the annotator to the bookkeeper)


Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Mon Jan 24 12:14:43 2005
@@ -9,6 +9,8 @@
 from pypy.interpreter.miscutils import getthreadlocals
 from pypy.tool.hack import func_with_new_name
 from pypy.interpreter.pycode import CO_VARARGS
+from pypy.interpreter.pycode import cpython_code_signature
+from pypy.interpreter.argument import ArgErr
 
 class Bookkeeper:
     """The log of choices that have been made while analysing the operations.
@@ -234,7 +236,20 @@
             func = self.specialize_by_key(func, nbargs,
                                           name='%s__%d' % (func.func_name,
                                                            nbargs))
-        return self.annotator.recursivecall(func, self.position_key, args)
+
+        # parse the arguments according to the function we are calling
+        signature = cpython_code_signature(func.func_code)
+        defs_s = []
+        if func.func_defaults:
+            for x in func.func_defaults:
+                defs_s.append(self.immutablevalue(x))
+        try:
+            inputcells = args.match_signature(signature, defs_s)
+        except ArgErr, e:
+            print 'IGNORED', e     # hopefully temporary hack
+            return SomeImpossibleValue()
+
+        return self.annotator.recursivecall(func, self.position_key, inputcells)
 
     def specialize_by_key(self, thing, key, name=None):
         key = thing, key

Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py	(original)
+++ pypy/dist/pypy/translator/annrpython.py	Mon Jan 24 12:14:43 2005
@@ -8,8 +8,6 @@
 from pypy.objspace.flow.model import Variable, Constant, UndefinedConstant
 from pypy.objspace.flow.model import SpaceOperation, FunctionGraph
 from pypy.objspace.flow.model import last_exception, last_exc_value
-from pypy.interpreter.pycode import cpython_code_signature
-from pypy.interpreter.argument import ArgErr
 
 
 class AnnotatorError(Exception):
@@ -177,7 +175,7 @@
 
     #___ interface for annotator.factory _______
 
-    def recursivecall(self, func, position_key, args):
+    def recursivecall(self, func, position_key, inputcells):
         parent_fn, parent_block, parent_index = position_key
         graph = self.translator.getflowgraph(func, parent_fn,
                                              position_key)
@@ -187,18 +185,6 @@
         callpositions = self.notify.setdefault(graph.returnblock, {})
         callpositions[position_key] = True
 
-        # parse the arguments according to the function we are calling
-        signature = cpython_code_signature(func.func_code)
-        defs_s = []
-        if func.func_defaults:
-            for x in func.func_defaults:
-                defs_s.append(self.bookkeeper.immutablevalue(x))
-        try:
-            inputcells = args.match_signature(signature, defs_s)
-        except ArgErr, e:
-            print 'IGNORED', e     # hopefully temporary hack
-            return annmodel.SomeImpossibleValue()
-
         # generalize the function's input arguments
         self.addpendingblock(func, graph.startblock, inputcells, position_key)
 



More information about the Pypy-commit mailing list