From 821e72d77536b201b3e6b801d8f0d9c5b624ec96 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 8 Mar 2021 07:27:57 -0700 Subject: [PATCH] Introduce multi_subscript_operation This adds class multi_subscript_operation, which implements MULTI_SUBSCRIPT. gdb/ChangeLog 2021-03-08 Tom Tromey * expop.h (class multi_subscript_operation): New. * eval.c (multi_subscript_operation::evaluate): New method. --- gdb/ChangeLog | 5 +++++ gdb/eval.c | 13 +++++++++++++ gdb/expop.h | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37fe24a89ca..10a738aa230 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-03-08 Tom Tromey + + * expop.h (class multi_subscript_operation): New. + * eval.c (multi_subscript_operation::evaluate): New method. + 2021-03-08 Tom Tromey * eval.c (objc_msgcall_operation::evaluate): New method. diff --git a/gdb/eval.c b/gdb/eval.c index 91965179a14..655e4efa13f 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2472,8 +2472,21 @@ objc_msgcall_operation::evaluate (struct type *expect_type, args.size () + 3)); } +value * +multi_subscript_operation::evaluate (struct type *expect_type, + struct expression *exp, + enum noside noside) +{ + value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp, noside); + std::vector &values = std::get<1> (m_storage); + value **argvec = XALLOCAVEC (struct value *, values.size ()); + for (int ix = 0; ix < values.size (); ++ix) + argvec[ix] = values[ix]->evaluate_with_coercion (exp, noside); + return eval_multi_subscript (expect_type, exp, noside, arg1, + gdb::make_array_view (argvec, values.size ())); } +} struct value * evaluate_subexp_standard (struct type *expect_type, diff --git a/gdb/expop.h b/gdb/expop.h index ef5b9bb197d..6b1a8753b97 100644 --- a/gdb/expop.h +++ b/gdb/expop.h @@ -1966,6 +1966,22 @@ using dynamic_cast_operation = cxx_cast_operation; +/* Multi-dimensional subscripting. */ +class multi_subscript_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; + + enum exp_opcode opcode () const override + { return MULTI_SUBSCRIPT; } +}; + } /* namespace expr */ #endif /* EXPOP_H */ -- 2.30.2