[fpc-pascal] Case statement for class introspection
Ryan Joseph
genericptr at gmail.com
Mon Jan 17 02:15:27 CET 2022
> On Jan 16, 2022, at 11:15 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
>
> The class type already is a unique "ID" for each class type when doing an equal comparison. You can essentially take the address of the VMT as the constant values that the loaded value is compared against.
Does that look something like this then? and if so, this is better then doing the if-statement block, like string case statements?
case PtrUInt(o.ClassType.ClassInfo) of
PtrUInt(TObject.ClassInfo): writeln('TObject');
end;
Question then is how you get the VMT address as a constant at compile time.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list