/* YACC parser for Pascal expressions, for GDB.
- Copyright (C) 2000-2021 Free Software Foundation, Inc.
+ Copyright (C) 2000-2022 Free Software Foundation, Inc.
This file is part of GDB.
block : BLOCKNAME
{
if ($1.sym.symbol != 0)
- $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
+ $$ = $1.sym.symbol->value_block ();
else
{
std::string copy = copy_name ($1.stoken);
struct symtab *tem =
lookup_symtab (copy.c_str ());
if (tem)
- $$ = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (tem),
- STATIC_BLOCK);
+ $$ = BLOCKVECTOR_BLOCK
+ (tem->compunit ()->blockvector (),
+ STATIC_BLOCK);
else
error (_("No file or function \"%s\"."),
copy.c_str ());
= lookup_symbol (copy.c_str (), $1,
VAR_DOMAIN, NULL).symbol;
- if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
+ if (!tem || tem->aclass () != LOC_BLOCK)
error (_("No function \"%s\" in specified context."),
copy.c_str ());
- $$ = SYMBOL_BLOCK_VALUE (tem); }
+ $$ = tem->value_block (); }
;
variable: block COLONCOLON name
error (_("No symbol \"%s\" in specified context."),
copy.c_str ());
- pstate->push_new<var_value_operation>
- (sym.symbol, sym.block);
+ pstate->push_new<var_value_operation> (sym);
}
;
if (symbol_read_needs_frame (sym.symbol))
pstate->block_tracker->update (sym);
- pstate->push_new<var_value_operation>
- (sym.symbol, sym.block);
- current_type = sym.symbol->type; }
+ pstate->push_new<var_value_operation> (sym);
+ current_type = sym.symbol->type (); }
else if ($1.is_a_field_of_this)
{
struct value * this_val;
lookup_bound_minimal_symbol (arg.c_str ());
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
- (msymbol.minsym, msymbol.objfile);
+ (msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
error (_("No symbol table is loaded. "
parse_number (struct parser_state *par_state,
const char *p, int len, int parsed_float, YYSTYPE *putithere)
{
- /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
- here, and we do kind of silly things like cast to unsigned. */
- LONGEST n = 0;
- LONGEST prevn = 0;
+ ULONGEST n = 0;
+ ULONGEST prevn = 0;
ULONGEST un;
int i = 0;
}
/* Handle base-switching prefixes 0x, 0t, 0d, 0. */
- if (p[0] == '0')
+ if (p[0] == '0' && len > 1)
switch (p[1])
{
case 'x':
on 0x123456789 when LONGEST is 32 bits. */
if (c != 'l' && c != 'u' && n != 0)
{
- if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
+ if (unsigned_p && prevn >= n)
error (_("Numeric constant too large."));
}
prevn = n;
the case where it is we just always shift the value more than
once, with fewer bits each time. */
- un = (ULONGEST)n >> 2;
+ un = n >> 2;
if (long_p == 0
&& (un >> (gdbarch_int_bit (par_state->gdbarch ()) - 2)) == 0)
{
/* See if it is a special token of length 3. */
if (explen > 2)
- for (int i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
- if (strncasecmp (tokstart, tokentab3[i].oper, 3) == 0
- && (!isalpha (tokentab3[i].oper[0]) || explen == 3
+ for (const auto &token : tokentab3)
+ if (strncasecmp (tokstart, token.oper, 3) == 0
+ && (!isalpha (token.oper[0]) || explen == 3
|| (!isalpha (tokstart[3])
&& !isdigit (tokstart[3]) && tokstart[3] != '_')))
{
pstate->lexptr += 3;
- yylval.opcode = tokentab3[i].opcode;
- return tokentab3[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
/* See if it is a special token of length 2. */
if (explen > 1)
- for (int i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
- if (strncasecmp (tokstart, tokentab2[i].oper, 2) == 0
- && (!isalpha (tokentab2[i].oper[0]) || explen == 2
+ for (const auto &token : tokentab2)
+ if (strncasecmp (tokstart, token.oper, 2) == 0
+ && (!isalpha (token.oper[0]) || explen == 2
|| (!isalpha (tokstart[2])
&& !isdigit (tokstart[2]) && tokstart[2] != '_')))
{
pstate->lexptr += 2;
- yylval.opcode = tokentab2[i].opcode;
- return tokentab2[i].token;
+ yylval.opcode = token.opcode;
+ return token.token;
}
switch (c = *tokstart)
/* Call lookup_symtab, not lookup_partial_symtab, in case there are
no psymtabs (coff, xcoff, or some future change to blow away the
psymtabs once once symbols are read). */
- if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
+ if ((sym && sym->aclass () == LOC_BLOCK)
|| lookup_symtab (tmp.c_str ()))
{
yylval.ssym.sym.symbol = sym;
free (uptokstart);
return BLOCKNAME;
}
- if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ if (sym && sym->aclass () == LOC_TYPEDEF)
{
#if 1
/* Despite the following flaw, we need to keep this code enabled.
VAR_DOMAIN, NULL).symbol;
if (cur_sym)
{
- if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
+ if (cur_sym->aclass () == LOC_TYPEDEF)
{
best_sym = cur_sym;
pstate->lexptr = p;
break;
}
- yylval.tsym.type = SYMBOL_TYPE (best_sym);
+ yylval.tsym.type = best_sym->type ();
#else /* not 0 */
- yylval.tsym.type = SYMBOL_TYPE (sym);
+ yylval.tsym.type = sym->type ();
#endif /* not 0 */
free (uptokstart);
return TYPENAME;