[pypy-svn] r35324 - in pypy/branch/jit-real-world/pypy/rpython: . ootypesystem test

arigo at codespeak.net arigo at codespeak.net
Tue Dec 5 19:20:24 CET 2006


Author: arigo
Date: Tue Dec  5 19:20:22 2006
New Revision: 35324

Modified:
   pypy/branch/jit-real-world/pypy/rpython/ootypesystem/rstr.py
   pypy/branch/jit-real-world/pypy/rpython/rmodel.py
   pypy/branch/jit-real-world/pypy/rpython/rtyper.py
   pypy/branch/jit-real-world/pypy/rpython/test/test_rlist.py
   pypy/branch/jit-real-world/pypy/rpython/test/test_rstr.py
Log:
svn merge -r35317:35323 http://codespeak.net/svn/pypy/dist/pypy/rpython


Modified: pypy/branch/jit-real-world/pypy/rpython/ootypesystem/rstr.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/ootypesystem/rstr.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/ootypesystem/rstr.py	Tue Dec  5 19:20:22 2006
@@ -241,9 +241,8 @@
                 vitem, r_arg = argsiter.next()
                 if not hasattr(r_arg, 'll_str'):
                     raise TyperError("ll_str unsupported for: %r" % r_arg)
-                if code == 's':
-                    # TODO: for now it works only with types supported by oostring
-                    vchunk = hop.genop('oostring', [vitem, cm1], resulttype=ootype.String)
+                if code == 's' or (code == 'r' and isinstance(r_arg, InstanceRepr)):
+                    vchunk = hop.gendirectcall(r_arg.ll_str, vitem)
                 elif code == 'd':
                     assert isinstance(r_arg, IntegerRepr)
                     vchunk = hop.genop('oostring', [vitem, c10], resulttype=ootype.String)
@@ -256,8 +255,6 @@
                 elif code == 'o':
                     assert isinstance(r_arg, IntegerRepr)
                     vchunk = hop.genop('oostring', [vitem, c8], resulttype=ootype.String)
-                elif code == 'r' and isinstance(r_arg, InstanceRepr):
-                    vchunk = hop.gendirectcall(r_arg.ll_str, vitem)
                 else:
                     raise TyperError, "%%%s is not RPython" % (code, )
             else:

Modified: pypy/branch/jit-real-world/pypy/rpython/rmodel.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/rmodel.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/rmodel.py	Tue Dec  5 19:20:22 2006
@@ -353,6 +353,7 @@
     def get_ll_eq_function(self): return None
     def get_ll_hash_function(self): return ll_hash_void
     get_ll_fasthash_function = get_ll_hash_function
+    def ll_str(self, nothing): raise AssertionError("unreachable code")
 impossible_repr = VoidRepr()
 
 class SimplePointerRepr(Repr):

Modified: pypy/branch/jit-real-world/pypy/rpython/rtyper.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/rtyper.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/rtyper.py	Tue Dec  5 19:20:22 2006
@@ -849,7 +849,7 @@
         newargs_v = []
         for v in args_v:
             if v.concretetype is Void:
-                s_value = rtyper.binding(v)
+                s_value = rtyper.binding(v, default=annmodel.s_None)
                 if not s_value.is_constant():
                     raise TyperError("non-constant variable of type Void")
                 if not isinstance(s_value, annmodel.SomePBC):

Modified: pypy/branch/jit-real-world/pypy/rpython/test/test_rlist.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/test/test_rlist.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/test/test_rlist.py	Tue Dec  5 19:20:22 2006
@@ -735,6 +735,12 @@
         res = self.interpret(fn, [])
         assert self.ll_to_string(res) == fn()
 
+        def fn():
+            return str([])
+
+        res = self.interpret(fn, [])
+        assert self.ll_to_string(res) == fn()
+
     def test_list_or_None(self):
         empty_list = []
         nonempty_list = [1, 2]

Modified: pypy/branch/jit-real-world/pypy/rpython/test/test_rstr.py
==============================================================================
--- pypy/branch/jit-real-world/pypy/rpython/test/test_rstr.py	(original)
+++ pypy/branch/jit-real-world/pypy/rpython/test/test_rstr.py	Tue Dec  5 19:20:22 2006
@@ -472,6 +472,32 @@
         res = res.replace('pypy.rpython.test.test_rstr.', '')        
         assert res == 'what a nice <D object>, much nicer than <C object>'
 
+    def test_percentformat_tuple(self):
+        for t, expected in [((),        "<<<()>>>"),
+                            ((5,),      "<<<(5,)>>>"),
+                            ((5, 6),    "<<<(5, 6)>>>"),
+                            ((5, 6, 7), "<<<(5, 6, 7)>>>")]:
+            def getter():
+                return t
+            def dummy():
+                return "<<<%s>>>" % (getter(),)
+
+            res = self.ll_to_string(self.interpret(dummy, []))
+            assert res == expected
+
+    def test_percentformat_list(self):
+        for t, expected in [([],        "<<<[]>>>"),
+                            ([5],       "<<<[5]>>>"),
+                            ([5, 6],    "<<<[5, 6]>>>"),
+                            ([5, 6, 7], "<<<[5, 6, 7]>>>")]:
+            def getter():
+                return t
+            def dummy():
+                return "<<<%s>>>" % (getter(),)
+
+            res = self.ll_to_string(self.interpret(dummy, []))
+            assert res == expected
+
     def test_split(self):
         def fn(i):
             s = ['', '0.1.2.4.8', '.1.2', '1.2.', '.1.2.4.'][i]



More information about the Pypy-commit mailing list