/* A helper for rust_evaluate_subexp that handles BINOP_SUBSCRIPT. */
static struct value *
-rust_subscript (struct expression *exp, int *pos, enum noside noside,
- int for_addr)
+rust_subscript (struct type *expect_type, struct expression *exp,
+ enum noside noside, bool for_addr,
+ struct value *lhs, struct value *rhs)
{
- struct value *lhs, *rhs, *result;
+ struct value *result;
struct type *rhstype;
LONGEST low, high_bound;
/* Initialized to appease the compiler. */
LONGEST high = 0;
int want_slice = 0;
- ++*pos;
- lhs = evaluate_subexp (nullptr, exp, pos, noside);
- rhs = evaluate_subexp (nullptr, exp, pos, noside);
-
if (noside == EVAL_SKIP)
return lhs;
break;
case BINOP_SUBSCRIPT:
- result = rust_subscript (exp, pos, noside, 0);
+ {
+ ++*pos;
+ struct value *lhs = evaluate_subexp (nullptr, exp, pos, noside);
+ struct value *rhs = evaluate_subexp (nullptr, exp, pos, noside);
+ result = rust_subscript (expect_type, exp, noside, false, lhs, rhs);
+ }
break;
case OP_FUNCALL:
if (exp->elts[*pos + 1].opcode == BINOP_SUBSCRIPT)
{
++*pos;
- result = rust_subscript (exp, pos, noside, 1);
+ ++*pos;
+ struct value *lhs = evaluate_subexp (nullptr, exp, pos, noside);
+ struct value *rhs = evaluate_subexp (nullptr, exp, pos, noside);
+
+ result = rust_subscript (expect_type, exp, noside, true, lhs, rhs);
break;
}
/* Fall through. */