Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: gdb@sources.redhat.com
Subject: Re: C++ nested classes, namespaces, structs, and compound statements
Date: Fri, 12 Apr 2002 16:56:00 -0000	[thread overview]
Message-ID: <20020412195613.C11562@nevyn.them.org> (raw)
In-Reply-To: <np7knc4osy.fsf@zwingli.cygnus.com>

On Fri, Apr 12, 2002 at 03:58:21PM -0500, Jim Blandy wrote:
> 
> Daniel Jacobowitz <drow@mvista.com> writes:
> > On Wed, Apr 10, 2002 at 12:31:27PM -0500, Jim Blandy wrote:
> > > Daniel Jacobowitz <drow@mvista.com> writes:
> > > > Sure.  But I think this is a chance (if we want one) to move in a
> > > > different direction.  We'd have to work out the details, but I envision
> > > > something like this (names made up as I go along):
> > > > 
> > > > struct environment_entry {
> > > >   const char *name;
> > > >   enum name_type kind;
> > > >   void *data;
> > > > }
> > > > 
> > > > enum name_type {
> > > >   type_kind,
> > > >   field_kind,
> > > >   symbol_kind,
> > > >   namespace_kind,
> > > > };
> > > 
> > > In other words, replace the sloppy union with a properly discriminated
> > > union?  I'm for it.
> > > 
> > > But granted that it's important to clearly distinguish between the
> > > expanding set of uses we're putting `struct symbol' to, and that
> > > extending enum address_class isn't the best idea, how is it better to
> > > make this change concurrently with the enclosing environment changes?
> > > We could do this change right now.  Isn't it basically independent?
> > 
> > Well, no.  I was suggesting this for things that are not currently in
> > symbols (well, types generally are...).  But namespaces are not
> > represented at all and fields are in a different structure entirely.
> 
> Okay, I think I see.  You're preserving the distinctions implicit in
> the existing structures (fields and symbols are separate),
> distinguishing types from symbols (i.e. an entry for a typedef would
> be an environment_entry whose kind == type_kind, instead of a symbol
> with an address class of LOC_TYPEDEF), and positing that namespaces
> would be a fourth kind of thing.  The `data' field would point to a
> `struct type' or a `struct field', or whatever.

Yes, that's right.  There's also transparent scopes (which might be a
special kind of namespace... or not).  By that I mean {} enclosed
regions with their own local variables.  A function belongs to a
namespace, a namespace does not enclose a particular range of PCs - but
a scope does enclose a particular PC range.  Hopefully but not
necessarily a single contiguous range.  Optimization or explicit
.section directives could break it up.

> 
> > Doing it for struct symbol would be a good idea, I think, but a better
> > approach would be:
> >   - start the environments properly, using a new enum.
> >   - Separate out those things which need to be "different kinds of
> >     struct symbol", and keep the factoring at the environment level.
> >   - Look up environment entries, not struct symbol's.  That way we can
> >     have a hope of keeping the right names attached to types, for
> >     instance.
> 
> By the last point here, are you suggesting that everyone hand around
> pointers to `struct environment_entry' objects, rather than pointers
> to `struct type', `struct field', etc.?  That would lose some
> typechecking, and some clarity.  If space is the concern, I think I'd
> rather see both the environment entry and the symbol/field/etc. have
> `name' fields, that perhaps point to the same string.

There's a question of correctness, though.  Suppose a type is imported
into a namespace - we don't want to create a new type for it, but we do
want to create a new name for it.  I'm not sure what to do.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


  reply	other threads:[~2002-04-12 23:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-05 20:42 Jim Blandy
2002-04-05 22:05 ` Daniel Berlin
2002-04-05 22:34 ` Daniel Jacobowitz
2002-04-05 23:49   ` Daniel Berlin
2002-04-06  7:18     ` Dan Kegel
2002-04-06  9:26     ` Gianni Mariani
2002-04-06 11:57       ` Daniel Berlin
2002-04-08 17:24       ` Jim Blandy
2002-04-08 17:03   ` Jim Blandy
2002-04-08 18:59     ` Daniel Jacobowitz
2002-04-09 18:35       ` Jim Blandy
2002-04-09 20:56         ` Daniel Jacobowitz
2002-04-12 15:08           ` Jim Blandy
2002-04-12 16:32             ` Daniel Jacobowitz
2002-04-08 17:19   ` Jim Blandy
2002-04-08 18:49     ` Daniel Jacobowitz
2002-04-10 10:31       ` Jim Blandy
2002-04-10 12:08         ` Daniel Jacobowitz
2002-04-12 13:58           ` Jim Blandy
2002-04-12 16:56             ` Daniel Jacobowitz [this message]
2002-04-16 12:08               ` Jim Blandy
2002-04-16 14:01                 ` Daniel Jacobowitz
2002-04-16 14:52               ` Jim Blandy
2002-04-16 14:58                 ` Daniel Jacobowitz
2002-04-06  6:31 ` Andrew Cagney
2002-04-06  7:58   ` Daniel Berlin
2002-04-08  0:59   ` Joel Brobecker
2002-04-08  2:01     ` Doubt in GDB SathisKanna k
2002-04-06  8:49 ` C++ nested classes, namespaces, structs, and compound statements Per Bothner
2002-04-08 16:29 ` Jim Blandy
2002-04-08 16:48   ` Daniel Jacobowitz
2002-04-09  6:55   ` Petr Sorfa
2002-04-10 10:34     ` Jim Blandy
2002-04-10 12:31       ` Daniel Berlin
2002-04-10 12:53         ` Petr Sorfa
2002-04-05 22:02 Michael Elizabeth Chastain
2002-04-05 22:13 ` Daniel Berlin
2002-04-05 22:30   ` Daniel Berlin

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=20020412195613.C11562@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=gdb@sources.redhat.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