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

Complete the AST with end-to-end connections

parent 376bcad6
......@@ -559,7 +559,72 @@ package body Parser_Utils is
return Result;
end Parse_Interface;
-- Parse the content of a single function :
-- Helper function - return the context name above the current one
-- Needed to resolve the connections to "_env".
function Parent_Context (Context : String) return String is
begin
for Each in Routes_Map.Iterate loop
if Context /= Connection_Maps.Key (Each) then
for Conn of Connection_Maps.Element (Each) loop
if Conn.Caller = Context or Conn.Callee = Context then
return Connection_Maps.Key (Each);
end if;
end loop;
end if;
end loop;
return "ERROR";
end Parent_Context;
-- Recursive function making jumps to find the provided interface
-- connected to a required interface. It returns a Remote Entity,
-- which contains the name of the remote PI and the name of the function
function Rec_Jump (From : String; RI : String;
Going_Out : Boolean := False) return Remote_Entity is
Context : constant String :=
(if Functions.Contains (Key => From)
then To_String (Functions.Element (Key => From).Context)
else (if not Going_Out then From else Parent_Context (From)));
Source : constant String :=
(if Context /= From then From else "_env");
Result : Remote_Entity := (US ("Not found!"), US ("Not found!"));
Connections : Channels.Vector;
Set_Going_Out : Boolean := False;
begin
-- Note: There is a limitation in the interface view when there are
-- nested functions. At the border of a nested function, there can
-- be only ONE function of a given name. This means that it is
-- impossible to have two PIs with the same name, even in different
-- functions, if they are located in the same nested context.
-- * This is NOT RIGHT and should be fixed by Ellidiss *
-- Retrieve the list of connections of the source function context
Connections := Routes_Map.Element (Key => Context);
for Each of Connections loop
if Each.Caller = Source and Each.RI_Name = US (RI) then
-- Found the connection in the current context
-- Now recurse if the callee is a nested block,
-- and return otherwise (if destination is a function)
if Each.Callee = "_env" then
Set_Going_Out := True;
end if;
Result :=
(if Functions.Contains (Key => To_String (Each.Callee))
then (Function_Name => Each.Callee,
Interface_Name => Each.PI_Name)
else Rec_Jump (From => (if not Set_Going_Out
then To_String (Each.Callee)
else Context),
Going_Out => Set_Going_Out,
RI => To_String (Each.PI_Name)));
end if;
exit when Each.Caller = Source and Each.RI_Name = US (RI);
end loop;
return Result;
end Rec_Jump;
-- Parse the following content of a single function :
-- * Name
-- * Language
-- * Zip File
......@@ -685,20 +750,46 @@ package body Parser_Utils is
Routes_Map.Insert (Key => "_Root",
New_Item => Parse_System_Connections (System));
for C in Routes_Map.Iterate loop
Put_Line ("Routes of Function " & Connection_Maps.Key (C));
for Each of Connection_Maps.Element (C) loop
Put_Line (" " & To_String (Each.Caller)
& "." & To_String (Each.RI_Name)
& " -> " & To_String (Each.Callee) & "." &
To_String (Each.PI_Name));
end loop;
end loop;
-- for C in Routes_Map.Iterate loop
-- for Each of Connection_Maps.Element (C) loop
-- Put_Line (" " & To_String (Each.Caller)
-- & "." & To_String (Each.RI_Name)
-- & " -> " & To_String (Each.Callee) & "." &
-- To_String (Each.PI_Name));
-- end loop;
-- end loop;
Put_Line ("Now the functions");
for Each of Functions loop
Put_Line ("Name : " & To_String (Each.Name));
Put_Line ("Context : " & To_String (Each.Context));
Put_Line ("Function: " & To_String (Each.Name));
for RI of Each.Required loop
declare
use Remote_Entities;
Remote : constant Remote_Entity := Rec_Jump
(To_String (Each.Name),
To_String (RI.Name));
V1 : Remote_Entities.Vector := Empty_Vector;
V2 : Remote_Entities.Vector := Empty_Vector;
Corr : Taste_Terminal_Function;
begin
Put (" ... RI " & To_String (RI.Name) & " ---> ");
Put (To_String (Remote.Function_Name) & ".");
Put_Line (To_String (Remote.Interface_Name));
if Remote.Function_Name /= "Not found!" then
V1 := RI.Remote_Interfaces.Value_Or (V1);
V1.Append (Remote);
Corr := Functions.Element (To_String (Remote.Function_Name));
for PI of Corr.Provided loop -- TODO: replace with a Map
if PI.Name = Remote.Interface_Name then
V2 := PI.Remote_Interfaces.Value_Or (V2);
V2.Append (Remote_Entity'(Function_Name => Each.Name,
Interface_Name => RI.Name));
end if;
exit when PI.Name = Remote.Interface_Name;
end loop;
end if;
end;
end loop;
end loop;
return IV_AST : constant Complete_Interface_View :=
......
......@@ -202,7 +202,7 @@ package Parser_Utils is
type Complete_Interface_View is
record
Flat_Functions : Function_Maps.Map; -- Functions.Vector;
Flat_Functions : Function_Maps.Map;
End_To_End_Conn : Channels.Vector;
Nested_Routes : Connection_Maps.Map;
end record;
......
......@@ -124,6 +124,12 @@ END RI_RI1;
SUBPROGRAM IMPLEMENTATION RI_RI1.others
END RI_RI1.others;
SUBPROGRAM RI_coucou
END RI_coucou;
SUBPROGRAM IMPLEMENTATION RI_coucou.others
END RI_coucou.others;
SYSTEM Nested2_Appear
FEATURES
PI_world : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Function1_ShouldNotAppear::Should_Not_Appear_Either::Nested2_Appear::PI_world.others {
......@@ -151,6 +157,12 @@ FEATURES
Taste::InterfaceName => "RI1";
Taste::labelInheritance => "true";
};
RI_coucou : REQUIRES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_coucou.others {
Taste::coordinates => "160536 91710";
Taste::RCMoperationKind => any;
Taste::InterfaceName => "coucou";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (Ada);
Taste::Active_Interfaces => any;
......@@ -207,6 +219,12 @@ END RI_ola;
SUBPROGRAM IMPLEMENTATION RI_ola.others
END RI_ola.others;
SUBPROGRAM RI_coucou
END RI_coucou;
SUBPROGRAM IMPLEMENTATION RI_coucou.others
END RI_coucou.others;
SYSTEM Should_Not_Appear_Either
FEATURES
PI_world : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Function1_ShouldNotAppear::Should_Not_Appear_Either::Nested2_Appear::PI_world.others {
......@@ -228,6 +246,12 @@ FEATURES
Taste::InterfaceName => "ola";
Taste::labelInheritance => "true";
};
RI_coucou : REQUIRES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_coucou.others {
Taste::coordinates => "154931 95943";
Taste::RCMoperationKind => any;
Taste::InterfaceName => "coucou";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (C);
Taste::Active_Interfaces => any;
......@@ -239,15 +263,18 @@ SUBCOMPONENTS
Taste::coordinates => "156260 76190 172016 91710";
};
CONNECTIONS
Nested2_PI_world_Function1_RI_world : SUBPROGRAM ACCESS Nested2_Appear.PI_world -> PI_world {
Nested2_Appear_PI_world_Should_Not_Appear_Either_PI_world : SUBPROGRAM ACCESS Nested2_Appear.PI_world -> PI_world {
Taste::coordinates => "158967 70311 158967 73250 159788 73250 159788 76190";
};
Function1_PI_my_final_result_Nested2_RI_my_final_result : SUBPROGRAM ACCESS RI_my_final_result -> Nested2_Appear.RI_my_final_result {
Should_Not_Appear_Either_RI_my_final_result_Nested2_Appear_RI_my_final_result : SUBPROGRAM ACCESS RI_my_final_result -> Nested2_Appear.RI_my_final_result {
Taste::coordinates => "156260 82070 150557 82070 150557 80895 144855 80895";
};
Should_Not_Appear_Either_PI_ola_Nested2_Appear_RI_ola : SUBPROGRAM ACCESS RI_ola -> Nested2_Appear.RI_ola {
Should_Not_Appear_Either_RI_ola_Nested2_Appear_RI_ola : SUBPROGRAM ACCESS RI_ola -> Nested2_Appear.RI_ola {
Taste::coordinates => "156260 86774 150558 86774 150558 90656 144855 90656";
};
Should_Not_Appear_Either_RI_coucou_Nested2_Appear_RI_coucou : SUBPROGRAM ACCESS RI_coucou -> Nested2_Appear.RI_coucou {
Taste::coordinates => "160536 91710 160536 93314 154931 93314 154931 95943";
};
END Should_Not_Appear_Either.others;
END interfaceview::IV::Function1_ShouldNotAppear::Should_Not_Appear_Either;
......@@ -334,6 +361,12 @@ END RI_ola_bis;
SUBPROGRAM IMPLEMENTATION RI_ola_bis.others
END RI_ola_bis.others;
SUBPROGRAM RI_coucou
END RI_coucou;
SUBPROGRAM IMPLEMENTATION RI_coucou.others
END RI_coucou.others;
SYSTEM Function1_ShouldNotAppear
FEATURES
PI_hello : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Function1_ShouldNotAppear::Nested1_Appear::PI_hello.others {
......@@ -361,6 +394,12 @@ FEATURES
Taste::InterfaceName => "ola_bis";
Taste::labelInheritance => "true";
};
RI_coucou : REQUIRES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_coucou.others {
Taste::coordinates => "124279 109383";
Taste::RCMoperationKind => any;
Taste::InterfaceName => "coucou";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (C);
Taste::Active_Interfaces => any;
......@@ -380,21 +419,24 @@ SUBCOMPONENTS
TASTE_IV_Properties::is_Component_Type => TRUE;
};
CONNECTIONS
Nested1_PI_hello_Function1_ShouldNotAppear_RI_hello : SUBPROGRAM ACCESS Nested1_Appear.PI_hello -> PI_hello {
Nested1_Appear_PI_hello_Function1_ShouldNotAppear_PI_hello : SUBPROGRAM ACCESS Nested1_Appear.PI_hello -> PI_hello {
Taste::coordinates => "124279 55614 130628 55614 130628 55732 136978 55732";
};
Function1_PI_world_Nested1_RI_world : SUBPROGRAM ACCESS Should_Not_Appear_Either.PI_world -> Nested1_Appear.RI_world {
Should_Not_Appear_Either_PI_world_Nested1_Appear_RI_world : SUBPROGRAM ACCESS Should_Not_Appear_Either.PI_world -> Nested1_Appear.RI_world {
Taste::coordinates => "153203 65140 158967 65140 158967 70311";
};
Function1_ShouldNotAppear_PI_ola_bis_Nested1_Appear_RI_ola_bis : SUBPROGRAM ACCESS RI_ola_bis -> Nested1_Appear.RI_ola_bis {
Function1_ShouldNotAppear_RI_ola_bis_Nested1_Appear_RI_ola_bis : SUBPROGRAM ACCESS RI_ola_bis -> Nested1_Appear.RI_ola_bis {
Taste::coordinates => "140345 66548 140345 84791 124279 84791";
};
Function1_ShouldNotAppear_PI_my_final_result_Function1_RI_my_final_result : SUBPROGRAM ACCESS RI_my_final_result -> Should_Not_Appear_Either.RI_my_final_result {
Function1_ShouldNotAppear_RI_my_final_result_Should_Not_Appear_Either_RI_my_final_result : SUBPROGRAM ACCESS RI_my_final_result -> Should_Not_Appear_Either.RI_my_final_result {
Taste::coordinates => "144855 80895 134567 80895 134567 80311 124279 80311";
};
Function1_ShouldNotAppear_PI_ola_Should_Not_Appear_Either_RI_ola : SUBPROGRAM ACCESS RI_ola -> Should_Not_Appear_Either.RI_ola {
Function1_ShouldNotAppear_RI_ola_Should_Not_Appear_Either_RI_ola : SUBPROGRAM ACCESS RI_ola -> Should_Not_Appear_Either.RI_ola {
Taste::coordinates => "144855 90656 134567 90656 134567 92808 124279 92808";
};
Function1_ShouldNotAppear_RI_coucou_Should_Not_Appear_Either_RI_coucou : SUBPROGRAM ACCESS RI_coucou -> Should_Not_Appear_Either.RI_coucou {
Taste::coordinates => "154931 95943 154931 109383 124279 109383";
};
END Function1_ShouldNotAppear.others;
END interfaceview::IV::Function1_ShouldNotAppear;
......@@ -462,6 +504,8 @@ WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_bonjour
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_bonjour;
SUBPROGRAM IMPLEMENTATION PI_bonjour.others
......@@ -469,13 +513,28 @@ PROPERTIES
Compute_Execution_Time => 0 ms .. 0 ms;
END PI_bonjour.others;
SUBPROGRAM PI_coucou
END PI_coucou;
SUBPROGRAM IMPLEMENTATION PI_coucou.others
PROPERTIES
Compute_Execution_Time => 0 ms .. 0 ms;
END PI_coucou.others;
SYSTEM Z_Shown
FEATURES
PI_bonjour : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_bonjour.others {
Taste::coordinates => "102645 107303";
Taste::RCMoperationKind => unprotected;
Taste::RCMperiod => 0 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "bonjour";
};
PI_coucou : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_coucou.others {
Taste::coordinates => "102645 112510";
Taste::RCMoperationKind => unprotected;
Taste::InterfaceName => "coucou";
};
PROPERTIES
Source_Language => (C);
Taste::Active_Interfaces => any;
......@@ -494,6 +553,8 @@ WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_bonjour
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_bonjour;
SUBPROGRAM IMPLEMENTATION PI_bonjour.others
......@@ -501,13 +562,28 @@ PROPERTIES
Compute_Execution_Time => 0 ms .. 0 ms;
END PI_bonjour.others;
SUBPROGRAM PI_coucou
END PI_coucou;
SUBPROGRAM IMPLEMENTATION PI_coucou.others
PROPERTIES
Compute_Execution_Time => 0 ms .. 0 ms;
END PI_coucou.others;
SYSTEM Y_Hidden
FEATURES
PI_bonjour : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_bonjour.others {
Taste::coordinates => "109817 102811";
Taste::RCMoperationKind => unprotected;
Taste::RCMperiod => 0 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "bonjour";
};
PI_coucou : PROVIDES SUBPROGRAM ACCESS interfaceview::IV::Y_Hidden::Z_Shown::PI_coucou.others {
Taste::coordinates => "109817 111577";
Taste::RCMoperationKind => unprotected;
Taste::InterfaceName => "coucou";
};
PROPERTIES
Source_Language => (C);
Taste::Active_Interfaces => any;
......@@ -519,9 +595,12 @@ SUBCOMPONENTS
Taste::coordinates => "82304 103585 102645 117224";
};
CONNECTIONS
Z_Shown_PI_bonjour_Y_Hidden_RI_bonjour : SUBPROGRAM ACCESS Z_Shown.PI_bonjour -> PI_bonjour {
Z_Shown_PI_bonjour_Y_Hidden_PI_bonjour : SUBPROGRAM ACCESS Z_Shown.PI_bonjour -> PI_bonjour {
Taste::coordinates => "109817 102811 104850 102811 104850 107303 102645 107303";
};
Z_Shown_PI_coucou_Y_Hidden_PI_coucou : SUBPROGRAM ACCESS Z_Shown.PI_coucou -> PI_coucou {
Taste::coordinates => "109817 111577 106231 111577 106231 112510 102645 112510";
};
END Y_Hidden.others;
END interfaceview::IV::Y_Hidden;
......@@ -541,7 +620,7 @@ END interfaceview;
SYSTEM IMPLEMENTATION interfaceview.others
SUBCOMPONENTS
Function1_ShouldNotAppear : SYSTEM interfaceview::IV::Function1_ShouldNotAppear::Function1_ShouldNotAppear.others {
Taste::coordinates => "124279 48559 182010 102410";
Taste::coordinates => "124279 48559 182010 120553";
};
Level0_Appear : SYSTEM interfaceview::IV::Level0_Appear::Level0_Appear.others {
Taste::coordinates => "81834 63257 99353 90064";
......@@ -550,10 +629,10 @@ SUBCOMPONENTS
Taste::coordinates => "81833 95002 109817 119693";
};
CONNECTIONS
Function1_ShouldNotAppear_PI_hello_Level0_RI_I_say_hello : SUBPROGRAM ACCESS Function1_ShouldNotAppear.PI_hello -> Level0_Appear.RI_I_say_hello {
Function1_ShouldNotAppear_PI_hello_Level0_Appear_RI_I_say_hello : SUBPROGRAM ACCESS Function1_ShouldNotAppear.PI_hello -> Level0_Appear.RI_I_say_hello {
Taste::coordinates => "99353 67961 111816 67961 111816 55614 124279 55614";
};
Level0_PI_final_result_Function1_ShouldNotAppear_RI_my_final_result : SUBPROGRAM ACCESS Level0_Appear.PI_final_result -> Function1_ShouldNotAppear.RI_my_final_result {
Level0_Appear_PI_final_result_Function1_ShouldNotAppear_RI_my_final_result : SUBPROGRAM ACCESS Level0_Appear.PI_final_result -> Function1_ShouldNotAppear.RI_my_final_result {
Taste::coordinates => "124279 80311 111816 80311 111816 83249 99353 83249";
};
Y_Hidden_PI_bonjour_Function1_ShouldNotAppear_RI_ola : SUBPROGRAM ACCESS Y_Hidden.PI_bonjour -> Function1_ShouldNotAppear.RI_ola {
......@@ -562,6 +641,9 @@ CONNECTIONS
Y_Hidden_PI_bonjour_Function1_ShouldNotAppear_RI_ola_bis : SUBPROGRAM ACCESS Y_Hidden.PI_bonjour -> Function1_ShouldNotAppear.RI_ola_bis {
Taste::coordinates => "124279 84791 115667 84791 115667 102811 109817 102811";
};
Y_Hidden_PI_coucou_Function1_ShouldNotAppear_RI_coucou : SUBPROGRAM ACCESS Y_Hidden.PI_coucou -> Function1_ShouldNotAppear.RI_coucou {
Taste::coordinates => "124279 109383 117277 109383 117277 111577 109817 111577";
};
END interfaceview.others;
PROPERTIES
......
Supports Markdown
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