aboutsummaryrefslogtreecommitdiff
path: root/gdb/eval.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2009-06-29 13:24:41 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2009-06-29 13:24:41 +0000
commit2497b4984582be980b40913ef1bf561ccad2f265 (patch)
tree3c63910f2617b06eb5f73bc95326f6eb7b73720a /gdb/eval.c
parent0c8b41f1c6ca809238df5662ea5f45e5f7a29121 (diff)
downloadgdb-2497b4984582be980b40913ef1bf561ccad2f265.zip
gdb-2497b4984582be980b40913ef1bf561ccad2f265.tar.gz
gdb-2497b4984582be980b40913ef1bf561ccad2f265.tar.bz2
* value.h (value_subscript, value_subscripted_rvalue,
value_bitstring_subscript, value_ptradd): Use LONGEST instead of value as type of the index argument. (value_ptrsub): Remove. * valarith.c (value_subscript, value_subscripted_rvalue, value_bitstring_subscript, value_ptradd): Use LONGEST instead of value as type of the index argument. (value_ptrsub): Remove. * wrapper.h (gdb_value_subscript): Use LONGEST instead of value as type of the index argument. * wrapper.c (gdb_value_subscript): Likewise. Update calls to gdb_value_subscript, value_subscript, value_subscripted_rvalue, value_bitstring_subscript and value_ptradd to use LONGEST instead of value as index argument type. Use value_ptradd instead of value_ptrsub. * ada-lang.c (ada_value_subscript, ada_value_ptr_subscript, ada_tag_name_2): Update. * ada-tasks.c (read_atcb): Update. * eval.c (evaluate_subexp_standard): Update. * valarith.c (value_subscript): Update. * gnu-v2-abi.c (gnuv2_virtual_fn_field): Update. * gnu-v3-abi.c (gnuv3_get_virtual_fn, gnuv3_baseclass_offset, gnuv3_method_ptr_to_value): Update. * jv-lang.c (evaluate_subexp_java): Update. * m2-lang.c (evaluate_subexp_modula2): Update. * python/python-value.c (valpy_getitem, valpy_binop): Update. * wrapper.c (gdb_value_subscript): Update. * varobj.c (c_describe_child): Update.
Diffstat (limited to 'gdb/eval.c')
-rw-r--r--gdb/eval.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/gdb/eval.c b/gdb/eval.c
index 4770197..67e94dd 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1574,7 +1574,7 @@ evaluate_subexp_standard (struct type *expect_type,
else
{
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- return value_subscript (arg1, arg2);
+ return value_subscript (arg1, value_as_long (arg2));
}
case TYPE_CODE_PTR:
@@ -1736,10 +1736,12 @@ evaluate_subexp_standard (struct type *expect_type,
op = exp->elts[pc + 1].opcode;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op, noside);
- else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1)))
- arg2 = value_ptradd (arg1, arg2);
- else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1)))
- arg2 = value_ptrsub (arg1, arg2);
+ else if (op == BINOP_ADD && ptrmath_type_p (value_type (arg1))
+ && is_integral_type (value_type (arg2)))
+ arg2 = value_ptradd (arg1, value_as_long (arg2));
+ else if (op == BINOP_SUB && ptrmath_type_p (value_type (arg1))
+ && is_integral_type (value_type (arg2)))
+ arg2 = value_ptradd (arg1, - value_as_long (arg2));
else
{
struct value *tmp = arg1;
@@ -1763,10 +1765,12 @@ evaluate_subexp_standard (struct type *expect_type,
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
- else if (ptrmath_type_p (value_type (arg1)))
- return value_ptradd (arg1, arg2);
- else if (ptrmath_type_p (value_type (arg2)))
- return value_ptradd (arg2, arg1);
+ else if (ptrmath_type_p (value_type (arg1))
+ && is_integral_type (value_type (arg2)))
+ return value_ptradd (arg1, value_as_long (arg2));
+ else if (ptrmath_type_p (value_type (arg2))
+ && is_integral_type (value_type (arg1)))
+ return value_ptradd (arg2, value_as_long (arg1));
else
{
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
@@ -1780,17 +1784,16 @@ evaluate_subexp_standard (struct type *expect_type,
goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
- else if (ptrmath_type_p (value_type (arg1)))
+ else if (ptrmath_type_p (value_type (arg1))
+ && ptrmath_type_p (value_type (arg2)))
{
- if (ptrmath_type_p (value_type (arg2)))
- {
- /* FIXME -- should be ptrdiff_t */
- type = builtin_type (exp->gdbarch)->builtin_long;
- return value_from_longest (type, value_ptrdiff (arg1, arg2));
- }
- else
- return value_ptrsub (arg1, arg2);
+ /* FIXME -- should be ptrdiff_t */
+ type = builtin_type (exp->gdbarch)->builtin_long;
+ return value_from_longest (type, value_ptrdiff (arg1, arg2));
}
+ else if (ptrmath_type_p (value_type (arg1))
+ && is_integral_type (value_type (arg2)))
+ return value_ptradd (arg1, - value_as_long (arg2));
else
{
binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
@@ -1885,7 +1888,7 @@ evaluate_subexp_standard (struct type *expect_type,
if (noside == EVAL_AVOID_SIDE_EFFECTS)
return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
else
- return value_subscript (arg1, arg2);
+ return value_subscript (arg1, value_as_long (arg2));
}
case BINOP_IN:
@@ -1950,12 +1953,13 @@ evaluate_subexp_standard (struct type *expect_type,
case TYPE_CODE_PTR:
case TYPE_CODE_ARRAY:
case TYPE_CODE_STRING:
- arg1 = value_subscript (arg1, arg2);
+ arg1 = value_subscript (arg1, value_as_long (arg2));
break;
case TYPE_CODE_BITSTRING:
type = language_bool_type (exp->language_defn, exp->gdbarch);
- arg1 = value_bitstring_subscript (type, arg1, arg2);
+ arg1 = value_bitstring_subscript (type, arg1,
+ value_as_long (arg2));
break;
default:
@@ -2035,10 +2039,6 @@ evaluate_subexp_standard (struct type *expect_type,
offset_item =
array_size_array[i - 1] * offset_item + subscript_array[i - 1];
- /* Construct a value node with the value of the offset */
-
- arg2 = value_from_longest (builtin_type_int32, offset_item);
-
/* Let us now play a dirty trick: we will take arg1
which is a value node pointing to the topmost level
of the multidimensional array-set and pretend
@@ -2047,7 +2047,7 @@ evaluate_subexp_standard (struct type *expect_type,
returns the correct type value */
deprecated_set_value_type (arg1, tmp_type);
- return value_subscripted_rvalue (arg1, arg2, 0);
+ return value_subscripted_rvalue (arg1, offset_item, 0);
}
case BINOP_LOGICAL_AND:
@@ -2386,12 +2386,12 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
- arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
if (ptrmath_type_p (value_type (arg1)))
- arg2 = value_ptradd (arg1, arg2);
+ arg2 = value_ptradd (arg1, 1);
else
{
struct value *tmp = arg1;
+ arg2 = value_one (value_type (arg1), not_lval);
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
arg2 = value_binop (tmp, arg2, BINOP_ADD);
}
@@ -2409,12 +2409,12 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
- arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
if (ptrmath_type_p (value_type (arg1)))
- arg2 = value_ptrsub (arg1, arg2);
+ arg2 = value_ptradd (arg1, -1);
else
{
struct value *tmp = arg1;
+ arg2 = value_one (value_type (arg1), not_lval);
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
arg2 = value_binop (tmp, arg2, BINOP_SUB);
}
@@ -2432,12 +2432,12 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
- arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
if (ptrmath_type_p (value_type (arg1)))
- arg2 = value_ptradd (arg1, arg2);
+ arg2 = value_ptradd (arg1, 1);
else
{
struct value *tmp = arg1;
+ arg2 = value_one (value_type (arg1), not_lval);
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
arg2 = value_binop (tmp, arg2, BINOP_ADD);
}
@@ -2456,12 +2456,12 @@ evaluate_subexp_standard (struct type *expect_type,
}
else
{
- arg2 = value_from_longest (builtin_type_uint8, (LONGEST) 1);
if (ptrmath_type_p (value_type (arg1)))
- arg2 = value_ptrsub (arg1, arg2);
+ arg2 = value_ptradd (arg1, -1);
else
{
struct value *tmp = arg1;
+ arg2 = value_one (value_type (arg1), not_lval);
binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2);
arg2 = value_binop (tmp, arg2, BINOP_SUB);
}