[fpc-pascal] virtual class var?

Andrew Haines AndrewD207 at aol.com
Tue Aug 7 05:24:50 CEST 2012


On 08/06/12 23:02, Paul Ishenin wrote:

> 
> Class variable is stored the same way as a regular variable and has the
> only difference is that it can be accessible with the class name prefix.
> The thing you need requires different implementation - something like
> storing a virtual class variable in VMT. There is no implementation for
> that.
> 
> Best regards,
> Paul Ishenin

What is the current implementation?

I would guess that class vars are stored in the vmt already...

Please correct me if I've got this wrong.

Current classes have a structure containing partially the following:

TClassInstance = record
vmt: Pointer;
{Space for parent class variables are stored here followed by variables
declared for this object}
variable1: SomeType;
variable2: SomeType;
etc.
end;


TClassVMT = record
  parent_class_vmt: Pointer;
  virtual_procs: array[0..n] of pointer;
  class_var_1: Sometype;
  class_var_2: Sometype;
  etc...
end;

Is this right?

Thanks,

Andrew



More information about the fpc-pascal mailing list