Make fixed_point_type_base_type a method of struct type
authorJoel Brobecker <brobecker@adacore.com>
Tue, 24 Nov 2020 02:48:23 +0000 (21:48 -0500)
committerJoel Brobecker <brobecker@adacore.com>
Tue, 24 Nov 2020 02:48:23 +0000 (21:48 -0500)
As suggested by Simon, to logically connect this function to
the object it inspects.

Note that, logically, this method should be "const". Unfortunately,
the implementation iterates on struct type objects starting with "this",
and thus trying to declare the method "const" triggers a compilation
error.

gdb/ChangeLog:

        * gdbtypes.h (struct type) <fixed_point_type_base_type> New method,
        replacing the fixed_point_type_base_type function. All callers
        updated throughout this project.
        (fixed_point_type_base_type): Remove declaration.
        * gdbtypes.c (type::fixed_point_type_base_type): Replaces
        fixed_point_type_base_type.  Adjust implementation accordingly.

gdb/ChangeLog
gdb/ada-valprint.c
gdb/gdbtypes.c
gdb/gdbtypes.h
gdb/valprint.c
gdb/value.c

index 5e34c7ef440af1b5d7aa472043acb08f4319f2c0..3db63657919321c71b2cf92d846da44b7bfa074f 100644 (file)
@@ -1,3 +1,12 @@
+2020-11-24  Joel Brobecker  <brobecker@adacore.com>
+
+       * gdbtypes.h (struct type) <fixed_point_type_base_type> New method,
+       replacing the fixed_point_type_base_type function. All callers
+       updated throughout this project.
+       (fixed_point_type_base_type): Remove declaration.
+       * gdbtypes.c (type::fixed_point_type_base_type): Replaces
+       fixed_point_type_base_type.  Adjust implementation accordingly.
+
 2020-11-24  Joel Brobecker  <brobecker@adacore.com>
 
        * gdbtypes.h (struct type) <fixed_point_info, set_fixed_point_info>:
index 482069a3fb2124168e8c7f436805f254a8be4157..6ddb584d11c18f2bc5ac3929eabd22719563384c 100644 (file)
@@ -1028,7 +1028,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
     }
 
   if (is_fixed_point_type (type))
-    type = fixed_point_type_base_type (type);
+    type = type->fixed_point_type_base_type ();
 
   switch (type->code ())
     {
index f0d9c24fa34a8241049ea0c0e459cba35e9bd9ff..fa4e8f01f29e8f3ac3379644c77b8d787ff3b65b 100644 (file)
@@ -5866,8 +5866,10 @@ is_fixed_point_type (struct type *type)
 /* See gdbtypes.h.  */
 
 struct type *
-fixed_point_type_base_type (struct type *type)
+type::fixed_point_type_base_type ()
 {
+  struct type *type = this;
+
   while (check_typedef (type)->code () == TYPE_CODE_RANGE)
     type = TYPE_TARGET_TYPE (check_typedef (type));
   type = check_typedef (type);
@@ -5881,7 +5883,7 @@ fixed_point_type_base_type (struct type *type)
 const gdb_mpq &
 fixed_point_scaling_factor (struct type *type)
 {
-  type = fixed_point_type_base_type (type);
+  type = type->fixed_point_type_base_type ();
 
   return type->fixed_point_info ().scaling_factor;
 }
index c9d23437cd46bf0027a2895a91ff9629074fa7fc..88fb0e7a3936a877758eae4604c4ef260f6ec6a5 100644 (file)
@@ -1215,6 +1215,15 @@ struct type
     this->main_type->type_specific.fixed_point_info = info;
   }
 
+  /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
+
+     In other words, this returns the type after having peeled all
+     intermediate type layers (such as TYPE_CODE_RANGE, for instance).
+     The TYPE_CODE of the type returned is guaranteed to be
+     a TYPE_CODE_FIXED_POINT.  */
+
+  struct type *fixed_point_type_base_type ();
+
   /* * Return the dynamic property of the requested KIND from this type's
      list of dynamic properties.  */
   dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
@@ -2587,14 +2596,6 @@ extern int type_not_associated (const struct type *type);
    a range type whose base type is a TYPE_CODE_FIXED_POINT.  */
 extern bool is_fixed_point_type (struct type *type);
 
-/* Assuming that TYPE is a fixed point type, return its base type.
-
-   In other words, this returns the type after having peeled all
-   intermediate type layers (such as TYPE_CODE_RANGE, for instance).
-   The TYPE_CODE of the type returned is guaranteed to be
-   a TYPE_CODE_FIXED_POINT.  */
-extern struct type *fixed_point_type_base_type (struct type *type);
-
 /* Given TYPE, which is a fixed point type, return its scaling factor.  */
 extern const gdb_mpq &fixed_point_scaling_factor (struct type *type);
 
index f428eb595d502b9b818d94e7cd9d833e77eba961..6e9262e7f6398205457ded05fae100bbab46fa57 100644 (file)
@@ -871,7 +871,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
   type = check_typedef (type);
 
   if (is_fixed_point_type (type))
-    type = fixed_point_type_base_type (type);
+    type = type->fixed_point_type_base_type ();
 
   switch (type->code ())
     {
index a1226749eb9bb87b1e3ab4f9dad220048a3403e2..f6c1a36ac0f84d94a2bad81f040256d6838e7a8e 100644 (file)
@@ -2759,7 +2759,7 @@ LONGEST
 unpack_long (struct type *type, const gdb_byte *valaddr)
 {
   if (is_fixed_point_type (type))
-    type = fixed_point_type_base_type (type);
+    type = type->fixed_point_type_base_type ();
 
   enum bfd_endian byte_order = type_byte_order (type);
   enum type_code code = type->code ();
This page took 0.037318 seconds and 4 git commands to generate.