From d9c3a9c03692c12b472c555f71fe7a2444a24d46 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 9 Dec 2020 13:43:44 -0700 Subject: [PATCH] Unify all operators into std-operator.def This removes ada-operator.def and fortran-operator.def, merging their contents into std-operator.def. Note that the comment for OP_EXTENDED0 is a bit wrong. IMO this constant could be removed, as it is only used for a single assert that does not provide much value. However, I haven't done so here. gdb/ChangeLog 2020-12-09 Tom Tromey * expprint.c (op_name): Update. * expression.h (enum exp_opcode): Update. * std-operator.def: Add more opcodes. * ada-operator.def, fortran-operator.def: Remove, moving contents into std-operator.def. --- gdb/ChangeLog | 8 +++ gdb/ada-operator.def | 98 ------------------------------------ gdb/expprint.c | 2 - gdb/expression.h | 9 ---- gdb/fortran-operator.def | 35 ------------- gdb/std-operator.def | 105 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 144 deletions(-) delete mode 100644 gdb/ada-operator.def delete mode 100644 gdb/fortran-operator.def diff --git a/gdb/ChangeLog b/gdb/ChangeLog index afdfc772094..6c76405458a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2020-12-09 Tom Tromey + + * expprint.c (op_name): Update. + * expression.h (enum exp_opcode): Update. + * std-operator.def: Add more opcodes. + * ada-operator.def, fortran-operator.def: Remove, moving contents + into std-operator.def. + 2020-12-09 Simon Marchi * gdbtypes.c (get_discrete_low_bound, get_discrete_high_bound): diff --git a/gdb/ada-operator.def b/gdb/ada-operator.def deleted file mode 100644 index 8a578cbc465..00000000000 --- a/gdb/ada-operator.def +++ /dev/null @@ -1,98 +0,0 @@ -/* Ada language operator definitions for GDB, the GNU debugger. - - Copyright (C) 1992-2020 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* X IN A'RANGE(N). N is an immediate operand, surrounded by - BINOP_IN_BOUNDS before and after. A is an array, X an index - value. Evaluates to true iff X is within range of the Nth - dimension (1-based) of A. (A multi-dimensional array - type is represented as array of array of ...) */ -OP (BINOP_IN_BOUNDS) - -/* X IN L .. U. True iff L <= X <= U. */ -OP (TERNOP_IN_RANGE) - -/* Ada attributes ('Foo). */ -OP (OP_ATR_FIRST) -OP (OP_ATR_LAST) -OP (OP_ATR_LENGTH) -OP (OP_ATR_IMAGE) -OP (OP_ATR_MAX) -OP (OP_ATR_MIN) -OP (OP_ATR_MODULUS) -OP (OP_ATR_POS) -OP (OP_ATR_SIZE) -OP (OP_ATR_TAG) -OP (OP_ATR_VAL) - -/* Ada type qualification. It is encoded as for UNOP_CAST, above, - and denotes the TYPE'(EXPR) construct. */ -OP (UNOP_QUAL) - -/* X IN TYPE. The `TYPE' argument is immediate, with - UNOP_IN_RANGE before and after it. True iff X is a member of - type TYPE (typically a subrange). */ -OP (UNOP_IN_RANGE) - -/* An aggregate. A single immediate operand, N>0, gives - the number of component specifications that follow. The - immediate operand is followed by a second OP_AGGREGATE. - Next come N component specifications. A component - specification is either an OP_OTHERS (others=>...), an - OP_CHOICES (for named associations), or other expression (for - positional aggregates only). Aggregates currently - occur only as the right sides of assignments. */ -OP (OP_AGGREGATE) - -/* An others clause. Followed by a single expression. */ -OP (OP_OTHERS) - -/* An aggregate component association. A single immediate operand, N, - gives the number of choices that follow. This is followed by a second - OP_CHOICES operator. Next come N operands, each of which is an - expression, an OP_DISCRETE_RANGE, or an OP_NAME---the latter - for a simple name that must be a record component name and does - not correspond to a single existing symbol. After the N choice - indicators comes an expression giving the value. - - In an aggregate such as (X => E1, ...), where X is a simple - name, X could syntactically be either a component_selector_name - or an expression used as a discrete_choice, depending on the - aggregate's type context. Since this is not known at parsing - time, we don't attempt to disambiguate X if it has multiple - definitions, but instead supply an OP_NAME. If X has a single - definition, we represent it with an OP_VAR_VALUE, even though - it may turn out to be within a record aggregate. Aggregate - evaluation can use either OP_NAMEs or OP_VAR_VALUEs to get a - record field name, and can evaluate OP_VAR_VALUE normally to - get its value as an expression. Unfortunately, we lose out in - cases where X has multiple meanings and is part of an array - aggregate. I hope these are not common enough to annoy users, - who can work around the problem in any case by putting - parentheses around X. */ -OP (OP_CHOICES) - -/* A positional aggregate component association. The operator is - followed by a single integer indicating the position in the - aggregate (0-based), followed by a second OP_POSITIONAL. Next - follows a single expression giving the component value. */ -OP (OP_POSITIONAL) - -/* A range of values. Followed by two expressions giving the - upper and lower bounds of the range. */ -OP (OP_DISCRETE_RANGE) diff --git a/gdb/expprint.c b/gdb/expprint.c index f1cf62e1c9a..5b4ea14d440 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -704,8 +704,6 @@ op_name (enum exp_opcode opcode) case name: \ return #name ; #include "std-operator.def" -#include "ada-operator.def" -#include "fortran-operator.def" #undef OP } } diff --git a/gdb/expression.h b/gdb/expression.h index 684274b90b8..9ac940fa4d0 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -61,15 +61,6 @@ enum exp_opcode : uint8_t #include "std-operator.def" - /* First extension operator. Individual language modules define extra - operators in *.def include files below with numbers higher than - OP_EXTENDED0. */ - OP (OP_EXTENDED0) - -/* Language specific operators. */ -#include "ada-operator.def" -#include "fortran-operator.def" - #undef OP /* Existing only to swallow the last comma (',') from last .inc file. */ diff --git a/gdb/fortran-operator.def b/gdb/fortran-operator.def deleted file mode 100644 index bfdbc401711..00000000000 --- a/gdb/fortran-operator.def +++ /dev/null @@ -1,35 +0,0 @@ -/* Fortran language operator definitions for GDB, the GNU debugger. - - Copyright (C) 2019-2020 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* This is EXACTLY like OP_FUNCALL but is semantically different. - In F77, array subscript expressions, substring expressions and - function calls are all exactly the same syntactically. They - may only be disambiguated at runtime. Thus this operator, - which indicates that we have found something of the form - ( ). */ -OP (OP_F77_UNDETERMINED_ARGLIST) - -/* Single operand builtins. */ -OP (UNOP_FORTRAN_KIND) -OP (UNOP_FORTRAN_FLOOR) -OP (UNOP_FORTRAN_CEILING) - -/* Two operand builtins. */ -OP (BINOP_FORTRAN_CMPLX) -OP (BINOP_FORTRAN_MODULO) diff --git a/gdb/std-operator.def b/gdb/std-operator.def index 6f90875f477..fadd092a15b 100644 --- a/gdb/std-operator.def +++ b/gdb/std-operator.def @@ -337,3 +337,108 @@ OP (OP_TYPEID) /* This is used for the Rust [expr; N] form of array construction. It takes two expression arguments. */ OP (OP_RUST_ARRAY) + +/* First extension operator. Some language modules define extra + operators below with numbers higher than OP_EXTENDED0. */ +OP (OP_EXTENDED0) + +/* ================ Ada operators ================ */ + +/* X IN A'RANGE(N). N is an immediate operand, surrounded by + BINOP_IN_BOUNDS before and after. A is an array, X an index + value. Evaluates to true iff X is within range of the Nth + dimension (1-based) of A. (A multi-dimensional array + type is represented as array of array of ...) */ +OP (BINOP_IN_BOUNDS) + +/* X IN L .. U. True iff L <= X <= U. */ +OP (TERNOP_IN_RANGE) + +/* Ada attributes ('Foo). */ +OP (OP_ATR_FIRST) +OP (OP_ATR_LAST) +OP (OP_ATR_LENGTH) +OP (OP_ATR_IMAGE) +OP (OP_ATR_MAX) +OP (OP_ATR_MIN) +OP (OP_ATR_MODULUS) +OP (OP_ATR_POS) +OP (OP_ATR_SIZE) +OP (OP_ATR_TAG) +OP (OP_ATR_VAL) + +/* Ada type qualification. It is encoded as for UNOP_CAST, above, + and denotes the TYPE'(EXPR) construct. */ +OP (UNOP_QUAL) + +/* X IN TYPE. The `TYPE' argument is immediate, with + UNOP_IN_RANGE before and after it. True iff X is a member of + type TYPE (typically a subrange). */ +OP (UNOP_IN_RANGE) + +/* An aggregate. A single immediate operand, N>0, gives + the number of component specifications that follow. The + immediate operand is followed by a second OP_AGGREGATE. + Next come N component specifications. A component + specification is either an OP_OTHERS (others=>...), an + OP_CHOICES (for named associations), or other expression (for + positional aggregates only). Aggregates currently + occur only as the right sides of assignments. */ +OP (OP_AGGREGATE) + +/* An others clause. Followed by a single expression. */ +OP (OP_OTHERS) + +/* An aggregate component association. A single immediate operand, N, + gives the number of choices that follow. This is followed by a second + OP_CHOICES operator. Next come N operands, each of which is an + expression, an OP_DISCRETE_RANGE, or an OP_NAME---the latter + for a simple name that must be a record component name and does + not correspond to a single existing symbol. After the N choice + indicators comes an expression giving the value. + + In an aggregate such as (X => E1, ...), where X is a simple + name, X could syntactically be either a component_selector_name + or an expression used as a discrete_choice, depending on the + aggregate's type context. Since this is not known at parsing + time, we don't attempt to disambiguate X if it has multiple + definitions, but instead supply an OP_NAME. If X has a single + definition, we represent it with an OP_VAR_VALUE, even though + it may turn out to be within a record aggregate. Aggregate + evaluation can use either OP_NAMEs or OP_VAR_VALUEs to get a + record field name, and can evaluate OP_VAR_VALUE normally to + get its value as an expression. Unfortunately, we lose out in + cases where X has multiple meanings and is part of an array + aggregate. I hope these are not common enough to annoy users, + who can work around the problem in any case by putting + parentheses around X. */ +OP (OP_CHOICES) + +/* A positional aggregate component association. The operator is + followed by a single integer indicating the position in the + aggregate (0-based), followed by a second OP_POSITIONAL. Next + follows a single expression giving the component value. */ +OP (OP_POSITIONAL) + +/* A range of values. Followed by two expressions giving the + upper and lower bounds of the range. */ +OP (OP_DISCRETE_RANGE) + +/* ================ Fortran operators ================ */ + +/* This is EXACTLY like OP_FUNCALL but is semantically different. + In F77, array subscript expressions, substring expressions and + function calls are all exactly the same syntactically. They + may only be disambiguated at runtime. Thus this operator, + which indicates that we have found something of the form + ( ). */ +OP (OP_F77_UNDETERMINED_ARGLIST) + +/* Single operand builtins. */ +OP (UNOP_FORTRAN_KIND) +OP (UNOP_FORTRAN_FLOOR) +OP (UNOP_FORTRAN_CEILING) + +/* Two operand builtins. */ +OP (BINOP_FORTRAN_CMPLX) +OP (BINOP_FORTRAN_MODULO) -- 2.30.2