mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-28 10:00:51 +00:00
Introduce op_this_operation
This adds class op_this_operation, which implements OP_THIS. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class op_this_operation): New. * ax-gdb.c (op_this_operation::do_generate_ax): New method.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* expop.h (class op_this_operation): New.
|
||||
* ax-gdb.c (op_this_operation::do_generate_ax): New method.
|
||||
|
||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* expop.h (class unop_memval_operation)
|
||||
|
||||
25
gdb/ax-gdb.c
25
gdb/ax-gdb.c
@@ -2554,6 +2554,31 @@ unop_memval_type_operation::do_generate_ax (struct expression *exp,
|
||||
value->kind = axs_lvalue_memory;
|
||||
}
|
||||
|
||||
void
|
||||
op_this_operation::do_generate_ax (struct expression *exp,
|
||||
struct agent_expr *ax,
|
||||
struct axs_value *value,
|
||||
struct type *cast_type)
|
||||
{
|
||||
struct symbol *sym, *func;
|
||||
const struct block *b;
|
||||
const struct language_defn *lang;
|
||||
|
||||
b = block_for_pc (ax->scope);
|
||||
func = block_linkage_function (b);
|
||||
lang = language_def (func->language ());
|
||||
|
||||
sym = lookup_language_this (lang, b).symbol;
|
||||
if (!sym)
|
||||
error (_("no `%s' found"), lang->name_of_this ());
|
||||
|
||||
gen_var_ref (ax, value, sym);
|
||||
|
||||
if (value->optimized_out)
|
||||
error (_("`%s' has been optimized out, cannot use"),
|
||||
sym->print_name ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* This handles the middle-to-right-side of code generation for binary
|
||||
|
||||
27
gdb/expop.h
27
gdb/expop.h
@@ -1713,6 +1713,33 @@ protected:
|
||||
override;
|
||||
};
|
||||
|
||||
/* Implement the 'this' expression. */
|
||||
class op_this_operation
|
||||
: public tuple_holding_operation<>
|
||||
{
|
||||
public:
|
||||
|
||||
using tuple_holding_operation::tuple_holding_operation;
|
||||
|
||||
value *evaluate (struct type *expect_type,
|
||||
struct expression *exp,
|
||||
enum noside noside) override
|
||||
{
|
||||
return value_of_this (exp->language_defn);
|
||||
}
|
||||
|
||||
enum exp_opcode opcode () const override
|
||||
{ return OP_THIS; }
|
||||
|
||||
protected:
|
||||
|
||||
void do_generate_ax (struct expression *exp,
|
||||
struct agent_expr *ax,
|
||||
struct axs_value *value,
|
||||
struct type *cast_type)
|
||||
override;
|
||||
};
|
||||
|
||||
} /* namespace expr */
|
||||
|
||||
#endif /* EXPOP_H */
|
||||
|
||||
Reference in New Issue
Block a user