Constructor and Destructor calls
Constructor and destructors have special invisible parameters which are passed to them. These invisible parameters are used internally to instantiate the objects and classes.
objects
The actual invisible declaration of an object constructor is as follows:
constructor init(_vmt : pointer; _self : pointer ...);
Where _vmt is a pointer to the virtual method table for this object. This value is nil if a constructor is called within the object instance (such as calling an inherited constructor).
_self is either nil if the instance must be allocated dynamically (object is declared as pointer), or the address of the object instance if the object is declared as a normal object (stored in the data area) or if the object instance has already been allocated.
The allocated instance (if allocated via new) (self) is returned in the accumulator.
The declaration of a destructor is as follows:
destructor done(_vmt : pointer; _self : pointer ...);
Where _vmt is a pointer to the virtual method table for this object. This value is nil if a destructor is called within the object instance (such as calling an inherited constructor), or if the object instance is a variable and not a pointer.
_self is the address of the object instance.
classes
The actual invisible declaration of a class constructor is as follows:
constructor init(_vmt: pointer; flag : longint; ..);
_vmt is either nil if called from the instance or if calling an inherited constructor, otherwise it points to the address of the virtual method table.
Where flag is zero if the constructor is called within the object instance or with an instance qualifier otherwise this flag is set to one.
The allocated instance (self) is returned in the accumulator.
The declaration of a destructor is as follows:
destructor done(_self : pointer; flag : longint ...);
_self is the address of the object instance.
flag is zero if the destructor is called within the object instance or with an instance qualifier otherwise this flag is set to one.
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
