[fpc-devel] Newbie question: how does the compiler know the class type of an object ( the Is operator)

Andrew Haines andrewd207 at aol.com
Sat Aug 23 03:42:27 CEST 2014


On 08/22/14 13:53, Dennis Poon wrote:
>
>
> Howard Page-Clark wrote:
>> program Project1;
>>
>> uses classes;
>> begin
>>   WriteLn('InstanceSize of TObject=',TObject.InstanceSize);
>>   ReadLn;
>> end.
>
> I tried and it says the instancesize is 4 (on win 32 bit).
> My question actually was how does the "as" and "is" get the class type
> of an object.
> So, does that imply the 4 byte is used to store a pointer to the class
> type and Virtual Method table?
>

http://www.freepascal.org/docs-html/prog/progsu168.html#x212-2250008.2.13

Table 8.6 is the class instance memory layout and 8.7 is the class vmt
which has info on it's name and ancestor classes.

Regards,

Andrew Haines



More information about the fpc-devel mailing list