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:09 -0700
commit41bdced5aef96b040b9b3eadf35306c8b2fc71d3 (patch)
tree8269cc788b0de806a203b910cb84e4f4830ef075 /gdb
parent13ea014aeefb4a11d43c2e9d9e28064a46bd5a4a (diff)
downloadgdb-41bdced5aef96b040b9b3eadf35306c8b2fc71d3.zip
gdb-41bdced5aef96b040b9b3eadf35306c8b2fc71d3.tar.gz
gdb-41bdced5aef96b040b9b3eadf35306c8b2fc71d3.tar.bz2
Split out eval_op_m2_high
This splits UNOP_HIGH into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * m2-lang.c (eval_op_m2_high): New function. (evaluate_subexp_modula2): Use it.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/m2-lang.c55
2 files changed, 37 insertions, 23 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0f3967f..582408f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * m2-lang.c (eval_op_m2_high): New function.
+ (evaluate_subexp_modula2): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (evaluate_subexp_for_address_base): New function.
(evaluate_subexp_for_address): Use it.
(evaluate_subexp_for_sizeof_base): New function.
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index fb49ba4..b0dafad 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -29,6 +29,37 @@
#include "valprint.h"
#include "gdbarch.h"
+/* A helper function for UNOP_HIGH. */
+
+static struct value *
+eval_op_m2_high (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1)
+{
+ if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
+ return arg1;
+ else
+ {
+ arg1 = coerce_ref (arg1);
+ struct type *type = check_typedef (value_type (arg1));
+
+ if (m2_is_unbounded_array (type))
+ {
+ struct value *temp = arg1;
+
+ type = type->field (1).type ();
+ /* i18n: Do not translate the "_m2_high" part! */
+ arg1 = value_struct_elt (&temp, NULL, "_m2_high", NULL,
+ _("unbounded structure "
+ "missing _m2_high field"));
+
+ if (value_type (arg1) != type)
+ arg1 = value_cast (type, arg1);
+ }
+ }
+ return arg1;
+}
+
static struct value *
evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
int *pos, enum noside noside)
@@ -43,29 +74,7 @@ evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
case UNOP_HIGH:
(*pos)++;
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
-
- if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
- return arg1;
- else
- {
- arg1 = coerce_ref (arg1);
- type = check_typedef (value_type (arg1));
-
- if (m2_is_unbounded_array (type))
- {
- struct value *temp = arg1;
-
- type = type->field (1).type ();
- /* i18n: Do not translate the "_m2_high" part! */
- arg1 = value_struct_elt (&temp, NULL, "_m2_high", NULL,
- _("unbounded structure "
- "missing _m2_high field"));
-
- if (value_type (arg1) != type)
- arg1 = value_cast (type, arg1);
- }
- }
- return arg1;
+ return eval_op_m2_high (expect_type, exp, noside, arg1);
case BINOP_SUBSCRIPT:
(*pos)++;