Change get_objfile_arch to a method on objfile
[deliverable/binutils-gdb.git] / gdb / valops.c
index e3fc2dc42e159eb0041279a7c52aef19d15c8296..04cf22cced138975ed58c56fd3ef58bd27ddae80 100644 (file)
@@ -1,6 +1,6 @@
 /* Perform non-arithmetic operations on values, for GDB.
 
-   Copyright (C) 1986-2019 Free Software Foundation, Inc.
+   Copyright (C) 1986-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -139,7 +139,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
       if (msymbol.minsym != NULL)
        {
          struct objfile *objfile = msymbol.objfile;
-         struct gdbarch *gdbarch = get_objfile_arch (objfile);
+         struct gdbarch *gdbarch = objfile->arch ();
 
          struct type *type;
          CORE_ADDR maddr;
@@ -175,7 +175,7 @@ value_allocate_space_in_inferior (int len)
 {
   struct objfile *objf;
   struct value *val = find_function_in_inferior ("malloc", &objf);
-  struct gdbarch *gdbarch = get_objfile_arch (objf);
+  struct gdbarch *gdbarch = objf->arch ();
   struct value *blocklen;
 
   blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
@@ -3854,14 +3854,10 @@ value_slice (struct value *array, int lowbound, int length)
   return slice;
 }
 
-/* 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  */
+/* See value.h.  */
 
 struct value *
-value_literal_complex (struct value *arg1, 
+value_literal_complex (struct value *arg1,
                       struct value *arg2,
                       struct type *type)
 {
@@ -3879,6 +3875,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 +3930,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.026836 seconds and 4 git commands to generate.