public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Multiple inheritance
@ 1997-12-02 22:54 Mike Stump
  1997-12-10  7:31 ` Joshua S. Allen
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Stump @ 1997-12-02 22:54 UTC (permalink / raw)
  To: allen, egcs

> From: "Joshua S. Allen" <allen@eecs.tulane.edu>
> To: egcs@cygnus.com
> Date: Mon, 1 Dec 1997 09:05:40 -0600 (CST)

> (1) I need to construct a table of direct parents of a class.

Why?  Anyway, you can construct it from BINFO_BASETYPES, but it sounds
more like you'd just be replicating it.

> Whereas this could easily be done at parse time,

Ick, very hard to do at parse time.

> it is presenting me with problems and I was wondering if you could
> direct me to how this information could be extracted from the parse
> tree.

Better to extract it from the internal data structures of the
compiler.

>     Once I locate the method in a class, what is the format of the return
> value I give to the calling function.

From the code (assuming just one value):

     return my_tree_cons (basetype_path, rval, NULL_TREE),

     where rval is TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), idx),
           and basetype_path denotes the subobject desired (you'll have to
	      understand the code a bit to understand how to figure out
	      this value.)

An easier way to do this would seem to me to just redefine hides with
whatever rules you want.  If you do that, then the rest of the code
should just work, though I may be missing something because you didn't
describe what it is you wanted to do very well.  I could give better
help with a better idea of what it is you wanted to do.

Good luck.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Multiple inheritance
  1997-12-02 22:54 Multiple inheritance Mike Stump
@ 1997-12-10  7:31 ` Joshua S. Allen
  0 siblings, 0 replies; 5+ messages in thread
From: Joshua S. Allen @ 1997-12-10  7:31 UTC (permalink / raw)
  To: Mike Stump; +Cc: egcs

> 
> > From: "Joshua S. Allen" <allen@eecs.tulane.edu>
> > To: egcs@cygnus.com
> > Date: Mon, 1 Dec 1997 09:05:40 -0600 (CST)
> 
> > (1) I need to construct a table of direct parents of a class.
> 
> Why?  Anyway, you can construct it from BINFO_BASETYPES, but it sounds
> more like you'd just be replicating it.

I've been trying to look at the data in BINFO_BASETYPES using TREE_VALUE but
it just gives me an integer, which I assume it an offset maybe.  Is there a
way to get a string value of the class name?  

For example, if a class named "A" has two direct parents named "B" and "C",
then I would like to retieve the strings "B" and "C." 

> An easier way to do this would seem to me to just redefine hides with
> whatever rules you want.  If you do that, then the rest of the code
> should just work, though I may be missing something because you didn't
> describe what it is you wanted to do very well.  I could give better
> help with a better idea of what it is you wanted to do.
> 

Specifically, what I am doing is computing a linearization of super classes
for each class.  Once I have this linearization, I will use it do automatic
conflict resolution of methods that have the same name in multiple
inheritance.

I already have the linearization algorithm developed in C.  I am now trying
to integrate it into the g++ compiler.  Basically, there are 2 steps: (1)
Compute the superclass linearization for each class. (2) When ambiguity
occurs in multiple inheritance with duplicate class names, resolve it by
using the one that first appears in the linearization.

In order to compute my linearization I need to know only the direct
superclasses of a particular class.  I use this informaiton to recursively
construct the complete linearization for a class.  If a conflict occurs, I
get the clases linearization.  If it has not been computed, then I compute
it.  Then I simply search each class in the lineartion from left to right
until I find the first method with the name I am looking for. 

I hope that helps to describe what I am doing.  Thanks for your help!

--Joshua

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Multiple inheritance
@ 1997-12-10 16:00 Mike Stump
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Stump @ 1997-12-10 16:00 UTC (permalink / raw)
  To: allen; +Cc: egcs

> From: "Joshua S. Allen" <allen@eecs.tulane.edu>
> To: mrs@wrs.com (Mike Stump)
> Date: Wed, 10 Dec 1997 09:21:57 -0600 (CST)

> I've been trying to look at the data in BINFO_BASETYPES using TREE_VALUE

Please refer to the code and the .h files:

/* A vector of additional binfos [...]

#define BINFO_BASETYPES(NODE)

This:

/* In a TREE_LIST node.  */
#define TREE_VALUE(NODE) ((NODE)->list.value)

means that this works for a TREE_LIST (only).  A vector isn't a TREE_LIST.

> but it just gives me an integer, which I assume it an offset maybe.

Now, it means nothing because it isn't valid.

> Is there a way to get a string value of the class name?

TYPE_NAME_STRING(TYPE), it's meant to be readable.  From a sample use:

	    cp_error ("`%D' is already defined in class %s", fndecl,
			         TYPE_NAME_STRING (DECL_CONTEXT (fndecl)));

We can see that it should give us a %s type name of a type.  The trick
then it to get the type from the binfo.  Guess what:

TYPE_BINFO (BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo_h), i)))

kinda sums up how to do that.  You can find these snippets in the
code.  In fact, looking further, we see:

/* Accessor macro to get to the Nth basetype of this basetype.  */
#define TYPE_BINFO_BASETYPE(NODE,N) BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (NODE)), (N)))

which even matches closer to what you wanted.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Multiple inheritance
       [not found] <199712011505.JAA11781.cygnus.egcs@duvieux.eecs.tulane.edu>
@ 1997-12-01 18:46 ` Jason Merrill
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 1997-12-01 18:46 UTC (permalink / raw)
  To: Joshua S. Allen, egcs

>>>>> Joshua S Allen <allen@eecs.tulane.edu> writes:

> I am making modifications to the gnu g++ compiler to include automatic
> conflict resolution of multiple inheritance using a linearization
> algorithm.

What do you mean?
 
> (1) I need to construct a table of direct parents of a class.  Whereas this
> could easily be done at parse time, it is presenting me with problems and I
> was wondering if you could direct me to how this information could be
> extracted from the parse tree.

TYPE_BINFO_BASETYPES (type) is a vector of the direct bases.
 
> (2) I am adding the algorithm within the function lookup_fnfields
> (cp/search.c) where
>         errstr = "request for method %D' is ambiguous"; 
 
>     Once I locate the method in a class, what is the format of the return
> value I give to the calling function.  I need a way of telling the calling
> function the particular method within a specific class to use.
 
lookup_fnfields returns a list where the PURPOSE is the basetype where the
functions are found, and the VALUE is the list of functions.

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Multiple inheritance
@ 1997-12-01  7:05 Joshua S. Allen
  0 siblings, 0 replies; 5+ messages in thread
From: Joshua S. Allen @ 1997-12-01  7:05 UTC (permalink / raw)
  To: egcs

I am making modifications to the gnu g++
compiler to include automatic conflict resolution of multiple inheritance
using a linearization algorithm.  I have the algorithm implemented but I
need to interface it with the compiler.  I am hoping that someone could 
explain a few things to me.
 
(1) I need to construct a table of direct parents of a class.  Whereas this
could easily be done at parse time, it is presenting me with problems and I
was wondering if you could direct me to how this information could be
extracted from the parse tree.
 
(2) I am adding the algorithm within the function lookup_fnfields
(cp/search.c) where
        errstr = "request for method %D' is ambiguous"; 
 
    Once I locate the method in a class, what is the format of the return
value I give to the calling function.  I need a way of telling the calling
function the particular method within a specific class to use.
 
 
If anyone could answer these questions I would really appreciate it.  Thanks
for your time.

--Joshua Allen
allen@eecs.tulane.edu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1997-12-10 16:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-02 22:54 Multiple inheritance Mike Stump
1997-12-10  7:31 ` Joshua S. Allen
  -- strict thread matches above, loose matches on Subject: below --
1997-12-10 16:00 Mike Stump
     [not found] <199712011505.JAA11781.cygnus.egcs@duvieux.eecs.tulane.edu>
1997-12-01 18:46 ` Jason Merrill
1997-12-01  7:05 Joshua S. Allen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).