[pypy-svn] r37139 - in pypy/dist/pypy/translator/jvm: . src/pypy test

niko at codespeak.net niko at codespeak.net
Mon Jan 22 14:39:27 CET 2007


Author: niko
Date: Mon Jan 22 14:39:26 2007
New Revision: 37139

Modified:
   pypy/dist/pypy/translator/jvm/builtin.py
   pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java
   pypy/dist/pypy/translator/jvm/test/test_string.py
Log:
revert ll_stritem_nonneg so that it calls charAt() directly, 
and throws a Java exception if it fails.  This is because
the bounds checking is performed at a different level, so
we have no need to translate the exception to a Python 
exception and thus introduce additional overhead.



Modified: pypy/dist/pypy/translator/jvm/builtin.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/builtin.py	(original)
+++ pypy/dist/pypy/translator/jvm/builtin.py	Mon Jan 22 14:39:26 2007
@@ -89,6 +89,9 @@
     (ootype.String.__class__, "ll_strlen"):
     jvmgen.Method.v(jString, "length", (), jInt),
     
+    (ootype.String.__class__, "ll_stritem_nonneg"):
+    jvmgen.Method.v(jString, "charAt", (jInt,), jChar),
+
     (ootype.String.__class__, "ll_startswith"):
     jvmgen.Method.v(jString, "startsWith", (jString,), jBool),
 

Modified: pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java
==============================================================================
--- pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java	(original)
+++ pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java	Mon Jan 22 14:39:26 2007
@@ -183,15 +183,6 @@
         return s.charAt(0);
     }
 
-    public static char ll_stritem_nonneg(String s, int idx) {
-        try {
-            return s.charAt(idx);
-        } catch (StringIndexOutOfBoundsException exc) {
-            throwIndexError();
-        }
-        throw new RuntimeException("Should not get here");
-    }
-
     // Used in testing:
 
     public static void dump(String text) {

Modified: pypy/dist/pypy/translator/jvm/test/test_string.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_string.py	(original)
+++ pypy/dist/pypy/translator/jvm/test/test_string.py	Mon Jan 22 14:39:26 2007
@@ -20,4 +20,8 @@
         py.test.skip("JVM does not yet support ooparse_float")
 
     def test_getitem_exc(self):
-        py.test.skip("TODO: Appears to be a bug in test_rstr.py??")
+        # This test is supposed to crash in a system specific way;
+        # in our case an StringIndexOutOfBounds exception is thrown,
+        # but we don't bother to make runtest understand how to parse that,
+        # so we just skip the test.
+        py.test.skip("test fails in JVM specific way")



More information about the Pypy-commit mailing list