[pypy-svn] r53053 - in pypy/branch/fixed-list-ootype/pypy/translator/jvm: . test

niko at codespeak.net niko at codespeak.net
Fri Mar 28 13:42:09 CET 2008


Author: niko
Date: Fri Mar 28 13:42:08 2008
New Revision: 53053

Modified:
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_list.py
   pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py
Log:
fix bug related to boolean arrays: we used to map them
to byte arrays, which caused us to incorrectly try
to box their arguments (since byte != boolean), etc



Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/database.py	Fri Mar 28 13:42:08 2008
@@ -538,7 +538,7 @@
         ootype.Signed   : jvm.jIntArray,
         ootype.Unsigned : jvm.jIntArray,
         ootype.Char     : jvm.jCharArray,
-        ootype.Bool     : jvm.jByteArray,
+        ootype.Bool     : jvm.jBoolArray,
         ootype.UniChar  : jvm.jCharArray,
         ootype.String   : jvm.jStringArray,
         ootype.Float    : jvm.jDoubleArray,

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_list.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_list.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/test/test_list.py	Fri Mar 28 13:42:08 2008
@@ -15,4 +15,17 @@
             return lst[0]
         res = self.interpret(fn, [])
         assert res == 0
+
+    def test_bool_fixed_list(self):
+        """ Tests that we handle boolean fixed lists, which do not require
+        boxing or unboxing """
+        def fn(i):
+            lst = [False, True]
+            if lst[i]:
+                return 22
+            else:
+                return 44
+        for i in range(0,2):
+            res = self.interpret(fn, [i])
+            assert res == fn(i)
         

Modified: pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py
==============================================================================
--- pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py	(original)
+++ pypy/branch/fixed-list-ootype/pypy/translator/jvm/typesystem.py	Fri Mar 28 13:42:08 2008
@@ -411,6 +411,7 @@
         else:
             raise KeyError(methodnm)
         
+jBoolArray = JvmArrayType(jBool)
 jByteArray = JvmArrayType(jByte)
 jObjectArray = JvmArrayType(jObject)
 jStringArray = JvmArrayType(jString)
@@ -555,6 +556,8 @@
             s = "newarray char"
         elif desc == '[B':
             s = "newarray byte"
+        elif desc == '[Z':
+            s = "newarray boolean"
         else:
             s = "anewarray " + arraytype.element_type.descriptor.int_class_name()
         self.cache[arraytype] = obj = Opcode(s)



More information about the Pypy-commit mailing list