[pypy-dev] Trouble with ooparse_int/ooparse_float

Antonio Cuni anto.cuni at gmail.com
Tue Aug 7 14:09:26 CEST 2007

Hi Paul!

Paul deGrandis wrote:
> Anto, Niko, and all,
> I've been trying to get some of the string and float tests to pass.  The 
> trouble I'm running into is that ooparse_float doesn't know how to parse 
> ll_str_0, but for the life of me can't find where I need to be looking 
> or where I should override the ooparse_float method.  I feel like it 
> should go in my opcodes.py file (translator/jvm).

I'm not sure to understand the question.
ooparse_float is an opcode which converts strings to floats.

To implement it, you must add the corresponding definition to 
translator/jvm/opcodes.py; the simplest thing to do is probably to call 
java.lang.Double.parseDouble(); I don't know the exact syntax to use, 
but I guess Niko could help here :-).

> Also, one question I had about long conversions, in 
> translator/jvm/test/test_float.py:22, there is a test for long 
> conversion.  Tracing the results shows I get the correct answer for the 
> conversion, but my result is not an r_longlong, the tests returns a Java 
> Long.  Any tips or hints?

This happens because the same tests are used to test both the 
llinterpreter and the backends: when run in the llinterpreter, the 
return type is effectively r_longlong and the test runs fine, but when 
translated by a backend such as cli or jvm, the result is simply printed 
to stdout, without any information about the type: thus, there is no way 
to test if the result was effectively a r_longlong.

Look at the source of the test, in rpython/test/test_rfloat.py:69: you 
see that the type-checking is done by calling the is_of_type method; 
now, look how the CLI test framerwork implements this method, in 
cli/test/runtest.py:299: as you can see, it simply returns always true, 
because it has no chance to test it.

What you need to do is simply to do the same in jvm/test/runtest.py.

ciao Anto

More information about the Pypy-dev mailing list