This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA]: Extend some arithmetic operations to range types.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]