This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA]: Extend some arithmetic operations to range types.
- From: Daniel Jacobowitz <drow at false dot org>
- To: Paul Hilfinger <hilfingr at gnat dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Fri, 26 Mar 2004 13:06:59 -0500
- Subject: Re: [RFA]: Extend some arithmetic operations to range types.
- References: <20040326105916.3FAA5F2DA7@nile.gnat.com>
On Fri, Mar 26, 2004 at 05:59:16AM -0500, Paul Hilfinger wrote:
> +/* The identity on non-range types. For range types, the underlying
> + non-range scalar type. */
> +
> +struct type*
> +base_type (struct type* type)
Is there something clearer you can call this? "base" to me means "as
in inheritance", which is not really appropriate here.
> @@ -99,8 +99,8 @@ value_add (struct value *arg1, struct va
> if ((TYPE_CODE (type1) == TYPE_CODE_PTR
> || TYPE_CODE (type2) == TYPE_CODE_PTR)
> &&
> - (TYPE_CODE (type1) == TYPE_CODE_INT
> - || TYPE_CODE (type2) == TYPE_CODE_INT))
> + (TYPE_CODE (base_type (type1)) == TYPE_CODE_INT
> + || TYPE_CODE (base_type (type2)) == TYPE_CODE_INT))
> /* Exactly one argument is a pointer, and one is an integer. */
> {
> struct value *retval;
Most of your changes just need a predicate for
integer-or-scalar-range-type. You can probably find a better name if
the predicate is all you need.
> @@ -1323,7 +1323,7 @@ value_neg (struct value *arg1)
> COERCE_REF (arg1);
> COERCE_ENUM (arg1);
>
> - type = check_typedef (VALUE_TYPE (arg1));
> + type = base_type (check_typedef (VALUE_TYPE (arg1)));
>
> if (TYPE_CODE (type) == TYPE_CODE_FLT)
> return value_from_double (result_type, -value_as_double (arg1));
> @@ -1353,7 +1353,7 @@ value_complement (struct value *arg1)
> COERCE_REF (arg1);
> COERCE_ENUM (arg1);
>
> - type = check_typedef (VALUE_TYPE (arg1));
> + type = base_type (check_typedef (VALUE_TYPE (arg1)));
>
> typecode = TYPE_CODE (type);
> if ((typecode != TYPE_CODE_INT) && (typecode != TYPE_CODE_BOOL))
I think that even these just need a predicate. All they use are
TYPE_CODE and TYPE_LENGTH of the range type.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer