gdb: Convert language skip_trampoline field to a method
[deliverable/binutils-gdb.git] / gdb / f-lang.c
index 4f4e8aedc4155531f200f2689bd5a2094d549960..90a794ef4bab10a3c940e767777bd4e5d6e72147 100644 (file)
@@ -165,44 +165,6 @@ enum f_primitive_types {
   nr_f_primitive_types
 };
 
-static void
-f_language_arch_info (struct gdbarch *gdbarch,
-                     struct language_arch_info *lai)
-{
-  const struct builtin_f_type *builtin = builtin_f_type (gdbarch);
-
-  lai->string_char_type = builtin->builtin_character;
-  lai->primitive_type_vector
-    = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_f_primitive_types + 1,
-                              struct type *);
-
-  lai->primitive_type_vector [f_primitive_type_character]
-    = builtin->builtin_character;
-  lai->primitive_type_vector [f_primitive_type_logical]
-    = builtin->builtin_logical;
-  lai->primitive_type_vector [f_primitive_type_logical_s1]
-    = builtin->builtin_logical_s1;
-  lai->primitive_type_vector [f_primitive_type_logical_s2]
-    = builtin->builtin_logical_s2;
-  lai->primitive_type_vector [f_primitive_type_logical_s8]
-    = builtin->builtin_logical_s8;
-  lai->primitive_type_vector [f_primitive_type_real]
-    = builtin->builtin_real;
-  lai->primitive_type_vector [f_primitive_type_real_s8]
-    = builtin->builtin_real_s8;
-  lai->primitive_type_vector [f_primitive_type_real_s16]
-    = builtin->builtin_real_s16;
-  lai->primitive_type_vector [f_primitive_type_complex_s8]
-    = builtin->builtin_complex_s8;
-  lai->primitive_type_vector [f_primitive_type_complex_s16]
-    = builtin->builtin_complex_s16;
-  lai->primitive_type_vector [f_primitive_type_void]
-    = builtin->builtin_void;
-
-  lai->bool_type_symbol = "logical";
-  lai->bool_type_default = builtin->builtin_logical_s2;
-}
-
 /* Remove the modules separator :: from the default break list.  */
 
 static const char *
@@ -268,7 +230,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
       if (noside == EVAL_SKIP)
        return eval_skip_value (exp);
       type = value_type (arg1);
-      switch (TYPE_CODE (type))
+      switch (type->code ())
        {
        case TYPE_CODE_FLT:
          {
@@ -292,9 +254,9 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
       if (noside == EVAL_SKIP)
        return eval_skip_value (exp);
       type = value_type (arg1);
-      if (TYPE_CODE (type) != TYPE_CODE (value_type (arg2)))
+      if (type->code () != value_type (arg2)->code ())
        error (_("non-matching types for parameters to MOD ()"));
-      switch (TYPE_CODE (type))
+      switch (type->code ())
        {
        case TYPE_CODE_FLT:
          {
@@ -325,7 +287,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
        if (noside == EVAL_SKIP)
          return eval_skip_value (exp);
        type = value_type (arg1);
-       if (TYPE_CODE (type) != TYPE_CODE_FLT)
+       if (type->code () != TYPE_CODE_FLT)
          error (_("argument to CEILING must be of type float"));
        double val
          = target_float_to_host_double (value_contents (arg1),
@@ -340,7 +302,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
        if (noside == EVAL_SKIP)
          return eval_skip_value (exp);
        type = value_type (arg1);
-       if (TYPE_CODE (type) != TYPE_CODE_FLT)
+       if (type->code () != TYPE_CODE_FLT)
          error (_("argument to FLOOR must be of type float"));
        double val
          = target_float_to_host_double (value_contents (arg1),
@@ -356,10 +318,10 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
        if (noside == EVAL_SKIP)
          return eval_skip_value (exp);
        type = value_type (arg1);
-       if (TYPE_CODE (type) != TYPE_CODE (value_type (arg2)))
+       if (type->code () != value_type (arg2)->code ())
          error (_("non-matching types for parameters to MODULO ()"));
         /* MODULO(A, P) = A - FLOOR (A / P) * P */
-       switch (TYPE_CODE (type))
+       switch (type->code ())
          {
          case TYPE_CODE_INT:
            {
@@ -399,7 +361,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
       arg1 = evaluate_subexp (NULL, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
       type = value_type (arg1);
 
-      switch (TYPE_CODE (type))
+      switch (type->code ())
         {
           case TYPE_CODE_STRUCT:
           case TYPE_CODE_UNION:
@@ -412,7 +374,7 @@ evaluate_subexp_f (struct type *expect_type, struct expression *exp,
         return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
                                   TYPE_LENGTH (type));
       return value_from_longest (builtin_type (exp->gdbarch)->builtin_int,
-                                TYPE_LENGTH (TYPE_TARGET_TYPE(type)));
+                                TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
     }
 
   /* Should be unreachable.  */
@@ -425,9 +387,9 @@ static bool
 f_is_string_type_p (struct type *type)
 {
   type = check_typedef (type);
-  return (TYPE_CODE (type) == TYPE_CODE_STRING
-         || (TYPE_CODE (type) == TYPE_CODE_ARRAY
-             && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR));
+  return (type->code () == TYPE_CODE_STRING
+         || (type->code () == TYPE_CODE_ARRAY
+             && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR));
 }
 
 /* Special expression lengths for Fortran.  */
@@ -628,7 +590,9 @@ static const struct exp_descriptor exp_descriptor_f =
   evaluate_subexp_f
 };
 
-extern const struct language_defn f_language_defn =
+/* Constant data that describes the Fortran language.  */
+
+extern const struct language_data f_language_data =
 {
   "fortran",
   "Fortran",
@@ -644,25 +608,12 @@ extern const struct language_defn f_language_defn =
   f_printchar,                 /* Print character constant */
   f_printstr,                  /* function to print string constant */
   f_emit_char,                 /* Function to print a single character */
-  f_print_type,                        /* Print a type using appropriate syntax */
   f_print_typedef,             /* Print a typedef using appropriate syntax */
-  f_val_print,                 /* Print a value using appropriate syntax */
-  nullptr,                     /* la_value_print_inner */
+  f_value_print_innner,                /* la_value_print_inner */
   c_value_print,               /* FIXME */
-  default_read_var_value,      /* la_read_var_value */
-  NULL,                                /* Language specific skip_trampoline */
   NULL,                        /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
-  basic_lookup_transparent_type,/* lookup_transparent_type */
-
-  /* We could support demangling here to provide module namespaces
-     also for inferiors with only minimal symbol table (ELF symbols).
-     Just the mangling standard is not standardized across compilers
-     and there is no DW_AT_producer available for inferiors with only
-     the ELF symbols to check the mangling kind.  */
-  NULL,                                /* Language specific symbol demangler */
-  NULL,
   NULL,                                /* Language specific
                                   class_name_from_physname */
   f_op_print_tab,              /* expression operators for printing */
@@ -670,20 +621,93 @@ extern const struct language_defn f_language_defn =
   1,                           /* String lower bound */
   f_word_break_characters,
   f_collect_symbol_completion_matches,
-  f_language_arch_info,
-  default_print_array_index,
-  default_pass_by_reference,
   c_watch_location_expression,
   cp_get_symbol_name_matcher,  /* la_get_symbol_name_matcher */
-  iterate_over_symbols,
-  cp_search_name_hash,
   &default_varobj_ops,
   NULL,
-  NULL,
   f_is_string_type_p,
   "(...)"                      /* la_struct_too_deep_ellipsis */
 };
 
+/* Class representing the Fortran language.  */
+
+class f_language : public language_defn
+{
+public:
+  f_language ()
+    : language_defn (language_fortran, f_language_data)
+  { /* Nothing.  */ }
+
+  /* See language.h.  */
+  void language_arch_info (struct gdbarch *gdbarch,
+                          struct language_arch_info *lai) const override
+  {
+    const struct builtin_f_type *builtin = builtin_f_type (gdbarch);
+
+    lai->string_char_type = builtin->builtin_character;
+    lai->primitive_type_vector
+      = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_f_primitive_types + 1,
+                               struct type *);
+
+    lai->primitive_type_vector [f_primitive_type_character]
+      = builtin->builtin_character;
+    lai->primitive_type_vector [f_primitive_type_logical]
+      = builtin->builtin_logical;
+    lai->primitive_type_vector [f_primitive_type_logical_s1]
+      = builtin->builtin_logical_s1;
+    lai->primitive_type_vector [f_primitive_type_logical_s2]
+      = builtin->builtin_logical_s2;
+    lai->primitive_type_vector [f_primitive_type_logical_s8]
+      = builtin->builtin_logical_s8;
+    lai->primitive_type_vector [f_primitive_type_real]
+      = builtin->builtin_real;
+    lai->primitive_type_vector [f_primitive_type_real_s8]
+      = builtin->builtin_real_s8;
+    lai->primitive_type_vector [f_primitive_type_real_s16]
+      = builtin->builtin_real_s16;
+    lai->primitive_type_vector [f_primitive_type_complex_s8]
+      = builtin->builtin_complex_s8;
+    lai->primitive_type_vector [f_primitive_type_complex_s16]
+      = builtin->builtin_complex_s16;
+    lai->primitive_type_vector [f_primitive_type_void]
+      = builtin->builtin_void;
+
+    lai->bool_type_symbol = "logical";
+    lai->bool_type_default = builtin->builtin_logical_s2;
+  }
+
+  /* See language.h.  */
+  unsigned int search_name_hash (const char *name) const override
+  {
+    return cp_search_name_hash (name);
+  }
+
+  /* See language.h.  */
+
+  char *demangle (const char *mangled, int options) const override
+  {
+      /* We could support demangling here to provide module namespaces
+        also for inferiors with only minimal symbol table (ELF symbols).
+        Just the mangling standard is not standardized across compilers
+        and there is no DW_AT_producer available for inferiors with only
+        the ELF symbols to check the mangling kind.  */
+    return nullptr;
+  }
+
+  /* See language.h.  */
+
+  void print_type (struct type *type, const char *varstring,
+                  struct ui_file *stream, int show, int level,
+                  const struct type_print_options *flags) const override
+  {
+    f_print_type (type, varstring, stream, show, level, flags);
+  }
+};
+
+/* Single instance of the Fortran language class.  */
+
+static f_language f_language_defn;
+
 static void *
 build_fortran_types (struct gdbarch *gdbarch)
 {
@@ -742,14 +766,16 @@ build_fortran_types (struct gdbarch *gdbarch)
       = arch_type (gdbarch, TYPE_CODE_ERROR, 128, "real*16");
 
   builtin_f_type->builtin_complex_s8
-    = arch_complex_type (gdbarch, "complex*8",
-                        builtin_f_type->builtin_real);
+    = init_complex_type ("complex*8", builtin_f_type->builtin_real);
   builtin_f_type->builtin_complex_s16
-    = arch_complex_type (gdbarch, "complex*16",
-                        builtin_f_type->builtin_real_s8);
-  builtin_f_type->builtin_complex_s32
-    = arch_complex_type (gdbarch, "complex*32",
-                        builtin_f_type->builtin_real_s16);
+    = init_complex_type ("complex*16", builtin_f_type->builtin_real_s8);
+
+  if (builtin_f_type->builtin_real_s16->code () == TYPE_CODE_ERROR)
+    builtin_f_type->builtin_complex_s32
+      = arch_type (gdbarch, TYPE_CODE_ERROR, 256, "complex*32");
+  else
+    builtin_f_type->builtin_complex_s32
+      = init_complex_type ("complex*32", builtin_f_type->builtin_real_s16);
 
   return builtin_f_type;
 }
@@ -801,7 +827,7 @@ fortran_argument_convert (struct value *value, bool is_artificial)
 struct type *
 fortran_preserve_arg_pointer (struct value *arg, struct type *type)
 {
-  if (TYPE_CODE (value_type (arg)) == TYPE_CODE_PTR)
+  if (value_type (arg)->code () == TYPE_CODE_PTR)
     return value_type (arg);
   return type;
 }
This page took 0.136435 seconds and 4 git commands to generate.