From a00b7254fb614af557de7ae7cc0eb39a0ce0e408 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: Implement function call operations This implement function call operations. The current function call code relies on some very lengthy code (evaluate_funcall is 398 lines...) to distinguish between the different opcodes that might appear in the callee position. Rather than try to replicate this, and have a function that tried to dissect many different kinds of operation subclass, this patch instead puts the work into the callee. A new operation::evaluate_funcall method is added, and then this is overridden in the classes that require special treatment. gdb/ChangeLog 2021-03-08 Tom Tromey * expression.h (class operation) : New methods. * expop.h (class scope_operation) : New method. (class var_value_operation) : New method. (class structop_base_operation) : New method. (class var_msym_value_operation) : New method. (class structop_member_base): New class. (class structop_member_operation): Derive from structop_member_base. (class structop_mptr_operation): Derive from structop_member_base. (class funcall_operation): New class. * eval.c (operation::evaluate_funcall) (var_value_operation::evaluate_funcall) (scope_operation::evaluate_funcall) (structop_member_base::evaluate_funcall) (structop_base_operation::evaluate_funcall): New methods. --- gdb/expression.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gdb/expression.h') diff --git a/gdb/expression.h b/gdb/expression.h index 4d75058..d20857b 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -144,6 +144,19 @@ public: virtual value *evaluate_for_address (struct expression *exp, enum noside noside); + /* Evaluate a function call, with this object as the callee. + EXPECT_TYPE, EXP, and NOSIDE have the same meaning as in + 'evaluate'. ARGS holds the operations that should be evaluated + to get the arguments to the call. */ + virtual value *evaluate_funcall (struct type *expect_type, + struct expression *exp, + enum noside noside, + const std::vector &args) + { + /* Defer to the helper overload. */ + return evaluate_funcall (expect_type, exp, noside, nullptr, args); + } + /* True if this is a constant expression. */ virtual bool constant_p () const { return false; } @@ -171,6 +184,13 @@ public: protected: + /* A helper overload that wraps evaluate_subexp_do_call. */ + value *evaluate_funcall (struct type *expect_type, + struct expression *exp, + enum noside noside, + const char *function_name, + const std::vector &args); + /* Called by generate_ax to do the work for this particular operation. */ virtual void do_generate_ax (struct expression *exp, -- cgit v1.1