Change how complex types are printed in C
[deliverable/binutils-gdb.git] / gdb / valops.c
index 8488576ef810cd3352151d797bd7d4573030d224..83fd2584b597475bc8a24646cbc6656f3c7d8d8b 100644 (file)
@@ -3856,9 +3856,7 @@ value_slice (struct value *array, int lowbound, int length)
 
 /* Create a value for a FORTRAN complex number.  Currently most of the
    time values are coerced to COMPLEX*16 (i.e. a complex number
-   composed of 2 doubles.  This really should be a smarter routine
-   that figures out precision intelligently as opposed to assuming
-   doubles.  FIXME: fmb  */
+   composed of 2 doubles.  */
 
 struct value *
 value_literal_complex (struct value *arg1, 
@@ -3879,6 +3877,31 @@ value_literal_complex (struct value *arg1,
   return val;
 }
 
+/* See value.h.  */
+
+struct value *
+value_real_part (struct value *value)
+{
+  struct type *type = check_typedef (value_type (value));
+  struct type *ttype = TYPE_TARGET_TYPE (type);
+
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_COMPLEX);
+  return value_from_component (value, ttype, 0);
+}
+
+/* See value.h.  */
+
+struct value *
+value_imaginary_part (struct value *value)
+{
+  struct type *type = check_typedef (value_type (value));
+  struct type *ttype = TYPE_TARGET_TYPE (type);
+
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_COMPLEX);
+  return value_from_component (value, ttype,
+                              TYPE_LENGTH (check_typedef (ttype)));
+}
+
 /* Cast a value into the appropriate complex data type.  */
 
 static struct value *
@@ -3909,8 +3932,9 @@ cast_into_complex (struct type *type, struct value *val)
     error (_("cannot cast non-number to complex"));
 }
 
+void _initialize_valops ();
 void
-_initialize_valops (void)
+_initialize_valops ()
 {
   add_setshow_boolean_cmd ("overload-resolution", class_support,
                           &overload_resolution, _("\
This page took 0.024265 seconds and 4 git commands to generate.