-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve iterator/indexing types and Implicit_Dereference aspect support
This change improves the support of both the user-defined iterator/indexing types and the Implicit_Dereference aspect. All related aspect are now searched with `p_get_aspect` instead of `p_get_aspect_spec_expr` in order to correctly take previous parts and parent types into account. Also, implicit dereference type matching is now done directly in `matching_type` instead of `matching_assign_type` because implicit dereference can also occur outside direct assignements as in the prefix of a `CallExpr` for example.
- Loading branch information
Showing
4 changed files
with
329 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
procedure Test is | ||
|
||
package P is | ||
type T is tagged null record; | ||
type T_Element is access all T; | ||
|
||
function Key (This : in T) return Integer is (1); | ||
|
||
type T_Constant_Reference (Element : access constant T_Element) is private | ||
with Implicit_Dereference => Element; | ||
|
||
type MyArr (Capacity : Integer) is tagged private | ||
with Constant_Indexing => Query, | ||
Iterator_Element => T_Element; | ||
|
||
type Elems_Access is access all MyArr; | ||
|
||
function Query(This: MyArr; Index : Integer) return T_Constant_Reference; | ||
private | ||
type T_Constant_Reference | ||
(Element : access constant T_Element) is null record; | ||
type MyArr (Capacity : Integer) is tagged null record; | ||
end P; | ||
|
||
package body P is | ||
function Query | ||
(This: MyArr; Index : Integer) return T_Constant_Reference is | ||
(T_Constant_Reference'(Element => null)); | ||
|
||
procedure X (Elems : Elems_Access) is | ||
T : T_Element := Elems.all (1); | ||
pragma Test_Statement; | ||
C : T_Constant_Reference := Elems.all (1); | ||
pragma Test_Statement; | ||
I : Integer := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
begin | ||
I := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
end X; | ||
end P; | ||
|
||
use P; | ||
|
||
procedure Y (Elems : Elems_Access) is | ||
T : T_Element := Elems.all (1); | ||
pragma Test_Statement; | ||
C : T_Constant_Reference := Elems.all (1); | ||
pragma Test_Statement; | ||
I : Integer := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
begin | ||
I := Elems.all (1).all.Key; | ||
pragma Test_Statement; | ||
end Y; | ||
|
||
begin | ||
null; | ||
end Test; |
Oops, something went wrong.