Commit 586ee6d8 authored by yoogx's avatar yoogx
Browse files

* (ocarina-instances-components-features.ad?,

          ocarina-instances-components.adb) : When instantiating
          feature groups, set the Parent_Component field of all the
          group feature as the containing component instance of the
          feature group.

          Patch contributed by Bechir Zalila @ ENIS
parent e5edbb12
...@@ -61,6 +61,7 @@ package body Ocarina.Instances.Components.Features is ...@@ -61,6 +61,7 @@ package body Ocarina.Instances.Components.Features is
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes; package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package ATE renames Ocarina.ME_AADL.AADL_Tree.Entities; package ATE renames Ocarina.ME_AADL.AADL_Tree.Entities;
package ATNU renames Ocarina.ME_AADL.AADL_Tree.Nutils; package ATNU renames Ocarina.ME_AADL.AADL_Tree.Nutils;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
function Instantiate_Corresponding_Entity function Instantiate_Corresponding_Entity
(Instance_Root : Node_Id; (Instance_Root : Node_Id;
...@@ -69,11 +70,12 @@ package body Ocarina.Instances.Components.Features is ...@@ -69,11 +70,12 @@ package body Ocarina.Instances.Components.Features is
return Node_Id; return Node_Id;
function Instantiate_Port_Group_Type function Instantiate_Port_Group_Type
(Instance_Root : Node_Id; (Instance_Root : Node_Id;
Port_Group : Node_Id; Port_Group : Node_Id;
Feature_List : List_Id; Feature_List : List_Id;
Container : Node_Id; Container : Node_Id;
Inverse : Boolean := False) Parent_Instance : Node_Id;
Inverse : Boolean := False)
return Boolean; return Boolean;
-- Recursively instantiate a port group type, with extensions, features -- Recursively instantiate a port group type, with extensions, features
-- and inverses. Return True if everything was OK, else False -- and inverses. Return True if everything was OK, else False
...@@ -83,9 +85,10 @@ package body Ocarina.Instances.Components.Features is ...@@ -83,9 +85,10 @@ package body Ocarina.Instances.Components.Features is
------------------------- -------------------------
function Instantiate_Feature function Instantiate_Feature
(Instance_Root : Node_Id; (Instance_Root : Node_Id;
Feature : Node_Id; Feature : Node_Id;
Inverse : Boolean := False) Parent_Instance : Node_Id;
Inverse : Boolean := False)
return Node_Id return Node_Id
is is
pragma Assert (Kind (Instance_Root) = K_Architecture_Instance); pragma Assert (Kind (Instance_Root) = K_Architecture_Instance);
...@@ -103,7 +106,7 @@ package body Ocarina.Instances.Components.Features is ...@@ -103,7 +106,7 @@ package body Ocarina.Instances.Components.Features is
begin begin
case ATN.Kind (Feature) is case ATN.Kind (Feature) is
when K_Port_Spec => when K_Port_Spec =>
New_Instance := Ocarina.ME_AADL.AADL_Instances.Nutils.New_Node New_Instance := AINU.New_Node
(K_Port_Spec_Instance, ATN.Loc (Feature)); (K_Port_Spec_Instance, ATN.Loc (Feature));
AIN.Set_Is_In (New_Instance, ATN.Is_In (Feature)); AIN.Set_Is_In (New_Instance, ATN.Is_In (Feature));
AIN.Set_Is_Out (New_Instance, ATN.Is_Out (Feature)); AIN.Set_Is_Out (New_Instance, ATN.Is_Out (Feature));
...@@ -132,11 +135,11 @@ package body Ocarina.Instances.Components.Features is ...@@ -132,11 +135,11 @@ package body Ocarina.Instances.Components.Features is
end if; end if;
when K_Feature_Group_Spec => when K_Feature_Group_Spec =>
if Entity_Ref (Feature) /= No_Node if Present (Entity_Ref (Feature)) and then
and then ATE.Get_Referenced_Entity Present (ATE.Get_Referenced_Entity
(Entity_Ref (Feature)) /= No_Node (Entity_Ref (Feature)))
then then
New_Instance := New_Node (K_Feature_Group_Spec_Instance, New_Instance := AINU.New_Node (K_Feature_Group_Spec_Instance,
ATN.Loc (Feature)); ATN.Loc (Feature));
AIN.Set_Features (New_Instance, AIN.Set_Features (New_Instance,
New_List (K_List_Id, ATN.Loc (Feature))); New_List (K_List_Id, ATN.Loc (Feature)));
...@@ -146,19 +149,20 @@ package body Ocarina.Instances.Components.Features is ...@@ -146,19 +149,20 @@ package body Ocarina.Instances.Components.Features is
AIN.Set_Sources AIN.Set_Sources
(New_Instance, New_List (K_List_Id, No_Location)); (New_Instance, New_List (K_List_Id, No_Location));
AIN.Set_Destinations (New_Instance, AIN.Set_Destinations (New_Instance,
New_List (K_List_Id, No_Location)); New_List (K_List_Id, No_Location));
Success := Instantiate_Port_Group_Type Success := Instantiate_Port_Group_Type
(Instance_Root, (Instance_Root,
Port_Group, Port_Group,
Ocarina.ME_AADL.AADL_Instances.Nodes.Features (New_Instance), AIN.Features (New_Instance),
Container, Container,
Parent_Instance,
Inverse); Inverse);
elsif Inverse_Of (Feature) /= No_Node elsif Inverse_Of (Feature) /= No_Node
and then ATE.Get_Referenced_Entity and then ATE.Get_Referenced_Entity
(Inverse_Of (Feature)) /= No_Node (Inverse_Of (Feature)) /= No_Node
then then
New_Instance := New_Node (K_Feature_Group_Spec_Instance, New_Instance := AINU.New_Node (K_Feature_Group_Spec_Instance,
ATN.Loc (Feature)); ATN.Loc (Feature));
AIN.Set_Features (New_Instance, AIN.Set_Features (New_Instance,
New_List (K_List_Id, ATN.Loc (Feature))); New_List (K_List_Id, ATN.Loc (Feature)));
...@@ -175,6 +179,7 @@ package body Ocarina.Instances.Components.Features is ...@@ -175,6 +179,7 @@ package body Ocarina.Instances.Components.Features is
Port_Group, Port_Group,
Ocarina.ME_AADL.AADL_Instances.Nodes.Features (New_Instance), Ocarina.ME_AADL.AADL_Instances.Nodes.Features (New_Instance),
Container, Container,
Parent_Instance,
Inverse); Inverse);
else else
Display_No_Entity_Ref (Feature); Display_No_Entity_Ref (Feature);
...@@ -368,21 +373,22 @@ package body Ocarina.Instances.Components.Features is ...@@ -368,21 +373,22 @@ package body Ocarina.Instances.Components.Features is
--------------------------------- ---------------------------------
function Instantiate_Port_Group_Type function Instantiate_Port_Group_Type
(Instance_Root : Node_Id; (Instance_Root : Node_Id;
Port_Group : Node_Id; Port_Group : Node_Id;
Feature_List : List_Id; Feature_List : List_Id;
Container : Node_Id; Container : Node_Id;
Inverse : Boolean := False) Parent_Instance : Node_Id;
Inverse : Boolean := False)
return Boolean return Boolean
is is
pragma Assert (Feature_List /= No_List); pragma Assert (Feature_List /= No_List);
pragma Assert (AIN.Kind (Instance_Root) = K_Architecture_Instance); pragma Assert (AIN.Kind (Instance_Root) = K_Architecture_Instance);
pragma Assert (ATN.Kind (Port_Group) = K_Feature_Group_Type); pragma Assert (ATN.Kind (Port_Group) = K_Feature_Group_Type);
Success : Boolean := True; Success : Boolean := True;
List_Node : Node_Id := No_Node; List_Node : Node_Id := No_Node;
Instantiateable_Node : Node_Id := No_Node; Instantiateable_Node : Node_Id := No_Node;
New_Subinstance : Node_Id := No_Node; New_Subinstance : Node_Id := No_Node;
begin begin
-- Annotate the parent port group with the container node -- Annotate the parent port group with the container node
...@@ -402,6 +408,7 @@ package body Ocarina.Instances.Components.Features is ...@@ -402,6 +408,7 @@ package body Ocarina.Instances.Components.Features is
(ATN.Parent (Port_Group)), (ATN.Parent (Port_Group)),
Feature_List, Feature_List,
Container, Container,
Parent_Instance,
Inverse); Inverse);
end if; end if;
...@@ -421,10 +428,17 @@ package body Ocarina.Instances.Components.Features is ...@@ -421,10 +428,17 @@ package body Ocarina.Instances.Components.Features is
New_Subinstance := Instantiate_Feature New_Subinstance := Instantiate_Feature
(Instance_Root, (Instance_Root,
Instantiateable_Node, Instantiateable_Node,
Parent_Instance,
Inverse); Inverse);
if Present (New_Subinstance) then if Present (New_Subinstance) then
Append_Node_To_List (New_Subinstance, Feature_List); Append_Node_To_List (New_Subinstance, Feature_List);
-- Mark the container component instance as a
-- parent component instance of the feature group
-- features as well.
AIN.Set_Parent_Component (New_Subinstance, Parent_Instance);
else else
Success := False; Success := False;
end if; end if;
...@@ -444,6 +458,7 @@ package body Ocarina.Instances.Components.Features is ...@@ -444,6 +458,7 @@ package body Ocarina.Instances.Components.Features is
ATE.Get_Referenced_Entity (Inverse_Of (Port_Group)), ATE.Get_Referenced_Entity (Inverse_Of (Port_Group)),
Feature_List, Feature_List,
Container, Container,
Parent_Instance,
not Inverse) not Inverse)
and then Success; and then Success;
end if; end if;
......
...@@ -34,11 +34,13 @@ ...@@ -34,11 +34,13 @@
package Ocarina.Instances.Components.Features is package Ocarina.Instances.Components.Features is
function Instantiate_Feature function Instantiate_Feature
(Instance_Root : Node_Id; (Instance_Root : Node_Id;
Feature : Node_Id; Feature : Node_Id;
Inverse : Boolean := False) Parent_Instance : Node_Id;
Inverse : Boolean := False)
return Node_Id; return Node_Id;
-- Instantiates a feature of a component type an returns the -- Instantiates a feature of a component type an returns the
-- corresponding instance. -- corresponding instance. Parent_Instance is the AADL instance
-- of the component containing the feature.
end Ocarina.Instances.Components.Features; end Ocarina.Instances.Components.Features;
...@@ -327,7 +327,7 @@ package body Ocarina.Instances.Components is ...@@ -327,7 +327,7 @@ package body Ocarina.Instances.Components is
List_Node)) List_Node))
then then
Instance_Node := Instantiate_Feature Instance_Node := Instantiate_Feature
(Instance_Root, List_Node); (Instance_Root, List_Node, New_Instance);
if Present (Instance_Node) then if Present (Instance_Node) then
Success := Apply_Properties Success := Apply_Properties
...@@ -366,7 +366,7 @@ package body Ocarina.Instances.Components is ...@@ -366,7 +366,7 @@ package body Ocarina.Instances.Components is
List_Node)) List_Node))
then then
Instance_Node := Instantiate_Feature Instance_Node := Instantiate_Feature
(Instance_Root, List_Node); (Instance_Root, List_Node, New_Instance);
if Present (Instance_Node) then if Present (Instance_Node) then
Success := Apply_Properties Success := Apply_Properties
......
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