Related articles |
---|
Interface implementation ramiro@cs.cornell.edu (Ramiro Rodriguez) (2004-10-12) |
Re: Interface implementation andi@a4.complang.tuwien.ac.at (2004-10-17) |
Re: Interface implementation tzvetanmi@yahoo.com (2004-10-17) |
Re: Interface implementation vbdis@aol.com (2004-10-17) |
Re: Interface implementation eeide@cs.utah.edu (Eric Eide) (2004-10-17) |
Re: Interface implementation cfc@shell01.TheWorld.com (Chris F Clark) (2004-10-17) |
From: | vbdis@aol.com (VBDis) |
Newsgroups: | comp.compilers |
Date: | 17 Oct 2004 16:08:58 -0400 |
Organization: | AOL Bertelsmann Online GmbH & Co. KG http://www.germany.aol.com |
References: | 04-10-102 |
Keywords: | OOP |
Posted-Date: | 17 Oct 2004 16:08:58 EDT |
, Ramiro Rodriguez <ramiro@cs.cornell.edu> schreibt:
>However for things like interfaces this seems
>to be not as easy if one allows multiple interface implementation. I
>could do a table which is referenced by the name of the function but I
>am wondering if there is some more efficient way of doing this.
You can have one VMT for every interface of an object. What remains to
implement is a link from the interface (object) reference to the
appropriate VMT.
I know of one implementation that puts the VMT pointers into every
instance of an object, and the interface reference to the object goes
exactly to that VMT pointer field. I.e. when an object reference is
converted into an interface reference, the offset of the interface VMT
pointer field is added to the object reference. When a method of that
interface is invoked, the function address is taken from the VMT, and
then the reference is decremented to point to the base address of the
object. The offset to subtract can be stored together with the VMT,
e.g. at a fixed negative offset. Now the called method receives the
address of the real object, regardless of whether it was called as a
class method or as an interface method.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.