aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:17 -0700
commit1594e0bb3d35b05aa53519f08021fb15bf26f1dc (patch)
tree7af417ce67f65839738a47860b3daba576426f41 /gdb
parentb50db09ff9c0a5d2220e73ddcff3a05e2e887b0e (diff)
downloadgdb-1594e0bb3d35b05aa53519f08021fb15bf26f1dc.zip
gdb-1594e0bb3d35b05aa53519f08021fb15bf26f1dc.tar.gz
gdb-1594e0bb3d35b05aa53519f08021fb15bf26f1dc.tar.bz2
Introduce ternop_slice_operation
This adds class ternop_slice_operation, which implements TERNOP_SLICE. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * expop.h (class ternop_slice_operation): New. * eval.c (eval_op_ternop): No longer static.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c2
-rw-r--r--gdb/expop.h29
3 files changed, 35 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ddf9342..c3fc9c8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * expop.h (class ternop_slice_operation): New.
+ * eval.c (eval_op_ternop): No longer static.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* expop.h (class string_operation): New.
* eval.c (eval_op_string): No longer static.
diff --git a/gdb/eval.c b/gdb/eval.c
index e68a93d..c667925 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1327,7 +1327,7 @@ eval_op_concat (struct type *expect_type, struct expression *exp,
/* A helper function for TERNOP_SLICE. */
-static struct value *
+struct value *
eval_op_ternop (struct type *expect_type, struct expression *exp,
enum noside noside,
struct value *array, struct value *low, struct value *upper)
diff --git a/gdb/expop.h b/gdb/expop.h
index 802be81..436a011 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -65,6 +65,11 @@ extern struct value *eval_op_string (struct type *expect_type,
struct expression *exp,
enum noside noside, int len,
const char *string);
+extern struct value *eval_op_ternop (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside,
+ struct value *array, struct value *low,
+ struct value *upper);
namespace expr
{
@@ -705,6 +710,30 @@ public:
{ return OP_STRING; }
};
+class ternop_slice_operation
+ : public maybe_constant_operation<operation_up, operation_up, operation_up>
+{
+public:
+
+ using maybe_constant_operation::maybe_constant_operation;
+
+ value *evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside) override
+ {
+ struct value *array
+ = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ struct value *low
+ = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ struct value *upper
+ = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
+ return eval_op_ternop (expect_type, exp, noside, array, low, upper);
+ }
+
+ enum exp_opcode opcode () const override
+ { return TERNOP_SLICE; }
+};
+
} /* namespace expr */
#endif /* EXPOP_H */