[fpc-devel] Differences between 'tsym' and 'tdef'

Paul Ishenin ip at kmiac.ru
Fri May 18 09:13:08 CEST 2012


18.05.2012 14:23, Joost van der Sluis wrote:

> This information can be bound to a properties but also whole classes at
> least. (I'll have to test for methods and public fields) So no, not only
> properties may have this information.

If methods may have this information then it is not possible to put it 
to tsym because paticular method is a tprocdef and several tprocdefs may 
have 1 tprocsym (overloaded methods). Therefore I would put this info to 
tstoreddef. But what to do with a property? Create a special def for it?

> And, to answer your second question, properties in a descendant class do
> *not* inherited the properties of the ancestor. I found that pretty
> strange, but that's how it is implemented in Delphi.

There may be 3 cases. Does it work in any:

case 1: property descendant

TAncestor = class
   [attributes]
   property SomeProp: TSomeType read GetSomeProp;
end;

TDescendant = class(TAncestor)
   property SomeProp write SetSomeProp; // <- this is property descendant
end;

case 2: new property hides old

TDescendant = class(TAncestor)
   property SomeProp: TSomeType read GetSomeProp; // <- this property 
hides old SomeProp
end;

case 3: new class uses property as is

TDescendant = class(TAncestor)
end;

> So in this case create a special symbol and symtable for it?

Looking at 
http://docwiki.embarcadero.com/RADStudio/en/Annotating_Types_and_Type_Members 
I see that attribute is a class + a list of arguments for that class 
contructor. As this is a class - compiler already creates a symbol and a 
definition for it and all it members. So you need to store a link to 
this class (or to class contructor) + a list of arguments to pass there. 
So it is not a special symbol, just a reference to it. If you need an 
example of how to store/restore reference to a class then look at how it 
is done with tobjectdef.childof or tobjectdef.extendeddef.

Best regards,
Paul Ishenin




More information about the fpc-devel mailing list