Re: [fpc-pascal] Case statement for class introspection

2022-01-17 Thread Sven Barth via fpc-pascal

Am 17.01.2022 um 13:58 schrieb Ryan Joseph via fpc-pascal:



On Jan 17, 2022, at 5:09 PM, Sven Barth  wrote:

The VMT writer already does that, cause the VMT pointer is required for each 
constructor call.


The pointer to the VMT table is just PVmt(self) right? If I make a program and 
do:

writeln(PtrUInt(TObject.ClassType));

the address changes every time the program reloads (as expected) so how do you 
use a constant memory address which would map to this?


The values will have the same differences between each other upon each 
start so ideally this would work anyway, but if one also throws dynamic 
packages into the mix things would get messed up. So better stay with 
the if-clauses.


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Case statement for class introspection

2022-01-17 Thread Ryan Joseph via fpc-pascal


> On Jan 17, 2022, at 5:09 PM, Sven Barth  wrote:
> 
> The VMT writer already does that, cause the VMT pointer is required for each 
> constructor call. 
> 

The pointer to the VMT table is just PVmt(self) right? If I make a program and 
do:

writeln(PtrUInt(TObject.ClassType));

the address changes every time the program reloads (as expected) so how do you 
use a constant memory address which would map to this?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Case statement for class introspection

2022-01-17 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal  schrieb am
Mo., 17. Jan. 2022, 08:53:

>
>
> > On Jan 17, 2022, at 1:55 PM, Sven Barth 
> wrote:
> >
> > Question then is how you get the VMT address as a constant at compile
> time.
> >
> > I'll need to get back to you with that.
> >
>
> I didn't test yet but I think what you're saying is that VMT writer would
> need to have generated this address in advance of doing tcasenode.pass_1,
> which could presumably get this address in some integer form. Is that
> basically what you're thinking is possible?
>

The VMT writer already does that, cause the VMT pointer is required for
each constructor call.


> If it's a big problem I guess the question is if the if blocks are really
> that bad compared to alternative ( I would need to basically redo the
> entire thing also).
>

That is of course the question.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal