[pypy-svn] r33810 - in pypy/dist/pypy/rpython/ootypesystem: . test

antocuni at codespeak.net antocuni at codespeak.net
Fri Oct 27 14:24:34 CEST 2006


Author: antocuni
Date: Fri Oct 27 14:24:33 2006
New Revision: 33810

Modified:
   pypy/dist/pypy/rpython/ootypesystem/ootype.py
   pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py
Log:
Make the annotation <--> ootype mapping for overloading not so smart
by default. Each backend should define its own mapping.



Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py	Fri Oct 27 14:24:33 2006
@@ -898,7 +898,6 @@
         METH = self.resolve(ARGS)._TYPE
         return self.lltype_to_annotation(METH.RESULT)
 
-
     def resolve(self, ARGS):
         # this overloading resolution algorithm is quite simple:
         # 1) if there is an exact match between ARGS and meth.ARGS, return meth
@@ -935,22 +934,12 @@
     
     def annotation_to_lltype(cls, ann):
         from pypy.annotation import model as annmodel
-        if isinstance(ann, annmodel.SomeChar):
-            return Char
-        elif isinstance(ann, annmodel.SomeString):
-            return String
-        else:
-            return annmodel.annotation_to_lltype(ann)
+        return annmodel.annotation_to_lltype(ann)
     annotation_to_lltype = classmethod(annotation_to_lltype)
 
     def lltype_to_annotation(cls, TYPE):
         from pypy.annotation import model as annmodel
-        if TYPE is Char:
-            return annmodel.SomeChar()
-        elif TYPE is String:
-            return annmodel.SomeString()
-        else:
-            return annmodel.lltype_to_annotation(TYPE)
+        return annmodel.lltype_to_annotation(TYPE)
     lltype_to_annotation = classmethod(lltype_to_annotation)
 
 

Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_ooann.py	Fri Oct 27 14:24:33 2006
@@ -253,24 +253,6 @@
     assert isinstance(a.build_types(fn2, []), annmodel.SomeInteger)
     assert isinstance(a.build_types(fn3, []), annmodel.SomeFloat)
 
-def test_overloaded_meth_string():
-    C = Instance("test", ROOT, {},
-                 {'foo': overload(meth(Meth([Char], Signed)),
-                                  meth(Meth([String], Float))),
-                  'bar': overload(meth(Meth([Signed], Char)),
-                                  meth(Meth([Float], String)))})
-    def fn1():
-        return new(C).foo('a')
-    def fn2():
-        return new(C).foo('aa')
-    def fn3(x):
-        return new(C).bar(x)
-    a = RPythonAnnotator()
-    assert isinstance(a.build_types(fn1, []), annmodel.SomeInteger)
-    assert isinstance(a.build_types(fn2, []), annmodel.SomeFloat)
-    assert isinstance(a.build_types(fn3, [int]), annmodel.SomeChar)
-    assert isinstance(a.build_types(fn3, [float]), annmodel.SomeString)
-
 def test_bad_overload():
     def fn():
         C = Instance("test", ROOT, {},
@@ -312,19 +294,19 @@
 def test_overload_upcast():
     C = Instance("base", ROOT, {}, {
         'foo': overload(meth(Meth([], Void)),
-                        meth(Meth([ROOT], String)))})
+                        meth(Meth([ROOT], Signed)))})
     def f():
         c = new(C)
         return c.foo(c)
     a = RPythonAnnotator()
-    assert isinstance(a.build_types(f, []), annmodel.SomeString)
+    assert isinstance(a.build_types(f, []), annmodel.SomeInteger)
 
 def test_overload_upcast_fail():
     C = Instance("base", ROOT, {}, {})
     C._add_methods({
         'foo': overload(meth(Meth([], Signed)),
-                        meth(Meth([ROOT, C], String)),
-                        meth(Meth([C, ROOT], String)))})
+                        meth(Meth([ROOT, C], Signed)),
+                        meth(Meth([C, ROOT], Signed)))})
     def f():
         c = new(C)
         return c.foo(c)



More information about the Pypy-commit mailing list