From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1869 invoked by alias); 26 Mar 2004 18:07:04 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1857 invoked from network); 26 Mar 2004 18:07:02 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sources.redhat.com with SMTP; 26 Mar 2004 18:07:02 -0000 Received: from drow by nevyn.them.org with local (Exim 4.30 #1 (Debian)) id 1B6vjP-0005eZ-Ph; Fri, 26 Mar 2004 13:06:59 -0500 Date: Fri, 26 Mar 2004 18:07:00 -0000 From: Daniel Jacobowitz To: Paul Hilfinger Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA]: Extend some arithmetic operations to range types. Message-ID: <20040326180659.GA21603@nevyn.them.org> Mail-Followup-To: Paul Hilfinger , gdb-patches@sources.redhat.com References: <20040326105916.3FAA5F2DA7@nile.gnat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040326105916.3FAA5F2DA7@nile.gnat.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2004-03/txt/msg00674.txt.bz2 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