2011-01-05 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / language.c
index 51a49f8ce32fa345b4992814e861c9d083f20677..374cdec7e4a0c28f3d547044798ce569975393d0 100644 (file)
@@ -1,7 +1,8 @@
 /* Multiple source language support for GDB.
 
    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+   Free Software Foundation, Inc.
 
    Contributed by the Department of Computer Science at the State University
    of New York at Buffalo.
@@ -63,7 +64,7 @@ static void unk_lang_emit_char (int c, struct type *type,
 static void unk_lang_printchar (int c, struct type *type,
                                struct ui_file *stream);
 
-static void unk_lang_print_type (struct type *, char *, struct ui_file *,
+static void unk_lang_print_type (struct type *, const char *, struct ui_file *,
                                 int, int);
 
 static int unk_lang_value_print (struct value *, struct ui_file *,
@@ -132,7 +133,8 @@ show_language_command (struct ui_file *file, int from_tty,
                        "\"auto; currently %s\".\n"),
                      current_language->la_name);
   else
-    fprintf_filtered (gdb_stdout, _("The current source language is \"%s\".\n"),
+    fprintf_filtered (gdb_stdout,
+                     _("The current source language is \"%s\".\n"),
                      current_language->la_name);
 
   flang = get_frame_language ();
@@ -361,7 +363,8 @@ show_case_command (struct ui_file *file, int from_tty,
                        tmp);
     }
   else
-    fprintf_filtered (gdb_stdout, _("Case sensitivity in name search is \"%s\".\n"),
+    fprintf_filtered (gdb_stdout,
+                     _("Case sensitivity in name search is \"%s\".\n"),
                      value);
 
   if (case_sensitivity != current_language->la_case_sensitivity)
@@ -485,6 +488,7 @@ binop_result_type (struct value *v1, struct value *v2)
     {
     case language_c:
     case language_cplus:
+    case language_d:
     case language_objc:
       if (TYPE_CODE (t1) == TYPE_CODE_FLT)
        return TYPE_CODE (t2) == TYPE_CODE_FLT && l2 > l1 ?
@@ -496,7 +500,8 @@ binop_result_type (struct value *v1, struct value *v2)
        return VALUE_TYPE (v1);
       else if (TYPE_UNSIGNED (t2) && l2 > l1)
        return VALUE_TYPE (v2);
-      else                     /* Both are signed.  Result is the longer type */
+      else                     /* Both are signed.  Result is the
+                                  longer type.  */
        return l1 > l2 ? VALUE_TYPE (v1) : VALUE_TYPE (v2);
       break;
     case language_m2:
@@ -574,7 +579,8 @@ int
 same_type (struct type *arg1, struct type *arg2)
 {
   CHECK_TYPEDEF (type);
-  if (structured_type (arg1) ? !structured_type (arg2) : structured_type (arg2))
+  if (structured_type (arg1)
+      ? !structured_type (arg2) : structured_type (arg2))
     /* One is structured and one isn't */
     return 0;
   else if (structured_type (arg1) && structured_type (arg2))
@@ -596,6 +602,7 @@ integral_type (struct type *type)
     {
     case language_c:
     case language_cplus:
+    case language_d:
     case language_objc:
       return (TYPE_CODE (type) != TYPE_CODE_INT) &&
        (TYPE_CODE (type) != TYPE_CODE_ENUM) ? 0 : 1;
@@ -636,6 +643,7 @@ character_type (struct type *type)
 
     case language_c:
     case language_cplus:
+    case language_d:
     case language_objc:
       return (TYPE_CODE (type) == TYPE_CODE_INT) &&
        TYPE_LENGTH (type) == sizeof (char)
@@ -658,6 +666,7 @@ string_type (struct type *type)
 
     case language_c:
     case language_cplus:
+    case language_d:
     case language_objc:
       /* C does not have distinct string type. */
       return (0);
@@ -677,6 +686,7 @@ boolean_type (struct type *type)
     {
     case language_c:
     case language_cplus:
+    case language_d:
     case language_objc:
       /* Might be more cleanly handled by having a
          TYPE_CODE_INT_NOT_BOOL for (the deleted) CHILL and such
@@ -696,6 +706,7 @@ float_type (struct type *type)
   CHECK_TYPEDEF (type);
   return TYPE_CODE (type) == TYPE_CODE_FLT;
 }
+#endif
 
 /* Returns non-zero if the value is a pointer type */
 int
@@ -705,6 +716,7 @@ pointer_type (struct type *type)
     TYPE_CODE (type) == TYPE_CODE_REF;
 }
 
+#if 0
 /* Returns non-zero if the value is a structured type */
 int
 structured_type (struct type *type)
@@ -714,6 +726,7 @@ structured_type (struct type *type)
     {
     case language_c:
     case language_cplus:
+    case language_d:
     case language_objc:
       return (TYPE_CODE (type) == TYPE_CODE_STRUCT) ||
        (TYPE_CODE (type) == TYPE_CODE_UNION) ||
@@ -764,8 +777,8 @@ void
 type_error (const char *string,...)
 {
   va_list args;
-  va_start (args, string);
 
+  va_start (args, string);
   switch (type_check)
     {
     case type_check_warn:
@@ -790,8 +803,8 @@ void
 range_error (const char *string,...)
 {
   va_list args;
-  va_start (args, string);
 
+  va_start (args, string);
   switch (range_check)
     {
     case range_check_warn:
@@ -891,9 +904,11 @@ add_language (const struct language_defn *lang)
 
   if (lang->la_magic != LANG_MAGIC)
     {
-      fprintf_unfiltered (gdb_stderr, "Magic number of %s language struct wrong\n",
+      fprintf_unfiltered (gdb_stderr,
+                         "Magic number of %s language struct wrong\n",
                          lang->la_name);
-      internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
+      internal_error (__FILE__, __LINE__,
+                     _("failed internal consistency check"));
     }
 
   if (!languages)
@@ -921,10 +936,10 @@ add_language (const struct language_defn *lang)
   /* Build the "help set language" docs.  */
   tmp_stream = mem_fileopen ();
 
-  fprintf_unfiltered (tmp_stream, _("\
-Set the current source language.\n\
-The currently understood settings are:\n\n\
-local or auto    Automatic setting based on source file\n"));
+  fprintf_unfiltered (tmp_stream,
+                     _("Set the current source language.\n"
+                       "The currently understood settings are:\n\nlocal or "
+                       "auto    Automatic setting based on source file\n"));
 
   for (i = 0; i < languages_size; ++i)
     {
@@ -949,9 +964,9 @@ local or auto    Automatic setting based on source file\n"));
   add_setshow_enum_cmd ("language", class_support,
                        (const char **) language_names,
                        &language,
-                       language_set_doc, _("\
-Show the current source language."), NULL,
-                       set_language_command,
+                       language_set_doc,
+                       _("Show the current source language."),
+                       NULL, set_language_command,
                        show_language_command,
                        &setlist, &showlist);
 
@@ -972,6 +987,7 @@ skip_language_trampoline (struct frame_info *frame, CORE_ADDR pc)
       if (languages[i]->skip_trampoline)
        {
          CORE_ADDR real_pc = (languages[i]->skip_trampoline) (frame, pc);
+
          if (real_pc)
            return real_pc;
        }
@@ -1000,7 +1016,8 @@ char *
 language_class_name_from_physname (const struct language_defn *current_language,
                                   const char *physname)
 {
-  if (current_language != NULL && current_language->la_class_name_from_physname)
+  if (current_language != NULL
+      && current_language->la_class_name_from_physname)
     return current_language->la_class_name_from_physname (physname);
   return NULL;
 }
@@ -1045,7 +1062,7 @@ default_print_array_index (struct value *index_value, struct ui_file *stream,
 
 void
 default_get_string (struct value *value, gdb_byte **buffer, int *length,
-                   const char **charset)
+                   struct type **char_type, const char **charset)
 {
   error (_("Getting a string is unsupported in this language."));
 }
@@ -1068,45 +1085,52 @@ static void
 unk_lang_emit_char (int c, struct type *type, struct ui_file *stream,
                    int quoter)
 {
-  error (_("internal error - unimplemented function unk_lang_emit_char called."));
+  error (_("internal error - unimplemented "
+          "function unk_lang_emit_char called."));
 }
 
 static void
 unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
 {
-  error (_("internal error - unimplemented function unk_lang_printchar called."));
+  error (_("internal error - unimplemented "
+          "function unk_lang_printchar called."));
 }
 
 static void
 unk_lang_printstr (struct ui_file *stream, struct type *type,
                   const gdb_byte *string, unsigned int length,
-                  int force_ellipses,
+                  const char *encoding, int force_ellipses,
                   const struct value_print_options *options)
 {
-  error (_("internal error - unimplemented function unk_lang_printstr called."));
+  error (_("internal error - unimplemented "
+          "function unk_lang_printstr called."));
 }
 
 static void
-unk_lang_print_type (struct type *type, char *varstring, struct ui_file *stream,
-                    int show, int level)
+unk_lang_print_type (struct type *type, const char *varstring,
+                    struct ui_file *stream, int show, int level)
 {
-  error (_("internal error - unimplemented function unk_lang_print_type called."));
+  error (_("internal error - unimplemented "
+          "function unk_lang_print_type called."));
 }
 
 static int
 unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
                    int embedded_offset, CORE_ADDR address,
                    struct ui_file *stream, int recurse,
+                   const struct value *val,
                    const struct value_print_options *options)
 {
-  error (_("internal error - unimplemented function unk_lang_val_print called."));
+  error (_("internal error - unimplemented "
+          "function unk_lang_val_print called."));
 }
 
 static int
 unk_lang_value_print (struct value *val, struct ui_file *stream,
                      const struct value_print_options *options)
 {
-  error (_("internal error - unimplemented function unk_lang_value_print called."));
+  error (_("internal error - unimplemented "
+          "function unk_lang_value_print called."));
 }
 
 static CORE_ADDR unk_lang_trampoline (struct frame_info *frame, CORE_ADDR pc)
@@ -1165,7 +1189,8 @@ const struct language_defn unknown_language_defn =
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   unk_lang_demangle,           /* Language specific symbol demangler */
-  unk_lang_class_name,         /* Language specific class_name_from_physname */
+  unk_lang_class_name,         /* Language specific
+                                  class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -1204,7 +1229,8 @@ const struct language_defn auto_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   unk_lang_demangle,           /* Language specific symbol demangler */
-  unk_lang_class_name,         /* Language specific class_name_from_physname */
+  unk_lang_class_name,         /* Language specific
+                                  class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -1242,7 +1268,8 @@ const struct language_defn local_language_defn =
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
   basic_lookup_transparent_type,/* lookup_transparent_type */
   unk_lang_demangle,           /* Language specific symbol demangler */
-  unk_lang_class_name,         /* Language specific class_name_from_physname */
+  unk_lang_class_name,         /* Language specific
+                                  class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -1289,6 +1316,7 @@ language_string_char_type (const struct language_defn *la,
 {
   struct language_gdbarch *ld = gdbarch_data (gdbarch,
                                              language_gdbarch_data);
+
   return ld->arch_info[la->la_language].string_char_type;
 }
 
@@ -1302,11 +1330,13 @@ language_bool_type (const struct language_defn *la,
   if (ld->arch_info[la->la_language].bool_type_symbol)
     {
       struct symbol *sym;
+
       sym = lookup_symbol (ld->arch_info[la->la_language].bool_type_symbol,
                           NULL, VAR_DOMAIN, NULL);
       if (sym)
        {
          struct type *type = SYMBOL_TYPE (sym);
+
          if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
            return type;
        }
@@ -1323,6 +1353,7 @@ language_lookup_primitive_type_by_name (const struct language_defn *la,
   struct language_gdbarch *ld = gdbarch_data (gdbarch,
                                              language_gdbarch_data);
   struct type *const *p;
+
   for (p = ld->arch_info[la->la_language].primitive_type_vector;
        (*p) != NULL;
        p++)
@@ -1361,18 +1392,18 @@ _initialize_language (void)
   add_alias_cmd ("c", "check", no_class, 1, &showlist);
   add_alias_cmd ("ch", "check", no_class, 1, &showlist);
 
-  add_setshow_enum_cmd ("type", class_support, type_or_range_names, &type, _("\
-Set type checking.  (on/warn/off/auto)"), _("\
-Show type checking.  (on/warn/off/auto)"), NULL,
-                       set_type_command,
+  add_setshow_enum_cmd ("type", class_support, type_or_range_names, &type,
+                       _("Set type checking.  (on/warn/off/auto)"),
+                       _("Show type checking.  (on/warn/off/auto)"),
+                       NULL, set_type_command,
                        show_type_command,
                        &setchecklist, &showchecklist);
 
   add_setshow_enum_cmd ("range", class_support, type_or_range_names,
-                       &range, _("\
-Set range checking.  (on/warn/off/auto)"), _("\
-Show range checking.  (on/warn/off/auto)"), NULL,
-                       set_range_command,
+                       &range,
+                       _("Set range checking.  (on/warn/off/auto)"),
+                       _("Show range checking.  (on/warn/off/auto)"),
+                       NULL, set_range_command,
                        show_range_command,
                        &setchecklist, &showchecklist);
 
This page took 0.030133 seconds and 4 git commands to generate.