diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-05-05 16:03:53 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2020-10-22 09:24:42 +0100 |
commit | 2f1b18db863d630b94f9454067597e0df648bf37 (patch) | |
tree | 6c054ad0964abdaa5173dc34b530689069bf7fbd /gdb/expprint.c | |
parent | c53dcd7785debc2e2a5b8b2dede45bbf32f2438d (diff) | |
download | fsf-binutils-gdb-2f1b18db863d630b94f9454067597e0df648bf37.zip fsf-binutils-gdb-2f1b18db863d630b94f9454067597e0df648bf37.tar.gz fsf-binutils-gdb-2f1b18db863d630b94f9454067597e0df648bf37.tar.bz2 |
gdb: Convert enum range_type to a bit field enum
The expression range_type enum represents the following ideas:
- Lower bound is set to default,
- Upper bound is set to default,
- Upper bound is exclusive.
There are currently 6 entries in the enum to represent the combination
of all those ideas.
In a future commit I'd like to add stride information to the range,
this could in theory appear with any of the existing enum entries, so
this would take us to 12 enum entries.
This feels like its getting a little out of hand, so in this commit I
switch the range_type enum over to being a flags style enum. There's
one entry to represent no flags being set, then 3 flags to represent
the 3 ideas above. Adding stride information will require adding only
one more enum flag.
I've then gone through and updated the code to handle this change.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* expprint.c (print_subexp_standard): Update to reflect changes to
enum range_type.
(dump_subexp_body_standard): Likewise.
* expression.h (enum range_type): Convert to a bit field enum, and
make the enum unsigned.
* f-exp.y (subrange): Update to reflect changes to enum
range_type.
* f-lang.c (value_f90_subarray): Likewise.
* parse.c (operator_length_standard): Likewise.
* rust-exp.y (rust_parser::convert_ast_to_expression): Likewise.
* rust-lang.c (rust_range): Likewise.
(rust_compute_range): Likewise.
(rust_subscript): Likewise.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r-- | gdb/expprint.c | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c index d7d7c87..bdb69a9 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -585,17 +585,13 @@ print_subexp_standard (struct expression *exp, int *pos, longest_to_int (exp->elts[pc + 1].longconst); *pos += 2; - if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE - || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE) + if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE) fputs_filtered ("EXCLUSIVE_", stream); fputs_filtered ("RANGE(", stream); - if (range_type == HIGH_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE) + if (!(range_type & RANGE_LOW_BOUND_DEFAULT)) print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered ("..", stream); - if (range_type == LOW_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT) + if (!(range_type & RANGE_HIGH_BOUND_DEFAULT)) print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered (")", stream); return; @@ -1116,36 +1112,19 @@ dump_subexp_body_standard (struct expression *exp, longest_to_int (exp->elts[elt].longconst); elt += 2; - switch (range_type) - { - case BOTH_BOUND_DEFAULT: - fputs_filtered ("Range '..'", stream); - break; - case LOW_BOUND_DEFAULT: - fputs_filtered ("Range '..EXP'", stream); - break; - case LOW_BOUND_DEFAULT_EXCLUSIVE: - fputs_filtered ("ExclusiveRange '..EXP'", stream); - break; - case HIGH_BOUND_DEFAULT: - fputs_filtered ("Range 'EXP..'", stream); - break; - case NONE_BOUND_DEFAULT: - fputs_filtered ("Range 'EXP..EXP'", stream); - break; - case NONE_BOUND_DEFAULT_EXCLUSIVE: - fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream); - break; - default: - fputs_filtered ("Invalid Range!", stream); - break; - } + if (range_type & RANGE_HIGH_BOUND_EXCLUSIVE) + fputs_filtered ("Exclusive", stream); + fputs_filtered ("Range '", stream); + if (!(range_type & RANGE_LOW_BOUND_DEFAULT)) + fputs_filtered ("EXP", stream); + fputs_filtered ("..", stream); + if (!(range_type & RANGE_HIGH_BOUND_DEFAULT)) + fputs_filtered ("EXP", stream); + fputs_filtered ("'", stream); - if (range_type == HIGH_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT) + if (!(range_type & RANGE_LOW_BOUND_DEFAULT)) elt = dump_subexp (exp, stream, elt); - if (range_type == LOW_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT) + if (!(range_type & RANGE_HIGH_BOUND_DEFAULT)) elt = dump_subexp (exp, stream, elt); } break; |