diff options
author | Andrew Cagney <cagney@redhat.com> | 2004-11-10 18:52:25 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2004-11-10 18:52:25 +0000 |
commit | 994b921186a7275b71c4462dbbb8895072fcbc64 (patch) | |
tree | d744788e3d80537d7c7cdd49d13e542ca7a3c146 /gdb/value.c | |
parent | 06987e6431adee88dcffb552d01162668efbf9f4 (diff) | |
download | gdb-994b921186a7275b71c4462dbbb8895072fcbc64.zip gdb-994b921186a7275b71c4462dbbb8895072fcbc64.tar.gz gdb-994b921186a7275b71c4462dbbb8895072fcbc64.tar.bz2 |
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
Diffstat (limited to 'gdb/value.c')
-rw-r--r-- | gdb/value.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/gdb/value.c b/gdb/value.c index 0a82927..e53f930 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -526,7 +526,7 @@ value_as_long (struct value *val) /* This coerces arrays and functions, which is necessary (e.g. in disassemble_command). It also dereferences references, which I suspect is the most logical thing to do. */ - COERCE_ARRAY (val); + val = coerce_array (val); return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val)); } @@ -597,7 +597,7 @@ value_as_address (struct value *val) || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_METHOD) return VALUE_ADDRESS (val); - COERCE_ARRAY (val); + val = coerce_array (val); /* Some architectures (e.g. Harvard), map instruction and data addresses onto a single large unified address space. For @@ -1197,6 +1197,45 @@ value_from_double (struct type *type, DOUBLEST num) return val; } + +struct value * +coerce_ref (struct value *arg) +{ + struct type *value_type_arg_tmp = check_typedef (VALUE_TYPE (arg)); + if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF) + arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp), + unpack_pointer (VALUE_TYPE (arg), + VALUE_CONTENTS (arg))); + return arg; +} + +struct value * +coerce_array (struct value *arg) +{ + arg = coerce_ref (arg); + if (current_language->c_style_arrays + && TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) + arg = value_coerce_array (arg); + if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC) + arg = value_coerce_function (arg); + return arg; +} + +struct value * +coerce_number (struct value *arg) +{ + arg = coerce_array (arg); + arg = coerce_enum (arg); + return arg; +} + +struct value * +coerce_enum (struct value *arg) +{ + if (TYPE_CODE (check_typedef (VALUE_TYPE (arg))) == TYPE_CODE_ENUM) + arg = value_cast (builtin_type_unsigned_int, arg); + return arg; +} /* Should we use DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS instead of |