diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-09-16 16:27:30 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-10-23 10:57:14 +0100 |
commit | 1a0ea39913588b4e7ae47e384683784314fca8fe (patch) | |
tree | eaacbc454afff822ae1f7495b6bc16532ce2de90 /gdb/f-lang.h | |
parent | 88cefd9be076ea1f66b933be484d82f200b0f6c3 (diff) | |
download | gdb-1a0ea39913588b4e7ae47e384683784314fca8fe.zip gdb-1a0ea39913588b4e7ae47e384683784314fca8fe.tar.gz gdb-1a0ea39913588b4e7ae47e384683784314fca8fe.tar.bz2 |
gdb: move f_language class into a header file
Moves the f_language class from f-lang.c into f-lang.h. The benefit
of this is that functions declared in other f-*.c files can become
member functions without having to go through a level of indirection.
Some additional support functions have now become private member
functions of the f_language class, these are mostly functions that
then called some other function that was itself a member of the
language_defn class hierarchy.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* f-exp.y (f_parse): Rename to...
(f_language::parser): ...this.
* f-lang.c (f_get_encoding): Rename to...
(f_language::get_encoding): ...this.
(f_op_print_tab): Rename to...
(f_language::op_print_tab): ...this.
(exp_descriptor_f): Rename to...
(f_language::exp_descriptor_tab): ...this.
(class f_language): Moved to f-lang.h.
(f_language::language_arch_info): New function, moved out of class
declaration.
(f_language::search_name_hash): Likewise.
(f_language::lookup_symbol_nonlocal): Likewise.
(f_language::get_symbol_name_matcher_inner): Likewise.
* f-lang.h: Add 'valprint.h' include.
(class f_language): Moved here from f-lang.c.
* f-typeprint.c (f_type_print_args): Delete commented out
declaration.
(f_print_typedef): Rename to...
(f_language::print_typedef): ...this.
(f_print_type): Rename to...
(f_language::print_type): ...this.
(f_type_print_varspec_prefix): Delete declaration and rename to...
(f_language::f_type_print_varspec_prefix): ...this.
(f_type_print_varspec_suffix): Delete declaration and rename to...
(f_language::f_type_print_varspec_suffix): ...this.
(f_type_print_base): Delete declaration and rename to...
(f_language::f_type_print_base): ...this.
* f-valprint.c (f_value_print_inner): Rename to...
(f_language::value_print_inner): ...this.
* parse.c: Delete 'f-lang.h' include.
Diffstat (limited to 'gdb/f-lang.h')
-rw-r--r-- | gdb/f-lang.h | 272 |
1 files changed, 262 insertions, 10 deletions
diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 4710b14..e59fdef 100644 --- a/gdb/f-lang.h +++ b/gdb/f-lang.h @@ -23,24 +23,276 @@ #ifndef F_LANG_H #define F_LANG_H +#include "valprint.h" + struct type_print_options; struct parser_state; -extern int f_parse (struct parser_state *); +/* Class representing the Fortran language. */ + +class f_language : public language_defn +{ +public: + f_language () + : language_defn (language_fortran) + { /* Nothing. */ } + + /* See language.h. */ + + const char *name () const override + { return "fortran"; } + + /* See language.h. */ + + const char *natural_name () const override + { return "Fortran"; } + + /* See language.h. */ + + const std::vector<const char *> &filename_extensions () const override + { + static const std::vector<const char *> extensions = { + ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP", + ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08" + }; + return extensions; + } + + /* See language.h. */ + void language_arch_info (struct gdbarch *gdbarch, + struct language_arch_info *lai) const override; + + /* See language.h. */ + unsigned int search_name_hash (const char *name) const override; + + /* See language.h. */ + + char *demangle_symbol (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; + + /* See language.h. This just returns default set of word break + characters but with the modules separator `::' removed. */ + + const char *word_break_characters (void) const override + { + static char *retval; + + if (!retval) + { + char *s; + + retval = xstrdup (language_defn::word_break_characters ()); + s = strchr (retval, ':'); + if (s) + { + char *last_char = &s[strlen (s) - 1]; + + *s = *last_char; + *last_char = 0; + } + } + return retval; + } + + + /* See language.h. */ + + void collect_symbol_completion_matches (completion_tracker &tracker, + complete_symbol_mode mode, + symbol_name_match_type name_match_type, + const char *text, const char *word, + enum type_code code) const override + { + /* Consider the modules separator :: as a valid symbol name character + class. */ + default_collect_symbol_completion_matches_break_on (tracker, mode, + name_match_type, + text, word, ":", + code); + } + + /* See language.h. */ + + void value_print_inner + (struct value *val, struct ui_file *stream, int recurse, + const struct value_print_options *options) const override; + + /* See language.h. */ + + struct block_symbol lookup_symbol_nonlocal + (const char *name, const struct block *block, + const domain_enum domain) const override; + + /* See language.h. */ + + int parser (struct parser_state *ps) const override; + + /* See language.h. */ + + void emitchar (int ch, struct type *chtype, + struct ui_file *stream, int quoter) const override + { + const char *encoding = get_encoding (chtype); + generic_emit_char (ch, chtype, stream, quoter, encoding); + } + + /* See language.h. */ + + void printchar (int ch, struct type *chtype, + struct ui_file *stream) const override + { + fputs_filtered ("'", stream); + LA_EMIT_CHAR (ch, chtype, stream, '\''); + fputs_filtered ("'", stream); + } + + /* See language.h. */ + + 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 + { + const char *type_encoding = get_encoding (elttype); + + if (TYPE_LENGTH (elttype) == 4) + fputs_filtered ("4_", stream); + + if (!encoding || !*encoding) + encoding = type_encoding; + + generic_printstr (stream, elttype, string, length, encoding, + force_ellipses, '\'', 0, options); + } -/* Implement the la_print_typedef language method for Fortran. */ + /* See language.h. */ -extern void f_print_typedef (struct type *type, struct symbol *new_symbol, - struct ui_file *stream); + void print_typedef (struct type *type, struct symbol *new_symbol, + struct ui_file *stream) const override; -extern void f_print_type (struct type *, const char *, struct ui_file *, int, - int, const struct type_print_options *); + /* See language.h. */ -/* Implement la_value_print_inner for Fortran. */ + bool is_string_type_p (struct type *type) const override + { + type = check_typedef (type); + return (type->code () == TYPE_CODE_STRING + || (type->code () == TYPE_CODE_ARRAY + && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_CHAR)); + } -extern void f_value_print_inner (struct value *val, struct ui_file *stream, - int recurse, - const struct value_print_options *options); + /* See language.h. */ + + const char *struct_too_deep_ellipsis () const override + { return "(...)"; } + + /* See language.h. */ + + bool c_style_arrays_p () const override + { return false; } + + /* See language.h. */ + + bool range_checking_on_by_default () const override + { return true; } + + /* See language.h. */ + + enum case_sensitivity case_sensitivity () const override + { return case_sensitive_off; } + + /* See language.h. */ + + enum array_ordering array_ordering () const override + { return array_column_major; } + + /* See language.h. */ + + const struct exp_descriptor *expression_ops () const override + { return &exp_descriptor_tab; } + + /* See language.h. */ + + const struct op_print *opcode_print_table () const override + { return op_print_tab; } + +protected: + + /* See language.h. */ + + symbol_name_matcher_ftype *get_symbol_name_matcher_inner + (const lookup_name_info &lookup_name) const override; + +private: + /* Table of expression handling functions for use by EXPRESSION_OPS + member function. */ + + static const struct exp_descriptor exp_descriptor_tab; + + /* Table of opcode data for use by OPCODE_PRINT_TABLE member function. */ + + static const struct op_print op_print_tab[]; + + /* Return the encoding that should be used for the character type + TYPE. */ + + static const char *get_encoding (struct type *type); + + /* Print any asterisks or open-parentheses needed before the variable + name (to describe its type). + + On outermost call, pass 0 for PASSED_A_PTR. + On outermost call, SHOW > 0 means should ignore + any typename for TYPE and show its details. + SHOW is always zero on recursive calls. */ + + void f_type_print_varspec_prefix (struct type *type, + struct ui_file * stream, + int show, int passed_a_ptr) const; + + /* Print any array sizes, function arguments or close parentheses needed + after the variable name (to describe its type). Args work like + c_type_print_varspec_prefix. + + PRINT_RANK_ONLY is true when TYPE is an array which should be printed + without the upper and lower bounds being specified, this will occur + when the array is not allocated or not associated and so there are no + known upper or lower bounds. */ + + void f_type_print_varspec_suffix (struct type *type, + struct ui_file *stream, + int show, int passed_a_ptr, + int demangled_args, + int arrayprint_recurse_level, + bool print_rank_only) const; + + /* Print the name of the type (or the ultimate pointer target, function + value or array element), or the description of a structure or union. + + SHOW nonzero means don't print this type as just its name; + show its real definition even if it has a name. + SHOW zero means print just typename or struct tag if there is one + SHOW negative means abbreviate structure elements. + SHOW is decremented for printing of structure elements. + + LEVEL is the depth to indent by. We increase it for some recursive + calls. */ + + void f_type_print_base (struct type *type, struct ui_file *stream, int show, + int level) const; +}; /* Language-specific data structures */ |