From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by sourceware.org (Postfix) with ESMTPS id C7D973944419 for ; Mon, 12 Oct 2020 14:46:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C7D973944419 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wm1-x343.google.com with SMTP id k18so17799269wmj.5 for ; Mon, 12 Oct 2020 07:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aos4GHPeybZ95BqdbIE+1rKgqCrWRs/g6SsrNFBeuk4=; b=aMz2tmb6BWUpJ/yWurMzI+KrfRy4D+Jko19sPjkokrhacoTvjLTVn9x1BytHdTqd1l 4LixdRxal2tVFch/WL31pKpFSsCf79n04Mykhb6EXjGJM5x4q4ecotur22aseYxh2p41 jvyJ/4MArUKqiWQ7mzJLaZWgQnSAZhJ4kwHwfNQeA21LuUY4hBfl4D3Q7QF8NvRqFMl2 Hlx0+sqNn7HgyxYjNbolN07Y9gTojxayyT/iWpSkBKO3fS+qfNGsRq8tue2N73JA4C2c 6nreoA3gnIZGA1OVZXZjqDLBOQN6Z0wdWJZlAc6D/RszGL8WBHfPpYQDhH6MsTTZlOhW E2Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aos4GHPeybZ95BqdbIE+1rKgqCrWRs/g6SsrNFBeuk4=; b=jhXdVVlC7qHs/yOnTfN5sLiMg5dKBgaK3Z5g4kDlf8YJI5e/T+yq0zHpVJHp8Nr4Pk ow8vVemZGU9cwd7ieXqMHgj+Iohk+XGUReeYYI/5TV7/1KlxvxrET638GtURcnoB+rfW fMr3/5iMIhjJTg6JHh0kXgmYgcCdMCp6nPKfasUEub8rNZvEFbX5WmGQFYSEWqizXow5 A+mOfstTQETO2hQum8/JRv329TAB9HAaroJIN1mKcNi7KDb33uoWoiPQXADf/op/NmGI g+id9J8S7KYeiAPPeFy3xhIFeHrsdqWhV8hpUgxtMVCrpdURUC+WUznrYlVM5V2wvM5v wQSg== X-Gm-Message-State: AOAM532Zs18N2yhT7ijkFmhvm358smN9FvNAn32MtLD27w6uonVVmdJL nWQo9EvuE995vdaNxbOztpShfffglOtFNA== X-Google-Smtp-Source: ABdhPJzgC2/X835DghWa0XdaTDMyh1WaCmcnSOqxtKmSsdlV2UqLKMCt7TW45HqMERtSPc41fv0QgA== X-Received: by 2002:a05:600c:1149:: with SMTP id z9mr11897055wmz.180.1602514012993; Mon, 12 Oct 2020 07:46:52 -0700 (PDT) Received: from localhost (host86-130-161-39.range86-130.btcentralplus.com. [86.130.161.39]) by smtp.gmail.com with ESMTPSA id q6sm23262118wma.0.2020.10.12.07.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Oct 2020 07:46:52 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCH 9/9] gdb: move f_language class into a header file Date: Mon, 12 Oct 2020 15:46:37 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2020 14:46:58 -0000 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. --- gdb/ChangeLog | 34 +++++ gdb/f-exp.y | 2 +- gdb/f-lang.c | 320 +++++++++------------------------------------- gdb/f-lang.h | 272 +++++++++++++++++++++++++++++++++++++-- gdb/f-typeprint.c | 82 ++++-------- gdb/f-valprint.c | 5 +- gdb/parse.c | 1 - 7 files changed, 387 insertions(+), 329 deletions(-) diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 0ccb3c68d3e..88f622cf8ec 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1343,7 +1343,7 @@ yylex (void) } int -f_parse (struct parser_state *par_state) +f_language::parser (struct parser_state *par_state) const { /* Setting up the parser state. */ scoped_restore pstate_restore = make_scoped_restore (&pstate); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 12fe561afe4..c70b2bcaebe 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -44,8 +44,8 @@ /* Return the encoding that should be used for the character type TYPE. */ -static const char * -f_get_encoding (struct type *type) +const char * +f_language::get_encoding (struct type *type) { const char *encoding; @@ -72,7 +72,7 @@ f_get_encoding (struct type *type) /* Table of operators and their precedences for printing expressions. */ -static const struct op_print f_op_print_tab[] = +const struct op_print f_language::op_print_tab[] = { {"+", BINOP_ADD, PREC_ADD, 0}, {"+", UNOP_PLUS, PREC_PREFIX, 0}, @@ -693,7 +693,7 @@ operator_check_f (struct expression *exp, int pos, } /* Expression processing for Fortran. */ -static const struct exp_descriptor exp_descriptor_f = +const struct exp_descriptor f_language::exp_descriptor_tab = { print_subexp_f, operator_length_f, @@ -703,268 +703,72 @@ static const struct exp_descriptor exp_descriptor_f = evaluate_subexp_f }; -/* Class representing the Fortran language. */ +/* See language.h. */ -class f_language : public language_defn +void +f_language::language_arch_info (struct gdbarch *gdbarch, + struct language_arch_info *lai) const { -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 &filename_extensions () const override - { - static const std::vector 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 - { - 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_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 - { - f_print_type (type, varstring, stream, show, level, flags); - } - - /* 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 - { - return f_value_print_inner (val, stream, recurse, options); - } - - /* See language.h. */ - - struct block_symbol lookup_symbol_nonlocal - (const char *name, const struct block *block, - const domain_enum domain) const override - { - return cp_lookup_symbol_nonlocal (this, name, block, domain); - } - - /* See language.h. */ - - int parser (struct parser_state *ps) const override - { - return f_parse (ps); - } - - /* See language.h. */ - - void emitchar (int ch, struct type *chtype, - struct ui_file *stream, int quoter) const override - { - const char *encoding = f_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 = f_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); - } - - /* See language.h. */ - - void print_typedef (struct type *type, struct symbol *new_symbol, - struct ui_file *stream) const override - { - f_print_typedef (type, new_symbol, stream); - } - - /* See language.h. */ - - 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)); - } - - /* 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 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; +} - const struct exp_descriptor *expression_ops () const override - { return &exp_descriptor_f; } +/* See language.h. */ - /* See language.h. */ +unsigned int +f_language::search_name_hash (const char *name) const +{ + return cp_search_name_hash (name); +} - const struct op_print *opcode_print_table () const override - { return f_op_print_tab; } +/* See language.h. */ -protected: +struct block_symbol +f_language::lookup_symbol_nonlocal (const char *name, + const struct block *block, + const domain_enum domain) const +{ + return cp_lookup_symbol_nonlocal (this, name, block, domain); +} - /* See language.h. */ +/* See language.h. */ - symbol_name_matcher_ftype *get_symbol_name_matcher_inner - (const lookup_name_info &lookup_name) const override - { - return cp_get_symbol_name_matcher (lookup_name); - } -}; +symbol_name_matcher_ftype * +f_language::get_symbol_name_matcher_inner + (const lookup_name_info &lookup_name) const +{ + return cp_get_symbol_name_matcher (lookup_name); +} /* Single instance of the Fortran language class. */ diff --git a/gdb/f-lang.h b/gdb/f-lang.h index 4710b14aa62..e59fdef1b19 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 &filename_extensions () const override + { + static const std::vector 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 */ diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 577ed3b9d24..0e8bbd61498 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -33,34 +33,22 @@ #include "typeprint.h" #include "cli/cli-style.h" -#if 0 /* Currently unused. */ -static void f_type_print_args (struct type *, struct ui_file *); -#endif - -static void f_type_print_varspec_suffix (struct type *, struct ui_file *, int, - int, int, int, bool); - -void f_type_print_varspec_prefix (struct type *, struct ui_file *, - int, int); - -void f_type_print_base (struct type *, struct ui_file *, int, int); - - -/* See documentation in f-lang.h. */ +/* See f-lang.h. */ void -f_print_typedef (struct type *type, struct symbol *new_symbol, - struct ui_file *stream) +f_language::print_typedef (struct type *type, struct symbol *new_symbol, + struct ui_file *stream) const { type = check_typedef (type); - f_print_type (type, "", stream, 0, 0, &type_print_raw_options); + print_type (type, "", stream, 0, 0, &type_print_raw_options); } -/* LEVEL is the depth to indent lines by. */ +/* See f-lang.h. */ void -f_print_type (struct type *type, const char *varstring, struct ui_file *stream, - int show, int level, const struct type_print_options *flags) +f_language::print_type (struct type *type, const char *varstring, + struct ui_file *stream, int show, int level, + const struct type_print_options *flags) const { enum type_code code; @@ -99,17 +87,12 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream, } } -/* 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. */ +/* See f-lang.h. */ void -f_type_print_varspec_prefix (struct type *type, struct ui_file *stream, - int show, int passed_a_ptr) +f_language::f_type_print_varspec_prefix (struct type *type, + struct ui_file *stream, + int show, int passed_a_ptr) const { if (type == 0) return; @@ -158,19 +141,15 @@ f_type_print_varspec_prefix (struct type *type, struct ui_file *stream, } } -/* 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. +/* See f-lang.h. */ - 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. */ - -static 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) +void +f_language::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 { /* No static variables are permitted as an error call may occur during execution of this function. */ @@ -263,7 +242,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, fprintf_filtered (stream, ") "); fprintf_filtered (stream, "("); if (nfields == 0 && type->is_prototyped ()) - f_print_type (builtin_f_type (get_type_arch (type))->builtin_void, + print_type (builtin_f_type (get_type_arch (type))->builtin_void, "", stream, -1, 0, 0); else for (i = 0; i < nfields; i++) @@ -273,7 +252,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, fputs_filtered (", ", stream); wrap_here (" "); } - f_print_type (type->field (i).type (), "", stream, -1, 0, 0); + print_type (type->field (i).type (), "", stream, -1, 0, 0); } fprintf_filtered (stream, ")"); } @@ -301,22 +280,11 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, } } -/* 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. */ +/* See f-lang.h. */ void -f_type_print_base (struct type *type, struct ui_file *stream, int show, - int level) +f_language::f_type_print_base (struct type *type, struct ui_file *stream, + int show, int level) const { int index; diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index e7dc20d0ea5..95630a76d7d 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -214,8 +214,9 @@ static const struct generic_val_print_decorations f_decorations = /* See f-lang.h. */ void -f_value_print_inner (struct value *val, struct ui_file *stream, int recurse, - const struct value_print_options *options) +f_language::value_print_inner (struct value *val, struct ui_file *stream, + int recurse, + const struct value_print_options *options) const { struct type *type = check_typedef (value_type (val)); struct gdbarch *gdbarch = get_type_arch (type); diff --git a/gdb/parse.c b/gdb/parse.c index 6b9541bfdc2..932b7f6e3db 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -39,7 +39,6 @@ #include "value.h" #include "command.h" #include "language.h" -#include "f-lang.h" #include "parser-defs.h" #include "gdbcmd.h" #include "symfile.h" /* for overlay functions */ -- 2.25.4