Add accessors for members of complex numbers
[deliverable/binutils-gdb.git] / gdb / valops.c
index d48474665c3dfa2823b49142cb55c2f2cad6e1c9..83fd2584b597475bc8a24646cbc6656f3c7d8d8b 100644 (file)
@@ -3877,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 *
This page took 0.025438 seconds and 4 git commands to generate.