[fpc-pascal] Obtain Class hierarchy (in MacPas mode)

Michael Van Canneyt michael at freepascal.org
Tue Sep 21 14:49:47 CEST 2010

On Tue, 21 Sep 2010, Adriaan van Os wrote:

> Michael Van Canneyt wrote:
>> On Tue, 21 Sep 2010, Florian Klaempfl wrote:
>>> Am 21.09.2010 13:42, schrieb Adriaan van Os:
>>>> Michael Van Canneyt wrote:
>>>>> On Tue, 21 Sep 2010, Adriaan van Os wrote:
>>>>>> I am looking for a way to obtain the class hierarchy of a program in
>>>>>> MacPas mode (where there are no published properties). TObject has
>>>>>> ClassParent, so a list of Class types would be sufficient, I think. I
>>>>>> can't find however a routine in the RTL to obtain such a list.
>>>>> There is no such routine in the RTL, to my knowledge.
>>>> Can I add it ? I guess a low-level pointer to a list of VMT's would be
>>>> sufficient to implement it ?
>>> Problem is: it breaks smartlinking.
> Yes, I understand that. I looked at the assembly generated for a simple test 
> program and there are separate al_globals entries for each vmt and separate 
> al_rtti entries for the vmt rtti. I asssume the very reason for the separate 
> entries is smart linking.
> Hm, I guess I can look at the data section of the executable but it would be 
> highly dependant of the executable binary format.
> Is it possible to produce a separate data section/entry that refers to all 
> al_globals and/or all al_rtti entries without breaking smart-linking ?

Maybe when doing whole-program optimization as implemented by Jonas.
I guess the WPO could be extended to generate the tree you want.

But under 'normal' compilation, I don't think it is possible to do as you
ask without breaking the smartlinking stuff; the tree would of necessity
contain all declared classes of all loaded units.


More information about the fpc-pascal mailing list