s/value_ptr/struct value */

This commit is contained in:
Andrew Cagney
2002-01-04 05:20:09 +00:00
parent 5c8844646d
commit f23631e444
8 changed files with 367 additions and 341 deletions

View File

@@ -1,6 +1,6 @@
/* Perform arithmetic and other operations on values, for GDB.
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
1997, 1998, 1999, 2000
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GDB.
@@ -38,15 +38,16 @@
#define TRUNCATION_TOWARDS_ZERO ((-5 / 2) == -2)
#endif
static value_ptr value_subscripted_rvalue (value_ptr, value_ptr, int);
static struct value *value_subscripted_rvalue (struct value *, struct value *, int);
void _initialize_valarith (void);
value_ptr
value_add (value_ptr arg1, value_ptr arg2)
struct value *
value_add (struct value *arg1, struct value *arg2)
{
register value_ptr valint, valptr;
struct value *valint;
struct value *valptr;
register int len;
struct type *type1, *type2, *valptrtype;
@@ -62,7 +63,7 @@ value_add (value_ptr arg1, value_ptr arg2)
|| TYPE_CODE (type2) == TYPE_CODE_INT))
/* Exactly one argument is a pointer, and one is an integer. */
{
value_ptr retval;
struct value *retval;
if (TYPE_CODE (type1) == TYPE_CODE_PTR)
{
@@ -89,8 +90,8 @@ value_add (value_ptr arg1, value_ptr arg2)
return value_binop (arg1, arg2, BINOP_ADD);
}
value_ptr
value_sub (value_ptr arg1, value_ptr arg2)
struct value *
value_sub (struct value *arg1, struct value *arg2)
{
struct type *type1, *type2;
COERCE_NUMBER (arg1);
@@ -135,10 +136,10 @@ an integer nor a pointer of the same type.");
FIXME: Perhaps we should validate that the index is valid and if
verbosity is set, warn about invalid indices (but still use them). */
value_ptr
value_subscript (value_ptr array, value_ptr idx)
struct value *
value_subscript (struct value *array, struct value *idx)
{
value_ptr bound;
struct value *bound;
int c_style = current_language->c_style_arrays;
struct type *tarray;
@@ -179,7 +180,7 @@ value_subscript (value_ptr array, value_ptr idx)
{
struct type *range_type = TYPE_INDEX_TYPE (tarray);
LONGEST index = value_as_long (idx);
value_ptr v;
struct value *v;
int offset, byte, bit_index;
LONGEST lowerbound, upperbound;
get_discrete_bounds (range_type, &lowerbound, &upperbound);
@@ -211,15 +212,15 @@ value_subscript (value_ptr array, value_ptr idx)
(eg, a vector register). This routine used to promote floats
to doubles, but no longer does. */
static value_ptr
value_subscripted_rvalue (value_ptr array, value_ptr idx, int lowerbound)
static struct value *
value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound)
{
struct type *array_type = check_typedef (VALUE_TYPE (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
unsigned int elt_size = TYPE_LENGTH (elt_type);
LONGEST index = value_as_long (idx);
unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
value_ptr v;
struct value *v;
if (index < lowerbound || elt_offs >= TYPE_LENGTH (array_type))
error ("no such vector element");
@@ -246,7 +247,7 @@ value_subscripted_rvalue (value_ptr array, value_ptr idx, int lowerbound)
For now, we do not overload the `=' operator. */
int
binop_user_defined_p (enum exp_opcode op, value_ptr arg1, value_ptr arg2)
binop_user_defined_p (enum exp_opcode op, struct value *arg1, struct value *arg2)
{
struct type *type1, *type2;
if (op == BINOP_ASSIGN || op == BINOP_CONCAT)
@@ -268,7 +269,7 @@ binop_user_defined_p (enum exp_opcode op, value_ptr arg1, value_ptr arg2)
For now, we do not overload the `&' operator. */
int
unop_user_defined_p (enum exp_opcode op, value_ptr arg1)
unop_user_defined_p (enum exp_opcode op, struct value *arg1)
{
struct type *type1;
if (op == UNOP_ADDR)
@@ -294,11 +295,11 @@ unop_user_defined_p (enum exp_opcode op, value_ptr arg1)
is the opcode saying how to modify it. Otherwise, OTHEROP is
unused. */
value_ptr
value_x_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op,
struct value *
value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
enum exp_opcode otherop, enum noside noside)
{
value_ptr *argvec;
struct value **argvec;
char *ptr;
char tstr[13];
int static_memfuncp;
@@ -314,7 +315,7 @@ value_x_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op,
if (TYPE_CODE (check_typedef (VALUE_TYPE (arg1))) != TYPE_CODE_STRUCT)
error ("Can't do that binary op on that type"); /* FIXME be explicit */
argvec = (value_ptr *) alloca (sizeof (value_ptr) * 4);
argvec = (struct value **) alloca (sizeof (struct value *) * 4);
argvec[1] = value_addr (arg1);
argvec[2] = arg2;
argvec[3] = 0;
@@ -457,10 +458,10 @@ value_x_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op,
and return that value (where '@' is (almost) any unary operator which
is legal for GNU C++). */
value_ptr
value_x_unop (value_ptr arg1, enum exp_opcode op, enum noside noside)
struct value *
value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
{
value_ptr *argvec;
struct value **argvec;
char *ptr, *mangle_ptr;
char tstr[13], mangle_tstr[13];
int static_memfuncp;
@@ -474,7 +475,7 @@ value_x_unop (value_ptr arg1, enum exp_opcode op, enum noside noside)
if (TYPE_CODE (check_typedef (VALUE_TYPE (arg1))) != TYPE_CODE_STRUCT)
error ("Can't do that unary op on that type"); /* FIXME be explicit */
argvec = (value_ptr *) alloca (sizeof (value_ptr) * 3);
argvec = (struct value **) alloca (sizeof (struct value *) * 3);
argvec[1] = value_addr (arg1);
argvec[2] = 0;
@@ -557,10 +558,12 @@ value_x_unop (value_ptr arg1, enum exp_opcode op, enum noside noside)
string values of length 1.
*/
value_ptr
value_concat (value_ptr arg1, value_ptr arg2)
struct value *
value_concat (struct value *arg1, struct value *arg2)
{
register value_ptr inval1, inval2, outval = NULL;
struct value *inval1;
struct value *inval2;
struct value *outval = NULL;
int inval1len, inval2len;
int count, idx;
char *ptr;
@@ -690,10 +693,10 @@ value_concat (value_ptr arg1, value_ptr arg2)
Does not support addition and subtraction on pointers;
use value_add or value_sub if you want to handle those possibilities. */
value_ptr
value_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op)
struct value *
value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
{
register value_ptr val;
struct value *val;
struct type *type1, *type2;
COERCE_REF (arg1);
@@ -1114,7 +1117,7 @@ value_binop (value_ptr arg1, value_ptr arg2, enum exp_opcode op)
/* Simulate the C operator ! -- return 1 if ARG1 contains zero. */
int
value_logical_not (value_ptr arg1)
value_logical_not (struct value *arg1)
{
register int len;
register char *p;
@@ -1142,7 +1145,7 @@ value_logical_not (value_ptr arg1)
necessarily null terminated) based on their length */
static int
value_strcmp (register value_ptr arg1, register value_ptr arg2)
value_strcmp (struct value *arg1, struct value *arg2)
{
int len1 = TYPE_LENGTH (VALUE_TYPE (arg1));
int len2 = TYPE_LENGTH (VALUE_TYPE (arg2));
@@ -1172,7 +1175,7 @@ value_strcmp (register value_ptr arg1, register value_ptr arg2)
iff ARG1 and ARG2 have equal contents. */
int
value_equal (register value_ptr arg1, register value_ptr arg2)
value_equal (struct value *arg1, struct value *arg2)
{
register int len;
register char *p1, *p2;
@@ -1231,7 +1234,7 @@ value_equal (register value_ptr arg1, register value_ptr arg2)
iff ARG1's contents are less than ARG2's. */
int
value_less (register value_ptr arg1, register value_ptr arg2)
value_less (struct value *arg1, struct value *arg2)
{
register enum type_code code1;
register enum type_code code2;
@@ -1272,8 +1275,8 @@ value_less (register value_ptr arg1, register value_ptr arg2)
/* The unary operators - and ~. Both free the argument ARG1. */
value_ptr
value_neg (register value_ptr arg1)
struct value *
value_neg (struct value *arg1)
{
register struct type *type;
register struct type *result_type = VALUE_TYPE (arg1);
@@ -1301,8 +1304,8 @@ value_neg (register value_ptr arg1)
}
}
value_ptr
value_complement (register value_ptr arg1)
struct value *
value_complement (struct value *arg1)
{
register struct type *type;
register struct type *result_type = VALUE_TYPE (arg1);
@@ -1349,8 +1352,8 @@ value_bit_index (struct type *type, char *valaddr, int index)
return (word >> rel_index) & 1;
}
value_ptr
value_in (value_ptr element, value_ptr set)
struct value *
value_in (struct value *element, struct value *set)
{
int member;
struct type *settype = check_typedef (VALUE_TYPE (set));