[Mono-dev] interface vtables and virtual calls

robnik at nc.rr.com robnik at nc.rr.com
Wed Jan 16 15:01:48 EST 2008


Hi all,

I'm trying to learn about the under-the-hood workings of virtual  
calls to interfaces methods in languages like C# and Java.  I'm  
asking on this mailing list because I figure someone here must have  
implemented this.

I understand virtual methods when you have a single inheritance class  
hierarchy.  Each object contains an extra field that effectively  
points to an array of the function pointers (the "vtable").  So the C  
equivalent of a virtual call would be something like:

     obj->type[method_offset](obj, arg, ...)

Can someone give me a similar C equivalent of a virtual call to an  
interface method?  Is there a generally accepted "best" solution,  or  
do different VMs have different techniques?

thanks,
Rob






More information about the Mono-devel-list mailing list