[Dwarf-discuss] Proposal: Add support for "property" with getter/setter (based on Pascal properties)

Cary Coutant ccoutant@gmail.com
Thu May 9 17:48:49 GMT 2024


I've posted this as issue 240507.1
<https://dwarfstd.org/issues/240507.1.html>.

-cary

On Wed, May 8, 2024 at 3:47 AM Martin via Dwarf-discuss <
dwarf-discuss@lists.dwarfstd.org> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20240509/e62d7cda/attachment.htm>


More information about the Dwarf-discuss mailing list