diff options
author | Tom Tromey <tom@tromey.com> | 2019-03-24 11:20:05 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-04-04 19:55:10 -0600 |
commit | 1e58a4a4db997cf09315c22f3da725d1da7f9ee7 (patch) | |
tree | 5166626dc2cad5a02581b158edaa245045922ab9 /gdb/rust-exp.y | |
parent | 37eedb39824dc26c82a92b5515a352d7de0c9b5b (diff) | |
download | gdb-1e58a4a4db997cf09315c22f3da725d1da7f9ee7.zip gdb-1e58a4a4db997cf09315c22f3da725d1da7f9ee7.tar.gz gdb-1e58a4a4db997cf09315c22f3da725d1da7f9ee7.tar.bz2 |
Move expression_context_* globals to parser_state
This moves the expression_context_block and expression_context_pc
globals to be members of parser_state and updates the parsers.
gdb/ChangeLog
2019-04-04 Tom Tromey <tom@tromey.com>
* rust-exp.y (rust_parser::crate_name, rust_parser::super_name)
(rust_parser::convert_ast_to_type)
(rust_parser::convert_ast_to_expression, rust_lex_tests): Update.
* parser-defs.h (struct parser_state) <parser_state>: Add
parameters. Initialize new members.
<expression_context_block, expression_context_pc>: New members.
* parse.c (expression_context_block, expression_context_pc):
Remove globals.
(parse_exp_in_context): Update.
* p-exp.y: Update all rules.
(yylex): Update.
* m2-exp.y: Update all rules.
(yylex): Update.
* go-exp.y (yylex): Update.
* f-exp.y (yylex): Update.
* d-exp.y: Update all rules.
(yylex): Update.
* c-exp.y: Update all rules.
(lex_one_token, classify_name, yylex, c_parse): Update.
* ada-exp.y (write_var_or_type, write_name_assoc): Update.
Diffstat (limited to 'gdb/rust-exp.y')
-rw-r--r-- | gdb/rust-exp.y | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index 9b6ca19..1b7e33e 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -1033,7 +1033,7 @@ rust_parser::concat3 (const char *s1, const char *s2, const char *s3) const struct rust_op * rust_parser::crate_name (const struct rust_op *name) { - std::string crate = rust_crate_for_block (expression_context_block); + std::string crate = rust_crate_for_block (pstate->expression_context_block); struct stoken result; gdb_assert (name->opcode == OP_VAR_VALUE); @@ -1053,7 +1053,7 @@ rust_parser::crate_name (const struct rust_op *name) const struct rust_op * rust_parser::super_name (const struct rust_op *ident, unsigned int n_supers) { - const char *scope = block_scope (expression_context_block); + const char *scope = block_scope (pstate->expression_context_block); int offset; gdb_assert (ident->opcode == OP_VAR_VALUE); @@ -2045,7 +2045,7 @@ rust_parser::convert_ast_to_type (const struct rust_op *operation) { const char *varname = convert_name (operation); - result = rust_lookup_type (varname, expression_context_block); + result = rust_lookup_type (varname, pstate->expression_context_block); if (result == NULL) error (_("No typed name '%s' in current context"), varname); return result; @@ -2118,7 +2118,7 @@ rust_parser::convert_ast_to_type (const struct rust_op *operation) /* We don't allow creating new tuple types (yet), but we do allow looking up existing tuple types. */ - result = rust_lookup_type (name, expression_context_block); + result = rust_lookup_type (name, pstate->expression_context_block); if (result == NULL) error (_("could not find tuple type '%s'"), name); } @@ -2311,7 +2311,8 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, struct type *type; const char *varname = convert_name (operation->left.op); - type = rust_lookup_type (varname, expression_context_block); + type = rust_lookup_type (varname, + pstate->expression_context_block); if (type != NULL) { /* This is actually a tuple struct expression, not a @@ -2372,7 +2373,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, } varname = convert_name (operation); - sym = rust_lookup_symbol (varname, expression_context_block, + sym = rust_lookup_symbol (varname, pstate->expression_context_block, VAR_DOMAIN); if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF) { @@ -2391,7 +2392,8 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, type = SYMBOL_TYPE (sym.symbol); } if (type == NULL) - type = rust_lookup_type (varname, expression_context_block); + type = rust_lookup_type (varname, + pstate->expression_context_block); if (type == NULL) error (_("No symbol '%s' in current context"), varname); @@ -2449,7 +2451,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, } name = convert_name (operation->left.op); - type = rust_lookup_type (name, expression_context_block); + type = rust_lookup_type (name, pstate->expression_context_block); if (type == NULL) error (_("Could not find type '%s'"), operation->left.sval.ptr); @@ -2707,7 +2709,8 @@ rust_lex_tests (void) int i; // Set up dummy "parser", so that rust_type works. - struct parser_state ps (&rust_language_defn, target_gdbarch ()); + struct parser_state ps (&rust_language_defn, target_gdbarch (), + nullptr, 0); rust_parser parser (&ps); rust_lex_test_one (&parser, "", 0); |