diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-05-07 16:27:16 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-09-19 09:44:58 +0100 |
commit | 6d81691950f8c4be4a49a85a672255c140e82468 (patch) | |
tree | 66e445599cf0dbd55335407b53133901c35fefbe /gdb/expprint.c | |
parent | 8c37706a511209f6a92d887812c14e860c3bd0a0 (diff) | |
download | binutils-6d81691950f8c4be4a49a85a672255c140e82468.zip binutils-6d81691950f8c4be4a49a85a672255c140e82468.tar.gz binutils-6d81691950f8c4be4a49a85a672255c140e82468.tar.bz2 |
gdb/fortran: Move Fortran expression handling into f-lang.c
The Fortran specific OP_F77_UNDETERMINED_ARGLIST is currently handled
in the generic expression handling code. There's no reason why this
should be the case, so this commit moves handling of this into Fortran
specific files.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* eval.c: Remove 'f-lang.h' include.
(value_f90_subarray): Moved to f-lang.c.
(eval_call): Renamed to...
(evaluate_subexp_do_call): ...this, is no longer static, header
comment moved into header file.
(evaluate_funcall): Update call to eval_call.
(skip_undetermined_arglist): Moved to f-lang.c.
(fortran_value_subarray): Likewise.
(evaluate_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to evaluate_subexp_f.
(calc_f77_array_dims): Moved to f-lang.c
* expprint.c (print_subexp_funcall): New function.
(print_subexp_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to print_subexp_f, OP_FUNCALL uses new function.
(dump_subexp_body_funcall): New function.
(dump_subexp_body_standard): OP_F77_UNDETERMINED_ARGLIST handling
moved to dump_subexp_f, OP_FUNCALL uses new function.
* expression.h (evaluate_subexp_do_call): Declare.
* f-lang.c (value_f90_subarray): Moved from eval.c.
(skip_undetermined_arglist): Likewise.
(calc_f77_array_dims): Likewise.
(fortran_value_subarray): Likewise.
(evaluate_subexp_f): Add OP_F77_UNDETERMINED_ARGLIST support.
(operator_length_f): Likewise.
(print_subexp_f): Likewise.
(dump_subexp_body_f): Likewise.
* fortran-operator.def (OP_F77_UNDETERMINED_ARGLIST): Move
declaration of this operation to here.
* parse.c (operator_length_standard): OP_F77_UNDETERMINED_ARGLIST
support moved to operator_length_f.
* parser-defs.h (dump_subexp_body_funcall): Declare.
(print_subexp_funcall): Declare.
* std-operator.def (OP_F77_UNDETERMINED_ARGLIST): Moved to
fortran-operator.def.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r-- | gdb/expprint.c | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c index 5bd9553..d7d7c87 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -54,6 +54,25 @@ print_subexp (struct expression *exp, int *pos, prec); } +/* See parser-defs.h. */ + +void +print_subexp_funcall (struct expression *exp, int *pos, + struct ui_file *stream) +{ + (*pos) += 2; + unsigned nargs = longest_to_int (exp->elts[*pos].longconst); + print_subexp (exp, pos, stream, PREC_SUFFIX); + fputs_filtered (" (", stream); + for (unsigned tem = 0; tem < nargs; tem++) + { + if (tem != 0) + fputs_filtered (", ", stream); + print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); + } + fputs_filtered (")", stream); +} + /* Standard implementation of print_subexp for use in language_defn vectors. */ void @@ -188,18 +207,7 @@ print_subexp_standard (struct expression *exp, int *pos, return; case OP_FUNCALL: - case OP_F77_UNDETERMINED_ARGLIST: - (*pos) += 2; - nargs = longest_to_int (exp->elts[pc + 1].longconst); - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered (" (", stream); - for (tem = 0; tem < nargs; tem++) - { - if (tem != 0) - fputs_filtered (", ", stream); - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - } - fputs_filtered (")", stream); + print_subexp_funcall (exp, pos, stream); return; case OP_NAME: @@ -798,6 +806,22 @@ dump_subexp_body (struct expression *exp, struct ui_file *stream, int elt) elt); } +/* See parser-defs.h. */ + +int +dump_subexp_body_funcall (struct expression *exp, + struct ui_file *stream, int elt) +{ + int nargs = longest_to_int (exp->elts[elt].longconst); + fprintf_filtered (stream, "Number of args: %d", nargs); + elt += 2; + + for (int i = 1; i <= nargs + 1; i++) + elt = dump_subexp (exp, stream, elt); + + return elt; +} + /* Default value for subexp_body in exp_descriptor vector. */ int @@ -933,18 +957,7 @@ dump_subexp_body_standard (struct expression *exp, elt += 2; break; case OP_FUNCALL: - case OP_F77_UNDETERMINED_ARGLIST: - { - int i, nargs; - - nargs = longest_to_int (exp->elts[elt].longconst); - - fprintf_filtered (stream, "Number of args: %d", nargs); - elt += 2; - - for (i = 1; i <= nargs + 1; i++) - elt = dump_subexp (exp, stream, elt); - } + elt = dump_subexp_body_funcall (exp, stream, elt); break; case OP_ARRAY: { |