Commit d5d1bf6b authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add prefix to nested function

parent e1c89179
...@@ -2,35 +2,25 @@ ...@@ -2,35 +2,25 @@
-- (c) 2008-2017 European Space Agency - maxime.perrotin@esa.int -- (c) 2008-2017 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file -- LGPL license, see LICENSE file
with Ada.Text_IO; with Ada.Text_IO,
with GNAT.OS_Lib; GNAT.OS_Lib,
Buildsupport_Version,
with Buildsupport_Version; Ocarina.Configuration,
-- with Ocarina.Namet; Ocarina.AADL_Values,
with Ocarina.Configuration; Ocarina.Instances.Queries,
with Ocarina.AADL_Values; Ocarina.ME_AADL.AADL_Instances.Nutils,
with Ocarina.Instances.Queries; Ocarina.ME_AADL.AADL_Instances.Entities,
-- with Ocarina.ME_AADL.AADL_Tree.Nodes; Ada.Characters.Latin_1;
-- with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ada.Characters.Latin_1;
package body Buildsupport_Utils is package body Buildsupport_Utils is
use Ada.Text_IO; use Ada.Text_IO,
use GNAT.OS_Lib; GNAT.OS_Lib,
Ocarina.Instances.Queries,
-- use Ocarina.Namet; Ocarina.ME_AADL.AADL_Instances.Nutils,
use Ocarina.Instances.Queries; Ada.Characters.Latin_1,
-- use Ocarina.ME_AADL.AADL_Instances.Nodes; Ocarina.ME_AADL.AADL_Instances.Entities,
use Ocarina.ME_AADL.AADL_Instances.Nutils; Ocarina.ME_AADL;
use Ada.Characters.Latin_1;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.ME_AADL;
-- package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
-- package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
-- use type ATN.Node_Kind;
------------ ------------
-- Banner -- -- Banner --
...@@ -106,7 +96,6 @@ package body Buildsupport_Utils is ...@@ -106,7 +96,6 @@ package body Buildsupport_Utils is
begin begin
if Error then if Error then
Put_Line (Reason); Put_Line (Reason);
-- Imported_Routines.C_End;
OS_Exit (1); OS_Exit (1);
end if; end if;
end Exit_On_Error; end Exit_On_Error;
...@@ -385,6 +374,10 @@ package body Buildsupport_Utils is ...@@ -385,6 +374,10 @@ package body Buildsupport_Utils is
return ASN1_Unknown; return ASN1_Unknown;
end Get_ASN1_Basic_Type; end Get_ASN1_Basic_Type;
---------------------------
-- AST Builder Functions --
---------------------------
function AADL_to_Ada_IV (System : Node_Id) return Complete_Interface_View is function AADL_to_Ada_IV (System : Node_Id) return Complete_Interface_View is
use type Functions.Vector; use type Functions.Vector;
use type Channels.Vector; use type Channels.Vector;
...@@ -392,28 +385,49 @@ package body Buildsupport_Utils is ...@@ -392,28 +385,49 @@ package body Buildsupport_Utils is
Routes : Channels.Vector; -- := Channels.Empty_Vector; Routes : Channels.Vector; -- := Channels.Empty_Vector;
Current_Function : Node_Id; Current_Function : Node_Id;
-- Parse the content of a single function :
-- * Name
-- * Language
-- * Zip File
-- * Context Parameters
-- * User Properties (from TASTE_IV_Properties.aadl)
-- * Timers
-- * Provided and Required Interfaces
function Parse_Function (Name : String;
Inst : Node_Id) return Taste_Terminal_Function
is
Result : Taste_Terminal_Function;
pragma Unreferenced (Inst);
begin
Result.Name := US (Name);
return Result;
end Parse_Function;
-- Recursive parsing of a system made of nested functions (TASTE v2) -- Recursive parsing of a system made of nested functions (TASTE v2)
function Rec_Function (Func : Node_Id) return Functions.Vector is function Rec_Function (Prefix : String := "";
Func : Node_Id) return Functions.Vector is
Inner : Node_Id; Inner : Node_Id;
Result : Functions.Vector := Functions.Empty_Vector; Result : Functions.Vector := Functions.Empty_Vector;
CI : constant Node_Id := Corresponding_Instance (Func); CI : constant Node_Id := Corresponding_Instance (Func);
AST_Function : Taste_Terminal_Function; Name : constant String := Prefix &
(if Prefix'Length > 0 then "_" else "") & AIN_Case (Func);
begin begin
if Get_Category_Of_Component (CI) /= CC_System then if Get_Category_Of_Component (CI) /= CC_System then
null; null;
elsif Present (AIN.Subcomponents (CI)) then elsif Present (AIN.Subcomponents (CI)) then
Inner := AIN.First_Node (AIN.Subcomponents (CI)); Inner := AIN.First_Node (AIN.Subcomponents (CI));
while Present (Inner) loop while Present (Inner) loop
Result := Result & Rec_Function (Inner); Result := Result & Rec_Function (Prefix => Name,
Inner := AIN.Next_Node (Inner); Func => Inner);
Inner := AIN.Next_Node (Inner);
end loop; end loop;
end if; end if;
if Get_Category_Of_Component (CI) = CC_System and then if Get_Category_Of_Component (CI) = CC_System and then
(No (AIN.Subcomponents (CI)) or Result = Functions.Empty_Vector) (No (AIN.Subcomponents (CI)) or Result = Functions.Empty_Vector)
then then
-- Here, parse the full function Result := Result & Parse_Function (Name => Name,
AST_Function.Name := US (AIN_Case (Func)); Inst => CI);
Result := Result & AST_Function;
end if; end if;
return Result; return Result;
end Rec_Function; end Rec_Function;
...@@ -422,9 +436,7 @@ package body Buildsupport_Utils is ...@@ -422,9 +436,7 @@ package body Buildsupport_Utils is
Current_Function := AIN.First_Node (AIN.Subcomponents (System)); Current_Function := AIN.First_Node (AIN.Subcomponents (System));
while Present (Current_Function) loop while Present (Current_Function) loop
-- Put_Line ("Function (Top level) " & AIN_Case (Current_Function)); Funcs := Funcs & Rec_Function (Func => Current_Function);
-- CI := Corresponding_Instance (Current_Function);
Funcs := Funcs & Rec_Function (Current_Function);
Current_Function := AIN.Next_Node (Current_Function); Current_Function := AIN.Next_Node (Current_Function);
end loop; end loop;
......
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