[pypy-svn] r17503 - pypy/dist/pypy/rpython

pedronis at codespeak.net pedronis at codespeak.net
Mon Sep 12 17:01:47 CEST 2005


Author: pedronis
Date: Mon Sep 12 17:01:45 2005
New Revision: 17503

Modified:
   pypy/dist/pypy/rpython/annlowlevel.py
   pypy/dist/pypy/rpython/lltype.py
   pypy/dist/pypy/rpython/rclass.py
   pypy/dist/pypy/rpython/rdict.py
   pypy/dist/pypy/rpython/rlist.py
   pypy/dist/pypy/rpython/rmodel.py
   pypy/dist/pypy/rpython/rtuple.py
Log:
more ll helpers name generation tweaks



Modified: pypy/dist/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/dist/pypy/rpython/annlowlevel.py	(original)
+++ pypy/dist/pypy/rpython/annlowlevel.py	Mon Sep 12 17:01:45 2005
@@ -29,7 +29,17 @@
     def __hash__(self):
         return hash(self.val)
     def __str__(self):
-        return getattr(self.val, '__name__', repr(self.val)) + 'Const'
+        val = self.val
+        if isinstance(val, lltype.LowLevelType):
+            return val._short_name() + 'LlT'
+        s = getattr(val, '__name__', None)
+        if s is None:
+            compact = getattr(val, 'compact_repr', None)
+            if compact is None:
+                s = repr(s)
+            else:
+                s = compact()        
+        return s + 'Const'
 
 class LowLevelAnnotatorPolicy(AnnotatorPolicy):
     allow_someobjects = False

Modified: pypy/dist/pypy/rpython/lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltype.py	(original)
+++ pypy/dist/pypy/rpython/lltype.py	Mon Sep 12 17:01:45 2005
@@ -243,8 +243,8 @@
                                self._str_fields(),)
 
     def _short_name(self):
-        return "%s of %s " % (self.__class__.__name__,
-                               self.OF._short_name(),)
+        return "%s %s" % (self.__class__.__name__,
+                          self.OF._short_name(),)
 
     def _container_example(self):
         return _array(self, 1)
@@ -272,7 +272,7 @@
 
     def _short_name(self):        
         args = ', '.join([ARG._short_name() for ARG in self.ARGS])
-        return "Func ( %s ) -> %s" % (args, self.RESULT._short_name)        
+        return "Func(%s)->%s" % (args, self.RESULT._short_name)        
         
     def _container_example(self):
         def ex(*args):
@@ -373,7 +373,7 @@
         return '* %s' % (self.TO, )
     
     def _short_name(self):
-        return 'Ptr to %s' % (self.TO._short_name(), )
+        return 'Ptr %s' % (self.TO._short_name(), )
     
 
     def _defl(self, parent=None, parentindex=None):

Modified: pypy/dist/pypy/rpython/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/rclass.py	(original)
+++ pypy/dist/pypy/rpython/rclass.py	Mon Sep 12 17:01:45 2005
@@ -115,6 +115,13 @@
             cls = self.classdef.cls
         return '<ClassRepr for %s.%s>' % (cls.__module__, cls.__name__)
 
+    def compact_repr(self):
+        if self.classdef is None:
+            cls = object
+        else:
+            cls = self.classdef.cls
+        return 'ClassR %s.%s' % (cls.__module__, cls.__name__)
+
     def _setup_repr(self):
         # NOTE: don't store mutable objects like the dicts below on 'self'
         #       before they are fully built, to avoid strange bugs in case
@@ -372,6 +379,13 @@
             cls = self.classdef.cls
         return '<InstanceRepr for %s.%s>' % (cls.__module__, cls.__name__)
 
+    def compact_repr(self):
+        if self.classdef is None:
+            cls = object
+        else:
+            cls = self.classdef.cls
+        return 'InstanceR %s.%s' % (cls.__module__, cls.__name__)
+
     def _setup_repr(self):
         # NOTE: don't store mutable objects like the dicts below on 'self'
         #       before they are fully built, to avoid strange bugs in case

Modified: pypy/dist/pypy/rpython/rdict.py
==============================================================================
--- pypy/dist/pypy/rpython/rdict.py	(original)
+++ pypy/dist/pypy/rpython/rdict.py	Mon Sep 12 17:01:45 2005
@@ -82,6 +82,9 @@
         self._custom_eq_hash_repr = custom_eq_hash
         # setup() needs to be called to finish this initialization
 
+    def compact_repr(self):
+        return 'DictR %s %s' % (self.key_repr.compact_repr(), self.value_repr.compact_repr())
+
     def _setup_repr(self):
         if 'key_repr' not in self.__dict__:
             self.key_repr = self._key_repr_computer()

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Mon Sep 12 17:01:45 2005
@@ -69,6 +69,9 @@
             self.LIST.become(GcStruct("list", ("length", Signed),
                                               ("items", Ptr(ITEMARRAY))))
 
+    def compact_repr(self):
+        return 'ListR %s' % (self.item_repr.compact_repr(),)
+
     def convert_const(self, listobj):
         # get object from bound list method
         #listobj = getattr(listobj, '__self__', listobj)

Modified: pypy/dist/pypy/rpython/rmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/rmodel.py	(original)
+++ pypy/dist/pypy/rpython/rmodel.py	Mon Sep 12 17:01:45 2005
@@ -27,7 +27,10 @@
     _initialized = setupstate.NOTINITIALIZED 
 
     def __repr__(self):
-        return '<%s %s>' % (self.__class__.__name__, self.lowleveltype._short_name())
+        return '<%s %s>' % (self.__class__.__name__, self.lowleveltype)
+
+    def compact_repr(self):
+        return '%s %s' % (self.__class__.__name__.replace('Repr','R'), self.lowleveltype._short_name())
 
     def setup(self): 
         """ call _setup_repr() and keep track of the initializiation

Modified: pypy/dist/pypy/rpython/rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/rtuple.py	(original)
+++ pypy/dist/pypy/rpython/rtuple.py	Mon Sep 12 17:01:45 2005
@@ -36,6 +36,9 @@
         fields = zip(self.fieldnames, self.lltypes)
         self.lowleveltype = Ptr(GcStruct('tuple%d' % len(items_r), *fields))
 
+    def compact_repr(self):
+        return "TupleR %s" % ' '.join([llt._short_name() for llt in self.lltypes])
+
     def convert_const(self, value):
         assert isinstance(value, tuple) and len(value) == len(self.items_r)
         p = malloc(self.lowleveltype.TO)



More information about the Pypy-commit mailing list