[fpc-devel] Optimization for TObject.InheritsFrom (and the 'is' operator)

Jonas Maebe jonas.maebe at elis.ugent.be
Sat Jul 21 15:37:11 CEST 2007

On 21 Jul 2007, at 15:06, Jonas Maebe wrote:

>>  InheritsFrom := (AClass <= Self) and (Self < PClass(pointer 
>> (AClass) + vmtNextSibling)^);
>> (In this implementation vmtNextSibling should not be nil for those  
>> classes that have no NextSibling in the hierarchy, but have a  
>> value larger than all vmts. An alternative is to have an  
>> vmtLastChild, which is always properly defined; it points to the  
>> last one of: itself, its children, its grandchildren, etc.)
> I don't think this can work, since a class hierarchy is a tree and  
> not a list. So in case of
> TObject
> |
> +-- TA
> |
> +-- TB
> How would you linearise that in memory? As TObject - TA - TB ?
> In that case, TB inherirtsFrom TA would be (afaics)
> (TA <= TB) and (TB < TA+(inf))

Sorry, no, this would be (TA <= TB) and (TB < TB), so it would be ok.  
Still, I don't think laying out classes in memory like this is easy  
to do without complex linker scripts (which are not supported on all  


More information about the fpc-devel mailing list