This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc][16/37] Eliminate builtin_type_ macros: Ada fixed/double conversions


Hello,

ada-lang.c uses builtin_type_double as intermediate type in some
type conversions.  This doesn't seem to be necessary, as the
value_as_double and value_from_double routines should be able
to handle the same types directly ...

Bye,
Ulrich

ChangeLog:

	* ada-lang.c (cast_to_fixed): Do not cast to builtin_type_double.
	(cast_from_fixed_to_double): Rename to ...
	(cast_from_fixed): ... this.  Add TYPE parameter.  Use it instead
	of builtin_type_double.
	(ada_value_cast): Use cast_from_fixed instead of casting result
	of cast_from_fixed_to_double.
	(ada_evaluate_subexp): Update calls to cast_from_fixed_to_double. 


Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -7944,8 +7944,7 @@ cast_to_fixed (struct type *type, struct
                                                   value_as_long (arg)));
   else
     {
-      DOUBLEST argd =
-        value_as_double (value_cast (builtin_type_double, value_copy (arg)));
+      DOUBLEST argd = value_as_double (arg);
       val = ada_float_to_fixed (type, argd);
     }
 
@@ -7953,11 +7952,11 @@ cast_to_fixed (struct type *type, struct
 }
 
 static struct value *
-cast_from_fixed_to_double (struct value *arg)
+cast_from_fixed (struct type *type, struct value *arg)
 {
   DOUBLEST val = ada_fixed_to_float (value_type (arg),
                                      value_as_long (arg));
-  return value_from_double (builtin_type_double, val);
+  return value_from_double (type, val);
 }
 
 /* Coerce VAL as necessary for assignment to an lval of type TYPE, and
@@ -8411,7 +8410,7 @@ ada_value_cast (struct type *type, struc
     return (cast_to_fixed (type, arg2));
 
   if (ada_is_fixed_point_type (value_type (arg2)))
-    return value_cast (type, cast_from_fixed_to_double (arg2));
+    return cast_from_fixed (type, arg2);
 
   return value_cast (type, arg2);
 }
@@ -8553,10 +8552,11 @@ ada_evaluate_subexp (struct type *expect
         return value_zero (value_type (arg1), not_lval);
       else
         {
+          type = builtin_type (exp->gdbarch)->builtin_double;
           if (ada_is_fixed_point_type (value_type (arg1)))
-            arg1 = cast_from_fixed_to_double (arg1);
+            arg1 = cast_from_fixed (type, arg1);
           if (ada_is_fixed_point_type (value_type (arg2)))
-            arg2 = cast_from_fixed_to_double (arg2);
+            arg2 = cast_from_fixed (type, arg2);
           binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
           return ada_value_binop (arg1, arg2, op);
         }

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]