<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-text-flowed" style="font-size: 17px;"
lang="x-unicode">I just got an update on the Dwarf mailing list on
how the property spec my look.
<br>
<br>
I thought I forward it here, in order to get additional feedback.
<br>
<br>
My initial proposal can be found here: <a
class="moz-txt-link-freetext"
href="https://dwarfstd.org/issues/240507.1.html">https://dwarfstd.org/issues/240507.1.html</a>
<br>
My reply is here: <a class="moz-txt-link-freetext"
href="https://lists.dwarfstd.org/pipermail/dwarf-discuss/2024-September/002520.html">https://lists.dwarfstd.org/pipermail/dwarf-discuss/2024-September/002520.html</a>
<br>
<br>
<br>
I commented on
<br>
<br>
- properties forwarding to field in record
<br>
TMyClass = class
<br>
FData: TMyRecord;
<br>
property ValA: integer read FData.a;
<br>
<br>
- DW_AT_Type can be optional / same as getter/setter
<br>
<br>
- clarification on function parameters
<br>
<br>
- oxygene different visibility for read/write
<br>
<br>
<br>
<br>
<br>
-------- Forwarded Message --------
<br>
Subject: Re: [Dwarf-discuss] Proposal: Add support for "property"
with getter/setter (based on Pascal properties)
<br>
Date: Mon, 30 Sep 2024 10:30:30 -0700
<br>
From: Adrian Prantl <a class="moz-txt-link-rfc2396E"
href="mailto:aprantl@apple.com"><aprantl@apple.com></a>
<br>
To: Martin <a class="moz-txt-link-rfc2396E"
href="mailto:lists@mfriebe.de"><lists@mfriebe.de></a>
<br>
CC: <a class="moz-txt-link-abbreviated moz-txt-link-freetext"
href="mailto:dwarf-discuss@lists.dwarfstd.org">dwarf-discuss@lists.dwarfstd.org</a>,
Augusto Noronha <a class="moz-txt-link-rfc2396E"
href="mailto:anoronha@apple.com"><anoronha@apple.com></a>, Michael Buch <a
class="moz-txt-link-rfc2396E" href="mailto:m_buch@apple.com"><m_buch@apple.com></a>
<br>
<br>
Hello Martin,
<br>
<br>
sorry for the long delay for getting back to you. The DWARF
committee was on hiatus over the summer but we're resuming regular
meetings now
and I would like to prepare this issue for discussion now.
<br>
<br>
I have tried to remove everything from the proposal that could be
considered an implementation detail of the Pascal compiler. DWARF
tries to be descriptive, and not prescriptive in its approach so
I'm intentionally leaving freedom for languages to pick the right
representation using the framework specified in the standard.
Below is my suggestion of what the wording could look like.
<br>
<br>
The wording I chose would also work with Objective-C and Swift
properties. To fully represent Objective-C properties we also need
the DW_AT_APPLE_property_attribute extension to encode
language-specific
flags, but I think I'd fine with just keeping this as an extension for now.<br>
<br>
Please let me know if I am missing any important use-cases that
you could not describe in the Pascal compiler following this
specification, if there are any mistakes in it, or if there are
Pascal-specific details we should really move into the DWARF spec
itself instead of leaving them
as an implementation detail to the compiler/debugger.
<br>
<br>
thanks,
<br>
Adrian
<br>
<br>
PS: One thing I left out is DW_AT_Property_Object. It wasn't clear
to me why this wouldn't always be the address of the parent object
of the DW_TAG_property.
<br>
<br>
<br>
# Proposal to implement "properties" (based on Pascal)
<br>
<br>
## Background
<br>
<br>
Pascal has a property construct, that allows a "variable like"
identifier, which can either point to a field (member variable) or
a getter/setter function.
<br>
```
<br>
TFoo = class
<br>
FField: integer;
<br>
function GetProp: integer;
<br>
procedure SetProp(AVal: Integer);
<br>
property MyProp: integer read GetProp write SetProp;
<br>
property MyOtherProp: integer read FField;
<br>
end;
<br>
```
<br>
* Properties can exist in a structure, interface, or on a global level.
<br>
* Properties can be read/write, read only, write only.
<br>
* Properties can have one or more array like indexes (of any type).
<br>
```
<br>
function GetProp(AIdx:word; AIdx2: boolean): integer;
<br>
procedure SetProp(AIdx:word; AIdx2: boolean; AVal: Integer);
<br>
property MyProp[AIdx:word; AIdx2: boolean]: integer read
GetProp write SetProp;
<br>
```
<br>
* Properties can share a method, and provide an index (constant)
to identify which property called the method.
<br>
```
<br>
function GetProp(AIndex: Integer): integer;
<br>
procedure SetProp(AIndex: Integer; AValue: integer);
<br>
property MyProp1: integer index 1 read GetProp write SetProp;
<br>
property MyProp2: integer index 2 read GetProp write SetProp;
<br>
```
<br>
* Properties can have a "default" flag, indicating that the array
[] access can omit the property name. I.e. accessing "Object[n]"
is a shortcut for the default property. (default for non-array
properties is being considered for future addition)
<br>
* Properties can have "default" and "stored" values for streaming
(constant or via function).
<br>
* Properties can be elevated to a higher visibility
(private/public) in inherited classes.
<br>
<br>
There may be partial overlaps with properties in Objective-C and C#
<br>
<br>
<br>
### References
<br>
<br>
FreePascal property doc <a class="moz-txt-link-freetext"
href="https://www.freepascal.org/docs-html/ref/refse27.html">https://www.freepascal.org/docs-html/ref/refse27.html</a>
<br>
Oxygene <a class="moz-txt-link-freetext"
href="https://docs.elementscompiler.com/Oxygene/Members/Properties/">https://docs.elementscompiler.com/Oxygene/Members/Properties/</a>
<br>
APPLE extension for Objective-C <a class="moz-txt-link-freetext"
href="https://github.com/llvm/llvm-project/blob/main/llvm/docs/SourceLevelDebugging.rst#debugging-information-format-1">https://github.com/llvm/llvm-project/blob/main/llvm/docs/SourceLevelDebugging.rst#debugging-information-format-1</a>
<br>
<br>
## Proposed Changes
<br>
<br>
### Table 2.1
<br>
add `DW_TAG_property`.
<br>
<br>
### 5.7.6 add the following normative text
<br>
<br>
#### `DW_TAG_property`
<br>
<br>
Non-normative: Many object-oriented languages like Pascal and
Objective-C have properties, which are member functions that
syntactically behave like data members of an object. Pascal can
also have global properties.
<br>
<br>
A property is represented by a debugging information entry with the
<br>
tag `DW_TAG_property`. At property entry has a `DW_AT_name` string
<br>
attribute whose value is the property name. A property entry has a
<br>
`DW_AT_type` attribute to denote the type of that property.
<br>
<br>
A property may have `DW_AT_Accessibility`, `DW_AT_external`,
`DW_AT_virtuality`, `DW_AT_start_scope`, `DW_AT_decl_column`,
`DW_AT_decl_file` and `DW_AT_decl_line` attributes with the
respective semantics described for these attributes for
`DW_TAG_member` (see chaper 5.7.6).
<br>
<br>
A property may have one or several of `DW_TAG_property_getter`,
`DW_TAG_property_setter`, or `DW_TAG_property_stored` children to
represent the getter and setter (member) functions, or the
Pascal-style `stored` accessor for this property. Each of these
tags have a `DW_AT_specification` attribute to point to a (member)
function declaration. They may also have `DW_TAG_formal_parameter`
children that can have `DW_AT_default_value` attributes to declare
additional default
arguments for when these functions are used as property accessors.
<br>
Some languages can automatically derive accessors for properties
from a field in the object. In such cases the
`DW_AT_specification` attribute of the accessor entry may point to
the `DW_TAG_member` entry of the
field that holds the properties underlying storage.
<br>
<br>
To change the accessibility of a property in an inherited class, a
`DW_TAG_property` can be specified with just a name and accessibility.
<br>
For example if in a subclass property a becomes private it is
sufficient to add the following to the subclass entry:
<br>
```
<br>
DW_TAG_property
<br>
DW_AT_name "a"
<br>
DW_AT_accessibility DW_ACCESS_private
<br>
```
<br>
<br>
<br>
### D Examples
<br>
<br>
Add
<br>
<br>
#### Properties
<br>
<br>
The properties in the Pascal object in this example is represented
by the following DWARF.
<br>
```
<br>
TClass = class
<br>
FField: integer;
<br>
function GetProp: integer;
<br>
procedure SetProp(AVal: Integer);
<br>
property MyProp: integer read GetProp write SetProp;
<br>
property MyOtherProp: integer read FField;
<br>
function GetFoo(x: word; AIndex: Integer): char;
<br>
property Foo[x: word]: char index 1 read GetFoo;
<br>
end;
<br>
<br>
```
<br>
<br>
```
<br>
DW_TAG_class_type
<br>
DW_AT_name "TClass"
<br>
DW_TAG_member
<br>
DW_AT_name "FField"
<br>
DW_AT_type <ref to integer>
<br>
DW_TAG_subprogram
<br>
DW_AT_name "GetProp"
<br>
...
<br>
DW_TAG_subprogram
<br>
DW_AT_name "SetProp"
<br>
...
<br>
DW_TAG_property
<br>
DW_AT_name "MyProp"
<br>
DW_TAG_property_getter
<br>
DW_AT_specification <ref to GetProp>
<br>
DW_TAG_property_setter
<br>
DW_AT_specification <ref to SetProp>
<br>
<br>
DW_TAG_property
<br>
DW_AT_name "MyOtherProp"
<br>
DW_TAG_property_getter
<br>
DW_AT_specification <ref to FField>
<br>
<br>
DW_TAG_subprogram
<br>
DW_AT_name "GetFoo"
<br>
...
<br>
<br>
DW_TAG_property
<br>
DW_AT_name "Foo"
<br>
<br>
DW_TAG_property_getter
<br>
DW_AT_specification <ref to GetFoo>
<br>
DW_TAG_formal_parameter ; _this (no default specified,
details inherited from GetFoo
<br>
DW_TAG_formal_parameter
<br>
DW_AT_default_value <DW_OP_lit 1> ; property index
<br>
DW_TAG_formal_parameter ; x (no default specified)
<br>
```
<br>
<br>
</div>
</body>
</html>