+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>
* mips-tdep.c (mips32_relative_offset): Change return type to
if (!toval->modifiable)
error ("Left operand of assignment is not a modifiable lvalue.");
- COERCE_REF (toval);
+ toval = coerce_ref (toval);
if (VALUE_LVAL (toval) == lval_memory
&& bits > 0
t1 = ada_check_typedef (t1);
if (TYPE_CODE (t1) == TYPE_CODE_PTR)
{
- COERCE_REF (arg);
+ arg = coerce_ref (arg);
t = t1;
}
}
if (TYPE_CODE (VALUE_TYPE (val0)) == TYPE_CODE_REF)
{
struct value *val = val0;
- COERCE_REF (val);
+ val = coerce_ref (val);
val = unwrap_value (val);
return ada_to_fixed_value (val);
}
struct type *type1, *type2;
LONGEST v, v1, v2;
- COERCE_REF (arg1);
- COERCE_REF (arg2);
+ arg1 = coerce_ref (arg1);
+ arg2 = coerce_ref (arg2);
type1 = base_type (ada_check_typedef (VALUE_TYPE (arg1)));
type2 = base_type (ada_check_typedef (VALUE_TYPE (arg2)));
evaluate_subexp (NULL_TYPE, exp, pos, noside);
LONGEST low_bound;
LONGEST high_bound;
- COERCE_REF (low_bound_val);
- COERCE_REF (high_bound_val);
+ low_bound_val = coerce_ref (low_bound_val);
+ high_bound_val = coerce_ref (high_bound_val);
low_bound = pos_atr (low_bound_val);
high_bound = pos_atr (high_bound_val);
array or pointer type (like a plain int variable for example),
then report this as an error. */
- COERCE_REF (arg1);
+ arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type) != TYPE_CODE_ARRAY
&& TYPE_CODE (type) != TYPE_CODE_PTR)
array or pointer type (like a plain int variable for example),
then report this as an error. */
- COERCE_REF (arg1);
+ arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type) == TYPE_CODE_PTR)
type = check_typedef (TYPE_TARGET_TYPE (type));
LONGEST sz;
struct type *type1, *type2, *valptrtype;
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
+ arg1 = coerce_array (arg1);
+ arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2));
value_sub (struct value *arg1, struct value *arg2)
{
struct type *type1, *type2;
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
+ arg1 = coerce_array (arg1);
+ arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2));
int c_style = current_language->c_style_arrays;
struct type *tarray;
- COERCE_REF (array);
+ array = coerce_ref (array);
tarray = check_typedef (VALUE_TYPE (array));
if (TYPE_CODE (tarray) == TYPE_CODE_ARRAY
char tstr[13];
int static_memfuncp;
- COERCE_REF (arg1);
- COERCE_REF (arg2);
- COERCE_ENUM (arg1);
- COERCE_ENUM (arg2);
+ arg1 = coerce_ref (arg1);
+ arg2 = coerce_ref (arg2);
+ arg1 = coerce_enum (arg1);
+ arg2 = coerce_enum (arg2);
/* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */
char tstr[13], mangle_tstr[13];
int static_memfuncp, nargs;
- COERCE_REF (arg1);
- COERCE_ENUM (arg1);
+ arg1 = coerce_ref (arg1);
+ arg1 = coerce_enum (arg1);
/* now we know that what we have to do is construct our
arg vector and find the right function to call it with. */
struct value *val;
struct type *type1, *type2;
- COERCE_REF (arg1);
- COERCE_REF (arg2);
+ arg1 = coerce_ref (arg1);
+ arg2 = coerce_ref (arg2);
type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2));
char *p;
struct type *type1;
- COERCE_NUMBER (arg1);
+ arg1 = coerce_number (arg1);
type1 = check_typedef (VALUE_TYPE (arg1));
if (TYPE_CODE (type1) == TYPE_CODE_FLT)
enum type_code code2;
int is_int1, is_int2;
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
+ arg1 = coerce_array (arg1);
+ arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2));
struct type *type1, *type2;
int is_int1, is_int2;
- COERCE_ARRAY (arg1);
- COERCE_ARRAY (arg2);
+ arg1 = coerce_array (arg1);
+ arg2 = coerce_array (arg2);
type1 = check_typedef (VALUE_TYPE (arg1));
type2 = check_typedef (VALUE_TYPE (arg2));
struct type *type;
struct type *result_type = VALUE_TYPE (arg1);
- COERCE_REF (arg1);
+ arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1));
struct type *type;
struct type *result_type = VALUE_TYPE (arg1);
- COERCE_REF (arg1);
+ arg1 = coerce_ref (arg1);
type = check_typedef (VALUE_TYPE (arg1));
CHECK_TYPEDEF (type);
code1 = TYPE_CODE (type);
- COERCE_REF (arg2);
+ arg2 = coerce_ref (arg2);
type2 = check_typedef (VALUE_TYPE (arg2));
/* A cast to an undetermined-length array_type, such as (TYPE [])OBJECT,
if (!toval->modifiable)
error ("Left operand of assignment is not a modifiable lvalue.");
- COERCE_REF (toval);
+ toval = coerce_ref (toval);
type = VALUE_TYPE (toval);
if (VALUE_LVAL (toval) != lval_internalvar)
fromval = value_cast (type, fromval);
else
- COERCE_ARRAY (fromval);
+ fromval = coerce_array (fromval);
CHECK_TYPEDEF (type);
/* Since modifying a register can trash the frame chain, and modifying memory
struct type *base_type;
struct value *arg2;
- COERCE_ARRAY (arg1);
+ arg1 = coerce_array (arg1);
base_type = check_typedef (VALUE_TYPE (arg1));
struct type *t;
struct value *v;
- COERCE_ARRAY (*argp);
+ *argp = coerce_array (*argp);
t = check_typedef (VALUE_TYPE (*argp));
*argp = value_ind (*argp);
/* Don't coerce fn pointer to fn and then back again! */
if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
- COERCE_ARRAY (*argp);
+ *argp = coerce_array (*argp);
t = check_typedef (VALUE_TYPE (*argp));
}
*argp = value_ind (*argp);
/* Don't coerce fn pointer to fn and then back again! */
if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC)
- COERCE_ARRAY (*argp);
+ *argp = coerce_array (*argp);
t = check_typedef (VALUE_TYPE (*argp));
}
{
struct type *t;
- COERCE_ARRAY (arg1);
+ arg1 = coerce_array (arg1);
t = VALUE_TYPE (arg1);
/* 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));
}
|| 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
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;
+}
\f
/* Should we use DEPRECATED_EXTRACT_STRUCT_VALUE_ADDRESS instead of
/* Convert a REF to the object referenced. */
-#define COERCE_REF(arg) \
- 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)
+extern struct value *coerce_ref (struct value *value);
/* If ARG is an array, convert it to a pointer.
If ARG is an enum, convert it to an integer.
References are dereferenced. */
-#define COERCE_ARRAY(arg) \
- do { \
- 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)
+extern struct value *coerce_array (struct value *value);
+extern struct value *coerce_number (struct value *value);
/* If ARG is an enum, convert it to an integer. */
-#define COERCE_ENUM(arg) \
- do { \
- if (TYPE_CODE (check_typedef (VALUE_TYPE (arg))) == TYPE_CODE_ENUM) \
- arg = value_cast (builtin_type_unsigned_int, arg); \
- } while (0)
+extern struct value *coerce_enum (struct value *value);
/* Internal variables (variables for convenience of use of debugger)
are recorded as a chain of these structures. */