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

nik at codespeak.net nik at codespeak.net
Thu Mar 2 00:09:34 CET 2006


Author: nik
Date: Thu Mar  2 00:09:30 2006
New Revision: 23874

Modified:
   pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py
   pypy/dist/pypy/rpython/ootypesystem/rclass.py
   pypy/dist/pypy/rpython/test/test_rpbc.py
Log:
(pedronis, nik)
made another rpbc test work for ootype. fixed a failure related to
exceptions, exception matching now works for ootype.


Modified: pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py	Thu Mar  2 00:09:30 2006
@@ -1,8 +1,17 @@
 from pypy.rpython.exceptiondata import AbstractExceptionData
+from pypy.rpython.ootypesystem import rclass
+from pypy.rpython.annlowlevel import annotate_lowlevel_helper
+from pypy.annotation import model as annmodel
 
 class ExceptionData(AbstractExceptionData):
     """Public information for the code generators to help with exceptions."""
 
     def make_helpers(self, rtyper):
-        pass
+        self.fn_exception_match = self.make_exception_matcher(rtyper)
 
+    def make_exception_matcher(self, rtyper):
+        # ll_exception_matcher(real_exception_meta, match_exception_meta)
+        s_classtype = annmodel.SomeOOInstance(self.lltype_of_exception_type)
+        helper_graph = annotate_lowlevel_helper(
+            rtyper.annotator, rclass.ll_issubclass, [s_classtype, s_classtype])
+        return rtyper.getcallable(helper_graph)

Modified: pypy/dist/pypy/rpython/ootypesystem/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/rclass.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/rclass.py	Thu Mar  2 00:09:30 2006
@@ -129,9 +129,9 @@
     def rtype_issubtype(self, hop):
         class_repr = get_type_repr(self.rtyper)
         vmeta1, vmeta2 = hop.inputargs(class_repr, class_repr)
-        return hop.gendirectcall(ll_issubtype, vmeta1, vmeta2)
+        return hop.gendirectcall(ll_issubclass, vmeta1, vmeta2)
 
-def ll_issubtype(meta1, meta2):
+def ll_issubclass(meta1, meta2):
     class1 = meta1.class_
     class2 = meta2.class_
     return ootype.subclassof(class1, class2)

Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py	Thu Mar  2 00:09:30 2006
@@ -831,39 +831,39 @@
         assert res == 3*2+11*7
         
 
-def test_multiple_ll_one_hl_op():
-    class E(Exception):
-        pass
-    class A(object):
-        pass
-    class B(A):
-        pass
-    class C(object):
-        def method(self, x):
-            if x:
-                raise E()
-            else:
-                return A()
-    class D(C):
-        def method(self, x):
-            if x:
-                raise E()
-            else:
-                return B()
-    def call(x):
-        c = D()
-        c.method(x)
-        try:
-            c.method(x + 1)
-        except E:
+    def test_multiple_ll_one_hl_op(self):
+        class E(Exception):
+            pass
+        class A(object):
+            pass
+        class B(A):
             pass
-        c = C()
-        c.method(x)
-        try:
-            return c.method(x + 1)
-        except E:
-            return None
-    res = interpret(call, [0])
+        class C(object):
+            def method(self, x):
+                if x:
+                    raise E()
+                else:
+                    return A()
+        class D(C):
+            def method(self, x):
+                if x:
+                    raise E()
+                else:
+                    return B()
+        def call(x):
+            c = D()
+            c.method(x)
+            try:
+                c.method(x + 1)
+            except E:
+                pass
+            c = C()
+            c.method(x)
+            try:
+                return c.method(x + 1)
+            except E:
+                return None
+        res = interpret(call, [0], type_system=self.ts)
 
 def test_multiple_pbc_with_void_attr():
     class A:



More information about the Pypy-commit mailing list