+2021-04-15 Tom Tromey <tromey@adacore.com>
+
+ * rust-exp.y (rust_parser::convert_ast_to_expression): Update.
+ * parse.c (parser_state::push_symbol, parser_state::push_dollar):
+ Update.
+ * p-exp.y (variable): Update.
+ * m2-exp.y (variable): Update.
+ * go-exp.y (variable): Update.
+ * expprint.c (dump_for_expression): New overload.
+ * expop.h (check_objfile): New overload.
+ (check_constant): New overload.
+ (class var_value_operation): Use block_symbol.
+ <get_symbol>: Rewrite.
+ * eval.c (var_value_operation::evaluate)
+ (var_value_operation::evaluate_funcall)
+ (var_value_operation::evaluate_for_address)
+ (var_value_operation::evaluate_for_address)
+ (var_value_operation::evaluate_with_coercion)
+ (var_value_operation::evaluate_for_sizeof)
+ (var_value_operation::evaluate_for_cast): Update.
+ * d-exp.y (PrimaryExpression): Update.
+ * c-exp.y (variable): Update.
+ * ax-gdb.c (var_value_operation::do_generate_ax): Update.
+ * ada-lang.c (ada_var_value_operation::evaluate_for_cast)
+ (ada_var_value_operation::evaluate)
+ (ada_var_value_operation::resolve)
+ (ada_funcall_operation::resolve): Update.
+ * ada-exp.y (write_var_from_sym, write_object_renaming)
+ (write_ambiguous_var, write_var_or_type, write_name_assoc)
+ (maybe_overload): Update.
+ * ada-exp.h (class ada_var_value_operation) <get_block>: Rewrite.
+
2021-04-15 Tom Tromey <tom@tromey.com>
Andrew Burgess <andrew.burgess@embecosm.com>
* top.c (print_gdb_version): Update copyright year.
-2021-01-01 Joel Brobecker <brobecker@adacore.com>
+2021-01-01, 21 Joel Brobecker <brobecker@adacore.com>
* config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2020.
/* Definitions for Ada expressions
- Copyright (C) 2020 Free Software Foundation, Inc.
+ Copyright (C) 2020, 2021 Free Software Foundation, Inc.
This file is part of GDB.
enum noside noside) override;
const block *get_block () const
- { return std::get<1> (m_storage); }
+ { return std::get<0> (m_storage).block; }
bool resolve (struct expression *exp,
bool deprocedure_p,
if (symbol_read_needs_frame (fn.symbol))
pstate->block_tracker->update (fn.block, INNERMOST_BLOCK_FOR_SYMBOLS);
- operation_up callee
- = make_operation<ada_var_value_operation> (fn.symbol, fn.block);
+ operation_up callee = make_operation<ada_var_value_operation> (fn);
std::vector<operation_up> argvec;
argvec.push_back (std::move (lhs));
non-NULL). */
static void
-write_var_from_sym (struct parser_state *par_state,
- const struct block *block,
- struct symbol *sym)
+write_var_from_sym (struct parser_state *par_state, block_symbol sym)
{
- if (symbol_read_needs_frame (sym))
- par_state->block_tracker->update (block, INNERMOST_BLOCK_FOR_SYMBOLS);
+ if (symbol_read_needs_frame (sym.symbol))
+ par_state->block_tracker->update (sym.block, INNERMOST_BLOCK_FOR_SYMBOLS);
- par_state->push_new<ada_var_value_operation> (sym, block);
+ par_state->push_new<ada_var_value_operation> (sym);
}
/* Write integer or boolean constant ARG of type TYPE. */
&inner_renaming_expr))
{
case ADA_NOT_RENAMING:
- write_var_from_sym (par_state, sym_info.block, sym_info.symbol);
+ write_var_from_sym (par_state, sym_info);
break;
case ADA_OBJECT_RENAMING:
write_object_renaming (par_state, sym_info.block,
else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
/* Index is an old-style renaming symbol. */
index_sym_info.block = orig_left_context;
- write_var_from_sym (par_state, index_sym_info.block,
- index_sym_info.symbol);
+ write_var_from_sym (par_state, index_sym_info);
}
if (slice_state == SIMPLE_INDEX)
ada_funcall (1);
sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
sym->set_language (language_ada, nullptr);
- par_state->push_new<ada_var_value_operation> (sym, block);
+ block_symbol bsym { sym, block };
+ par_state->push_new<ada_var_value_operation> (bsym);
}
/* A convenient wrapper around ada_get_field_index that takes
if (syms.size () == 1)
{
- write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
+ write_var_from_sym (par_state, syms[0]);
write_selectors (par_state, encoded_name + tail_index);
return NULL;
}
if (syms.size () != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
pstate->push_new<ada_string_operation> (copy_name (name));
else
- write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
+ write_var_from_sym (par_state, syms[0]);
}
else
if (write_var_or_type (par_state, NULL, name) != NULL)
enum noside noside)
{
value *val = evaluate_var_value (noside,
- std::get<1> (m_storage),
- std::get<0> (m_storage));
+ std::get<0> (m_storage).block,
+ std::get<0> (m_storage).symbol);
val = ada_value_cast (expect_type, val);
struct expression *exp,
enum noside noside)
{
- symbol *sym = std::get<0> (m_storage);
+ symbol *sym = std::get<0> (m_storage).symbol;
if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
/* Only encountered when an unresolved symbol occurs in a
innermost_block_tracker *tracker,
struct type *context_type)
{
- symbol *sym = std::get<0> (m_storage);
+ symbol *sym = std::get<0> (m_storage).symbol;
if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
{
block_symbol resolved
- = ada_resolve_variable (sym, std::get<1> (m_storage),
+ = ada_resolve_variable (sym, std::get<0> (m_storage).block,
context_type, parse_completion,
deprocedure_p, tracker);
- std::get<0> (m_storage) = resolved.symbol;
- std::get<1> (m_storage) = resolved.block;
+ std::get<0> (m_storage) = resolved;
}
if (deprocedure_p
- && SYMBOL_TYPE (std::get<0> (m_storage))->code () == TYPE_CODE_FUNC)
+ && (SYMBOL_TYPE (std::get<0> (m_storage).symbol)->code ()
+ == TYPE_CODE_FUNC))
return true;
return false;
tracker);
std::get<0> (m_storage)
- = make_operation<ada_var_value_operation> (resolved.symbol,
- resolved.block);
+ = make_operation<ada_var_value_operation> (resolved);
return false;
}
struct axs_value *value,
struct type *cast_type)
{
- gen_var_ref (ax, value, std::get<0> (m_storage));
+ gen_var_ref (ax, value, std::get<0> (m_storage).symbol);
if (value->optimized_out)
error (_("`%s' has been optimized out, cannot use"),
- std::get<0> (m_storage)->print_name ());
+ std::get<0> (m_storage).symbol->print_name ());
if (value->type->code () == TYPE_CODE_ERROR)
{
if (cast_type == nullptr)
- error_unknown_type (std::get<0> (m_storage)->print_name ());
+ error_unknown_type (std::get<0> (m_storage).symbol->print_name ());
value->type = cast_type;
}
}
if (symbol_read_needs_frame (sym.symbol))
pstate->block_tracker->update (sym);
- pstate->push_new<var_value_operation> (sym.symbol,
- sym.block);
+ pstate->push_new<var_value_operation> (sym);
}
;
pstate->push_new<var_msym_value_operation>
(resolver);
else
- pstate->push_new<var_value_operation>
- (sym.symbol, sym.block);
+ pstate->push_new<var_value_operation> (sym);
}
else if ($1.is_a_field_of_this)
{
? find_function_alias_target (msymbol)
: NULL);
if (alias_target != NULL)
- pstate->push_new<var_value_operation>
- (alias_target, SYMBOL_BLOCK_VALUE (alias_target));
+ {
+ block_symbol bsym { alias_target,
+ SYMBOL_BLOCK_VALUE (alias_target) };
+ pstate->push_new<var_value_operation> (bsym);
+ }
else
pstate->push_new<var_msym_value_operation>
(msymbol);
{
if (symbol_read_needs_frame (sym.symbol))
pstate->block_tracker->update (sym);
- pstate->push_new<var_value_operation> (sym.symbol,
- sym.block);
+ pstate->push_new<var_value_operation> (sym);
}
else if (is_a_field_of_this.type != NULL)
{
struct expression *exp,
enum noside noside)
{
- symbol *var = std::get<0> (m_storage);
+ symbol *var = std::get<0> (m_storage).symbol;
if (SYMBOL_TYPE (var)->code () == TYPE_CODE_ERROR)
error_unknown_type (var->print_name ());
- return evaluate_var_value (noside, std::get<1> (m_storage), var);
+ return evaluate_var_value (noside, std::get<0> (m_storage).block, var);
}
} /* namespace expr */
struct symbol *symp;
find_overload_match (argvec, NULL, NON_METHOD,
- NULL, std::get<0> (m_storage),
+ NULL, std::get<0> (m_storage).symbol,
NULL, &symp, NULL, 0, noside);
if (SYMBOL_TYPE (symp)->code () == TYPE_CODE_ERROR)
error_unknown_type (symp->print_name ());
- value *callee = evaluate_var_value (noside, std::get<1> (m_storage), symp);
+ value *callee = evaluate_var_value (noside, std::get<0> (m_storage).block,
+ symp);
return evaluate_subexp_do_call (exp, noside, callee, argvec,
nullptr, expect_type);
var_value_operation::evaluate_for_address (struct expression *exp,
enum noside noside)
{
- symbol *var = std::get<0> (m_storage);
+ symbol *var = std::get<0> (m_storage).symbol;
/* C++: The "address" of a reference should yield the address
* of the object pointed to. Let value_addr() deal with it. */
return value_zero (type, not_lval);
}
else
- return address_of_variable (var, std::get<1> (m_storage));
+ return address_of_variable (var, std::get<0> (m_storage).block);
}
value *
var_value_operation::evaluate_with_coercion (struct expression *exp,
enum noside noside)
{
- struct symbol *var = std::get<0> (m_storage);
+ struct symbol *var = std::get<0> (m_storage).symbol;
struct type *type = check_typedef (SYMBOL_TYPE (var));
if (type->code () == TYPE_CODE_ARRAY
&& !type->is_vector ()
&& CAST_IS_CONVERSION (exp->language_defn))
{
- struct value *val = address_of_variable (var, std::get<1> (m_storage));
+ struct value *val = address_of_variable (var,
+ std::get<0> (m_storage).block);
return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)), val);
}
return evaluate (nullptr, exp, noside);
var_value_operation::evaluate_for_sizeof (struct expression *exp,
enum noside noside)
{
- struct type *type = SYMBOL_TYPE (std::get<0> (m_storage));
+ struct type *type = SYMBOL_TYPE (std::get<0> (m_storage).symbol);
if (is_dynamic_type (type))
{
value *val = evaluate (nullptr, exp, EVAL_NORMAL);
enum noside noside)
{
value *val = evaluate_var_value (noside,
- std::get<1> (m_storage),
- std::get<0> (m_storage));
+ std::get<0> (m_storage).block,
+ std::get<0> (m_storage).symbol);
val = value_cast (to_type, val);
return exp_objfile == objfile;
}
-static inline bool
+static inline bool
check_objfile (struct type *type, struct objfile *objfile)
{
struct objfile *ty_objfile = type->objfile_owner ();
return false;
}
-static inline bool
+static inline bool
check_objfile (struct symbol *sym, struct objfile *objfile)
{
return check_objfile (symbol_objfile (sym), objfile);
}
-static inline bool
+static inline bool
check_objfile (const struct block *block, struct objfile *objfile)
{
return check_objfile (block_objfile (block), objfile);
}
+static inline bool
+check_objfile (const block_symbol &sym, struct objfile *objfile)
+{
+ return (check_objfile (sym.symbol, objfile)
+ || check_objfile (sym.block, objfile));
+}
+
static inline bool
check_objfile (bound_minimal_symbol minsym, struct objfile *objfile)
{
return false;
}
-static inline bool
+static inline bool
check_objfile (const operation_up &op, struct objfile *objfile)
{
return op->uses_objfile (objfile);
}
template<typename T>
-static inline bool
+static inline bool
check_objfile (const std::vector<T> &collection, struct objfile *objfile)
{
for (const auto &item : collection)
}
template<typename S, typename T>
-static inline bool
+static inline bool
check_objfile (const std::pair<S, T> &item, struct objfile *objfile)
{
return (check_objfile (item.first, objfile)
internalvar *ivar);
extern void dump_for_expression (struct ui_file *stream, int depth,
symbol *sym);
+extern void dump_for_expression (struct ui_file *stream, int depth,
+ const block_symbol &sym);
extern void dump_for_expression (struct ui_file *stream, int depth,
bound_minimal_symbol msym);
extern void dump_for_expression (struct ui_file *stream, int depth,
|| sc == LOC_LABEL);
}
+static inline bool
+check_constant (const block_symbol &sym)
+{
+ /* We know the block is constant, so we only need to check the
+ symbol. */
+ return check_constant (sym.symbol);
+}
+
template<typename T>
static inline bool
check_constant (const std::vector<T> &collection)
/* Compute the value of a variable. */
class var_value_operation
- : public maybe_constant_operation<symbol *, const block *>
+ : public maybe_constant_operation<block_symbol>
{
public:
/* Return the symbol referenced by this object. */
symbol *get_symbol () const
{
- return std::get<0> (m_storage);
+ return std::get<0> (m_storage).symbol;
}
protected:
fprintf_filtered (stream, _("%*sBlock: %p\n"), depth, "", bl);
}
+void
+dump_for_expression (struct ui_file *stream, int depth,
+ const block_symbol &sym)
+{
+ fprintf_filtered (stream, _("%*sBlock symbol:\n"), depth, "");
+ dump_for_expression (stream, depth + 1, sym.symbol);
+ dump_for_expression (stream, depth + 1, sym.block);
+}
+
void
dump_for_expression (struct ui_file *stream, int depth,
type_instance_flags flags)
if (symbol_read_needs_frame (sym.symbol))
pstate->block_tracker->update (sym);
- pstate->push_new<var_value_operation>
- (sym.symbol, sym.block);
+ pstate->push_new<var_value_operation> (sym);
}
else if ($1.is_a_field_of_this)
{
/* Useful for assigning to PROCEDURE variables */
variable: fblock
{
- pstate->push_new<var_value_operation>
- ($1, nullptr);
+ block_symbol sym { $1, nullptr };
+ 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);
+ pstate->push_new<var_value_operation> (sym);
}
;
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);
+ pstate->push_new<var_value_operation> (sym);
current_type = sym.symbol->type; }
else if ($1.is_a_field_of_this)
{
{
if (symbol_read_needs_frame (sym.symbol))
block_tracker->update (sym);
- push_new<expr::var_value_operation> (sym.symbol, sym.block);
+ push_new<expr::var_value_operation> (sym);
}
else
{
sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL);
if (sym.symbol)
{
- push_new<expr::var_value_operation> (sym.symbol, sym.block);
+ push_new<expr::var_value_operation> (sym);
return;
}
msym = lookup_bound_minimal_symbol (copy.c_str ());
VAR_DOMAIN);
operation_up result;
if (sym.symbol != NULL && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
- result.reset (new var_value_operation (sym.symbol, sym.block));
+ result.reset (new var_value_operation (sym));
else
{
struct type *type = NULL;