aboutsummaryrefslogtreecommitdiff
path: root/gdb/rust-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-31 17:20:24 -0600
committerTom Tromey <tom@tromey.com>2019-04-04 19:55:11 -0600
commit699bd4cfa8895d0767d491a3e44ac09d3f4d1801 (patch)
tree6f0f6dea3ef2cd37f4e0b9173d38431b27df17fd /gdb/rust-exp.y
parentdac43e327d002107f6bc9481749de039f410df73 (diff)
downloadgdb-699bd4cfa8895d0767d491a3e44ac09d3f4d1801.zip
gdb-699bd4cfa8895d0767d491a3e44ac09d3f4d1801.tar.gz
gdb-699bd4cfa8895d0767d491a3e44ac09d3f4d1801.tar.bz2
Move innermost_block_tracker global to parse_state
This changes the parsing API so that callers that are interested in tracking the innermost block must instantiate an innermost_block_tracker and pass it in. Then, a pointer to this object is stored in the parser_state. 2019-04-04 Tom Tromey <tom@tromey.com> * varobj.c (varobj_create): Update. * rust-exp.y (struct rust_parser) <update_innermost_block, lookup_symbol>: New methods. (rust_parser::update_innermost_block, rust_parser::lookup_symbol): Rename. (rust_parser::rust_lookup_type) (rust_parser::convert_ast_to_expression, rust_lex_tests): Update. * printcmd.c (display_command, do_one_display): Update. * parser-defs.h (struct parser_state) <parser_state>: Add "tracker" parameter. (block_tracker): New member. (class innermost_block_tracker) <innermost_block_tracker>: Add "types" parameter. <reset>: Remove method. (innermost_block): Don't declare. (null_post_parser): Update. * parse.c (innermost_block): Remove global. (write_dollar_variable): Update. (parse_exp_1, parse_exp_in_context): Add "tracker" parameter. Remove "tracker_types" parameter. (parse_expression): Add "tracker" parameter. (parse_expression_for_completion): Update. (null_post_parser): Add "tracker" parameter. * p-exp.y: Update rules. * m2-exp.y: Update rules. * language.h (struct language_defn) <la_post_parser>: Add "tracker" parameter. * go-exp.y: Update rules. * f-exp.y: Update rules. * expression.h (parse_expression, parse_exp_1): Add "tracker" parameter. * d-exp.y: Update rules. * c-exp.y: Update rules. * breakpoint.c (set_breakpoint_condition): Create an innermost_block_tracker. (watch_command_1): Likewise. * ada-lang.c (resolve): Add "tracker" parameter. (resolve_subexp): Likewise. * ada-exp.y (write_var_from_sym): Update.
Diffstat (limited to 'gdb/rust-exp.y')
-rw-r--r--gdb/rust-exp.y29
1 files changed, 15 insertions, 14 deletions
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index 999ab25..6e22620 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -118,9 +118,6 @@ static int rustyylex (YYSTYPE *, rust_parser *);
static void rustyyerror (rust_parser *parser, const char *msg);
static struct stoken make_stoken (const char *);
-static struct block_symbol rust_lookup_symbol (const char *name,
- const struct block *block,
- const domain_enum domain);
/* A regular expression for matching Rust numbers. This is split up
since it is very long and this gives us a way to comment the
@@ -241,6 +238,10 @@ struct rust_parser
int lex_operator (YYSTYPE *lvalp);
void push_back (char c);
+ void update_innermost_block (struct block_symbol sym);
+ struct block_symbol lookup_symbol (const char *name,
+ const struct block *block,
+ const domain_enum domain);
struct type *rust_lookup_type (const char *name, const struct block *block);
std::vector<struct type *> convert_params_to_types (rust_op_vector *params);
struct type *convert_ast_to_type (const struct rust_op *operation);
@@ -1104,11 +1105,11 @@ rust_parser::super_name (const struct rust_op *ident, unsigned int n_supers)
/* A helper that updates the innermost block as appropriate. */
-static void
-update_innermost_block (struct block_symbol sym)
+void
+rust_parser::update_innermost_block (struct block_symbol sym)
{
if (symbol_read_needs_frame (sym.symbol))
- innermost_block.update (sym);
+ pstate->block_tracker->update (sym);
}
/* Lex a hex number with at least MIN digits and at most MAX
@@ -1992,15 +1993,15 @@ munge_name_and_block (const char **name, const struct block **block)
/* Like lookup_symbol, but handles Rust namespace conventions, and
doesn't require field_of_this_result. */
-static struct block_symbol
-rust_lookup_symbol (const char *name, const struct block *block,
- const domain_enum domain)
+struct block_symbol
+rust_parser::lookup_symbol (const char *name, const struct block *block,
+ const domain_enum domain)
{
struct block_symbol result;
munge_name_and_block (&name, &block);
- result = lookup_symbol (name, block, domain, NULL);
+ result = ::lookup_symbol (name, block, domain, NULL);
if (result.symbol != NULL)
update_innermost_block (result);
return result;
@@ -2016,7 +2017,7 @@ rust_parser::rust_lookup_type (const char *name, const struct block *block)
munge_name_and_block (&name, &block);
- result = lookup_symbol (name, block, STRUCT_DOMAIN, NULL);
+ result = ::lookup_symbol (name, block, STRUCT_DOMAIN, NULL);
if (result.symbol != NULL)
{
update_innermost_block (result);
@@ -2387,8 +2388,8 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
}
varname = convert_name (operation);
- sym = rust_lookup_symbol (varname, pstate->expression_context_block,
- VAR_DOMAIN);
+ sym = lookup_symbol (varname, pstate->expression_context_block,
+ VAR_DOMAIN);
if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
{
write_exp_elt_opcode (pstate, OP_VAR_VALUE);
@@ -2726,7 +2727,7 @@ rust_lex_tests (void)
// Set up dummy "parser", so that rust_type works.
struct parser_state ps (&rust_language_defn, target_gdbarch (),
- nullptr, 0, 0, nullptr, 0);
+ nullptr, 0, 0, nullptr, 0, nullptr);
rust_parser parser (&ps);
rust_lex_test_one (&parser, "", 0);