[pypy-svn] r10507 - in pypy/dist/pypy: annotation translator/test

arigo at codespeak.net arigo at codespeak.net
Sun Apr 10 14:49:14 CEST 2005


Author: arigo
Date: Sun Apr 10 14:49:14 2005
New Revision: 10507

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/translator/test/test_annrpython.py
Log:
Support for prebuilt r_uint constants.


Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Sun Apr 10 14:49:14 2005
@@ -12,6 +12,7 @@
 from pypy.interpreter.pycode import CO_VARARGS
 from pypy.interpreter.pycode import cpython_code_signature
 from pypy.interpreter.argument import ArgErr
+from pypy.tool.rarithmetic import r_uint
 
 import inspect, new
 
@@ -84,6 +85,8 @@
             result = SomeBool()
         elif tp is int:
             result = SomeInteger(nonneg = x>=0)
+        elif tp is r_uint:
+            result = SomeInteger(nonneg = True, unsigned = True)
         elif tp is str:
             result = SomeString()
         elif tp is tuple:
@@ -164,6 +167,8 @@
             return SomeBool()
         elif t is int:
             return SomeInteger()
+        elif t is r_uint:
+            return SomeInteger(nonneg = True, unsigned = True)
         elif t is str:
             return SomeString()
         elif t is float:

Modified: pypy/dist/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/translator/test/test_annrpython.py	Sun Apr 10 14:49:14 2005
@@ -6,6 +6,7 @@
 from pypy.translator.annrpython import RPythonAnnotator, annmodel
 from pypy.translator.translator import Translator
 from pypy.objspace.flow.model import *
+from pypy.tool.rarithmetic import r_uint
 
 from pypy.translator.test import snippet
 
@@ -716,6 +717,13 @@
         s = a.build_types(f, [int])
         assert s.knowntype == float
 
+    def test_r_uint(self):
+        def f(n):
+            return n + constant_unsigned_five
+        a = RPythonAnnotator()
+        s = a.build_types(f, [r_uint])
+        assert s == annmodel.SomeInteger(nonneg = True, unsigned = True)
+
 
 def g(n):
     return [0,1,2,n]
@@ -728,3 +736,5 @@
         total += i
         i += 1
     return total
+
+constant_unsigned_five = r_uint(5)



More information about the Pypy-commit mailing list