Skip to content

Commit

Permalink
* Correct implementation of naming rules for rename declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
yoogx committed Feb 18, 2013
1 parent 9836f4d commit 2c7a952
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 49 deletions.
32 changes: 22 additions & 10 deletions src/core/model/ocarina-analyzer-aadl-names.adb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
------------------------------------------------------------------------------

with Ocarina.Analyzer.Messages;
with Ocarina.Analyzer.AADL.Finder;
with Ocarina.Analyzer.AADL.Naming_Rules;

with Ocarina.ME_AADL.AADL_Tree.Nodes;
Expand All @@ -40,6 +41,7 @@ with Ocarina.ME_AADL.AADL_Tree.Entities;

package body Ocarina.Analyzer.AADL.Names is

use Ocarina.Analyzer.AADL.Finder;
use Ocarina.Analyzer.Messages;
use Ocarina.Analyzer.AADL.Naming_Rules;

Expand Down Expand Up @@ -89,8 +91,7 @@ package body Ocarina.Analyzer.AADL.Names is
(Name_Visibility_Node : Node_Id;
Package_Node : Node_Id)
return Boolean;
-- Check if package or property in with sublcause
-- exists in global scope
-- Check if package or property in with sublcause exists in global scope

------------------------------
-- Check_Import_Declaration --
Expand Down Expand Up @@ -127,12 +128,12 @@ package body Ocarina.Analyzer.AADL.Names is
if Kind (Import_Node) = K_Package_Name then
Identifier := Build_Package_Identifier (Import_Node);

In_Node := Node_Explicitly_In_Scope (Identifier,
Current_Scope);
else
In_Node := Node_Explicitly_In_Scope (Import_Node,
Current_Scope);
In_Node :=
Node_Explicitly_In_Scope (Identifier, Current_Scope);

else
In_Node :=
Node_Explicitly_In_Scope (Import_Node, Current_Scope);
end if;

if In_Node = No_Node then
Expand Down Expand Up @@ -185,10 +186,21 @@ package body Ocarina.Analyzer.AADL.Names is
Loc => Loc (List_Node));

else
In_Node := Node_Explicitly_In_Scope
(Alias, Current_Scope);
In_Node := Node_In_Scope (Alias, Current_Scope);

if No (In_Node)
and then Present (Corresponding_Entity (Alias))
then
In_Node := Find_Component_Classifier
(Root => 1,
Package_Identifier => Namespace_Identifier
(Corresponding_Entity (Alias)),
Component_Identifier =>
Ocarina.ME_AADL.AADL_Tree.Nodes.Identifier
(Corresponding_Entity (Alias)));
end if;

if In_Node = No_Node then
if No (In_Node) then
Success := False;
Display_Analyzer_Error (Alias, "is not visible");
end if;
Expand Down
88 changes: 49 additions & 39 deletions src/core/model/ocarina-analyzer-aadl-naming_rules.adb
Original file line number Diff line number Diff line change
Expand Up @@ -440,43 +440,55 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is
(Declarations (Entity));

while Present (List_Node) loop
if Kind (List_Node)
= K_Name_Visibility_Declaration
then
List_Node_2 :=
Ocarina.ME_AADL.AADL_Tree.Nodes.First_Node
(List_Items (List_Node));
while Present (List_Node_2) loop
if Kind (List_Node_2) = K_Alias_Declaration then
if Is_All (List_Node_2) then
List_Node_3 :=
Ocarina.ME_AADL.AADL_Tree.Nodes.
First_Node
(Declarations
(Parent (Parent (List_Node_2))));
while Present (List_Node_3) loop
if Name (Identifier (List_Node_3))
= Name (Build_Package_Identifier
(Package_Name
(List_Node_2)))
then
Test_Node := Node_In_Scope
(Name_Of_Identifier,
Entity_Scope
(List_Node_3));

if Present (Test_Node) then
First_Node := Test_Node;
case Kind (List_Node) is
when K_Component_Type
| K_Component_Implementation =>

if Name (Identifier (List_Node))
= Name_Of_Identifier
then
First_Node := List_Node;
end if;

when K_Name_Visibility_Declaration =>
List_Node_2 :=
Ocarina.ME_AADL.AADL_Tree.Nodes.First_Node
(List_Items (List_Node));

while Present (List_Node_2) loop
if Kind (List_Node_2) =
K_Alias_Declaration then
if Is_All (List_Node_2) then
List_Node_3 :=
Ocarina.ME_AADL.AADL_Tree.Nodes.
First_Node
(Declarations
(Parent (Parent (List_Node_2))));
while Present (List_Node_3) loop
if Name (Identifier (List_Node_3))
= Name (Build_Package_Identifier
(Package_Name
(List_Node_2)))
then
Test_Node := Node_In_Scope
(Name_Of_Identifier,
Entity_Scope
(List_Node_3));

if Present (Test_Node) then
First_Node := Test_Node;
end if;
end if;
end if;
List_Node_3
:= Next_Node (List_Node_3);
end loop;
List_Node_3
:= Next_Node (List_Node_3);
end loop;
end if;
end if;
end if;
List_Node_2 := Next_Node (List_Node_2);
end loop;
end if;
List_Node_2 := Next_Node (List_Node_2);
end loop;

when others => null;
end case;
List_Node := Next_Node (List_Node);
end loop;
end;
Expand Down Expand Up @@ -826,8 +838,7 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is
-- Internal_Node_In_Scope --
----------------------------

function Internal_Node_In_Scope (N : Name_Id; S : Node_Id) return Node_Id
is
function Internal_Node_In_Scope (N : Name_Id; S : Node_Id) return Node_Id is
I_Name : constant Name_Id := Internal_Scope_Name (N, S);
begin
return Node_Id (Get_Name_Table_Info (I_Name));
Expand Down Expand Up @@ -857,8 +868,7 @@ package body Ocarina.Analyzer.AADL.Naming_Rules is
-- Internal_Scope_Name --
-------------------------

function Internal_Scope_Name (N : Name_Id; S : Node_Id) return Name_Id
is
function Internal_Scope_Name (N : Name_Id; S : Node_Id) return Name_Id is
begin
Get_Name_String (N);
Add_Str_To_Name_Buffer ("%in_scope%");
Expand Down

0 comments on commit 2c7a952

Please sign in to comment.