Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Paul Hilfinger <hilfingr@gnat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA]: Extend some arithmetic operations to range types.
Date: Fri, 26 Mar 2004 18:07:00 -0000	[thread overview]
Message-ID: <20040326180659.GA21603@nevyn.them.org> (raw)
In-Reply-To: <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


  reply	other threads:[~2004-03-26 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-26 10:59 Paul Hilfinger
2004-03-26 18:07 ` Daniel Jacobowitz [this message]
2004-03-26 19:03   ` Joel Brobecker
2004-03-26 20:32     ` Daniel Jacobowitz
2004-03-29 11:29   ` Paul Hilfinger
2004-03-31 19:05     ` Daniel Jacobowitz
2004-04-01 12:11       ` Paul Hilfinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040326180659.GA21603@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=hilfingr@gnat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox