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 ...@@ -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;
use Ocarina.ME_AADL.AADL_Tree.Entities.Properties; 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 function Link_Declarations_Of_Package
(Root : Node_Id; (Root : Node_Id;
Node : Node_Id) return Boolean; Node : Node_Id) return Boolean;
...@@ -439,13 +436,22 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -439,13 +436,22 @@ package body Ocarina.Analyzer.AADL.Links is
Success : Boolean := True; Success : Boolean := True;
Subclause_Success : Boolean := True; Subclause_Success : Boolean := True;
begin begin
-- 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, -- subcomponents and features were correctly linked. Indeed,
-- those subclauses may access elements pointed by -- those subclauses may access elements pointed by
-- subcomponents or features. -- subcomponents or features.
if not Is_Empty if not Is_Empty
(Ocarina.ME_AADL.AADL_Tree.Nodes.Refines_Type (Node)) (Ocarina.ME_AADL.AADL_Tree.Nodes.Refines_Type (Node))
then then
List_Node := List_Node :=
First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Refines_Type (Node)); First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Refines_Type (Node));
...@@ -504,16 +510,16 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -504,16 +510,16 @@ package body Ocarina.Analyzer.AADL.Links is
First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Connections (Node)); First_Node (Ocarina.ME_AADL.AADL_Tree.Nodes.Connections (Node));
while Present (List_Node) loop while Present (List_Node) loop
Global_Root := Root;
Success := Success :=
Link_Connection (Node, List_Node) Link_Connection (Node, List_Node)
and then Link_In_Modes_Statement (Node, In_Modes (List_Node)) and then Link_In_Modes_Statement (Node, In_Modes (List_Node))
and then Success; and then Success;
List_Node := Next_Node (List_Node); List_Node := Next_Node (List_Node);
Global_Root := No_Node;
end loop; end loop;
end if; end if;
Subclause_Success := Success;
if Subclause_Success if Subclause_Success
and then not Is_Empty (Ocarina.ME_AADL.AADL_Tree.Nodes.Flows (Node)) and then not Is_Empty (Ocarina.ME_AADL.AADL_Tree.Nodes.Flows (Node))
then then
...@@ -1078,6 +1084,7 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -1078,6 +1084,7 @@ package body Ocarina.Analyzer.AADL.Links is
DLTWN (Node, Component_Ref); DLTWN (Node, Component_Ref);
Success := False; Success := False;
end if; end if;
else else
Pointed_Node := No_Node; Pointed_Node := No_Node;
No_Ref_Given := True; No_Ref_Given := True;
...@@ -1103,6 +1110,7 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -1103,6 +1110,7 @@ package body Ocarina.Analyzer.AADL.Links is
then then
DLTWN (Node, Pointed_Node); DLTWN (Node, Pointed_Node);
Success := False; Success := False;
else else
Set_Referenced_Entity (Component_Ref, Pointed_Node); Set_Referenced_Entity (Component_Ref, Pointed_Node);
Success := True; Success := True;
...@@ -3476,6 +3484,25 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -3476,6 +3484,25 @@ package body Ocarina.Analyzer.AADL.Links is
Package_Identifier => Pack_Identifier, Package_Identifier => Pack_Identifier,
Component_Identifier => Component_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
then
Pack_Identifier := Identifier
(Namespace (Container_Component (Node)));
Pointed_Node :=
Find_Component_Classifier
(Root => Root,
Package_Identifier => Pack_Identifier,
Component_Identifier => Component_Identifier);
end if;
if No (Pointed_Node) then if No (Pointed_Node) then
DLTWN (Node, Component_Ref, Non_Existent => True); DLTWN (Node, Component_Ref, Non_Existent => True);
Success := False; Success := False;
...@@ -3494,7 +3521,7 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -3494,7 +3521,7 @@ package body Ocarina.Analyzer.AADL.Links is
elsif not elsif not
((Kind (Pointed_Node) = K_Component_Type ((Kind (Pointed_Node) = K_Component_Type
or else Kind (Pointed_Node) = K_Component_Implementation)) or else Kind (Pointed_Node) = K_Component_Implementation))
then then
DAE DAE
(Node1 => Node, (Node1 => Node,
...@@ -3514,8 +3541,8 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -3514,8 +3541,8 @@ package body Ocarina.Analyzer.AADL.Links is
elsif Category (Pointed_Node) /= Category (Node) elsif Category (Pointed_Node) /= Category (Node)
and then and then
Category (Pointed_Node) /= Category (Pointed_Node) /=
Component_Category'Pos (CC_Abstract) Component_Category'Pos (CC_Abstract)
then then
DAE DAE
(Node1 => Node, (Node1 => Node,
...@@ -3729,38 +3756,18 @@ package body Ocarina.Analyzer.AADL.Links is ...@@ -3729,38 +3756,18 @@ package body Ocarina.Analyzer.AADL.Links is
Corresponding_Node); Corresponding_Node);
if Present (Corresponding_Node) then if Present (Corresponding_Node) then
if Kind (Corresponding_Node) = K_Subcomponent then if Kind (Corresponding_Node) = K_Subcomponent and then
if Present Present
(Get_Referenced_Entity (Entity_Ref (Corresponding_Node))) (Get_Referenced_Entity (Entity_Ref (Corresponding_Node)))
then then
Corresponding_Node := Corresponding_Node :=
Find_Feature Find_Feature
(Component => (Component =>
Get_Referenced_Entity Get_Referenced_Entity
(Entity_Ref (Corresponding_Node)), (Entity_Ref (Corresponding_Node)),
Feature_Identifier => Feature_Identifier =>
Item Item
(Next_Node (First_Node (Path (Connection_End))))); (Next_Node (First_Node (Path (Connection_End)))));
else
-- 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 :=
Find_Feature
(Component =>
Find_Component_Classifier
(Root => Global_Root,
Package_Identifier =>
Namespace_Identifier
(Entity_Ref (Corresponding_Node)),
Component_Identifier =>
Identifier (Entity_Ref (Corresponding_Node))),
Feature_Identifier =>
Item
(Next_Node (First_Node (Path (Connection_End)))));
end if;
elsif Kind (Corresponding_Node) = K_Subprogram_Call elsif Kind (Corresponding_Node) = K_Subprogram_Call
and then Present 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