From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 4BEB83858404; Mon, 13 Feb 2023 22:30:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BEB83858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676327442; bh=aYWZkn6KFzGJ1wfkOXBuhf4T4pNK4YOgJx/2/11Jx7s=; h=From:To:Subject:Date:From; b=xSwU1jHsO0DzWPo3IehsokHL4eMbPh2l51oeFp/gLjtHnAivs03a7Bfay4IJ5NuTe Dgw/TCfr0kEreLnGSOYQSip8obMZ3vMG0ZSiV3ryLXdAvnzbvZfH0yORY++lCv5sUX x2vFIYXvQgk6d5+Dl1VphR7XqO42fG3Mx3cJyvbs= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Turn some xmethod functions into methods X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: fcf86fe5977ec47a0a6e32be9c1434ac808e2c4e X-Git-Newrev: 6bd5c75435099f09bf1b2027e118f66a6fd94218 Message-Id: <20230213223042.4BEB83858404@sourceware.org> Date: Mon, 13 Feb 2023 22:30:42 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D6bd5c7543509= 9f09bf1b2027e118f66a6fd94218 commit 6bd5c75435099f09bf1b2027e118f66a6fd94218 Author: Tom Tromey Date: Tue Jan 31 20:59:39 2023 -0700 Turn some xmethod functions into methods =20 This turns value_from_xmethod, result_type_of_xmethod, and call_xmethod to be methods of value. value_from_xmethod is a static "constructor" now. =20 Approved-By: Simon Marchi Diff: --- gdb/eval.c | 4 ++-- gdb/valarith.c | 8 ++++---- gdb/valops.c | 2 +- gdb/value.c | 22 +++++++++++----------- gdb/value.h | 22 +++++++++++----------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index 808cc916bb4..b263dc998d6 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -640,7 +640,7 @@ evaluate_subexp_do_call (expression *exp, enum noside n= oside, } else if (ftype->code () =3D=3D TYPE_CODE_XMETHOD) { - type *return_type =3D result_type_of_xmethod (callee, argvec); + type *return_type =3D callee->result_type_of_xmethod (argvec); =20 if (return_type =3D=3D NULL) error (_("Xmethod is missing return type.")); @@ -678,7 +678,7 @@ evaluate_subexp_do_call (expression *exp, enum noside n= oside, return call_internal_function (exp->gdbarch, exp->language_defn, callee, argvec.size (), argvec.data ()); case TYPE_CODE_XMETHOD: - return call_xmethod (callee, argvec); + return callee->call_xmethod (argvec); default: return call_function_by_hand (callee, default_return_type, argvec); } diff --git a/gdb/valarith.c b/gdb/valarith.c index e3c51609172..8e4c4182fb5 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -528,13 +528,13 @@ value_x_binop (struct value *arg1, struct value *arg2= , enum exp_opcode op, if (noside =3D=3D EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type - =3D result_type_of_xmethod (argvec[0], argvec.slice (1)); + =3D argvec[0]->result_type_of_xmethod (argvec.slice (1)); =20 if (return_type =3D=3D NULL) error (_("Xmethod is missing return type.")); return value::zero (return_type, VALUE_LVAL (arg1)); } - return call_xmethod (argvec[0], argvec.slice (1)); + return argvec[0]->call_xmethod (argvec.slice (1)); } if (noside =3D=3D EVAL_AVOID_SIDE_EFFECTS) { @@ -641,13 +641,13 @@ value_x_unop (struct value *arg1, enum exp_opcode op,= enum noside noside) if (noside =3D=3D EVAL_AVOID_SIDE_EFFECTS) { struct type *return_type - =3D result_type_of_xmethod (argvec[0], argvec[1]); + =3D argvec[0]->result_type_of_xmethod (argvec[1]); =20 if (return_type =3D=3D NULL) error (_("Xmethod is missing return type.")); return value::zero (return_type, VALUE_LVAL (arg1)); } - return call_xmethod (argvec[0], argvec[1]); + return argvec[0]->call_xmethod (argvec[1]); } if (noside =3D=3D EVAL_AVOID_SIDE_EFFECTS) { diff --git a/gdb/valops.c b/gdb/valops.c index 137134abe6c..89bd5c95a2c 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3028,7 +3028,7 @@ find_overload_match (gdb::array_view args, method_oload_champ, basetype, boffset); } else - *valp =3D value_from_xmethod + *valp =3D value::from_xmethod (std::move (xmethods[ext_method_oload_champ])); } else diff --git a/gdb/value.c b/gdb/value.c index 73c3eaf4659..730ca7c73e9 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2517,7 +2517,7 @@ show_convenience (const char *ignore, int from_tty) /* See value.h. */ =20 struct value * -value_from_xmethod (xmethod_worker_up &&worker) +value::from_xmethod (xmethod_worker_up &&worker) { struct value *v; =20 @@ -2529,26 +2529,26 @@ value_from_xmethod (xmethod_worker_up &&worker) return v; } =20 -/* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */ +/* See value.h. */ =20 struct type * -result_type_of_xmethod (struct value *method, gdb::array_view arg= v) +value::result_type_of_xmethod (gdb::array_view argv) { - gdb_assert (method->type ()->code () =3D=3D TYPE_CODE_XMETHOD - && method->m_lval =3D=3D lval_xcallable && !argv.empty ()); + gdb_assert (type ()->code () =3D=3D TYPE_CODE_XMETHOD + && m_lval =3D=3D lval_xcallable && !argv.empty ()); =20 - return method->m_location.xm_worker->get_result_type (argv[0], argv.slic= e (1)); + return m_location.xm_worker->get_result_type (argv[0], argv.slice (1)); } =20 -/* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value METHOD. = */ +/* See value.h. */ =20 struct value * -call_xmethod (struct value *method, gdb::array_view argv) +value::call_xmethod (gdb::array_view argv) { - gdb_assert (method->type ()->code () =3D=3D TYPE_CODE_XMETHOD - && method->m_lval =3D=3D lval_xcallable && !argv.empty ()); + gdb_assert (type ()->code () =3D=3D TYPE_CODE_XMETHOD + && m_lval =3D=3D lval_xcallable && !argv.empty ()); =20 - return method->m_location.xm_worker->invoke (argv[0], argv.slice (1)); + return m_location.xm_worker->invoke (argv[0], argv.slice (1)); } =0C /* Extract a value as a C number (either long or double). diff --git a/gdb/value.h b/gdb/value.h index 448f0123f70..36e7a89359d 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -543,6 +543,17 @@ public: WHOLE --- regardless of what kind of lvalue WHOLE is. */ void set_component_location (const struct value *whole); =20 + /* Build a value wrapping and representing WORKER. The value takes + ownership of the xmethod_worker object. */ + static struct value *from_xmethod (xmethod_worker_up &&worker); + + /* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */ + struct type *result_type_of_xmethod (gdb::array_view argv); + + /* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value + METHOD. */ + struct value *call_xmethod (gdb::array_view argv); + =20 /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -1514,17 +1525,6 @@ struct value *call_internal_function (struct gdbarch= *gdbarch, =20 const char *value_internal_function_name (struct value *); =20 -/* Build a value wrapping and representing WORKER. The value takes owners= hip - of the xmethod_worker object. */ - -extern struct value *value_from_xmethod (xmethod_worker_up &&worker); - -extern struct type *result_type_of_xmethod (struct value *method, - gdb::array_view argv); - -extern struct value *call_xmethod (struct value *method, - gdb::array_view argv); - /* Destroy the values currently allocated. This is called when GDB is exiting (e.g., on quit_force). */ extern void finalize_values ();