Turn parse_language into a method
This changes parse_language into a method of parser_state. This patch was written by a script. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y: Replace "parse_language" with method call. * p-exp.y: (yylex): Replace "parse_language" with method call. * m2-exp.y: (yylex): Replace "parse_language" with method call. * go-exp.y (classify_name): Replace "parse_language" with method call. * f-exp.y (yylex): Replace "parse_language" with method call. * d-exp.y (lex_one_token): Replace "parse_language" with method call. * c-exp.y: (lex_one_token, classify_name, yylex): Replace "parse_language" with method call. * ada-exp.y (find_primitive_type, type_char) (type_system_address): Replace "parse_language" with method call.
This commit is contained in:
parent
fa9f5be683
commit
73923d7eed
@ -1,3 +1,21 @@
|
||||
2019-04-04 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* rust-exp.y: Replace "parse_language" with method call.
|
||||
* p-exp.y:
|
||||
(yylex): Replace "parse_language" with method call.
|
||||
* m2-exp.y:
|
||||
(yylex): Replace "parse_language" with method call.
|
||||
* go-exp.y (classify_name): Replace "parse_language" with method
|
||||
call.
|
||||
* f-exp.y (yylex): Replace "parse_language" with method call.
|
||||
* d-exp.y (lex_one_token): Replace "parse_language" with method
|
||||
call.
|
||||
* c-exp.y:
|
||||
(lex_one_token, classify_name, yylex): Replace "parse_language"
|
||||
with method call.
|
||||
* ada-exp.y (find_primitive_type, type_char)
|
||||
(type_system_address): Replace "parse_language" with method call.
|
||||
|
||||
2019-04-04 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* rust-exp.y: Replace "parse_gdbarch" with method call.
|
||||
|
@ -1027,7 +1027,7 @@ static struct type*
|
||||
find_primitive_type (struct parser_state *par_state, char *name)
|
||||
{
|
||||
struct type *type;
|
||||
type = language_lookup_primitive_type (parse_language (par_state),
|
||||
type = language_lookup_primitive_type (par_state->language (),
|
||||
par_state->gdbarch (),
|
||||
name);
|
||||
if (type == NULL && strcmp ("system__address", name) == 0)
|
||||
@ -1442,7 +1442,7 @@ type_long_double (struct parser_state *par_state)
|
||||
static struct type *
|
||||
type_char (struct parser_state *par_state)
|
||||
{
|
||||
return language_string_char_type (parse_language (par_state),
|
||||
return language_string_char_type (par_state->language (),
|
||||
par_state->gdbarch ());
|
||||
}
|
||||
|
||||
@ -1456,7 +1456,7 @@ static struct type *
|
||||
type_system_address (struct parser_state *par_state)
|
||||
{
|
||||
struct type *type
|
||||
= language_lookup_primitive_type (parse_language (par_state),
|
||||
= language_lookup_primitive_type (par_state->language (),
|
||||
par_state->gdbarch (),
|
||||
"system__address");
|
||||
return type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
|
||||
|
92
gdb/c-exp.y
92
gdb/c-exp.y
@ -815,7 +815,7 @@ exp : SIZEOF '(' type ')' %prec UNARY
|
||||
{ struct type *type = $3;
|
||||
write_exp_elt_opcode (pstate, OP_LONG);
|
||||
write_exp_elt_type (pstate, lookup_signed_typename
|
||||
(parse_language (pstate),
|
||||
(pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"int"));
|
||||
type = check_typedef (type);
|
||||
@ -1284,117 +1284,117 @@ typebase
|
||||
: TYPENAME
|
||||
{ $$ = $1.type; }
|
||||
| INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"int"); }
|
||||
| LONG
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| SHORT
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| LONG INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| LONG SIGNED_KEYWORD INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| LONG SIGNED_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| SIGNED_KEYWORD LONG INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| UNSIGNED LONG INT_KEYWORD
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| LONG UNSIGNED INT_KEYWORD
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| LONG UNSIGNED
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long"); }
|
||||
| LONG LONG
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| LONG LONG INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| LONG LONG SIGNED_KEYWORD INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| LONG LONG SIGNED_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| SIGNED_KEYWORD LONG LONG
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| SIGNED_KEYWORD LONG LONG INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| UNSIGNED LONG LONG
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| UNSIGNED LONG LONG INT_KEYWORD
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| LONG LONG UNSIGNED
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| LONG LONG UNSIGNED INT_KEYWORD
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long long"); }
|
||||
| SHORT INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| SHORT SIGNED_KEYWORD INT_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| SHORT SIGNED_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| UNSIGNED SHORT INT_KEYWORD
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| SHORT UNSIGNED
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| SHORT UNSIGNED INT_KEYWORD
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short"); }
|
||||
| DOUBLE_KEYWORD
|
||||
{ $$ = lookup_typename (parse_language (pstate),
|
||||
{ $$ = lookup_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"double",
|
||||
NULL,
|
||||
0); }
|
||||
| LONG DOUBLE_KEYWORD
|
||||
{ $$ = lookup_typename (parse_language (pstate),
|
||||
{ $$ = lookup_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long double",
|
||||
NULL,
|
||||
@ -1456,19 +1456,19 @@ typebase
|
||||
$$ = NULL;
|
||||
}
|
||||
| UNSIGNED type_name
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
TYPE_NAME($2.type)); }
|
||||
| UNSIGNED
|
||||
{ $$ = lookup_unsigned_typename (parse_language (pstate),
|
||||
{ $$ = lookup_unsigned_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"int"); }
|
||||
| SIGNED_KEYWORD type_name
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
TYPE_NAME($2.type)); }
|
||||
| SIGNED_KEYWORD
|
||||
{ $$ = lookup_signed_typename (parse_language (pstate),
|
||||
{ $$ = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"int"); }
|
||||
/* It appears that this rule for templates is never
|
||||
@ -1489,7 +1489,7 @@ type_name: TYPENAME
|
||||
{
|
||||
$$.stoken.ptr = "int";
|
||||
$$.stoken.length = 3;
|
||||
$$.type = lookup_signed_typename (parse_language (pstate),
|
||||
$$.type = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"int");
|
||||
}
|
||||
@ -1497,7 +1497,7 @@ type_name: TYPENAME
|
||||
{
|
||||
$$.stoken.ptr = "long";
|
||||
$$.stoken.length = 4;
|
||||
$$.type = lookup_signed_typename (parse_language (pstate),
|
||||
$$.type = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"long");
|
||||
}
|
||||
@ -1505,7 +1505,7 @@ type_name: TYPENAME
|
||||
{
|
||||
$$.stoken.ptr = "short";
|
||||
$$.stoken.length = 5;
|
||||
$$.type = lookup_signed_typename (parse_language (pstate),
|
||||
$$.type = lookup_signed_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"short");
|
||||
}
|
||||
@ -2555,7 +2555,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
|
||||
if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
|
||||
{
|
||||
if ((tokentab3[i].flags & FLAG_CXX) != 0
|
||||
&& parse_language (par_state)->la_language != language_cplus)
|
||||
&& par_state->language ()->la_language != language_cplus)
|
||||
break;
|
||||
|
||||
lexptr += 3;
|
||||
@ -2568,7 +2568,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
|
||||
if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
|
||||
{
|
||||
if ((tokentab2[i].flags & FLAG_CXX) != 0
|
||||
&& parse_language (par_state)->la_language != language_cplus)
|
||||
&& par_state->language ()->la_language != language_cplus)
|
||||
break;
|
||||
|
||||
lexptr += 2;
|
||||
@ -2612,7 +2612,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
|
||||
case '(':
|
||||
paren_depth++;
|
||||
lexptr++;
|
||||
if (parse_language (par_state)->la_language == language_objc
|
||||
if (par_state->language ()->la_language == language_objc
|
||||
&& c == '[')
|
||||
return OBJC_LBRAC;
|
||||
return c;
|
||||
@ -2710,7 +2710,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
|
||||
{
|
||||
const char *p = &tokstart[1];
|
||||
|
||||
if (parse_language (par_state)->la_language == language_objc)
|
||||
if (par_state->language ()->la_language == language_objc)
|
||||
{
|
||||
size_t len = strlen ("selector");
|
||||
|
||||
@ -2862,7 +2862,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
|
||||
if (strcmp (copy, ident_tokens[i].oper) == 0)
|
||||
{
|
||||
if ((ident_tokens[i].flags & FLAG_CXX) != 0
|
||||
&& parse_language (par_state)->la_language != language_cplus)
|
||||
&& par_state->language ()->la_language != language_cplus)
|
||||
break;
|
||||
|
||||
if ((ident_tokens[i].flags & FLAG_SHADOW) != 0)
|
||||
@ -2871,7 +2871,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
|
||||
|
||||
if (lookup_symbol (copy, expression_context_block,
|
||||
VAR_DOMAIN,
|
||||
(parse_language (par_state)->la_language
|
||||
(par_state->language ()->la_language
|
||||
== language_cplus ? &is_a_field_of_this
|
||||
: NULL)).symbol
|
||||
!= NULL)
|
||||
@ -2940,7 +2940,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
|
||||
memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
|
||||
|
||||
bsym = lookup_symbol (copy, block, VAR_DOMAIN,
|
||||
parse_language (par_state)->la_name_of_this
|
||||
par_state->language ()->la_name_of_this
|
||||
? &is_a_field_of_this : NULL);
|
||||
|
||||
if (bsym.symbol && SYMBOL_CLASS (bsym.symbol) == LOC_BLOCK)
|
||||
@ -2999,7 +2999,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
|
||||
}
|
||||
|
||||
/* See if it's an ObjC classname. */
|
||||
if (parse_language (par_state)->la_language == language_objc && !bsym.symbol)
|
||||
if (par_state->language ()->la_language == language_objc && !bsym.symbol)
|
||||
{
|
||||
CORE_ADDR Class = lookup_objc_class (par_state->gdbarch (), copy);
|
||||
if (Class)
|
||||
@ -3038,7 +3038,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
|
||||
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
|
||||
|
||||
if (bsym.symbol == NULL
|
||||
&& parse_language (par_state)->la_language == language_cplus
|
||||
&& par_state->language ()->la_language == language_cplus
|
||||
&& is_a_field_of_this.type == NULL
|
||||
&& lookup_minimal_symbol (copy, NULL, NULL).minsym == NULL)
|
||||
return UNKNOWN_CPP_NAME;
|
||||
@ -3147,7 +3147,7 @@ yylex (void)
|
||||
if (current.token == NAME)
|
||||
current.token = classify_name (pstate, expression_context_block,
|
||||
is_quoted_name, last_lex_was_structop);
|
||||
if (parse_language (pstate)->la_language != language_cplus
|
||||
if (pstate->language ()->la_language != language_cplus
|
||||
|| (current.token != TYPENAME && current.token != COLONCOLON
|
||||
&& current.token != FILENAME))
|
||||
return current.token;
|
||||
|
@ -1288,7 +1288,7 @@ lex_one_token (struct parser_state *par_state)
|
||||
return DOLLAR_VARIABLE;
|
||||
|
||||
yylval.tsym.type
|
||||
= language_lookup_primitive_type (parse_language (par_state),
|
||||
= language_lookup_primitive_type (par_state->language (),
|
||||
par_state->gdbarch (), copy);
|
||||
if (yylval.tsym.type != NULL)
|
||||
return TYPENAME;
|
||||
|
@ -1276,7 +1276,7 @@ yylex (void)
|
||||
|
||||
result = lookup_symbol (tmp, expression_context_block,
|
||||
lookup_domains[i],
|
||||
parse_language (pstate)->la_language
|
||||
pstate->language ()->la_language
|
||||
== language_cplus
|
||||
? &is_a_field_of_this : NULL);
|
||||
if (result.symbol && SYMBOL_CLASS (result.symbol) == LOC_TYPEDEF)
|
||||
@ -1290,7 +1290,7 @@ yylex (void)
|
||||
}
|
||||
|
||||
yylval.tsym.type
|
||||
= language_lookup_primitive_type (parse_language (pstate),
|
||||
= language_lookup_primitive_type (pstate->language (),
|
||||
pstate->gdbarch (), tmp);
|
||||
if (yylval.tsym.type != NULL)
|
||||
return TYPENAME;
|
||||
|
@ -1400,7 +1400,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
|
||||
copy = copy_name (yylval.sval);
|
||||
|
||||
/* Try primitive types first so they win over bad/weird debug info. */
|
||||
type = language_lookup_primitive_type (parse_language (par_state),
|
||||
type = language_lookup_primitive_type (par_state->language (),
|
||||
par_state->gdbarch (),
|
||||
copy);
|
||||
if (type != NULL)
|
||||
|
@ -596,7 +596,7 @@ variable: NAME
|
||||
|
||||
type
|
||||
: TYPENAME
|
||||
{ $$ = lookup_typename (parse_language (pstate),
|
||||
{ $$ = lookup_typename (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
copy_name ($1),
|
||||
expression_context_block, 0); }
|
||||
@ -968,7 +968,7 @@ yylex (void)
|
||||
sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, 0).symbol;
|
||||
if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
|
||||
return BLOCKNAME;
|
||||
if (lookup_typename (parse_language (pstate), pstate->gdbarch (),
|
||||
if (lookup_typename (pstate->language (), pstate->gdbarch (),
|
||||
copy_name (yylval.sval),
|
||||
expression_context_block, 1))
|
||||
return TYPENAME;
|
||||
|
@ -591,7 +591,7 @@ exp : THIS
|
||||
write_exp_elt_opcode (pstate, OP_THIS);
|
||||
/* We need type of this. */
|
||||
this_val
|
||||
= value_of_this_silent (parse_language (pstate));
|
||||
= value_of_this_silent (pstate->language ());
|
||||
if (this_val)
|
||||
this_type = value_type (this_val);
|
||||
else
|
||||
@ -731,7 +731,7 @@ variable: name_not_typename
|
||||
write_exp_elt_opcode (pstate, STRUCTOP_PTR);
|
||||
/* We need type of this. */
|
||||
this_val
|
||||
= value_of_this_silent (parse_language (pstate));
|
||||
= value_of_this_silent (pstate->language ());
|
||||
if (this_val)
|
||||
this_type = value_type (this_val);
|
||||
else
|
||||
@ -1675,7 +1675,7 @@ yylex (void)
|
||||
return TYPENAME;
|
||||
}
|
||||
yylval.tsym.type
|
||||
= language_lookup_primitive_type (parse_language (pstate),
|
||||
= language_lookup_primitive_type (pstate->language (),
|
||||
pstate->gdbarch (), tmp);
|
||||
if (yylval.tsym.type != NULL)
|
||||
{
|
||||
|
@ -32,8 +32,6 @@ struct internalvar;
|
||||
|
||||
extern int parser_debug;
|
||||
|
||||
#define parse_language(ps) ((ps)->expout->language_defn)
|
||||
|
||||
struct parser_state
|
||||
{
|
||||
/* Constructor. LANG is the language used to parse the expression.
|
||||
@ -55,6 +53,13 @@ struct parser_state
|
||||
return expout->gdbarch;
|
||||
}
|
||||
|
||||
/* Return the language that was passed to the constructor. */
|
||||
|
||||
const struct language_defn *language ()
|
||||
{
|
||||
return expout->language_defn;
|
||||
}
|
||||
|
||||
/* The size of the expression above. */
|
||||
|
||||
size_t expout_size;
|
||||
|
@ -205,7 +205,7 @@ struct rust_parser
|
||||
/* Return the parser's language. */
|
||||
const struct language_defn *language () const
|
||||
{
|
||||
return parse_language (pstate);
|
||||
return pstate->language ();
|
||||
}
|
||||
|
||||
/* Return the parser's gdbarch. */
|
||||
@ -2280,7 +2280,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
|
||||
{
|
||||
struct type *type;
|
||||
|
||||
type = language_lookup_primitive_type (parse_language (pstate),
|
||||
type = language_lookup_primitive_type (pstate->language (),
|
||||
pstate->gdbarch (),
|
||||
"()");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user