/* YACC parser for Ada expressions, for GDB.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2020 Free Software Foundation, Inc.
This file is part of GDB.
#define yy_switch_to_buffer ada_yy_switch_to_buffer
#define yyrestart ada_yyrestart
#define yytext ada_yytext
-#define yywrap ada_yywrap
static struct obstack temp_parse_space;
static void
yyerror (const char *msg)
{
- error (_("Error in expression, near `%s'."), lexptr);
+ error (_("Error in expression, near `%s'."), pstate->lexptr);
}
/* Emit expression to access an instance of SYM, in block BLOCK (if
struct symbol *sym)
{
if (symbol_read_needs_frame (sym))
- innermost_block.update (block, INNERMOST_BLOCK_FOR_SYMBOLS);
+ par_state->block_tracker->update (block, INNERMOST_BLOCK_FOR_SYMBOLS);
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
write_exp_elt_block (par_state, block);
if (orig_left_context == NULL)
orig_left_context = get_selected_block (NULL);
- name = (char *) obstack_copy0 (&temp_parse_space, renamed_entity,
- renamed_entity_len);
+ name = obstack_strndup (&temp_parse_space, renamed_entity,
+ renamed_entity_len);
ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
if (sym_info.symbol == NULL)
- error (_("Could not find renamed variable: %s"), ada_decode (name));
+ error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
else if (SYMBOL_CLASS (sym_info.symbol) == LOC_TYPEDEF)
/* We have a renaming of an old-style renaming symbol. Don't
trust the block information. */
if (end == NULL)
end = renaming_expr + strlen (renaming_expr);
- index_name
- = (char *) obstack_copy0 (&temp_parse_space, renaming_expr,
- end - renaming_expr);
+ index_name = obstack_strndup (&temp_parse_space, renaming_expr,
+ end - renaming_expr);
renaming_expr = end;
ada_lookup_encoded_symbol (index_name, orig_left_context,
(char *) alloca (strlen (name) + sizeof ("standard__"));
strcpy (expanded_name, "standard__");
strcat (expanded_name, name);
- sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL).symbol;
+ sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol;
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
type = SYMBOL_TYPE (sym);
}
write_ambiguous_var (struct parser_state *par_state,
const struct block *block, char *name, int len)
{
- struct symbol *sym = XOBNEW (&temp_parse_space, struct symbol);
+ struct symbol *sym = new (&temp_parse_space) symbol ();
- memset (sym, 0, sizeof (struct symbol));
SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
- SYMBOL_LINKAGE_NAME (sym)
- = (const char *) obstack_copy0 (&temp_parse_space, name, len);
- SYMBOL_LANGUAGE (sym) = language_ada;
+ sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
+ sym->set_language (language_ada, nullptr);
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
write_exp_elt_block (par_state, block);
fieldno = ada_get_field_index (type, field_name, 1);
if (fieldno >= 0)
- return TYPE_FIELD_TYPE (type, fieldno);
+ return type->field (fieldno).type ();
subfield_name = field_name;
while (*subfield_name != '\0' && *subfield_name != '.'
if (fieldno < 0)
return NULL;
- type = TYPE_FIELD_TYPE (type, fieldno);
+ type = type->field (fieldno).type ();
field_name = subfield_name;
}
int name_len;
if (block == NULL)
- block = expression_context_block;
+ block = par_state->expression_context_block;
encoded_name = ada_encode (name0.ptr);
name_len = strlen (encoded_name);
- encoded_name
- = (char *) obstack_copy0 (&temp_parse_space, encoded_name, name_len);
+ encoded_name = obstack_strndup (&temp_parse_space, encoded_name, name_len);
for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1)
{
int tail_index;
VAR_DOMAIN, &syms);
encoded_name[tail_index] = terminator;
- /* A single symbol may rename a package or object. */
-
- /* This should go away when we move entirely to new version.
- FIXME pnh 7/20/2007. */
- if (nsyms == 1)
- {
- struct symbol *ren_sym =
- ada_find_renaming_symbol (syms[0].symbol, syms[0].block);
-
- if (ren_sym != NULL)
- syms[0].symbol = ren_sym;
- }
-
type_sym = select_possible_type_sym (syms);
if (type_sym != NULL)
if (!have_full_symbols () && !have_partial_symbols () && block == NULL)
error (_("No symbol table is loaded. Use the \"file\" command."));
- if (block == expression_context_block)
+ if (block == par_state->expression_context_block)
error (_("No definition of \"%s\" in current context."), name0.ptr);
else
error (_("No definition of \"%s\" in specified context."), name0.ptr);
if (strchr (name.ptr, '.') == NULL)
{
std::vector<struct block_symbol> syms;
- int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
+ int nsyms = ada_lookup_symbol_list (name.ptr,
+ par_state->expression_context_block,
VAR_DOMAIN, &syms);
if (nsyms != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
if (type == NULL)
return val;
type = check_typedef (type);
- if (TYPE_CODE (type) != TYPE_CODE_ENUM)
+ if (type->code () != TYPE_CODE_ENUM)
return val;
- xsnprintf (name, sizeof (name), "QU%02x", (int) val);
- for (f = 0; f < TYPE_NFIELDS (type); f += 1)
+ if ((val >= 'a' && val <= 'z') || (val >= '0' && val <= '9'))
+ xsnprintf (name, sizeof (name), "Q%c", (int) val);
+ else
+ xsnprintf (name, sizeof (name), "QU%02x", (int) val);
+ size_t len = strlen (name);
+ for (f = 0; f < type->num_fields (); f += 1)
{
- if (strcmp (name, TYPE_FIELD_NAME (type, f)) == 0)
+ /* Check the suffix because an enum constant in a package will
+ have a name like "pkg__QUxx". This is safe enough because we
+ already have the correct type, and because mangling means
+ there can't be clashes. */
+ const char *ename = TYPE_FIELD_NAME (type, f);
+ size_t elen = strlen (ename);
+
+ if (elen >= len && strcmp (name, ename + elen - len) == 0)
return TYPE_FIELD_ENUMVAL (type, f);
}
return val;
return type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
}
+void _initialize_ada_exp ();
void
-_initialize_ada_exp (void)
+_initialize_ada_exp ()
{
obstack_init (&temp_parse_space);
}