[pypy-svn] r73028 - in pypy/branch/cpython-extension/pypy/annotation: . test

xoraxax at codespeak.net xoraxax at codespeak.net
Sun Mar 28 17:20:55 CEST 2010


Author: xoraxax
Date: Sun Mar 28 17:20:54 2010
New Revision: 73028

Modified:
   pypy/branch/cpython-extension/pypy/annotation/annrpython.py
   pypy/branch/cpython-extension/pypy/annotation/test/test_annrpython.py
Log:
Update build_types to use better code that can also handle varargs.

Modified: pypy/branch/cpython-extension/pypy/annotation/annrpython.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/annotation/annrpython.py	(original)
+++ pypy/branch/cpython-extension/pypy/annotation/annrpython.py	Sun Mar 28 17:20:54 2010
@@ -86,12 +86,12 @@
         """Recursively build annotations about the specific entry point."""
         assert isinstance(function, FunctionType), "fix that!"
 
+        from pypy.annotation.policy import AnnotatorPolicy
+        policy = AnnotatorPolicy()
         # make input arguments and set their type
-        inputcells = [self.typeannotation(t) for t in input_arg_types]
+        args_s = [self.typeannotation(t) for t in input_arg_types]
 
-        desc = self.bookkeeper.getdesc(function)
-        desc.getcallfamily()   # record this implicit call (hint for back-ends)
-        flowgraph = desc.specialize(inputcells)
+        flowgraph, inputcells = self.get_call_parameters(function, args_s, policy)
         if not isinstance(flowgraph, FunctionGraph):
             assert isinstance(flowgraph, annmodel.SomeObject)
             return flowgraph

Modified: pypy/branch/cpython-extension/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/cpython-extension/pypy/annotation/test/test_annrpython.py	Sun Mar 28 17:20:54 2010
@@ -3164,6 +3164,13 @@
         assert isinstance(s, annmodel.SomeList)
         assert s.listdef.listitem.resized
 
+    def test_varargs(self):
+        def f(*args):
+            return args[0] + 42
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [int, int])
+        assert isinstance(s, annmodel.SomeInteger)
+
     def test_listitem_no_mutating(self):
         from pypy.rlib.debug import check_annotation
         called = []



More information about the Pypy-commit mailing list