[pypy-svn] r13699 - pypy/dist/pypy/annotation

mwh at codespeak.net mwh at codespeak.net
Thu Jun 23 13:51:30 CEST 2005


Author: mwh
Date: Thu Jun 23 13:51:25 2005
New Revision: 13699

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/annotation/unaryop.py
Log:
count some more stuff

(untested, checking in to get stuff on samuele's machine...)


Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Thu Jun 23 13:51:25 2005
@@ -47,7 +47,7 @@
 
     def count(self, category, *args):
         for_category = self.classify.setdefault(category, {})
-        classifier = getattr(self, 'consider_%s' % category)
+        classifier = getattr(self, 'consider_%s' % category, self.consider_generic)
         outcome = classifier(*args)
         for_category[self.bookkeeper.position_key] = outcome
 
@@ -79,6 +79,8 @@
         else:
             return 'non-const-step %s' % self.typerepr(stp)
 
+    def consider_generic(self, *args):
+        return tuple([self.typerepr(x) for x in args])
 
     def consider_newslice(self, s_start, s_stop, s_step):
         return ':'.join([self.indexrepr(s_start), self.indexrepr(s_stop), self.steprepr(s_step)])
@@ -129,7 +131,7 @@
             return "NON-CONSTANT"
 
     def consider_str_getitem(self, idx):
-        return self.indexrepr(idx)        
+        return self.indexrepr(idx)
 
 class Bookkeeper:
     """The log of choices that have been made while analysing the operations.

Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py	(original)
+++ pypy/dist/pypy/annotation/unaryop.py	Thu Jun 23 13:51:25 2005
@@ -83,9 +83,20 @@
         return SomeInteger()
 
     def str(obj):
+        getbookkeeper().count('str', obj)
         return SomeString()
 
-    repr = hex = oct = str
+    def repr(obj):
+        getbookkeeper().count('repr', obj)
+        return SomeString()
+
+    def hex(obj):
+        getbookkeeper().count('hex', obj)
+        return SomeString()
+
+    def oct(obj):
+        getbookkeeper().count('oct', obj)
+        return SomeString()
 
     def id(obj): # xxx
         return SomeInteger()



More information about the Pypy-commit mailing list