Re: [Dwarf-discuss] Proposal: Add support for "property" with getter/setter (based on Pascal properties)
On 08/05/2024 06:34, Cary Coutant via Dwarf-discuss wrote: It will support the following new attributes * DW_AT_Default_Property flag Specify this is a default property * DW_TAG_Property_Setter * DW_TAG_Property_Reader * DW_TAG_Property_Default * DW_TAG_Property_Stored ### `DW_TAG_Property_[Setter|Getter|...]` Should these all be DW_AT_xxx? No, they should have been a separate list "It will have the following new tags" As the next big header "### `DW_TAG_Property_[Setter|Getter|...]`" shows, they each contain several attributes. Maybe, it would be clearer, if they were moved into the next header, but then it needs to be clarified that they are children of the DW_Tag_Property. -- Dwarf-discuss mailing list Dwarf-discuss@lists.dwarfstd.org https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
Re: [Dwarf-discuss] Proposal: Add support for "property" with getter/setter (based on Pascal properties)
Here are 2 examples of what it would look like ## Property with different visibility ``` type TFoo = class private MyMember: integer; function MyFunc: integer; protected // "read public" is currently from oxygene, but may be added to FreePascal property MyProp: integer read public MyFunc write MyMember; end; TBar = clall(TFoo) public property MyProp; // elevate to public end; ``` ``` DW_TAG_Structure_type DW_AT_Name : "TFoo" L1: DW_TAG_Member DW_AT_Name: "MyMember" DW_AT_Type: <...> DW_AT_Member_location : <...> L2: DW_TAG_subprogram DW_AT_Name: "MyFunc" DW_AT_Type: <...> DW_TAG_Property DW_AT_Name : "MyProp" DW_AT_Type : <...> DW_AT_Accessibility: DW_ACCESS_protected DW_AT_Default_Property : TRUE DW_TAG_Property_Getter DW_AT_Property_Forward : reference to L2 DW_AT_Accessibility: DW_ACCESS_public DW_TAG_Property_Setter DW_AT_Property_Forward : reference to L1 DW_TAG_Structure_type DW_AT_Name : "TBar" DW_TAG_Inheritance <...> DW_TAG_Property DW_AT_Name : "MyProp" DW_AT_Accessibility: DW_ACCESS_public ``` ## Property with access to nested field ``` type TFoo = class OtherData: DWORD; FNested: record MyMember: integer; end; property MyProp: integer read FNested.MyMember; end; ``` ``` L1: DW_TAG_Structure_type L2: DW_TAG_Member DW_AT_Name: "MyMember" DW_AT_Type: <...> DW_AT_Member_location : <...>! inside FNested DW_TAG_Structure_type DW_AT_Name : "TFoo" DW_TAG_Member DW_AT_Name : "OtherData" DW_TAG_Member DW_AT_Name : "FNested" DW_AT_Type: reference to L1 DW_AT_Member_location : DW_OP_plus_uconst 4 ! where 4 == offset of MyMember in the instance data DW_TAG_Property DW_AT_Name : "MyProp" DW_AT_Type : <...> DW_TAG_Property_Getter DW_AT_Property_Forward : reference to L2 DW_AT_Property_Object : DW_OP_push_object_address ! maybe should be on stack by default DW_OP_plus_uconst 4! where 4 == offset of MyMember in the instance data ! There could be several levels of nesting, so that expression could be more complex ``` In the example the property does not have a reference to FNested itself. All it needs is the object_address of FNested, so it can calculate the location of the referenced field MyMember (using the member_location). -- Dwarf-discuss mailing list Dwarf-discuss@lists.dwarfstd.org https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
Re: [Dwarf-discuss] Proposal: Add support for "property" with getter/setter (based on Pascal properties)
Small correction property MyProp: integer read public MyFunc write MyMember; Should be property MyProp: integer read public MyFunc write MyMember; default; As I added the DW_AT_Default_Property flag in the example. In FreePascal, this would currently only be valid for properties with array-indexes, but may be extended in future. For the example it just shows where the attribute would go. On 08/05/2024 12:35, Martin via Dwarf-discuss wrote: Here are 2 examples of what it would look like ## Property with different visibility ``` type TFoo = class private MyMember: integer; function MyFunc: integer; protected // "read public" is currently from oxygene, but may be added to FreePascal property MyProp: integer read public MyFunc write MyMember; end; TBar = clall(TFoo) public property MyProp; // elevate to public end; ``` ``` DW_TAG_Structure_type DW_AT_Name : "TFoo" L1: DW_TAG_Member DW_AT_Name : "MyMember" DW_AT_Type : <...> DW_AT_Member_location : <...> L2: DW_TAG_subprogram DW_AT_Name : "MyFunc" DW_AT_Type : <...> DW_TAG_Property DW_AT_Name : "MyProp" DW_AT_Type : <...> DW_AT_Accessibility : DW_ACCESS_protected DW_AT_Default_Property : TRUE DW_TAG_Property_Getter DW_AT_Property_Forward : reference to L2 DW_AT_Accessibility : DW_ACCESS_public DW_TAG_Property_Setter DW_AT_Property_Forward : reference to L1 DW_TAG_Structure_type DW_AT_Name : "TBar" DW_TAG_Inheritance <...> DW_TAG_Property DW_AT_Name : "MyProp" DW_AT_Accessibility : DW_ACCESS_public ``` ## Property with access to nested field ``` type TFoo = class OtherData: DWORD; FNested: record MyMember: integer; end; property MyProp: integer read FNested.MyMember; end; ``` ``` L1: DW_TAG_Structure_type L2: DW_TAG_Member DW_AT_Name : "MyMember" DW_AT_Type : <...> DW_AT_Member_location : <...> ! inside FNested DW_TAG_Structure_type DW_AT_Name : "TFoo" DW_TAG_Member DW_AT_Name : "OtherData" DW_TAG_Member DW_AT_Name : "FNested" DW_AT_Type : reference to L1 DW_AT_Member_location : DW_OP_plus_uconst 4 ! where 4 == offset of MyMember in the instance data DW_TAG_Property DW_AT_Name : "MyProp" DW_AT_Type : <...> DW_TAG_Property_Getter DW_AT_Property_Forward : reference to L2 DW_AT_Property_Object : DW_OP_push_object_address ! maybe should be on stack by default DW_OP_plus_uconst 4 ! where 4 == offset of MyMember in the instance data ! There could be several levels of nesting, so that expression could be more complex ``` In the example the property does not have a reference to FNested itself. All it needs is the object_address of FNested, so it can calculate the location of the referenced field MyMember (using the member_location). -- Dwarf-discuss mailing list Dwarf-discuss@lists.dwarfstd.org https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss