Am 04.08.2018 um 01:17 schrieb Ryan Joseph:
On Aug 2, 2018, at 2:41 PM, Ryan Joseph <r...@thealchemistguild.com> wrote:
So the way FreeInstance is called by adding it within a destructor isn’t
exactly what I needed because it requires a destructor actually be present in
the class.
The next thing I’d like to try is adding a procedure dynamically using nodes.
I’ve seen how if statements are made doing things like:
Once again I think this is not useful so it can be disregarded.
I wanted to learn how I could call Free on class fields (like management
operators call Finalize on records) but it’s more complicated than I thought
(again). Records with management operators hook into the RTTI system it looks
like, but how does a record with management operators get added to the classes
RTTI information? I mean in TObject.CleanupInstance there is a vInitTable which
gets set if the record has management operators in them but I can’t find where.
The whole VMT including vInitTable is generated by the compiler in
ncgvmt. Take this example:
=== code begin ===
program thelloworld;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TTestRec = record
f: LongInt;
class operator Initialize(var aRec: TTestRec);
end;
TTest = class
fRec: TTestRec;
end;
class operator TTestRec.Initialize(var aRec: TTestRec);
begin
end;
var
t: TTest;
begin
t := TTest.Create;
end.
=== code end ===
If you compile this with -al you'll see the following symbols in the
assembly code:
VMT_$P$THELLOWORLD_$$_TTEST: The VMT of the TTest class (look at
rtl/inc/objpash.inc for the type TVmt to see how a VMT is structured)
INIT_$P$THELLOWORLD_$$_TTEST: The init table of the TTest class
(referenced from the VMT)
INIT_$P$THELLOWORLD_$$_TTESTREC: The init table of the TTestRec record
(referenced from TTest's init table using an indirect reference)
Regards,
Sven
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel