Re: Interface implementation (VBDis)
17 Oct 2004 16:08:58 -0400

          From comp.compilers

Related articles
Interface implementation (Ramiro Rodriguez) (2004-10-12)
Re: Interface implementation (2004-10-17)
Re: Interface implementation (2004-10-17)
Re: Interface implementation (2004-10-17)
Re: Interface implementation (Eric Eide) (2004-10-17)
Re: Interface implementation (Chris F Clark) (2004-10-17)
| List of all articles for this month |

From: (VBDis)
Newsgroups: comp.compilers
Date: 17 Oct 2004 16:08:58 -0400
Organization: AOL Bertelsmann Online GmbH & Co. KG
References: 04-10-102
Keywords: OOP
Posted-Date: 17 Oct 2004 16:08:58 EDT

, Ramiro Rodriguez <> 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.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.