Split out eval_op_postdec
This splits UNOP_POSTDECREMENT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_postdec): New function. (evaluate_subexp_standard): Use it.
This commit is contained in:
parent
abffe11606
commit
a220ead5d4
2 changed files with 40 additions and 25 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* eval.c (eval_op_postdec): New function.
|
||||||
|
(evaluate_subexp_standard): Use it.
|
||||||
|
|
||||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* eval.c (eval_op_postinc): New function.
|
* eval.c (eval_op_postinc): New function.
|
||||||
|
|
60
gdb/eval.c
60
gdb/eval.c
|
@ -2005,6 +2005,40 @@ eval_op_postinc (struct type *expect_type, struct expression *exp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A helper function for UNOP_POSTDECREMENT. */
|
||||||
|
|
||||||
|
static struct value *
|
||||||
|
eval_op_postdec (struct type *expect_type, struct expression *exp,
|
||||||
|
enum noside noside, enum exp_opcode op,
|
||||||
|
struct value *arg1)
|
||||||
|
{
|
||||||
|
if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||||
|
return arg1;
|
||||||
|
else if (unop_user_defined_p (op, arg1))
|
||||||
|
{
|
||||||
|
return value_x_unop (arg1, op, noside);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct value *arg3 = value_non_lval (arg1);
|
||||||
|
struct value *arg2;
|
||||||
|
|
||||||
|
if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
|
||||||
|
arg2 = value_ptradd (arg1, -1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct value *tmp = arg1;
|
||||||
|
|
||||||
|
arg2 = value_one (value_type (arg1));
|
||||||
|
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
|
||||||
|
arg2 = value_binop (tmp, arg2, BINOP_SUB);
|
||||||
|
}
|
||||||
|
|
||||||
|
value_assign (arg1, arg2);
|
||||||
|
return arg3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct value *
|
struct value *
|
||||||
evaluate_subexp_standard (struct type *expect_type,
|
evaluate_subexp_standard (struct type *expect_type,
|
||||||
struct expression *exp, int *pos,
|
struct expression *exp, int *pos,
|
||||||
|
@ -2015,7 +2049,6 @@ evaluate_subexp_standard (struct type *expect_type,
|
||||||
int pc, oldpos;
|
int pc, oldpos;
|
||||||
struct value *arg1 = NULL;
|
struct value *arg1 = NULL;
|
||||||
struct value *arg2 = NULL;
|
struct value *arg2 = NULL;
|
||||||
struct value *arg3;
|
|
||||||
struct type *type;
|
struct type *type;
|
||||||
int nargs;
|
int nargs;
|
||||||
struct value **argvec;
|
struct value **argvec;
|
||||||
|
@ -2951,30 +2984,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
||||||
|
|
||||||
case UNOP_POSTDECREMENT:
|
case UNOP_POSTDECREMENT:
|
||||||
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
|
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
|
||||||
if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
|
return eval_op_postdec (expect_type, exp, noside, op, arg1);
|
||||||
return arg1;
|
|
||||||
else if (unop_user_defined_p (op, arg1))
|
|
||||||
{
|
|
||||||
return value_x_unop (arg1, op, noside);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
arg3 = value_non_lval (arg1);
|
|
||||||
|
|
||||||
if (ptrmath_type_p (exp->language_defn, value_type (arg1)))
|
|
||||||
arg2 = value_ptradd (arg1, -1);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct value *tmp = arg1;
|
|
||||||
|
|
||||||
arg2 = value_one (value_type (arg1));
|
|
||||||
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
|
|
||||||
arg2 = value_binop (tmp, arg2, BINOP_SUB);
|
|
||||||
}
|
|
||||||
|
|
||||||
value_assign (arg1, arg2);
|
|
||||||
return arg3;
|
|
||||||
}
|
|
||||||
|
|
||||||
case OP_THIS:
|
case OP_THIS:
|
||||||
(*pos) += 1;
|
(*pos) += 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue