return &exp_descriptor_standard;
}
-/* Return true if TYPE is a string type, otherwise return false. This
- default implementation only detects TYPE_CODE_STRING. */
+/* Parent class for both the "auto" and "unknown" languages. These two
+ pseudo-languages are very similar so merging their implementations like
+ this makes sense. */
-static bool
-default_is_string_type_p (struct type *type)
-{
- type = check_typedef (type);
- while (type->code () == TYPE_CODE_REF)
- {
- type = TYPE_TARGET_TYPE (type);
- type = check_typedef (type);
- }
- return (type->code () == TYPE_CODE_STRING);
-}
-
-static const struct op_print unk_op_print_tab[] =
-{
- {NULL, OP_NULL, PREC_NULL, 0}
-};
-
-static void
-unknown_language_arch_info (struct gdbarch *gdbarch,
- struct language_arch_info *lai)
-{
- lai->string_char_type = builtin_type (gdbarch)->builtin_char;
- lai->bool_type_default = builtin_type (gdbarch)->builtin_int;
- lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1,
- struct type *);
-}
-
-/* Class representing the unknown language. */
-
-class unknown_language : public language_defn
+class auto_or_unknown_language : public language_defn
{
public:
- unknown_language ()
- : language_defn (language_unknown)
+ auto_or_unknown_language (enum language lang)
+ : language_defn (lang)
{ /* Nothing. */ }
- /* See language.h. */
-
- const char *name () const override
- { return "unknown"; }
-
- /* See language.h. */
-
- const char *natural_name () const override
- { return "Unknown"; }
-
/* See language.h. */
void language_arch_info (struct gdbarch *gdbarch,
struct language_arch_info *lai) const override
{
- unknown_language_arch_info (gdbarch, lai);
+ lai->string_char_type = builtin_type (gdbarch)->builtin_char;
+ lai->bool_type_default = builtin_type (gdbarch)->builtin_int;
+ lai->primitive_type_vector = GDBARCH_OBSTACK_CALLOC (gdbarch, 1,
+ struct type *);
}
/* See language.h. */
struct ui_file *stream, int show, int level,
const struct type_print_options *flags) const override
{
- error (_("unimplemented unknown_language::print_type called"));
+ error (_("type printing not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
char *demangle (const char *mangled, int options) const override
{
- /* The unknown language just uses the C++ demangler. */
+ /* The auto language just uses the C++ demangler. */
return gdb_demangle (mangled, options);
}
void value_print (struct value *val, struct ui_file *stream,
const struct value_print_options *options) const override
{
- error (_("unimplemented unknown_language::value_print called"));
+ error (_("value printing not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
(struct value *val, struct ui_file *stream, int recurse,
const struct value_print_options *options) const override
{
- error (_("unimplemented unknown_language::value_print_inner called"));
+ error (_("inner value printing not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
void emitchar (int ch, struct type *chtype,
struct ui_file *stream, int quoter) const override
{
- error (_("unimplemented unknown_language::emitchar called"));
+ error (_("emit character not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
void printchar (int ch, struct type *chtype,
struct ui_file *stream) const override
{
- error (_("unimplemented unknown_language::printchar called"));
+ error (_("print character not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
const char *encoding, int force_ellipses,
const struct value_print_options *options) const override
{
- error (_("unimplemented unknown_language::printstr called"));
+ error (_("print string not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
void print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream) const override
{
- error (_("unimplemented unknown_language::print_typedef called"));
+ error (_("print typedef not implemented for language \"%s\""),
+ natural_name ());
}
/* See language.h. */
bool is_string_type_p (struct type *type) const override
{
- return default_is_string_type_p (type);
+ type = check_typedef (type);
+ while (type->code () == TYPE_CODE_REF)
+ {
+ type = TYPE_TARGET_TYPE (type);
+ type = check_typedef (type);
+ }
+ return (type->code () == TYPE_CODE_STRING);
}
/* See language.h. */
/* See language.h. */
- bool store_sym_names_in_linkage_form_p () const override
- { return true; }
-
- /* See language.h. */
-
const struct op_print *opcode_print_table () const override
- { return unk_op_print_tab; }
-};
-
-/* Single instance of the unknown language class. */
+ {
+ static const struct op_print unk_op_print_tab[] =
+ {
+ {NULL, OP_NULL, PREC_NULL, 0}
+ };
-static unknown_language unknown_language_defn;
+ return unk_op_print_tab;
+ }
+};
/* Class representing the fake "auto" language. */
-class auto_language : public language_defn
+class auto_language : public auto_or_unknown_language
{
public:
auto_language ()
- : language_defn (language_auto)
+ : auto_or_unknown_language (language_auto)
{ /* Nothing. */ }
/* See language.h. */
const char *natural_name () const override
{ return "Auto"; }
+};
- /* See language.h. */
- void language_arch_info (struct gdbarch *gdbarch,
- struct language_arch_info *lai) const override
- {
- unknown_language_arch_info (gdbarch, lai);
- }
-
- /* 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
- {
- error (_("unimplemented auto_language::print_type called"));
- }
-
- /* See language.h. */
-
- char *demangle (const char *mangled, int options) const override
- {
- /* The auto language just uses the C++ demangler. */
- return gdb_demangle (mangled, options);
- }
-
- /* See language.h. */
-
- void value_print (struct value *val, struct ui_file *stream,
- const struct value_print_options *options) const override
- {
- error (_("unimplemented auto_language::value_print called"));
- }
-
- /* See language.h. */
-
- void value_print_inner
- (struct value *val, struct ui_file *stream, int recurse,
- const struct value_print_options *options) const override
- {
- error (_("unimplemented auto_language::value_print_inner called"));
- }
-
- /* See language.h. */
-
- int parser (struct parser_state *ps) const override
- {
- /* No parsing is done, just claim success. */
- return 1;
- }
-
- /* See language.h. */
-
- void emitchar (int ch, struct type *chtype,
- struct ui_file *stream, int quoter) const override
- {
- error (_("unimplemented auto_language::emitchar called"));
- }
-
- /* See language.h. */
-
- void printchar (int ch, struct type *chtype,
- struct ui_file *stream) const override
- {
- error (_("unimplemented auto_language::printchar called"));
- }
-
- /* See language.h. */
+/* Single instance of the fake "auto" language. */
- void printstr (struct ui_file *stream, struct type *elttype,
- const gdb_byte *string, unsigned int length,
- const char *encoding, int force_ellipses,
- const struct value_print_options *options) const override
- {
- error (_("unimplemented auto_language::printstr called"));
- }
+static auto_language auto_language_defn;
- /* See language.h. */
+/* Class representing the unknown language. */
- void print_typedef (struct type *type, struct symbol *new_symbol,
- struct ui_file *stream) const override
- {
- error (_("unimplemented auto_language::print_typedef called"));
- }
+class unknown_language : public auto_or_unknown_language
+{
+public:
+ unknown_language ()
+ : auto_or_unknown_language (language_unknown)
+ { /* Nothing. */ }
/* See language.h. */
- bool is_string_type_p (struct type *type) const override
- {
- return default_is_string_type_p (type);
- }
+ const char *name () const override
+ { return "unknown"; }
/* See language.h. */
- const char *name_of_this () const override
- { return "this"; }
+ const char *natural_name () const override
+ { return "Unknown"; }
/* See language.h. */
- const struct op_print *opcode_print_table () const override
- { return unk_op_print_tab; }
+ bool store_sym_names_in_linkage_form_p () const override
+ { return true; }
};
-/* Single instance of the fake "auto" language. */
+/* Single instance of the unknown language class. */
-static auto_language auto_language_defn;
+static unknown_language unknown_language_defn;
\f
/* Per-architecture language information. */