Commit 71831dd4 authored by jhugues's avatar jhugues

* Rework code to avoid name collision for MAST and Cheddar



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@6171 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 1ba3ec56
...@@ -348,7 +348,8 @@ package body Ocarina.Backends.Cheddar.Mapping is ...@@ -348,7 +348,8 @@ package body Ocarina.Backends.Cheddar.Mapping is
N := Make_XML_Node ("address_space"); N := Make_XML_Node ("address_space");
-- name: computed from process instance name -- name: computed from process instance name
P := Map_Node_Identifier_To_XML_Node ("name", Parent_Subcomponent (E)); P := Map_Node_Identifier_To_XML_Node
("name", Fully_Qualified_Instance_Name (E));
Append_Node_To_List (P, XTN.Subitems (N)); Append_Node_To_List (P, XTN.Subitems (N));
-- cpu_name: computed from the processor binding of the -- cpu_name: computed from the processor binding of the
...@@ -453,12 +454,14 @@ package body Ocarina.Backends.Cheddar.Mapping is ...@@ -453,12 +454,14 @@ package body Ocarina.Backends.Cheddar.Mapping is
-- address_space: name of the enclosing process -- address_space: name of the enclosing process
P := Map_Node_Identifier_To_XML_Node P := Map_Node_Identifier_To_XML_Node
("address_space_name", ("address_space_name",
Get_Container_Process (Parent_Subcomponent (E))); Fully_Qualified_Instance_Name
(Corresponding_Instance
(Get_Container_Process (Parent_Subcomponent (E)))));
Append_Node_To_List (P, XTN.Subitems (N)); Append_Node_To_List (P, XTN.Subitems (N));
-- name: computed from thread instance name -- name: computed from thread instance name
P := Map_Node_Identifier_To_XML_Node P := Map_Node_Identifier_To_XML_Node
("name", Parent_Subcomponent (E)); ("name", Fully_Qualified_Instance_Name (E));
Append_Node_To_List (P, XTN.Subitems (N)); Append_Node_To_List (P, XTN.Subitems (N));
-- capacity: computed from the Compute_Execution_Time property -- capacity: computed from the Compute_Execution_Time property
......
...@@ -576,17 +576,15 @@ package body Ocarina.Backends.MAST.Main is ...@@ -576,17 +576,15 @@ package body Ocarina.Backends.MAST.Main is
Port_Shared_Resource_Op_List : List_Id; Port_Shared_Resource_Op_List : List_Id;
begin begin
Set_Str_To_Name_Buffer (""); Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name Get_Name_String (Fully_Qualified_Instance_Name (E));
(Name (Identifier (Parent_Subcomponent (E)))));
Add_Str_To_Name_Buffer ("_operations");
Operation_Name := Name_Find;
Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name
(Name (Identifier (Parent_Subcomponent (E)))));
Add_Str_To_Name_Buffer ("_sched_server"); Add_Str_To_Name_Buffer ("_sched_server");
Server_Sched_Name := Name_Find; Server_Sched_Name := Name_Find;
Set_Str_To_Name_Buffer ("");
Get_Name_String (Fully_Qualified_Instance_Name (E));
Add_Str_To_Name_Buffer ("_operations");
Operation_Name := Name_Find;
Prio := Get_Thread_Priority (E); Prio := Get_Thread_Priority (E);
if Prio = 0 then if Prio = 0 then
Prio := 1; Prio := 1;
...@@ -609,13 +607,12 @@ package body Ocarina.Backends.MAST.Main is ...@@ -609,13 +607,12 @@ package body Ocarina.Backends.MAST.Main is
Append_Node_To_List (N, MTN.Declarations (MAST_File)); Append_Node_To_List (N, MTN.Declarations (MAST_File));
N := Make_Transaction N := Make_Transaction
(Normalize_Name (Name (Identifier (Parent_Subcomponent (E)))), (Fully_Qualified_Instance_Name (E),
Regular); Regular);
Append_Node_To_List (N, MTN.Declarations (MAST_File)); Append_Node_To_List (N, MTN.Declarations (MAST_File));
Set_Str_To_Name_Buffer (""); Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name Get_Name_String (Fully_Qualified_Instance_Name (E));
(Name (Identifier (Parent_Subcomponent (E)))));
Add_Str_To_Name_Buffer ("_activation_event"); Add_Str_To_Name_Buffer ("_activation_event");
Activation_Event_Name := Name_Find; Activation_Event_Name := Name_Find;
...@@ -662,8 +659,7 @@ package body Ocarina.Backends.MAST.Main is ...@@ -662,8 +659,7 @@ package body Ocarina.Backends.MAST.Main is
(Activation_Event, MTN.External_Events (N)); (Activation_Event, MTN.External_Events (N));
Set_Str_To_Name_Buffer (""); Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name Get_Name_String (Fully_Qualified_Instance_Name (E));
(Name (Identifier (Parent_Subcomponent (E)))));
Add_Str_To_Name_Buffer ("_output_event"); Add_Str_To_Name_Buffer ("_output_event");
Output_Event_Name := Name_Find; Output_Event_Name := Name_Find;
......
...@@ -345,6 +345,37 @@ package body Ocarina.Backends.Utils is ...@@ -345,6 +345,37 @@ package body Ocarina.Backends.Utils is
return Normalized_Name; return Normalized_Name;
end Normalize_Name; end Normalize_Name;
-----------------------------------
-- Fully_Qualified_Instance_Name --
-----------------------------------
function Fully_Qualified_Instance_Name (E : Node_Id) return Name_Id is
Current_Node : Node_Id := Parent_Subcomponent (E);
Current_Name : Name_Id;
begin
Set_Str_To_Name_Buffer ("");
Get_Name_String (Normalize_Name (Name (Identifier (Current_Node))));
Current_Name := Name_Find;
Current_Node := Parent_Component (Current_Node);
while Present (Current_Node) loop
exit when No (Parent_Subcomponent (Current_Node));
Get_Name_String (Normalize_Name
(Name
(Identifier
(Parent_Subcomponent (Current_Node)))));
Set_Str_To_Name_Buffer (Get_Name_String (Name_Find)
& "_" & Get_Name_String (Current_Name));
Current_Name := Name_Find;
Current_Node := Parent_Component (Parent_Subcomponent (Current_Node));
end loop;
return Current_Name;
end Fully_Qualified_Instance_Name;
------------------ ------------------
-- Is_Namespace -- -- Is_Namespace --
------------------ ------------------
......
...@@ -71,6 +71,12 @@ package Ocarina.Backends.Utils is ...@@ -71,6 +71,12 @@ package Ocarina.Backends.Utils is
-- in most languages: a-z, 0-9, _. -- in most languages: a-z, 0-9, _.
-- If Ada_Style is set to True, '.' is replaced by "__" -- If Ada_Style is set to True, '.' is replaced by "__"
function Fully_Qualified_Instance_Name (E : Node_Id) return Name_Id;
-- Return a fully qualified name for component instance E, the
-- fully qualified name is built from
-- <system_name>_<process_name>_<thread_name> to avoid name
-- collision
----------------------------------------------------- -----------------------------------------------------
-- Routines that are common to the code generators -- -- Routines that are common to the code generators --
----------------------------------------------------- -----------------------------------------------------
...@@ -491,4 +497,5 @@ package Ocarina.Backends.Utils is ...@@ -491,4 +497,5 @@ package Ocarina.Backends.Utils is
return Boolean; return Boolean;
function Get_Associated_Bus (Port : Node_Id) return Node_Id; function Get_Associated_Bus (Port : Node_Id) return Node_Id;
end Ocarina.Backends.Utils; end Ocarina.Backends.Utils;
...@@ -132,4 +132,16 @@ package body Ocarina.Backends.XML_Common.Mapping is ...@@ -132,4 +132,16 @@ package body Ocarina.Backends.XML_Common.Mapping is
return N; return N;
end Map_Node_Identifier_To_XML_Node; end Map_Node_Identifier_To_XML_Node;
function Map_Node_Identifier_To_XML_Node
(Name : String; The_Node : Name_Id) return Node_Id
is
N, V : Node_Id;
begin
N := Make_XML_Node (Name);
V := Make_Defining_Identifier (The_Node);
Append_Node_To_List (V, Subitems (N));
return N;
end Map_Node_Identifier_To_XML_Node;
end Ocarina.Backends.XML_Common.Mapping; end Ocarina.Backends.XML_Common.Mapping;
...@@ -49,4 +49,7 @@ package Ocarina.Backends.XML_Common.Mapping is ...@@ -49,4 +49,7 @@ package Ocarina.Backends.XML_Common.Mapping is
(Name : String; The_Node : Node_Id) return Node_Id; (Name : String; The_Node : Node_Id) return Node_Id;
-- Build a node whose structure is <name>the_node'identifier</name> -- Build a node whose structure is <name>the_node'identifier</name>
function Map_Node_Identifier_To_XML_Node
(Name : String; The_Node : Name_Id) return Node_Id;
end Ocarina.Backends.XML_Common.Mapping; end Ocarina.Backends.XML_Common.Mapping;
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