Commit 2671e391 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Build up templates parser structures

parent 8f6a1bcd
Pipeline #1232 failed with stages
......@@ -41,12 +41,55 @@ package body TASTE.Concurrency_View is
end loop;
end Debug_Dump;
-- This function translates a protected block into a template
function Pro_To_ST (B : Protected_Block) return Translate_Set is
Calling_Threads : Tag;
-- TODO: Provided and Required
for Thread of B.Calling_Threads loop
Calling_Threads := Calling_Threads & Thread;
end loop;
return Result : constant Translate_Set :=
(+Assoc ("Name", To_String (B.Name))
& Assoc ("Calling_Threads", Calling_Threads)
& Assoc ("Node_Name", To_String (B.Node.Value_Or
(Taste_Node'(Name => US (""), others => <>)).Name)));
end Pro_To_ST;
-- This function translates a thread definition into a template
function Thread_To_ST (T : AADL_Thread) return Translate_Set is
Remote_Thread : Vector_Tag;
Remote_PI : Vector_Tag;
Ports_Matrix : Matrix_Tag;
for Out_Port of T.Output_Ports loop
Remote_Thread := Remote_Thread & To_String (Out_Port.Remote_Thread);
Remote_PI := Remote_PI & To_String (Out_Port.Remote_PI);
end loop;
Ports_Matrix := +Remote_Thread & Remote_PI;
return Result : constant Translate_Set :=
(+Assoc ("Name", To_String (T.Name))
& Assoc ("Entry_Port_Name", To_String (T.Entry_Port_Name))
& Assoc ("Pro_Block_Name", To_String (T.Protected_Block_Name))
& Assoc ("Node_Name", To_String (T.Node.Value_Or
(Taste_Node'(Name => US (""), others => <>)).Name))
& Assoc ("Out_Ports", Ports_Matrix));
end Thread_To_ST;
function Concurrency_View_Template (CV : Taste_Concurrency_View)
return CV_As_Template is
return CV_As_Template
Result : CV_As_Template;
pragma Unreferenced (CV);
for Thread of CV.Threads loop
Result.Threads.Append (Thread_To_ST (Thread));
end loop;
for Pro of CV.Blocks loop
Result.Blocks.Append (Pro_To_ST (Pro));
end loop;
return Result;
end Concurrency_View_Template;
end TASTE.Concurrency_View;
......@@ -75,28 +75,14 @@ package TASTE.Concurrency_View is
procedure Debug_Dump (CV : Taste_Concurrency_View;
Output : File_Type);
-- Set of types to transform the AST into String Template entities
type ST_port is
Header : Translate_Set;
end record;
package ST_Ports is new Indefinite_Vectors (Natural, ST_Port);
type ST_Thread is
Header : Translate_Set;
Output_Ports : ST_Ports.Vector;
end record;
package ST_Threads is new Indefinite_Ordered_Maps (String, ST_Thread);
-- package ST_Blocks is new Indefinite_Ordered_Maps (String, ST_Block);
-- Set of constructs for transforming the AST into Template entities
package ST_Threads is new Indefinite_Vectors (Natural, Translate_Set);
package ST_Blocks is new Indefinite_Vectors (Natural, Translate_Set);
type CV_As_Template is
Threads : ST_Threads.Map;
-- Blocks : ST_Blocks.Map;
Threads : ST_Threads.Vector;
Blocks : ST_Blocks.Vector;
end record;
function Concurrency_View_Template (CV : Taste_Concurrency_View)
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