[gcjx] Patch: FYI: handle float->int conversions
Tom Tromey
tromey@redhat.com
Tue Oct 11 18:08:00 GMT 2005
I'm checking this in on the gcjx branch.
This fixes a gcjx bug when folding float->int conversions.
When converting to an integer type narrower than 'int', we must first
convert to 'int'.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* model/primitive.hh (model_int_primitive::convert): Perform
intermediate conversions.
Index: model/primitive.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcjx/model/Attic/primitive.hh,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 primitive.hh
--- model/primitive.hh 9 Oct 2005 20:08:03 -0000 1.1.2.3
+++ model/primitive.hh 11 Oct 2005 18:07:33 -0000
@@ -467,12 +467,25 @@
jvalue convert (const model_type *from_type, const jvalue &from_val)
{
- if (from_type == primitive_float_type)
- return convert_from_float<T, jfloat> (from_val, MIN, MAX);
- else if (from_type == primitive_double_type)
- return convert_from_float<T, jdouble> (from_val, MIN, MAX);
- else
- return model_primitive<T, sig_char>::convert (from_type, from_val);
+ if (from_type == primitive_float_type
+ || from_type == primitive_double_type)
+ {
+ if (this != primitive_int_type && this != primitive_long_type)
+ {
+ // Must use an intermediate cast.
+ model_primitive_base *mpb
+ = assert_cast<model_primitive_base *> (primitive_int_type);
+ jvalue inter = mpb->convert (from_type, from_val);
+ return convert (mpb, inter);
+ }
+
+ if (from_type == primitive_float_type)
+ return convert_from_float<T, jfloat> (from_val, MIN, MAX);
+ else
+ return convert_from_float<T, jdouble> (from_val, MIN, MAX);
+ }
+
+ return model_primitive<T, sig_char>::convert (from_type, from_val);
}
// This is out-of-line so we can specialize for jlong.
More information about the Java-patches
mailing list