[pypy-svn] r18474 - pypy/branch/hl-backend/pypy/rpython

boria at codespeak.net boria at codespeak.net
Wed Oct 12 15:58:05 CEST 2005


Author: boria
Date: Wed Oct 12 15:58:03 2005
New Revision: 18474

Modified:
   pypy/branch/hl-backend/pypy/rpython/rtyper.py
   pypy/branch/hl-backend/pypy/rpython/typesystem.py
Log:
(Samuele, Boris)
* Beginnings of multiple dispatch on type system and annotation.


Modified: pypy/branch/hl-backend/pypy/rpython/rtyper.py
==============================================================================
--- pypy/branch/hl-backend/pypy/rpython/rtyper.py	(original)
+++ pypy/branch/hl-backend/pypy/rpython/rtyper.py	Wed Oct 12 15:58:03 2005
@@ -102,12 +102,10 @@
         return self.exceptiondata    # built at the end of specialize()
 
     def makekey(self, s_obj):
-        if hasattr(s_obj, "rtyper_makekey_ex"):
-            return s_obj.rtyper_makekey_ex(self)
-        return s_obj.rtyper_makekey()
+        return pair(self.type_system, s_obj).rtyper_makekey(self)
 
     def makerepr(self, s_obj):
-        return s_obj.rtyper_makerepr(self)
+        return pair(self.type_system, s_obj).rtyper_makerepr(self)
         
     def getrepr(self, s_obj):
         # s_objs are not hashable... try hard to find a unique key anyway

Modified: pypy/branch/hl-backend/pypy/rpython/typesystem.py
==============================================================================
--- pypy/branch/hl-backend/pypy/rpython/typesystem.py	(original)
+++ pypy/branch/hl-backend/pypy/rpython/typesystem.py	Wed Oct 12 15:58:03 2005
@@ -52,3 +52,19 @@
 # All typesystems are singletons
 LowLevelTypeSystem.instance = LowLevelTypeSystem()
 ObjectOrientedTypeSystem.instance = ObjectOrientedTypeSystem()
+
+# Multiple dispatch on type system and high-level annotation
+
+from pypy.annotation.pairtype import pairtype
+from pypy.annotation.model import SomeObject
+
+class __extend__(pairtype(TypeSystem, SomeObject)):
+    def rtyper_makerepr((ts, s_obj), rtyper):
+        return s_obj.rtyper_makerepr(rtyper)
+
+    def rtyper_makekey((ts, s_obj), rtyper):
+        if hasattr(s_obj, "rtyper_makekey_ex"):
+            return s_obj.rtyper_makekey_ex(rtyper)
+        return s_obj.rtyper_makekey()
+
+



More information about the Pypy-commit mailing list