Commit 8da066fd authored by yoogx's avatar yoogx

* Rework link resolution to take into account parent that must

          be resolved first

          For openaadl/ocarina#108
parent 37c20790
......@@ -54,9 +54,6 @@ package body Ocarina.Analyzer.AADL.Links is
use Ocarina.ME_AADL.AADL_Tree.Entities;
use Ocarina.ME_AADL.AADL_Tree.Entities.Properties;
Global_Root : Node_Id := No_Node;
-- Store the root of the current AADL_Specification
function Link_Declarations_Of_Package
(Root : Node_Id;
Node : Node_Id) return Boolean;
......@@ -439,7 +436,16 @@ package body Ocarina.Analyzer.AADL.Links is
Success : Boolean := True;
Subclause_Success : Boolean := True;
-- modes, connections and flows are linked only if
-- First, we resolve link for the parent node, as we may extend
-- its features, or refine its subcomponents.
if Present (Parent (Node)) then
Success := Link_Component_Implementation_Subclauses
(Root, Get_Referenced_Entity
(Corresponding_Entity (Identifier (Parent (Node)))));
end if;
-- Modes, connections and flows are linked only if
-- subcomponents and features were correctly linked. Indeed,
-- those subclauses may access elements pointed by
-- subcomponents or features.
......@@ -504,16 +510,16 @@ package body Ocarina.Analyzer.AADL.Links is
First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Connections (Node));
while Present (List_Node) loop
Global_Root := Root;
Success :=
Link_Connection (Node, List_Node)
and then Link_In_Modes_Statement (Node, In_Modes (List_Node))
and then Success;
List_Node := Next_Node (List_Node);
Global_Root := No_Node;
end loop;
end if;
Subclause_Success := Success;
if Subclause_Success
and then not Is_Empty (Ocarina.ME_AADL.AADL_Tree.Nodes.Flows (Node))
......@@ -1078,6 +1084,7 @@ package body Ocarina.Analyzer.AADL.Links is
DLTWN (Node, Component_Ref);
Success := False;
end if;
Pointed_Node := No_Node;
No_Ref_Given := True;
......@@ -1103,6 +1110,7 @@ package body Ocarina.Analyzer.AADL.Links is
DLTWN (Node, Pointed_Node);
Success := False;
Set_Referenced_Entity (Component_Ref, Pointed_Node);
Success := True;
......@@ -3476,6 +3484,25 @@ package body Ocarina.Analyzer.AADL.Links is
Package_Identifier => Pack_Identifier,
Component_Identifier => Component_Identifier);
-- If no package name is given, we try again in the current
-- package forcing explictly the name of the package.
if No (Pointed_Node)
and then No (Pack_Identifier)
and then Present (Namespace (Container_Component (Node)))
and then Kind (Namespace (Container_Component (Node)))
/= K_AADL_Specification
Pack_Identifier := Identifier
(Namespace (Container_Component (Node)));
Pointed_Node :=
(Root => Root,
Package_Identifier => Pack_Identifier,
Component_Identifier => Component_Identifier);
end if;
if No (Pointed_Node) then
DLTWN (Node, Component_Ref, Non_Existent => True);
Success := False;
......@@ -3729,8 +3756,8 @@ package body Ocarina.Analyzer.AADL.Links is
if Present (Corresponding_Node) then
if Kind (Corresponding_Node) = K_Subcomponent then
if Present
if Kind (Corresponding_Node) = K_Subcomponent and then
(Get_Referenced_Entity (Entity_Ref (Corresponding_Node)))
Corresponding_Node :=
......@@ -3741,26 +3768,6 @@ package body Ocarina.Analyzer.AADL.Links is
Feature_Identifier =>
(Next_Node (First_Node (Path (Connection_End)))));
-- If there is no Referenced_Entity, we try to find
-- directly the corresponding component, and then
-- its feature. XXX to be investigated, is this a
-- hole in the instantiation process ?
Corresponding_Node :=
(Component =>
(Root => Global_Root,
Package_Identifier =>
(Entity_Ref (Corresponding_Node)),
Component_Identifier =>
Identifier (Entity_Ref (Corresponding_Node))),
Feature_Identifier =>
(Next_Node (First_Node (Path (Connection_End)))));
end if;
elsif Kind (Corresponding_Node) = K_Subprogram_Call
and then Present
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment