Commit 0f7baaea authored by Bechir Zalila's avatar Bechir Zalila
Browse files

* (ocarina-me_aadl-aadl_instances-nodes.idl): Added some necessary

	nodes for instantiating annexes.

	* (ocarina-instances-annexes.ad*): New Package for instantiating
	annexes.

	* (ocarina-instances-components.adb): Apply annex instanciation to
        all components having annex subclauses.

        * (ocarina-me_aadl-aadl_instances-debug.adb): Avoid infinite loops
        when dumping instance tree.

	* (ocarina-me_aadl-aadl_tree-nodes.idl): Minor reformatting
parent 26f70a87
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . I N S T A N C E S . A N N E X E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. Ocarina is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with Ocarina; see file COPYING. --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- Ocarina is maintained by the Ocarina team --
-- (ocarina-users@listes.enst.fr) --
-- --
------------------------------------------------------------------------------
with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.ME_AADL.AADL_Tree.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
package body Ocarina.Instances.Annexes is
use Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.ME_AADL.AADL_Tree.Nutils;
package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
package ATU renames Ocarina.ME_AADL.AADL_Tree.Nutils;
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AIU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package AIE renames Ocarina.ME_AADL.AADL_Instances.Entities;
-------------------
-- Apply_Annexes --
-------------------
function Apply_Annexes
(Instance_Root : Node_Id;
Instance : Node_Id;
Annex_List : List_Id;
Override_Mode : Boolean)
return Boolean
is
pragma Assert (Kind (Instance_Root) = K_Architecture_Instance);
pragma Assert (Present (Instance));
Annex_Subclause : Node_Id;
Success : Boolean := True;
begin
if not ATU.Is_Empty (Annex_List) then
Annex_Subclause := ATN.First_Node (Annex_List);
while Present (Annex_Subclause) loop
Success := Add_Annex_Instance
(Instance_Root, Instance, Annex_Subclause, Override_Mode)
and then Success;
Annex_Subclause := ATN.Next_Node (Annex_Subclause);
end loop;
end if;
return Success;
end Apply_Annexes;
------------------------
-- Add_Annex_Instance --
------------------------
function Add_Annex_Instance
(Instance_Root : Node_Id;
Entity_Instance : Node_Id;
Annex_Subclause : Node_Id;
Override_Mode : Boolean)
return Boolean
is
pragma Assert
(Kind (Entity_Instance) = K_Component_Instance
or else Kind (Entity_Instance) = K_Feature_Group_Spec_Instance);
pragma Unreferenced (Instance_Root);
Annex_Instance : Node_Id;
begin
Annex_Instance := AIU.New_Node
(K_Annex_Instance, ATN.Loc (Annex_Subclause));
AIN.Set_Identifier (Annex_Instance,
AIE.Duplicate_Identifier
(ATN.Identifier (Annex_Subclause)));
AIN.Set_Corresponding_Annex (Annex_Instance,
ATN.Corresponding_Annex (Annex_Subclause));
if Override_Mode then
-- Append the node to the BEGINNING of the annex list of the
-- instance so that annexes that are declared for inheriting
-- components override the annexes that are declared for the
-- parent component.
AIU.Push_Node_To_List
(Annex_Instance,
AIN.Annexes (Entity_Instance));
else
AIU.Append_Node_To_List
(Annex_Instance,
AIN.Annexes (Entity_Instance));
end if;
return True;
end Add_Annex_Instance;
end Ocarina.Instances.Annexes;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . I N S T A N C E S . A N N E X E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. Ocarina is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with Ocarina; see file COPYING. --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- Ocarina is maintained by the Ocarina team --
-- (ocarina-users@listes.enst.fr) --
-- --
------------------------------------------------------------------------------
package Ocarina.Instances.Annexes is
function Apply_Annexes
(Instance_Root : Node_Id;
Instance : Node_Id;
Annex_List : List_Id;
Override_Mode : Boolean)
return Boolean;
-- Add annexes to the entity instance. If 'Override_Mode' is set
-- any previous homonym annex under the same mode will be
-- overriden. Otherwise, the old value will be kept.
function Add_Annex_Instance
(Instance_Root : Node_Id;
Entity_Instance : Node_Id;
Annex_Subclause : Node_Id;
Override_Mode : Boolean)
return Boolean;
-- Same as above but for one single annex
end Ocarina.Instances.Annexes;
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -48,6 +48,7 @@ with Ocarina.Instances.Components.Connections;
with Ocarina.Instances.Components.Modes;
with Ocarina.Instances.Namespaces;
with Ocarina.Instances.Properties;
with Ocarina.Instances.Annexes;
with Ocarina.Instances.Messages;
package body Ocarina.Instances.Components is
......@@ -68,6 +69,7 @@ package body Ocarina.Instances.Components is
use Ocarina.Instances.Components.Modes;
use Ocarina.Instances.Namespaces;
use Ocarina.Instances.Properties;
use Ocarina.Instances.Annexes;
use Ocarina.Instances.Messages;
package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
......@@ -162,7 +164,9 @@ package body Ocarina.Instances.Components is
-- (b) we instantiate recursively the parents of the component
-- (c) we apply the component properties properties
-- (c) we apply the component properties
-- (d) we apply the component annexes
-- We chose this order because applying properties may require
-- visibility on features that are inherited form other
......@@ -187,6 +191,8 @@ package body Ocarina.Instances.Components is
-- (h) we apply the properties
-- (i) we apply the annexes
-- We chose this order because instantiating connections, modes
-- and applying properties may require visibility on subclauses
-- that are inherited form other parents.
......@@ -589,6 +595,19 @@ package body Ocarina.Instances.Components is
Override_Mode => True)
and then Success;
-- Apply the annexes to the new instance
AIN.Set_Annexes (New_Instance,
New_List (K_List_Id, No_Location));
Success :=
Apply_Annexes
(Instance_Root,
New_Instance,
ATN.Annexes (Component),
Override_Mode => True)
and then Success;
if not Success then
Display_Instantiation_Error (Component);
elsif No (Default_Instance (Component)) then
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -189,6 +189,7 @@ package body Ocarina.ME_AADL.AADL_Instances.Debug is
if A /= "Corresponding_Entity"
and then A /= "Corresponding_Declaration"
and then A /= "Corresponding_Annex"
and then A /= "Container_Component"
and then A /= "Item"
and then A /= "Extra_Item"
......
......@@ -4,7 +4,7 @@
** **
** OCARINA.ME_AADL.AADL_INSTANCES.NODES **
** **
** Copyright (C) 2004-2008, GET-Telecom Paris. **
** Copyright (C) 2004-2009, GET-Telecom Paris, 2010-2016 ESA & ISAE. **
** **
** Ocarina is free software; you can redistribute it and/or modify **
** it under terms of the GNU General Public License as published by the **
......@@ -67,8 +67,8 @@ module Ocarina::ME_AADL::AADL_Instances::Nodes {
};
interface AADL_Entity : Node_Id {
Node_Id Next_Entity;// Used by the Ocarina core to build
// list of elements
Node_Id Next_Entity;
// Used by the Ocarina core to build list of elements
};
interface Named_AADL_Entity : AADL_Entity {
......@@ -309,4 +309,12 @@ module Ocarina::ME_AADL::AADL_Instances::Nodes {
Node_Id In_Modes;
};
interface Annex_Instance : Named_AADL_Entity {
Node_Id In_Modes;
Node_Id Corresponding_Annex;
// Root of the tree of the parsed annex. This node is not an AADL
// tree node.
};
};
......@@ -4,7 +4,7 @@
** **
** O C A R I N A . N O D E S **
** **
** Copyright (C) 2004-2009, GET-Telecom Paris. **
** Copyright (C) 2004-2009, GET-Telecom Paris, 2010-2016 ESA & ISAE. **
** **
** Ocarina is free software; you can redistribute it and/or modify **
** it under terms of the GNU General Public License as published by the **
......@@ -1624,6 +1624,7 @@ module Ocarina::ME_AADL::AADL_Tree::Nodes {
Node_Id In_Modes;
Node_Id Corresponding_Annex;
// Root of the parsed annex tree. This note is not an AADL tree node
};
interface Annex_Library : Named_AADL_Entity {
......
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