[pypy-svn] r13477 - in pypy/dist/pypy: annotation translator/goal

pedronis at codespeak.net pedronis at codespeak.net
Thu Jun 16 16:07:48 CEST 2005


Author: pedronis
Date: Thu Jun 16 16:07:47 2005
New Revision: 13477

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/annotation/unaryop.py
   pypy/dist/pypy/translator/goal/query.py
Log:
some other statics about border-case RPython usages.



Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Thu Jun 16 16:07:47 2005
@@ -95,42 +95,49 @@
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(obj1.const < obj2.const)
         else:
+            getbookkeeper().count("non_int_comp", obj1, obj2)
             return SomeBool()
 
     def le((obj1, obj2)):
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(obj1.const <= obj2.const)
         else:
+            getbookkeeper().count("non_int_comp", obj1, obj2)
             return SomeBool()
 
     def eq((obj1, obj2)):
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(obj1.const == obj2.const)
         else:
+            getbookkeeper().count("non_int_eq", obj1, obj2)
             return SomeBool()
 
     def ne((obj1, obj2)):
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(obj1.const != obj2.const)
         else:
+            getbookkeeper().count("non_int_eq", obj1, obj2)
             return SomeBool()
 
     def gt((obj1, obj2)):
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(obj1.const > obj2.const)
         else:
+            getbookkeeper().count("non_int_comp", obj1, obj2)
             return SomeBool()
 
     def ge((obj1, obj2)):
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(obj1.const >= obj2.const)
         else:
+            getbookkeeper().count("non_int_comp", obj1, obj2)
             return SomeBool()
 
     def cmp((obj1, obj2)):
         if obj1.is_constant() and obj2.is_constant():
             return immutablevalue(cmp(obj1.const, obj2.const))
         else:
+            getbookkeeper().count("non_int_comp", obj1, obj2)
             return SomeInteger()
 
     def is_((obj1, obj2)):
@@ -388,6 +395,7 @@
             except IndexError:
                 return SomeImpossibleValue()
         else:
+            getbookkeeper().count("tuple_random_getitem", tup1)
             return unionof(*tup1.items)
 
 

Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Thu Jun 16 16:07:47 2005
@@ -58,6 +58,35 @@
             return 'proper'
         return 'improper'
 
+    def consider_non_int_eq(self, obj1, obj2):
+        return obj1.knowntype.__name__, obj2.knowntype.__name__
+
+    def consider_non_int_comp(self, obj1, obj2):
+        return obj1.knowntype.__name__, obj2.knowntype.__name__
+
+    def short(self, obj):
+        if isinstance(obj, SomeInstance):
+            return obj.classdef.cls.__name__
+        else:
+            return obj.knowntype.__name__
+
+    def consider_tuple_iter(self, tup):
+        if tup.is_constant():
+            return 'constant tuple'
+        else:
+            return tuple([self.short(x) for x in tup.items])
+
+    def consider_tuple_random_getitem(self, tup):
+        return tuple([self.short(x) for x in tup.items])
+
+    def consider_list_index(self):
+        return '!'
+
+    def consider_str_join(self, s):
+        if s.is_constant():
+            return repr(s.const)
+        else:
+            return "NON-CONSTANT"
 
 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 16 16:07:47 2005
@@ -197,6 +197,7 @@
         return immutablevalue(len(tup.items))
 
     def iter(tup):
+        getbookkeeper().count("tuple_iter", tup)
         return SomeIterator(tup)
 
     def getanyitem(tup):
@@ -226,6 +227,7 @@
         return lst.listdef.read_item()
 
     def method_index(lst, el):
+        getbookkeeper().count("list_index")
         return SomeInteger(nonneg=True)
 
     def len(lst):
@@ -289,6 +291,7 @@
         return SomeBool()
 
     def method_join(str, s_list):
+        getbookkeeper().count("str_join", str)
         return SomeString()
 
     def iter(str):

Modified: pypy/dist/pypy/translator/goal/query.py
==============================================================================
--- pypy/dist/pypy/translator/goal/query.py	(original)
+++ pypy/dist/pypy/translator/goal/query.py	Thu Jun 16 16:07:47 2005
@@ -318,7 +318,7 @@
     counters = {}
     for pos, outcome in for_category.iteritems():
         counters[outcome] = counters.get(outcome, 0) + 1
-    w = max([len(o) for o in counters.keys()])+1
+    w = max([len(str(o)) for o in counters.keys()])+1
     for outcome, n in counters.iteritems():
         print "%*s | %d" % (w, outcome, n)
 



More information about the Pypy-commit mailing list