diff options
author | Tom Tromey <tom@tromey.com> | 2023-01-31 07:52:09 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-02-13 15:21:06 -0700 |
commit | d0c9791728caa0d3b3270a997c7fd97919976c97 (patch) | |
tree | 1753b7232efa89e05696d4289d60ad019fc161e4 /gdb/valarith.c | |
parent | 7cf57bc5be656c62cc6b80280a9eddad2b8ded3f (diff) | |
download | binutils-gdb-d0c9791728caa0d3b3270a997c7fd97919976c97.tar.gz |
Turn value_type into method
This changes value_type to be a method of value. Much of this patch
was written by script.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 7312f0b5493..ae81ea578fe 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -88,7 +88,7 @@ value_ptradd (struct value *arg1, LONGEST arg2) struct value *result; arg1 = coerce_array (arg1); - valptrtype = check_typedef (value_type (arg1)); + valptrtype = check_typedef (arg1->type ()); sz = find_size_for_pointer_math (valptrtype); result = value_from_pointer (valptrtype, @@ -109,8 +109,8 @@ value_ptrdiff (struct value *arg1, struct value *arg2) arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); gdb_assert (type1->code () == TYPE_CODE_PTR); gdb_assert (type2->code () == TYPE_CODE_PTR); @@ -149,7 +149,7 @@ value_subscript (struct value *array, LONGEST index) struct type *tarray; array = coerce_ref (array); - tarray = check_typedef (value_type (array)); + tarray = check_typedef (array->type ()); if (tarray->code () == TYPE_CODE_ARRAY || tarray->code () == TYPE_CODE_STRING) @@ -214,7 +214,7 @@ static struct value * value_subscripted_rvalue (struct value *array, LONGEST index, LONGEST lowerbound) { - struct type *array_type = check_typedef (value_type (array)); + struct type *array_type = check_typedef (array->type ()); struct type *elt_type = array_type->target_type (); LONGEST elt_size = type_length_units (elt_type); @@ -292,7 +292,7 @@ int binop_user_defined_p (enum exp_opcode op, struct value *arg1, struct value *arg2) { - return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2)); + return binop_types_user_defined_p (op, arg1->type (), arg2->type ()); } /* Check to see if argument is a structure. This is called so @@ -308,7 +308,7 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1) if (op == UNOP_ADDR) return 0; - type1 = check_typedef (value_type (arg1)); + type1 = check_typedef (arg1->type ()); if (TYPE_IS_REFERENCE (type1)) type1 = check_typedef (type1->target_type ()); return type1->code () == TYPE_CODE_STRUCT; @@ -394,7 +394,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, /* now we know that what we have to do is construct our arg vector and find the right function to call it with. */ - if (check_typedef (value_type (arg1))->code () != TYPE_CODE_STRUCT) + if (check_typedef (arg1->type ())->code () != TYPE_CODE_STRUCT) error (_("Can't do that binary op on that type")); /* FIXME be explicit */ value *argvec_storage[3]; @@ -521,7 +521,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, argvec[1] = argvec[0]; argvec = argvec.slice (1); } - if (value_type (argvec[0])->code () == TYPE_CODE_XMETHOD) + if (argvec[0]->type ()->code () == TYPE_CODE_XMETHOD) { /* Static xmethods are not supported yet. */ gdb_assert (static_memfuncp == 0); @@ -540,7 +540,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, { struct type *return_type; - return_type = check_typedef (value_type (argvec[0]))->target_type (); + return_type = check_typedef (argvec[0]->type ())->target_type (); return value_zero (return_type, VALUE_LVAL (arg1)); } return call_function_by_hand (argvec[0], NULL, @@ -559,7 +559,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, struct value * value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) { - struct gdbarch *gdbarch = value_type (arg1)->arch (); + struct gdbarch *gdbarch = arg1->type ()->arch (); char *ptr; char tstr[13], mangle_tstr[13]; int static_memfuncp, nargs; @@ -569,7 +569,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) /* now we know that what we have to do is construct our arg vector and find the right function to call it with. */ - if (check_typedef (value_type (arg1))->code () != TYPE_CODE_STRUCT) + if (check_typedef (arg1->type ())->code () != TYPE_CODE_STRUCT) error (_("Can't do that unary op on that type")); /* FIXME be explicit */ value *argvec_storage[3]; @@ -634,7 +634,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) argvec[1] = argvec[0]; argvec = argvec.slice (1); } - if (value_type (argvec[0])->code () == TYPE_CODE_XMETHOD) + if (argvec[0]->type ()->code () == TYPE_CODE_XMETHOD) { /* Static xmethods are not supported yet. */ gdb_assert (static_memfuncp == 0); @@ -653,7 +653,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) { struct type *return_type; - return_type = check_typedef (value_type (argvec[0]))->target_type (); + return_type = check_typedef (argvec[0]->type ())->target_type (); return value_zero (return_type, VALUE_LVAL (arg1)); } return call_function_by_hand (argvec[0], NULL, @@ -671,8 +671,8 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) struct value * value_concat (struct value *arg1, struct value *arg2) { - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); if (type1->code () != TYPE_CODE_ARRAY && type2->code () != TYPE_CODE_ARRAY) error ("no array provided to concatenation"); @@ -766,8 +766,8 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, { struct type *type1, *type2; - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); /* At least one of the arguments must be of floating-point type. */ gdb_assert (is_floating_type (type1) || is_floating_type (type2)); @@ -826,8 +826,8 @@ value_args_as_target_float (struct value *arg1, struct value *arg2, static struct value * fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); const struct language_defn *language = current_language; struct gdbarch *gdbarch = type1->arch (); @@ -976,8 +976,8 @@ static struct value *scalar_binop (struct value *arg1, struct value *arg2, static struct value * complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { - struct type *arg1_type = check_typedef (value_type (arg1)); - struct type *arg2_type = check_typedef (value_type (arg2)); + struct type *arg1_type = check_typedef (arg1->type ()); + struct type *arg2_type = check_typedef (arg2->type ()); struct value *arg1_real, *arg1_imag, *arg2_real, *arg2_imag; if (arg1_type->code () == TYPE_CODE_COMPLEX) @@ -1001,8 +1001,8 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) arg2_imag = value_zero (arg2_type, not_lval); } - struct type *comp_type = promotion_type (value_type (arg1_real), - value_type (arg2_real)); + struct type *comp_type = promotion_type (arg1_real->type (), + arg2_real->type ()); if (!can_create_complex_type (comp_type)) error (_("Argument to complex arithmetic operation not supported.")); @@ -1072,7 +1072,7 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) else v1 = v1 || v2; - return value_from_longest (value_type (x1), v1); + return value_from_longest (x1->type (), v1); } break; @@ -1158,8 +1158,8 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) arg1 = coerce_ref (arg1); arg2 = coerce_ref (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); if (type1->code () == TYPE_CODE_COMPLEX || type2->code () == TYPE_CODE_COMPLEX) @@ -1377,7 +1377,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_unsigned_integer (value_contents_raw (val).data (), - value_type (val)->length (), + val->type ()->length (), type_byte_order (result_type), v); } @@ -1538,7 +1538,7 @@ scalar_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) val = allocate_value (result_type); store_signed_integer (value_contents_raw (val).data (), - value_type (val)->length (), + val->type ()->length (), type_byte_order (result_type), v); } @@ -1573,7 +1573,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) eltype = check_typedef (vector_type->target_type ()); elval = value_cast (eltype, scalar_value); - scalar_type = check_typedef (value_type (scalar_value)); + scalar_type = check_typedef (scalar_value->type ()); /* If we reduced the length of the scalar then check we didn't loose any important bits. */ @@ -1603,8 +1603,8 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) int t1_is_vec, t2_is_vec, elsize, i; LONGEST low_bound1, high_bound1, low_bound2, high_bound2; - type1 = check_typedef (value_type (val1)); - type2 = check_typedef (value_type (val2)); + type1 = check_typedef (val1->type ()); + type2 = check_typedef (val2->type ()); t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()) ? 1 : 0; @@ -1648,8 +1648,8 @@ struct value * value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) { struct value *val; - struct type *type1 = check_typedef (value_type (arg1)); - struct type *type2 = check_typedef (value_type (arg2)); + struct type *type1 = check_typedef (arg1->type ()); + struct type *type2 = check_typedef (arg2->type ()); int t1_is_vec = (type1->code () == TYPE_CODE_ARRAY && type1->is_vector ()); int t2_is_vec = (type2->code () == TYPE_CODE_ARRAY @@ -1689,7 +1689,7 @@ value_logical_not (struct value *arg1) struct type *type1; arg1 = coerce_array (arg1); - type1 = check_typedef (value_type (arg1)); + type1 = check_typedef (arg1->type ()); if (is_floating_value (arg1)) return target_float_is_zero (value_contents (arg1).data (), type1); @@ -1712,8 +1712,8 @@ value_logical_not (struct value *arg1) static int value_strcmp (struct value *arg1, struct value *arg2) { - int len1 = value_type (arg1)->length (); - int len2 = value_type (arg2)->length (); + int len1 = arg1->type ()->length (); + int len2 = arg2->type ()->length (); const gdb_byte *s1 = value_contents (arg1).data (); const gdb_byte *s2 = value_contents (arg2).data (); int i, len = len1 < len2 ? len1 : len2; @@ -1753,8 +1753,8 @@ value_equal (struct value *arg1, struct value *arg2) arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); code1 = type1->code (); code2 = type2->code (); is_int1 = is_integral_type (type1); @@ -1816,8 +1816,8 @@ value_equal_contents (struct value *arg1, struct value *arg2) { struct type *type1, *type2; - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); return (type1->code () == type2->code () && type1->length () == type2->length () @@ -1840,8 +1840,8 @@ value_less (struct value *arg1, struct value *arg2) arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); - type1 = check_typedef (value_type (arg1)); - type2 = check_typedef (value_type (arg2)); + type1 = check_typedef (arg1->type ()); + type2 = check_typedef (arg2->type ()); code1 = type1->code (); code2 = type2->code (); is_int1 = is_integral_type (type1); @@ -1892,7 +1892,7 @@ value_pos (struct value *arg1) struct type *type; arg1 = coerce_ref (arg1); - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); if (is_integral_type (type) || is_floating_value (arg1) || (type->code () == TYPE_CODE_ARRAY && type->is_vector ()) @@ -1908,7 +1908,7 @@ value_neg (struct value *arg1) struct type *type; arg1 = coerce_ref (arg1); - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); if (is_integral_type (type) || is_floating_type (type)) return value_binop (value_from_longest (type, 0), arg1, BINOP_SUB); @@ -1955,7 +1955,7 @@ value_complement (struct value *arg1) struct value *val; arg1 = coerce_ref (arg1); - type = check_typedef (value_type (arg1)); + type = check_typedef (arg1->type ()); if (is_integral_type (type)) val = value_from_longest (type, ~value_as_long (arg1)); @@ -2025,8 +2025,8 @@ int value_in (struct value *element, struct value *set) { int member; - struct type *settype = check_typedef (value_type (set)); - struct type *eltype = check_typedef (value_type (element)); + struct type *settype = check_typedef (set->type ()); + struct type *eltype = check_typedef (element->type ()); if (eltype->code () == TYPE_CODE_RANGE) eltype = eltype->target_type (); |