[pypy-svn] r20352 - in pypy/branch/somepbc-refactoring/pypy/rpython: . lltypesystem

mwh at codespeak.net mwh at codespeak.net
Mon Nov 28 13:54:56 CET 2005


Author: mwh
Date: Mon Nov 28 13:54:55 2005
New Revision: 20352

Modified:
   pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py
   pypy/branch/somepbc-refactoring/pypy/rpython/normalizecalls.py
   pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py
Log:
support in the rtyper for overridden functions -- all tests now pass
in rpython/test, yay!


Modified: pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/lltypesystem/rpbc.py	Mon Nov 28 13:54:55 2005
@@ -11,9 +11,8 @@
 from pypy.rpython import robject
 from pypy.rpython import rtuple
 from pypy.rpython.rpbc import SingleFrozenPBCRepr, samesig,\
-                                commonbase, allattributenames, \
-                                MultiplePBCRepr, FunctionsPBCRepr, \
-                                AbstractClassesPBCRepr, AbstractMethodsPBCRepr
+     commonbase, allattributenames, MultiplePBCRepr, FunctionsPBCRepr, \
+     AbstractClassesPBCRepr, AbstractMethodsPBCRepr, OverriddenFunctionPBCRepr
 from pypy.rpython.lltypesystem import rclass
 from pypy.tool.sourcetools import has_varargs
 
@@ -203,7 +202,8 @@
         hop2 = hop.copy()
         r_class = self.r_im_self.rclass
         mangled_name, r_func = r_class.clsfields[self.methodname]
-        assert isinstance(r_func, FunctionsPBCRepr)
+        assert isinstance(r_func, (FunctionsPBCRepr,
+                                   OverriddenFunctionPBCRepr))
         s_func = r_func.s_pbc
         v_im_self = hop.inputarg(self, arg=0)
         v_cls = self.r_im_self.getfield(v_im_self, '__class__', hop.llops)

Modified: pypy/branch/somepbc-refactoring/pypy/rpython/normalizecalls.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/normalizecalls.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/normalizecalls.py	Mon Nov 28 13:54:55 2005
@@ -13,10 +13,19 @@
 
 def normalize_call_familes(annotator):
     for callfamily in annotator.bookkeeper.pbc_maximal_call_families.infos():
-       normalize_calltable(annotator, callfamily)
+        normalize_calltable(annotator, callfamily)
 
 def normalize_calltable(annotator, callfamily):
     """Try to normalize all rows of a table."""
+    overridden = False
+    for desc in callfamily.descs:
+        if getattr(desc, 'overridden', False):
+            overridden = True
+    if overridden:
+        if len(callfamily.descs) > 1:
+            raise Exception("non-static call to overridden function")
+        callfamily.overridden = True
+        return
     nshapes = len(callfamily.calltables)
     for shape, table in callfamily.calltables.items():
         for row in table:

Modified: pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py
==============================================================================
--- pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py	(original)
+++ pypy/branch/somepbc-refactoring/pypy/rpython/rpbc.py	Mon Nov 28 13:54:55 2005
@@ -19,8 +19,12 @@
             return none_frozen_pbc_repr 
         kind = self.getKind()
         if issubclass(kind, description.FunctionDesc):
-            if self.descriptions.keys()[0].querycallfamily():
-                getRepr = FunctionsPBCRepr
+            sample = self.descriptions.keys()[0]
+            if sample.querycallfamily():
+                if sample.overridden:
+                    getRepr = OverriddenFunctionPBCRepr
+                else:
+                    getRepr = FunctionsPBCRepr
             else:
                 getRepr = getFrozenPBCRepr
         elif issubclass(kind, description.ClassDesc):
@@ -275,6 +279,17 @@
                 return inputconst(r_fpbc2, r_fpbc1.s_pbc.const)
             return NotImplemented
 
+class OverriddenFunctionPBCRepr(Repr):
+    def __init__(self, rtyper, s_pbc):
+        self.rtyper = rtyper
+        self.s_pbc = s_pbc
+        assert len(s_pbc.descriptions) == 1
+        self.lowleveltype = Void
+
+    def rtype_simple_call(self, hop):
+        from pypy.rpython.rspecialcase import rtype_call_specialcase
+        return rtype_call_specialcase(hop)
+        
 def getPyObjRepr(rtyper, s_pbc):
     return robject.pyobj_repr
 



More information about the Pypy-commit mailing list