[pypy-svn] r13892 - in pypy/dist/pypy/rpython: . test

hpk at codespeak.net hpk at codespeak.net
Sat Jun 25 19:21:31 CEST 2005


Author: hpk
Date: Sat Jun 25 19:21:28 2005
New Revision: 13892

Modified:
   pypy/dist/pypy/rpython/rbool.py
   pypy/dist/pypy/rpython/rclass.py
   pypy/dist/pypy/rpython/rfloat.py
   pypy/dist/pypy/rpython/rint.py
   pypy/dist/pypy/rpython/rlist.py
   pypy/dist/pypy/rpython/rmodel.py
   pypy/dist/pypy/rpython/rstr.py
   pypy/dist/pypy/rpython/rtuple.py
   pypy/dist/pypy/rpython/test/test_rtuple.py
Log:
(arigo, hpk) 

- new Repr.get_ll_eq_function which returns a lowlevel 
  function suitable for checking equality for the given repr. 
  None means that values/pointers can be =='ed 

- prepare rtuple's contains a bit 



Modified: pypy/dist/pypy/rpython/rbool.py
==============================================================================
--- pypy/dist/pypy/rpython/rbool.py	(original)
+++ pypy/dist/pypy/rpython/rbool.py	Sat Jun 25 19:21:28 2005
@@ -23,6 +23,9 @@
             raise TyperError("not a bool: %r" % (value,))
         return value
 
+    def get_ll_eq_function(self):
+        return None 
+
     def rtype_is_true(_, hop):
         vlist = hop.inputargs(Bool)
         return vlist[0]

Modified: pypy/dist/pypy/rpython/rclass.py
==============================================================================
--- pypy/dist/pypy/rpython/rclass.py	(original)
+++ pypy/dist/pypy/rpython/rclass.py	Sat Jun 25 19:21:28 2005
@@ -386,6 +386,9 @@
             self.initialize_prebuilt_instance(value, classdef, result)
             return result
 
+    def get_ll_eq_function(self):
+        return None
+
     def initialize_prebuilt_instance(self, value, classdef, result):
         if self.classdef is not None:
             # recursively build the parent part of the instance

Modified: pypy/dist/pypy/rpython/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py	(original)
+++ pypy/dist/pypy/rpython/rfloat.py	Sat Jun 25 19:21:28 2005
@@ -100,6 +100,9 @@
             raise TyperError("not a float: %r" % (value,))
         return float(value)
 
+    def get_ll_eq_function(self):
+        return None 
+
     def rtype_is_true(_, hop):
         vlist = hop.inputargs(Float)
         return hop.genop('float_is_true', vlist, resulttype=Bool)

Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py	(original)
+++ pypy/dist/pypy/rpython/rint.py	Sat Jun 25 19:21:28 2005
@@ -198,6 +198,9 @@
             return r_uint(value)
         raise NotImplementedError
 
+    def get_ll_eq_function(self):
+        return None 
+
     def rtype_float(_, hop):
         vlist = hop.inputargs(Float)
         return vlist[0]

Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py	(original)
+++ pypy/dist/pypy/rpython/rlist.py	Sat Jun 25 19:21:28 2005
@@ -78,15 +78,7 @@
             return result
 
     def get_eqfunc(self):
-        if self.item_repr == string_repr:
-            func = ll_streq
-        elif isinstance(self.item_repr.lowleveltype, Primitive):
-            func = None
-        elif isinstance(self.item_repr, InstanceRepr):
-            func = None
-        else:
-            raise TyperError, 'comparison not implemented for %r' % self
-        return inputconst(Void, func)
+        return inputconst(Void, self.item_repr.get_ll_eq_function())
 
     def rtype_bltn_list(self,hop):
         v_lst = hop.inputarg(self,0)

Modified: pypy/dist/pypy/rpython/rmodel.py
==============================================================================
--- pypy/dist/pypy/rpython/rmodel.py	(original)
+++ pypy/dist/pypy/rpython/rmodel.py	Sat Jun 25 19:21:28 2005
@@ -49,6 +49,9 @@
                     self, value))
         return value
 
+    def get_ll_eq_function(self): 
+        raise TyperError, 'no equality function for %r' % self
+
     # default implementation of some operations
 
     def rtype_getattr(self, hop):
@@ -223,3 +226,4 @@
     lloutput = getconcretetype(graph.getreturnvar())
     FT = FuncType(llinputs, lloutput)
     return functionptr(FT, func.func_name, graph = graph, _callable = func)
+

Modified: pypy/dist/pypy/rpython/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/rstr.py	(original)
+++ pypy/dist/pypy/rpython/rstr.py	Sat Jun 25 19:21:28 2005
@@ -70,6 +70,9 @@
             CONST_STR_CACHE[value] = p
             return p
 
+    def get_ll_eq_function(self):
+        return ll_streq
+
     def rtype_len(_, hop):
         v_str, = hop.inputargs(string_repr)
         return hop.gendirectcall(ll_strlen, v_str)
@@ -277,6 +280,9 @@
             raise TyperError("not a character: %r" % (value,))
         return value
 
+    def get_ll_eq_function(self):
+        return None 
+
     def rtype_len(_, hop):
         return hop.inputconst(Signed, 1)
 
@@ -313,6 +319,9 @@
             raise TyperError("not a unicode character: %r" % (value,))
         return value
 
+    def get_ll_eq_function(self):
+        return None 
+
 ##    def rtype_len(_, hop):
 ##        return hop.inputconst(Signed, 1)
 ##

Modified: pypy/dist/pypy/rpython/rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/rtuple.py	(original)
+++ pypy/dist/pypy/rpython/rtuple.py	Sat Jun 25 19:21:28 2005
@@ -41,6 +41,9 @@
             setattr(p, name, r.convert_const(obj))
         return p
 
+    #def get_eqfunc(self):
+    #    return inputconst(Void, self.item_repr.get_ll_eq_function())
+
     def rtype_len(self, hop):
         return hop.inputconst(Signed, len(self.items_r))
 
@@ -60,6 +63,10 @@
             cindex = inputconst(Signed, index)
             hop.gendirectcall(rlist.ll_setitem_nonneg, vlist, cindex, vitem)
         return vlist
+
+#class __extend__(pairtype(TupleRepr, Repr)): 
+#    def rtype_contains((r_tup, r_item), hop): 
+#        XXX
            
 class __extend__(pairtype(TupleRepr, IntegerRepr)):
 

Modified: pypy/dist/pypy/rpython/test/test_rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rtuple.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rtuple.py	Sat Jun 25 19:21:28 2005
@@ -5,6 +5,7 @@
 from pypy.rpython.rint import signed_repr
 from pypy.rpython.rbool import bool_repr
 from pypy.rpython.test.test_llinterp import interpret, make_interpreter
+import py
 
 def test_rtuple():
     rtuple = TupleRepr([signed_repr, bool_repr])
@@ -69,3 +70,18 @@
     fn = make_interpreter(f,[])#,view=True)
     res = fn()
     assert res == 123
+
+def test_constant_tuple_contains(): 
+    py.test.skip("tuple contains not implemented")
+    def f(i): 
+        t1 = (1, 2, 3, 4)
+        return i in t1 
+    fn = make_interpreter(f, [3], view=False, viewbefore=False) 
+    res = fn(3)
+    assert res is True 
+    res = fn(0) 
+    assert res is False 
+
+    
+        
+    



More information about the Pypy-commit mailing list