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

for CV: translate PI and RI to templates

parent 13ce1261
......@@ -42,19 +42,33 @@ package body TASTE.Concurrency_View is
end Debug_Dump;
-- This function translates a protected block into a template
function To_Template (B : Protected_Block) return Translate_Set is
function To_Template (B : Protected_Block) return Block_As_Template is
Calling_Threads : Tag;
-- TODO: Provided and Required
Result : Block_As_Template;
begin
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)));
for PI of B.Provided loop
declare
Basic : constant Translate_Set := PI.PI.To_Template
& Assoc ("Protected_Block_Name", To_String (PI.Name))
& Assoc ("Caller_Is_Local", PI.Local_Caller);
begin
Result.Provided.Append (Basic);
end;
end loop;
for RI of B.Required loop
Result.Required.Append (RI.To_Template);
end loop;
Result.Header := +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));
return Result;
end To_Template;
-- This function translates a thread definition into a template
......
......@@ -44,7 +44,14 @@ package TASTE.Concurrency_View is
Node : Option_Node.Option;
end record;
function To_Template (B : Protected_Block) return Translate_Set;
-- Data model for the template backends (templates_parser)
type Block_As_Template is
record
Header : Translate_Set;
Provided : Translate_Sets.Vector;
Required : Translate_Sets.Vector;
end record;
function To_Template (B : Protected_Block) return Block_As_Template;
package Protected_Blocks is new Indefinite_Ordered_Maps
(String, Protected_Block);
......@@ -80,12 +87,11 @@ package TASTE.Concurrency_View is
Output : File_Type);
-- 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);
package ST_Blocks is new Indefinite_Vectors (Natural, Block_As_Template);
type CV_As_Template is
record
Threads : ST_Threads.Vector;
Threads : Translate_Sets.Vector;
Blocks : ST_Blocks.Vector;
end record;
......
......@@ -8,7 +8,6 @@ with Ada.Characters.Latin_1,
Ada.Strings,
GNAT.OS_Lib,
GNAT.Command_Line,
Templates_Parser,
Templates_Parser.Utils,
Ocarina.AADL_Values,
Ocarina.Configuration,
......@@ -20,10 +19,8 @@ package body TASTE.Parser_Utils is
use GNAT.OS_Lib,
GNAT.Command_Line,
Templates_Parser,
Templates_Parser.Utils,
Ocarina.Instances.Queries;
-- Ocarina.ME_AADL;
procedure Put_Info (Info : String) is
begin
......
......@@ -12,6 +12,7 @@ with Ada.Containers.Indefinite_Ordered_Maps,
Text_IO,
GNAT.Strings,
Interfaces.C_Streams,
Templates_Parser,
Ocarina,
Ocarina.Types,
Ocarina.Namet,
......@@ -27,7 +28,8 @@ use Ocarina,
Ada.Containers,
Ada.Strings.Unbounded,
Text_IO,
Interfaces.C_Streams;
Interfaces.C_Streams,
Templates_Parser;
package TASTE.Parser_Utils is
......@@ -138,4 +140,8 @@ package TASTE.Parser_Utils is
procedure Debug_Dump (Config : Taste_Configuration; Output : File_Type);
procedure Parse_Command_Line (Result : out Taste_Configuration);
-- Define a vector for template_parser translate sets
package Translate_Sets is new Indefinite_Vectors (Natural, Translate_Set);
end TASTE.Parser_Utils;
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