diff options
author | Tom Tromey <tom@tromey.com> | 2018-03-29 14:14:07 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-04-27 13:20:13 -0600 |
commit | 6873858b7e464e114f9a877e216949ad8350b4cf (patch) | |
tree | 8812199c58f09c14b00dc50805d9b066f02d28bd /gdb/expprint.c | |
parent | 632e107b32c0fe8aede62e070b00756e9fdd2c01 (diff) | |
download | gdb-6873858b7e464e114f9a877e216949ad8350b4cf.zip gdb-6873858b7e464e114f9a877e216949ad8350b4cf.tar.gz gdb-6873858b7e464e114f9a877e216949ad8350b4cf.tar.bz2 |
Add inclusive range support for Rust
This is version 2 of the patch to add inclusive range support for
Rust. I believe it addresses all review comments.
Rust recently stabilized the inclusive range feature:
https://github.com/rust-lang/rust/issues/28237
An inclusive range is an expression like "..= EXPR" or "EXPR ..=
EXPR". It is like an ordinary range, except the upper bound is
inclusive, not exclusive.
This patch adds support for this feature to gdb.
Regression tested on x86-64 Fedora 27.
2018-04-27 Tom Tromey <tom@tromey.com>
PR rust/22545:
* rust-lang.c (rust_inclusive_range_type_p): New function.
(rust_range): Handle inclusive ranges.
(rust_compute_range): Likewise.
* rust-exp.y (struct rust_op) <inclusive>: New field.
(DOTDOTEQ): New constant.
(range_expr): Add "..=" productions.
(operator_tokens): Add "..=" token.
(ast_range): Add "inclusive" parameter.
(convert_ast_to_expression) <case OP_RANGE>: Handle inclusive
ranges.
* parse.c (operator_length_standard) <case OP_RANGE>: Handle new
bounds values.
* expression.h (enum range_type) <NONE_BOUND_DEFAULT_EXCLUSIVE,
LOW_BOUND_DEFAULT_EXCLUSIVE>: New constants.
Update comments.
* expprint.c (print_subexp_standard): Handle new bounds values.
(dump_subexp_body_standard): Likewise.
2018-04-27 Tom Tromey <tom@tromey.com>
PR rust/22545:
* gdb.rust/simple.exp: Add inclusive range tests.
Diffstat (limited to 'gdb/expprint.c')
-rw-r--r-- | gdb/expprint.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gdb/expprint.c b/gdb/expprint.c index c906904..047ec11 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -578,9 +578,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) + fputs_filtered ("EXCLUSIVE_", stream); fputs_filtered ("RANGE(", stream); if (range_type == HIGH_BOUND_DEFAULT - || range_type == NONE_BOUND_DEFAULT) + || range_type == NONE_BOUND_DEFAULT + || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE) print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); fputs_filtered ("..", stream); if (range_type == LOW_BOUND_DEFAULT @@ -1099,12 +1103,18 @@ dump_subexp_body_standard (struct expression *exp, 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; |