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:02 -0700
commiteed70b1c374ac4155f5d18b87a5a6a74581f2076 (patch)
treed6a32e816366f74f671223cb5021cd4624f92570 /gdb
parent60cdd4871ac9c9e0118cd47c7fce36cd5163404a (diff)
downloadgdb-eed70b1c374ac4155f5d18b87a5a6a74581f2076.zip
gdb-eed70b1c374ac4155f5d18b87a5a6a74581f2076.tar.gz
gdb-eed70b1c374ac4155f5d18b87a5a6a74581f2076.tar.bz2
Split out eval_op_repeat
This splits BINOP_REPEAT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_repeat): New function. (evaluate_subexp_standard): Use it.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c36
2 files changed, 28 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6cc3729..1da2a5c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_repeat): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_leq): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index 4e02bc0..4ac323e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1729,6 +1729,28 @@ eval_op_leq (struct type *expect_type, struct expression *exp,
}
}
+/* A helper function for BINOP_REPEAT. */
+
+static struct value *
+eval_op_repeat (struct type *expect_type, struct expression *exp,
+ enum noside noside,
+ struct value *arg1, struct value *arg2)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ struct type *type = check_typedef (value_type (arg2));
+ if (type->code () != TYPE_CODE_INT
+ && type->code () != TYPE_CODE_ENUM)
+ error (_("Non-integral right operand for \"@\" operator."));
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ {
+ return allocate_repeat_value (value_type (arg1),
+ longest_to_int (value_as_long (arg2)));
+ }
+ else
+ return value_repeat (arg1, longest_to_int (value_as_long (arg2)));
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -2570,19 +2592,7 @@ evaluate_subexp_standard (struct type *expect_type,
case BINOP_REPEAT:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
arg2 = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- type = check_typedef (value_type (arg2));
- if (type->code () != TYPE_CODE_INT
- && type->code () != TYPE_CODE_ENUM)
- error (_("Non-integral right operand for \"@\" operator."));
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- {
- return allocate_repeat_value (value_type (arg1),
- longest_to_int (value_as_long (arg2)));
- }
- else
- return value_repeat (arg1, longest_to_int (value_as_long (arg2)));
+ return eval_op_repeat (expect_type, exp, noside, arg1, arg2);
case BINOP_COMMA:
evaluate_subexp (nullptr, exp, pos, noside);