Split out eval_multi_subscript
This splits MULTI_SUBSCRIPT into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_multi_subscript): New function. (evaluate_subexp_standard): Use it.
This commit is contained in:
parent
dd5fd28346
commit
c0d7ed8ca8
2 changed files with 47 additions and 33 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* eval.c (eval_multi_subscript): New function.
|
||||||
|
(evaluate_subexp_standard): Use it.
|
||||||
|
|
||||||
2021-03-08 Tom Tromey <tom@tromey.com>
|
2021-03-08 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* ada-lang.c (ada_binop_exp): New function.
|
* ada-lang.c (ada_binop_exp): New function.
|
||||||
|
|
75
gdb/eval.c
75
gdb/eval.c
|
@ -2360,6 +2360,46 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
|
||||||
return call_function_by_hand (called_method, NULL, args);
|
return call_function_by_hand (called_method, NULL, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper function for MULTI_SUBSCRIPT. */
|
||||||
|
|
||||||
|
static struct value *
|
||||||
|
eval_multi_subscript (struct type *expect_type, struct expression *exp,
|
||||||
|
enum noside noside, value *arg1,
|
||||||
|
gdb::array_view<value *> args)
|
||||||
|
{
|
||||||
|
if (noside == EVAL_SKIP)
|
||||||
|
return arg1;
|
||||||
|
for (value *arg2 : args)
|
||||||
|
{
|
||||||
|
if (binop_user_defined_p (MULTI_SUBSCRIPT, arg1, arg2))
|
||||||
|
{
|
||||||
|
arg1 = value_x_binop (arg1, arg2, MULTI_SUBSCRIPT, OP_NULL, noside);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arg1 = coerce_ref (arg1);
|
||||||
|
struct type *type = check_typedef (value_type (arg1));
|
||||||
|
|
||||||
|
switch (type->code ())
|
||||||
|
{
|
||||||
|
case TYPE_CODE_PTR:
|
||||||
|
case TYPE_CODE_ARRAY:
|
||||||
|
case TYPE_CODE_STRING:
|
||||||
|
arg1 = value_subscript (arg1, value_as_long (arg2));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (type->name ())
|
||||||
|
error (_("cannot subscript something of type `%s'"),
|
||||||
|
type->name ());
|
||||||
|
else
|
||||||
|
error (_("cannot subscript requested type"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (arg1);
|
||||||
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
@ -2815,39 +2855,8 @@ evaluate_subexp_standard (struct type *expect_type,
|
||||||
argvec = XALLOCAVEC (struct value *, nargs);
|
argvec = XALLOCAVEC (struct value *, nargs);
|
||||||
for (ix = 0; ix < nargs; ++ix)
|
for (ix = 0; ix < nargs; ++ix)
|
||||||
argvec[ix] = evaluate_subexp_with_coercion (exp, pos, noside);
|
argvec[ix] = evaluate_subexp_with_coercion (exp, pos, noside);
|
||||||
if (noside == EVAL_SKIP)
|
return eval_multi_subscript (expect_type, exp, noside, arg1,
|
||||||
return arg1;
|
gdb::make_array_view (argvec, nargs));
|
||||||
for (ix = 0; ix < nargs; ++ix)
|
|
||||||
{
|
|
||||||
arg2 = argvec[ix];
|
|
||||||
|
|
||||||
if (binop_user_defined_p (op, arg1, arg2))
|
|
||||||
{
|
|
||||||
arg1 = value_x_binop (arg1, arg2, op, OP_NULL, noside);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
arg1 = coerce_ref (arg1);
|
|
||||||
type = check_typedef (value_type (arg1));
|
|
||||||
|
|
||||||
switch (type->code ())
|
|
||||||
{
|
|
||||||
case TYPE_CODE_PTR:
|
|
||||||
case TYPE_CODE_ARRAY:
|
|
||||||
case TYPE_CODE_STRING:
|
|
||||||
arg1 = value_subscript (arg1, value_as_long (arg2));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (type->name ())
|
|
||||||
error (_("cannot subscript something of type `%s'"),
|
|
||||||
type->name ());
|
|
||||||
else
|
|
||||||
error (_("cannot subscript requested type"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (arg1);
|
|
||||||
|
|
||||||
case BINOP_LOGICAL_AND:
|
case BINOP_LOGICAL_AND:
|
||||||
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
|
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue