Decode properly flags of %ccr register on sparc64.
[deliverable/binutils-gdb.git] / gdb / rust-lang.c
index a483b96125d796608d4e29f4a080c9fdb3d55b08..4977b0a1aa3f04b18e8e6179915b9898156cb75e 100644 (file)
@@ -124,7 +124,6 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
   struct disr_info ret;
   struct type *disr_type;
   struct value_print_options opts;
-  struct cleanup *cleanup;
   const char *name_segment;
 
   get_no_prettyformat_print_options (&opts);
@@ -272,7 +271,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
 
 /* See rust-lang.h.  */
 
-int
+bool
 rust_tuple_type_p (struct type *type)
 {
   /* The current implementation is a bit of a hack, but there's
@@ -287,7 +286,7 @@ rust_tuple_type_p (struct type *type)
 /* Return true if all non-static fields of a structlike type are in a
    sequence like __0, __1, __2.  OFFSET lets us skip fields.  */
 
-static int
+static bool
 rust_underscore_fields (struct type *type, int offset)
 {
   int i, field_number;
@@ -295,7 +294,7 @@ rust_underscore_fields (struct type *type, int offset)
   field_number = 0;
 
   if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
-    return 0;
+    return false;
   for (i = 0; i < TYPE_NFIELDS (type); ++i)
     {
       if (!field_is_static (&TYPE_FIELD (type, i)))
@@ -308,17 +307,17 @@ rust_underscore_fields (struct type *type, int offset)
 
              xsnprintf (buf, sizeof (buf), "__%d", field_number);
              if (strcmp (buf, TYPE_FIELD_NAME (type, i)) != 0)
-               return 0;
+               return false;
              field_number++;
            }
        }
     }
-  return 1;
+  return true;
 }
 
 /* See rust-lang.h.  */
 
-int
+bool
 rust_tuple_struct_type_p (struct type *type)
 {
   /* This is just an approximation until DWARF can represent Rust more
@@ -329,7 +328,7 @@ rust_tuple_struct_type_p (struct type *type)
 
 /* Return true if a variant TYPE is a tuple variant, false otherwise.  */
 
-static int
+static bool
 rust_tuple_variant_type_p (struct type *type)
 {
   /* First field is discriminant */
@@ -338,7 +337,7 @@ rust_tuple_variant_type_p (struct type *type)
 
 /* Return true if TYPE is a slice type, otherwise false.  */
 
-static int
+static bool
 rust_slice_type_p (struct type *type)
 {
   return (TYPE_CODE (type) == TYPE_CODE_STRUCT
@@ -348,7 +347,7 @@ rust_slice_type_p (struct type *type)
 
 /* Return true if TYPE is a range type, otherwise false.  */
 
-static int
+static bool
 rust_range_type_p (struct type *type)
 {
   int i;
@@ -357,22 +356,22 @@ rust_range_type_p (struct type *type)
       || TYPE_NFIELDS (type) > 2
       || TYPE_TAG_NAME (type) == NULL
       || strstr (TYPE_TAG_NAME (type), "::Range") == NULL)
-    return 0;
+    return false;
 
   if (TYPE_NFIELDS (type) == 0)
-    return 1;
+    return true;
 
   i = 0;
   if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
     {
       if (TYPE_NFIELDS (type) == 1)
-       return 1;
+       return true;
       i = 1;
     }
   else if (TYPE_NFIELDS (type) == 2)
     {
       /* First field had to be "start".  */
-      return 0;
+      return false;
     }
 
   return strcmp (TYPE_FIELD_NAME (type, i), "end") == 0;
@@ -380,7 +379,7 @@ rust_range_type_p (struct type *type)
 
 /* Return true if TYPE seems to be the type "u8", otherwise false.  */
 
-static int
+static bool
 rust_u8_type_p (struct type *type)
 {
   return (TYPE_CODE (type) == TYPE_CODE_INT
@@ -390,7 +389,7 @@ rust_u8_type_p (struct type *type)
 
 /* Return true if TYPE is a Rust character type.  */
 
-static int
+static bool
 rust_chartype_p (struct type *type)
 {
   return (TYPE_CODE (type) == TYPE_CODE_CHAR
@@ -479,8 +478,8 @@ val_print_struct (struct type *type, int embedded_offset,
 {
   int i;
   int first_field;
-  int is_tuple = rust_tuple_type_p (type);
-  int is_tuple_struct = !is_tuple && rust_tuple_struct_type_p (type);
+  bool is_tuple = rust_tuple_type_p (type);
+  bool is_tuple_struct = !is_tuple && rust_tuple_struct_type_p (type);
   struct value_print_options opts;
 
   if (!is_tuple)
@@ -763,7 +762,8 @@ rust_print_struct_def (struct type *type, const char *varstring,
                       struct ui_file *stream, int show, int level,
                       const struct type_print_options *flags)
 {
-  int is_tuple_struct, i;
+  bool is_tuple_struct;
+  int i;
 
   /* Print a tuple type simply.  */
   if (rust_tuple_type_p (type))
@@ -976,6 +976,8 @@ rust_print_type (struct type *type, const char *varstring,
                skip_to = 0;
              }
          }
+       else if (TYPE_NFIELDS (type) == 1)
+         skip_to = 0;
 
        for (i = 0; i < TYPE_NFIELDS (type); ++i)
          {
@@ -988,7 +990,9 @@ rust_print_type (struct type *type, const char *varstring,
            if (TYPE_NFIELDS (variant_type) > skip_to)
              {
                int first = 1;
-               int is_tuple = rust_tuple_variant_type_p (variant_type);
+               bool is_tuple = (TYPE_NFIELDS (type) == 1
+                                ? rust_tuple_struct_type_p (variant_type)
+                                : rust_tuple_variant_type_p (variant_type));
                int j;
 
                fputs_filtered (is_tuple ? "(" : "{", stream);
This page took 0.02561 seconds and 4 git commands to generate.