[pypy-svn] r48184 - in pypy/dist/pypy/translator/llvm: . test

rxe at codespeak.net rxe at codespeak.net
Tue Oct 30 00:35:30 CET 2007


Author: rxe
Date: Tue Oct 30 00:35:29 2007
New Revision: 48184

Modified:
   pypy/dist/pypy/translator/llvm/arraynode.py
   pypy/dist/pypy/translator/llvm/test/test_lltype.py
Log:
an epiphany: an array is an array

Modified: pypy/dist/pypy/translator/llvm/arraynode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/arraynode.py	(original)
+++ pypy/dist/pypy/translator/llvm/arraynode.py	Tue Oct 30 00:35:29 2007
@@ -50,7 +50,6 @@
         ref = "cast(%s* %s to %s*)" % (self.get_typerepr(),
                                        ref,
                                        typeval)
-        print 'KKKKKKKKKK', ref
         return ref
 
     def get_pbcref(self, toptr):
@@ -59,7 +58,6 @@
 
         fromptr = "%s*" % self.get_typerepr()
         ref = "cast(%s %s to %s)" % (fromptr, self.name, toptr)
-        print 'XXXXXXXXX', ref
         return ref
 
     def get_childref(self, index):
@@ -86,7 +84,7 @@
     def get_typerepr(self):
         arraylen = self.get_arrayvalue()[0]
         typeval = self.db.repr_type(self.arraytype)
-        return "{ [%s x %s] }" % (arraylen, typeval)
+        return "[%s x %s]" % (arraylen, typeval)
     
     def get_childref(self, index):
         return "getelementptr(%s* %s, int 0, int %s)" %(
@@ -97,12 +95,7 @@
     def constantvalue(self):
         physicallen, arrayrepr = self.get_arrayvalue()
         typeval = self.db.repr_type(self.arraytype)
-
-        value = "[%s x %s] %s" % (physicallen,
-                                  typeval,
-                                  arrayrepr)
-
-        s = "%s {%s}" % (self.get_typerepr(), value)
+        s = "%s %s" % (self.get_typerepr(), arrayrepr)
         return s
 
 class StrArrayNode(ArrayNode):

Modified: pypy/dist/pypy/translator/llvm/test/test_lltype.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/test_lltype.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/test_lltype.py	Tue Oct 30 00:35:29 2007
@@ -374,7 +374,8 @@
 
 def test_direct_arrayitems():
     for a in [malloc(GcArray(Signed), 5),
-              malloc(FixedSizeArray(Signed, 5), immortal=True)]:
+              malloc(FixedSizeArray(Signed, 5), immortal=True),
+              malloc(Array(Signed, hints={'nolength': True}), 5, immortal=True)]:
         a[0] = 0
         a[1] = 10
         a[2] = 20
@@ -763,41 +764,6 @@
     def getcompiled(self, f, args=[]):
         return compile_function(f, args)
 
-    def test_direct_arrayitems(self):
-        py.test.skip("nolength ???")
-        for a in [malloc(GcArray(Signed), 5),
-                  malloc(FixedSizeArray(Signed, 5), immortal=True),
-                  malloc(Array(Signed, hints={'nolength': True}), 5, immortal=True),
-                  ]:
-            a[0] = 0
-            a[1] = 10
-            a[2] = 20
-            a[3] = 30
-            a[4] = 40
-            b0 = direct_arrayitems(a)
-            b1 = direct_ptradd(b0, 1)
-            b2 = direct_ptradd(b1, 1)
-            def llf(n):
-                b0 = direct_arrayitems(a)
-                b3 = direct_ptradd(direct_ptradd(b0, 5), -2)
-                saved = a[n]
-                a[n] = 1000
-                try:
-                    return b0[0] + b3[-2] + b2[1] + b1[3]
-                finally:
-                    a[n] = saved
-            fn = self.getcompiled(llf, [int])
-            res = fn(0)
-            assert res == 1000 + 10 + 30 + 40
-            res = fn(1)
-            assert res == 0 + 1000 + 30 + 40
-            res = fn(2)
-            assert res == 0 + 10 + 30 + 40
-            res = fn(3)
-            assert res == 0 + 10 + 1000 + 40
-            res = fn(4)
-            assert res == 0 + 10 + 30 + 1000
-
     def test_arithmetic_cornercases(self):
         py.test.skip("pyobject in this test - but why ???")
         import operator, sys



More information about the Pypy-commit mailing list