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.
This commit is contained in:
Andrew Cagney 2004-11-10 18:52:25 +00:00
parent 06987e6431
commit 994b921186
8 changed files with 100 additions and 64 deletions

View file

@ -1,3 +1,21 @@
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.
2004-11-10 Mark Kettenis <kettenis@gnu.org> 2004-11-10 Mark Kettenis <kettenis@gnu.org>
* mips-tdep.c (mips32_relative_offset): Change return type to * mips-tdep.c (mips32_relative_offset): Change return type to

View file

@ -2006,7 +2006,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
if (!toval->modifiable) if (!toval->modifiable)
error ("Left operand of assignment is not a modifiable lvalue."); error ("Left operand of assignment is not a modifiable lvalue.");
COERCE_REF (toval); toval = coerce_ref (toval);
if (VALUE_LVAL (toval) == lval_memory if (VALUE_LVAL (toval) == lval_memory
&& bits > 0 && bits > 0
@ -5479,7 +5479,7 @@ ada_value_struct_elt (struct value *arg, char *name, char *err)
t1 = ada_check_typedef (t1); t1 = ada_check_typedef (t1);
if (TYPE_CODE (t1) == TYPE_CODE_PTR) if (TYPE_CODE (t1) == TYPE_CODE_PTR)
{ {
COERCE_REF (arg); arg = coerce_ref (arg);
t = t1; t = t1;
} }
} }
@ -5766,7 +5766,7 @@ ada_coerce_ref (struct value *val0)
if (TYPE_CODE (VALUE_TYPE (val0)) == TYPE_CODE_REF) if (TYPE_CODE (VALUE_TYPE (val0)) == TYPE_CODE_REF)
{ {
struct value *val = val0; struct value *val = val0;
COERCE_REF (val); val = coerce_ref (val);
val = unwrap_value (val); val = unwrap_value (val);
return ada_to_fixed_value (val); return ada_to_fixed_value (val);
} }
@ -7030,8 +7030,8 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
struct type *type1, *type2; struct type *type1, *type2;
LONGEST v, v1, v2; LONGEST v, v1, v2;
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
COERCE_REF (arg2); arg2 = coerce_ref (arg2);
type1 = base_type (ada_check_typedef (VALUE_TYPE (arg1))); type1 = base_type (ada_check_typedef (VALUE_TYPE (arg1)));
type2 = base_type (ada_check_typedef (VALUE_TYPE (arg2))); type2 = base_type (ada_check_typedef (VALUE_TYPE (arg2)));
@ -7406,8 +7406,8 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
evaluate_subexp (NULL_TYPE, exp, pos, noside); evaluate_subexp (NULL_TYPE, exp, pos, noside);
LONGEST low_bound; LONGEST low_bound;
LONGEST high_bound; LONGEST high_bound;
COERCE_REF (low_bound_val); low_bound_val = coerce_ref (low_bound_val);
COERCE_REF (high_bound_val); high_bound_val = coerce_ref (high_bound_val);
low_bound = pos_atr (low_bound_val); low_bound = pos_atr (low_bound_val);
high_bound = pos_atr (high_bound_val); high_bound = pos_atr (high_bound_val);

View file

@ -1532,7 +1532,7 @@ evaluate_subexp_standard (struct type *expect_type,
array or pointer type (like a plain int variable for example), array or pointer type (like a plain int variable for example),
then report this as an error. */ then report this as an error. */
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1)); type = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type) != TYPE_CODE_ARRAY if (TYPE_CODE (type) != TYPE_CODE_ARRAY
&& TYPE_CODE (type) != TYPE_CODE_PTR) && TYPE_CODE (type) != TYPE_CODE_PTR)

View file

@ -867,7 +867,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
array or pointer type (like a plain int variable for example), array or pointer type (like a plain int variable for example),
then report this as an error. */ then report this as an error. */
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1)); type = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type) == TYPE_CODE_PTR) if (TYPE_CODE (type) == TYPE_CODE_PTR)
type = check_typedef (TYPE_TARGET_TYPE (type)); type = check_typedef (TYPE_TARGET_TYPE (type));

View file

@ -91,8 +91,8 @@ value_add (struct value *arg1, struct value *arg2)
LONGEST sz; LONGEST sz;
struct type *type1, *type2, *valptrtype; struct type *type1, *type2, *valptrtype;
COERCE_ARRAY (arg1); arg1 = coerce_array (arg1);
COERCE_ARRAY (arg2); arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1)); type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2)); type2 = check_typedef (VALUE_TYPE (arg2));
@ -132,8 +132,8 @@ struct value *
value_sub (struct value *arg1, struct value *arg2) value_sub (struct value *arg1, struct value *arg2)
{ {
struct type *type1, *type2; struct type *type1, *type2;
COERCE_ARRAY (arg1); arg1 = coerce_array (arg1);
COERCE_ARRAY (arg2); arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1)); type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2)); type2 = check_typedef (VALUE_TYPE (arg2));
@ -182,7 +182,7 @@ value_subscript (struct value *array, struct value *idx)
int c_style = current_language->c_style_arrays; int c_style = current_language->c_style_arrays;
struct type *tarray; struct type *tarray;
COERCE_REF (array); array = coerce_ref (array);
tarray = check_typedef (VALUE_TYPE (array)); tarray = check_typedef (VALUE_TYPE (array));
if (TYPE_CODE (tarray) == TYPE_CODE_ARRAY if (TYPE_CODE (tarray) == TYPE_CODE_ARRAY
@ -346,10 +346,10 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
char tstr[13]; char tstr[13];
int static_memfuncp; int static_memfuncp;
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
COERCE_REF (arg2); arg2 = coerce_ref (arg2);
COERCE_ENUM (arg1); arg1 = coerce_enum (arg1);
COERCE_ENUM (arg2); arg2 = coerce_enum (arg2);
/* now we know that what we have to do is construct our /* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */ arg vector and find the right function to call it with. */
@ -508,8 +508,8 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
char tstr[13], mangle_tstr[13]; char tstr[13], mangle_tstr[13];
int static_memfuncp, nargs; int static_memfuncp, nargs;
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
COERCE_ENUM (arg1); arg1 = coerce_enum (arg1);
/* now we know that what we have to do is construct our /* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */ arg vector and find the right function to call it with. */
@ -747,8 +747,8 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
struct value *val; struct value *val;
struct type *type1, *type2; struct type *type1, *type2;
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
COERCE_REF (arg2); arg2 = coerce_ref (arg2);
type1 = check_typedef (VALUE_TYPE (arg1)); type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2)); type2 = check_typedef (VALUE_TYPE (arg2));
@ -1155,7 +1155,7 @@ value_logical_not (struct value *arg1)
char *p; char *p;
struct type *type1; struct type *type1;
COERCE_NUMBER (arg1); arg1 = coerce_number (arg1);
type1 = check_typedef (VALUE_TYPE (arg1)); type1 = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type1) == TYPE_CODE_FLT) if (TYPE_CODE (type1) == TYPE_CODE_FLT)
@ -1216,8 +1216,8 @@ value_equal (struct value *arg1, struct value *arg2)
enum type_code code2; enum type_code code2;
int is_int1, is_int2; int is_int1, is_int2;
COERCE_ARRAY (arg1); arg1 = coerce_array (arg1);
COERCE_ARRAY (arg2); arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1)); type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2)); type2 = check_typedef (VALUE_TYPE (arg2));
@ -1275,8 +1275,8 @@ value_less (struct value *arg1, struct value *arg2)
struct type *type1, *type2; struct type *type1, *type2;
int is_int1, is_int2; int is_int1, is_int2;
COERCE_ARRAY (arg1); arg1 = coerce_array (arg1);
COERCE_ARRAY (arg2); arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1)); type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2)); type2 = check_typedef (VALUE_TYPE (arg2));
@ -1317,7 +1317,7 @@ value_neg (struct value *arg1)
struct type *type; struct type *type;
struct type *result_type = VALUE_TYPE (arg1); struct type *result_type = VALUE_TYPE (arg1);
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1)); type = check_typedef (VALUE_TYPE (arg1));
@ -1345,7 +1345,7 @@ value_complement (struct value *arg1)
struct type *type; struct type *type;
struct type *result_type = VALUE_TYPE (arg1); struct type *result_type = VALUE_TYPE (arg1);
COERCE_REF (arg1); arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1)); type = check_typedef (VALUE_TYPE (arg1));

View file

@ -212,7 +212,7 @@ value_cast (struct type *type, struct value *arg2)
CHECK_TYPEDEF (type); CHECK_TYPEDEF (type);
code1 = TYPE_CODE (type); code1 = TYPE_CODE (type);
COERCE_REF (arg2); arg2 = coerce_ref (arg2);
type2 = check_typedef (VALUE_TYPE (arg2)); type2 = check_typedef (VALUE_TYPE (arg2));
/* A cast to an undetermined-length array_type, such as (TYPE [])OBJECT, /* A cast to an undetermined-length array_type, such as (TYPE [])OBJECT,
@ -524,13 +524,13 @@ value_assign (struct value *toval, struct value *fromval)
if (!toval->modifiable) if (!toval->modifiable)
error ("Left operand of assignment is not a modifiable lvalue."); error ("Left operand of assignment is not a modifiable lvalue.");
COERCE_REF (toval); toval = coerce_ref (toval);
type = VALUE_TYPE (toval); type = VALUE_TYPE (toval);
if (VALUE_LVAL (toval) != lval_internalvar) if (VALUE_LVAL (toval) != lval_internalvar)
fromval = value_cast (type, fromval); fromval = value_cast (type, fromval);
else else
COERCE_ARRAY (fromval); fromval = coerce_array (fromval);
CHECK_TYPEDEF (type); CHECK_TYPEDEF (type);
/* Since modifying a register can trash the frame chain, and modifying memory /* Since modifying a register can trash the frame chain, and modifying memory
@ -896,7 +896,7 @@ value_ind (struct value *arg1)
struct type *base_type; struct type *base_type;
struct value *arg2; struct value *arg2;
COERCE_ARRAY (arg1); arg1 = coerce_array (arg1);
base_type = check_typedef (VALUE_TYPE (arg1)); base_type = check_typedef (VALUE_TYPE (arg1));
@ -1589,7 +1589,7 @@ value_struct_elt (struct value **argp, struct value **args,
struct type *t; struct type *t;
struct value *v; struct value *v;
COERCE_ARRAY (*argp); *argp = coerce_array (*argp);
t = check_typedef (VALUE_TYPE (*argp)); t = check_typedef (VALUE_TYPE (*argp));
@ -1600,7 +1600,7 @@ value_struct_elt (struct value **argp, struct value **args,
*argp = value_ind (*argp); *argp = value_ind (*argp);
/* Don't coerce fn pointer to fn and then back again! */ /* Don't coerce fn pointer to fn and then back again! */
if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC) if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
COERCE_ARRAY (*argp); *argp = coerce_array (*argp);
t = check_typedef (VALUE_TYPE (*argp)); t = check_typedef (VALUE_TYPE (*argp));
} }
@ -1799,7 +1799,7 @@ value_find_oload_method_list (struct value **argp, char *method, int offset,
*argp = value_ind (*argp); *argp = value_ind (*argp);
/* Don't coerce fn pointer to fn and then back again! */ /* Don't coerce fn pointer to fn and then back again! */
if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC) if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
COERCE_ARRAY (*argp); *argp = coerce_array (*argp);
t = check_typedef (VALUE_TYPE (*argp)); t = check_typedef (VALUE_TYPE (*argp));
} }
@ -2320,7 +2320,7 @@ check_field (struct value *arg1, const char *name)
{ {
struct type *t; struct type *t;
COERCE_ARRAY (arg1); arg1 = coerce_array (arg1);
t = VALUE_TYPE (arg1); t = VALUE_TYPE (arg1);

View file

@ -526,7 +526,7 @@ value_as_long (struct value *val)
/* This coerces arrays and functions, which is necessary (e.g. /* This coerces arrays and functions, which is necessary (e.g.
in disassemble_command). It also dereferences references, which in disassemble_command). It also dereferences references, which
I suspect is the most logical thing to do. */ 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)); 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) || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_METHOD)
return VALUE_ADDRESS (val); return VALUE_ADDRESS (val);
COERCE_ARRAY (val); val = coerce_array (val);
/* Some architectures (e.g. Harvard), map instruction and data /* Some architectures (e.g. Harvard), map instruction and data
addresses onto a single large unified address space. For addresses onto a single large unified address space. For
@ -1197,6 +1197,45 @@ value_from_double (struct type *type, DOUBLEST num)
return val; 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 /* Should we use DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS instead of

View file

@ -226,14 +226,7 @@ extern int value_fetch_lazy (struct value *val);
/* Convert a REF to the object referenced. */ /* Convert a REF to the object referenced. */
#define COERCE_REF(arg) \ extern struct value *coerce_ref (struct value *value);
do { \
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))); \
} while (0)
/* If ARG is an array, convert it to a pointer. /* If ARG is an array, convert it to a pointer.
If ARG is an enum, convert it to an integer. If ARG is an enum, convert it to an integer.
@ -241,26 +234,12 @@ extern int value_fetch_lazy (struct value *val);
References are dereferenced. */ References are dereferenced. */
#define COERCE_ARRAY(arg) \ extern struct value *coerce_array (struct value *value);
do { \ extern struct value *coerce_number (struct value *value);
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); \
} while (0)
#define COERCE_NUMBER(arg) \
do { COERCE_ARRAY(arg); COERCE_ENUM(arg); } while (0)
/* If ARG is an enum, convert it to an integer. */ /* If ARG is an enum, convert it to an integer. */
#define COERCE_ENUM(arg) \ extern struct value *coerce_enum (struct value *value);
do { \
if (TYPE_CODE (check_typedef (VALUE_TYPE (arg))) == TYPE_CODE_ENUM) \
arg = value_cast (builtin_type_unsigned_int, arg); \
} while (0)
/* Internal variables (variables for convenience of use of debugger) /* Internal variables (variables for convenience of use of debugger)
are recorded as a chain of these structures. */ are recorded as a chain of these structures. */