Skip to content

Commit

Permalink
Merge branch 'topic/981' into 'master'
Browse files Browse the repository at this point in the history
Refactor visibility checking for types

See merge request eng/libadalang/libadalang!1427
  • Loading branch information
Roldak committed Oct 19, 2023
2 parents 7408474 + 05d5cd6 commit 197e850
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 144 deletions.
254 changes: 112 additions & 142 deletions ada/ast.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions testsuite/tests/name_resolution/for_of_incomplete/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Expr: <AttributeRef test.adb:6:35-6:44>
type: None
expected type: None
Expr: <Id "Foo" test.adb:6:35-6:38>
references: <DefiningName "Foo" test.adb:3:12-3:15>
type: <IncompleteTaggedTypeDecl ["Foo"] test.adb:3:7-3:26>
references: <DefiningName "Foo" test.adb:8:12-8:15>
type: <ConcreteTypeDecl ["Foo"] test.adb:8:7-8:38>
expected type: None
Expr: <Id "Class" test.adb:6:39-6:44>
references: None
Expand Down
8 changes: 8 additions & 0 deletions testsuite/tests/properties/most_visible_part_2/pkg_g.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package body Pkg_G is
type U is null record;

procedure Foo (X : T) is
begin
null;
end Foo;
end Pkg_G;
13 changes: 13 additions & 0 deletions testsuite/tests/properties/most_visible_part_2/pkg_g.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
generic
package Pkg_G is
type T is private;

X : constant T;

procedure Foo (X : T);
private
type T is null record;
type U;

X : constant T := (others => <>);
end Pkg_G;
12 changes: 12 additions & 0 deletions testsuite/tests/properties/most_visible_part_2/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
with Pkg_G;

procedure Test is
package My_Pkg is new Pkg_G;
begin
My_Pkg.Foo (My_Pkg.X);
--% fun = node.f_call.f_name.p_referenced_decl()
--% typ_t = fun.findall(lal.Identifier)[2].p_referenced_decl()
--% complete_t = typ_t.p_most_visible_part(fun.p_body_part())
--% typ_u = complete_t.next_sibling
--% complete_u = typ_u.p_most_visible_part(fun.p_body_part())
end Test;
17 changes: 17 additions & 0 deletions testsuite/tests/properties/most_visible_part_2/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Working on node <CallStmt test.adb:6:4-6:26>
============================================

Set 'fun' to 'node.f_call.f_name.p_referenced_decl()'
Result: <| SubpDecl ["Foo"] pkg_g.ads:7:4-7:26 [test.adb:4:4] |>

Set 'typ_t' to 'fun.findall(lal.Identifier)[2].p_referenced_decl()'
Result: <| ConcreteTypeDecl ["T"] pkg_g.ads:3:4-3:22 [test.adb:4:4] |>

Set 'complete_t' to 'typ_t.p_most_visible_part(fun.p_body_part())'
Result: <| ConcreteTypeDecl ["T"] pkg_g.ads:9:4-9:26 [test.adb:4:4] |>

Set 'typ_u' to 'complete_t.next_sibling'
Result: <| IncompleteTypeDecl ["U"] pkg_g.ads:10:4-10:11 [test.adb:4:4] |>

Set 'complete_u' to 'typ_u.p_most_visible_part(fun.p_body_part())'
Result: <| ConcreteTypeDecl ["U"] pkg_g.adb:2:4-2:26 [test.adb:4:4] |>
2 changes: 2 additions & 0 deletions testsuite/tests/properties/most_visible_part_2/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: inline-playground
input_sources: [test.adb]
12 changes: 12 additions & 0 deletions testsuite/tests/properties/type_next_part/test.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
procedure Test is
package Pkg is
type T is tagged private;

type T_Access is access all T'Class;
--% typ = node.f_type_def.f_subtype_indication.p_designated_type_decl
--% typ.p_next_part
private
type T is tagged null record;
end Pkg;
begin
end Test;
8 changes: 8 additions & 0 deletions testsuite/tests/properties/type_next_part/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Working on node <ConcreteTypeDecl ["T_Access"] test.adb:5:7-5:43>
=================================================================

Set 'typ' to 'node.f_type_def.f_subtype_indication.p_designated_type_decl'
Result: <ClasswideTypeDecl ["T"] test.adb:3:7-3:32>

Eval 'typ.p_next_part'
Result: <ClasswideTypeDecl ["T"] test.adb:9:7-9:36>
2 changes: 2 additions & 0 deletions testsuite/tests/properties/type_next_part/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
driver: inline-playground
input_sources: [test.adb]

0 comments on commit 197e850

Please sign in to comment.