Commit 6b93db20 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Recursively parse nested functions (support TASTE v2)

parent e9a02817
......@@ -1477,6 +1477,7 @@ procedure BuildSupport is
end Initialize;
IV_Root : Node_Id;
AST : Complete_Interface_View;
begin
Banner;
......@@ -1493,12 +1494,10 @@ begin
Get_String_Name ("interfaceview.others");
IV_Root := Root_System (Instantiate_Model (Root => Interface_Root));
declare
AST : Complete_Interface_View := AADL_to_Ada_IV (IV_Root);
pragma Unreferenced (AST);
begin
null;
end;
AST := AADL_to_Ada_IV (IV_Root);
for each of AST.Flat_Functions loop
Put_Line ("From New AST: " & To_String (Each.Name));
end loop;
Process_Interface_View (IV_Root);
-- (Root_System (Instantiate_Model (Root => Interface_Root)));
......
......@@ -13,6 +13,7 @@ with Ocarina.Instances.Queries;
-- with Ocarina.ME_AADL.AADL_Tree.Nodes;
-- 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
......@@ -25,6 +26,8 @@ package body Buildsupport_Utils is
-- use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Nutils;
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;
......@@ -383,18 +386,45 @@ package body Buildsupport_Utils is
end Get_ASN1_Basic_Type;
function AADL_to_Ada_IV (System : Node_Id) return Complete_Interface_View is
Funcs : Functions.Vector;
Routes : Channels.Vector;
use type Functions.Vector;
use type Channels.Vector;
Funcs : Functions.Vector := Functions.Empty_Vector;
Routes : Channels.Vector; -- := Channels.Empty_Vector;
Current_Function : Node_Id;
CI : Node_Id;
pragma Unreferenced (CI);
-- Recursive parsing of a system made of nested functions (TASTE v2)
function Rec_Function (Func : Node_Id) return Functions.Vector is
Inner : Node_Id;
Result : Functions.Vector := Functions.Empty_Vector;
CI : constant Node_Id := Corresponding_Instance (Func);
AST_Function : Taste_Terminal_Function;
begin
if Get_Category_Of_Component (CI) /= CC_System then
null;
elsif Present (AIN.Subcomponents (CI)) then
Inner := AIN.First_Node (AIN.Subcomponents (CI));
while Present (Inner) loop
Result := Result & Rec_Function (Inner);
Inner := AIN.Next_Node (Inner);
end loop;
end if;
if Get_Category_Of_Component (CI) = CC_System and then
(No (AIN.Subcomponents (CI)) or Result = Functions.Empty_Vector)
then
Put_Line ("Terminal: " & AIN_Case (Func));
AST_Function.Name := US (AIN_Case (Func));
Result := Result & AST_Function;
end if;
return Result;
end Rec_Function;
begin
Exit_On_Error (No (System), "Missing or erroneous interface view");
Current_Function := AIN.First_Node (AIN.Subcomponents (System));
while Present (Current_Function) loop
CI := Corresponding_Instance (Current_Function);
Put_Line ("Function " & AIN_Case (Current_Function));
-- Put_Line ("Function (Top level) " & AIN_Case (Current_Function));
-- CI := Corresponding_Instance (Current_Function);
Funcs := Funcs & Rec_Function (Current_Function);
Current_Function := AIN.Next_Node (Current_Function);
end loop;
......
......@@ -168,7 +168,7 @@ package Buildsupport_Utils is
package Channels is new Indefinite_Vectors (Natural, Connection);
type Complete_Interface_View is limited
type Complete_Interface_View is
record
Flat_Functions : Functions.Vector;
Connections : Channels.Vector;
......
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