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

Work on concurrency view template engine

parent 8e6ec1fc
...@@ -76,7 +76,7 @@ package body TASTE.Concurrency_View is ...@@ -76,7 +76,7 @@ package body TASTE.Concurrency_View is
end Debug_Dump; end Debug_Dump;
-- This function translates a protected block into a template -- This function translates a protected block into a template
function To_Template (B : Protected_Block) return Block_As_Template is function Prepare_Template (B : Protected_Block) return Block_As_Template is
Calling_Threads : Tag; Calling_Threads : Tag;
Result : Block_As_Template; Result : Block_As_Template;
begin begin
...@@ -103,7 +103,7 @@ package body TASTE.Concurrency_View is ...@@ -103,7 +103,7 @@ package body TASTE.Concurrency_View is
& Assoc ("Node_Name", To_String (B.Node.Value_Or & Assoc ("Node_Name", To_String (B.Node.Value_Or
(Taste_Node'(Name => US (""), others => <>)).Name)); (Taste_Node'(Name => US (""), others => <>)).Name));
return Result; return Result;
end To_Template; end Prepare_Template;
-- This function translates a thread definition into a template -- This function translates a thread definition into a template
function To_Template (T : AADL_Thread) return Translate_Set is function To_Template (T : AADL_Thread) return Translate_Set is
...@@ -189,15 +189,38 @@ package body TASTE.Concurrency_View is ...@@ -189,15 +189,38 @@ package body TASTE.Concurrency_View is
Threads : Tag; Threads : Tag;
Blocks : Tag; Blocks : Tag;
begin begin
for Thread of Partition.Threads loop for T of Partition.Threads loop
declare
-- Render each thread -- Render each thread
Threads := Threads & "This_Thread"; Thread_Assoc : constant Translate_Set := T.To_Template;
-- & String'(Parse (Path & "/thread.tmplt", Thread_Assoc)); Result : constant String :=
(Parse (Path & "/thread.tmplt", Thread_Assoc));
begin
Threads := Threads & Result;
end;
end loop; end loop;
for Block of Partition.Blocks loop for B of Partition.Blocks loop
-- Render each block declare
Blocks := Blocks & "This block"; Tmpl : constant Block_As_Template := B.Prepare_Template;
-- String'(Parse (Path & "/block.tmplt", Block_Assoc)); Block_Assoc : Translate_Set := Tmpl.Header;
PI_Tag : Tag;
RI_Tag : Tag;
begin
for PI_Assoc of Tmpl.Provided loop
PI_Tag := PI_Tag
& String'(Parse (Path & "/pi.tmplt", PI_Assoc));
end loop;
for RI_Assoc of Tmpl.Required loop
RI_Tag := RI_Tag
& String'(Parse (Path & "/ri.tmplt", RI_Assoc));
end loop;
Block_Assoc := Block_Assoc
& Assoc ("Provided", PI_Tag)
& Assoc ("Required", RI_Tag);
Blocks := Blocks &
String'(Parse (Path & "/block.tmplt", Block_Assoc));
end;
end loop; end loop;
return Translate_Set'(+Assoc ("Threads", Threads) return Translate_Set'(+Assoc ("Threads", Threads)
& Assoc ("Blocks", Blocks)); & Assoc ("Blocks", Blocks));
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
-- Model of the Concurrency View -- Model of the Concurrency View
with Ada.Containers.Indefinite_Ordered_Maps, with Ada.Containers.Indefinite_Ordered_Maps,
Ada.Containers.Indefinite_Vectors,
Ada.Strings.Unbounded, Ada.Strings.Unbounded,
Text_IO, Text_IO,
Templates_Parser, Templates_Parser,
...@@ -51,8 +50,7 @@ package TASTE.Concurrency_View is ...@@ -51,8 +50,7 @@ package TASTE.Concurrency_View is
Provided : Translate_Sets.Vector; Provided : Translate_Sets.Vector;
Required : Translate_Sets.Vector; Required : Translate_Sets.Vector;
end record; end record;
function To_Template (B : Protected_Block) return Block_As_Template; function Prepare_Template (B : Protected_Block) return Block_As_Template;
package ST_Blocks is new Indefinite_Vectors (Natural, Block_As_Template);
package Protected_Blocks is new Indefinite_Ordered_Maps package Protected_Blocks is new Indefinite_Ordered_Maps
(String, Protected_Block); (String, Protected_Block);
...@@ -78,13 +76,6 @@ package TASTE.Concurrency_View is ...@@ -78,13 +76,6 @@ package TASTE.Concurrency_View is
package AADL_Threads is new Indefinite_Ordered_Maps (String, AADL_Thread); package AADL_Threads is new Indefinite_Ordered_Maps (String, AADL_Thread);
-- a Partition is eventually a process (binaray) or a TSP partition
type CV_Partition_As_Template is
record
Threads : Translate_Sets.Vector;
Blocks : ST_Blocks.Vector;
end record;
type CV_Partition is tagged type CV_Partition is tagged
record record
Threads : AADL_Threads.Map; Threads : AADL_Threads.Map;
......
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the interface
@@-- @_Direction_@ : "PI" or "RI"
@@-- @_Kind_@ : The RCM Kind
@@-- @_Parent_Function_@ : The name of the function
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
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