[pypy-svn] r26732 - in pypy/dist/pypy/translator/cl: . test

dialtone at codespeak.net dialtone at codespeak.net
Wed May 3 18:53:26 CEST 2006


Author: dialtone
Date: Wed May  3 18:53:24 2006
New Revision: 26732

Modified:
   pypy/dist/pypy/translator/cl/gencl.py
   pypy/dist/pypy/translator/cl/opformatter.py
   pypy/dist/pypy/translator/cl/test/test_cltrans.py
Log:
pass new version of half_of_n, avoid undeclared free variable style warning

Modified: pypy/dist/pypy/translator/cl/gencl.py
==============================================================================
--- pypy/dist/pypy/translator/cl/gencl.py	(original)
+++ pypy/dist/pypy/translator/cl/gencl.py	Wed May  3 18:53:24 2006
@@ -109,12 +109,13 @@
         # const.concretetype is Instance
         if const in self.declarations:
             return self.declarations[const][0]
-        name = "const" + str(self.constcount)
+        name = "+const" + str(self.constcount) + "+"
         INST = dynamicType(const.value)
         self.declare_class(INST)
         inst = oodowncast(INST, const.value)
         cls = clrepr(INST)
         const_declaration = []
+        const_declaration.append("(defvar %s nil)" % clrepr(name, True))
         const_declaration.append("(setf %s (make-instance %s))" % (clrepr(name, True),
                                                                    clrepr(cls, True)))
         fields = INST._allfields()

Modified: pypy/dist/pypy/translator/cl/opformatter.py
==============================================================================
--- pypy/dist/pypy/translator/cl/opformatter.py	(original)
+++ pypy/dist/pypy/translator/cl/opformatter.py	Wed May  3 18:53:24 2006
@@ -34,6 +34,7 @@
     op_cast_int_to_char = make_unary_op("code-char")
     op_cast_float_to_int = make_unary_op("truncate")
     op_cast_int_to_float = make_unary_op("float")
+    op_int_neg = make_unary_op("not")
 
     def make_binary_op(cl_op):
         def binary_op(self, result, arg1, arg2):
@@ -47,6 +48,7 @@
     op_int_eq = make_binary_op("=")
     op_int_gt = make_binary_op(">")
     op_int_ge = make_binary_op(">=")
+    op_int_ne = make_binary_op("/=")
     op_int_lt = make_binary_op("<")
     op_int_le = make_binary_op("<=")
     op_int_and = make_binary_op("logand")
@@ -165,6 +167,12 @@
 
     def ll_setitem_fast(self, index, value):
         return "(setf (aref %s %s) %s)" % (self.obj, index, value)
+    
+    def _ll_resize_le(self, size):
+        return "(adjust-array %s %s)" % (self.obj, size)
+    
+    def _ll_resize_ge(self, size):
+        return "(adjust-array %s %s)" % (self.obj, size)
 
     def _ll_resize(self, size):
         return "(adjust-array %s %s)" % (self.obj, size)

Modified: pypy/dist/pypy/translator/cl/test/test_cltrans.py
==============================================================================
--- pypy/dist/pypy/translator/cl/test/test_cltrans.py	(original)
+++ pypy/dist/pypy/translator/cl/test/test_cltrans.py	Wed May  3 18:53:24 2006
@@ -131,8 +131,19 @@
     assert cl_builtinusage() == 4
 
 def test_slice():
-    py.test.skip("either this is not RPython or gencl has something horribly wrong")
-    cl_half = make_cl_func(t.half_of_n, [int])
+    def half_of_n(n=int):
+        """Slice test"""
+        i = 0
+        lst = range(n)
+        while lst:
+            lst = lst[1:]
+            if len(lst) > 0:
+                lst.pop()
+            i = i + 1
+        return i
+    cl_half = make_cl_func(half_of_n, [int])
+    assert cl_half(2) == 1
+    assert cl_half(4) == 2
     assert cl_half(10) == 5
 
 def test_powerset():



More information about the Pypy-commit mailing list