Commit d5f30628 authored by Jerome Hugues's avatar Jerome Hugues Committed by GitHub

Merge pull request #230 from...

Merge pull request #230 from bouazizrahma/continue_with_mapping_many_transitions_in_BA_of_Sporadic_thread

Continue with mapping many transitions in ba of sporadic thread
parents 62e7f0ca b12ed924
......@@ -46,4 +46,9 @@ package Ocarina.Backends.C_Common.BA is
function Is_To_Make_Init_Sequence (S : Node_Id) return Boolean;
function Make_Specification_Of_BA_Related_Function
(S : Node_Id;
BA_Body : Boolean := False;
BA_Initialization : Boolean := False) return Node_Id;
end Ocarina.Backends.C_Common.BA;
......@@ -41,6 +41,8 @@ with Ocarina.Backends.C_Tree.Nodes;
with Ocarina.Backends.C_Common.Mapping;
with Ocarina.Backends.PO_HI_C.Runtime;
with Ocarina.Backends.C_Common.BA;
with Ocarina.ME_AADL_BA.BA_Tree.Nutils;
with Ocarina.ME_AADL_BA.BA_Tree.Nodes;
package body Ocarina.Backends.C_Common.Subprograms is
......@@ -59,6 +61,8 @@ package body Ocarina.Backends.C_Common.Subprograms is
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package CTN renames Ocarina.Backends.C_Tree.Nodes;
package BANu renames Ocarina.ME_AADL_BA.BA_Tree.Nutils;
package BATN renames Ocarina.ME_AADL_BA.BA_Tree.Nodes;
C_Root : Node_Id;
......@@ -584,8 +588,6 @@ package body Ocarina.Backends.C_Common.Subprograms is
Spg_Call : Node_Id;
Feature : Node_Id;
N : Node_Id;
Def_Idt : Node_Id;
Parameter_List : constant List_Id := New_List (CTN.K_List_Id);
S : constant Node_Id := Parent_Subcomponent (E);
begin
if Has_In_Ports (E) then
......@@ -630,21 +632,37 @@ package body Ocarina.Backends.C_Common.Subprograms is
if Has_Behavior_Specification (E) then
Def_Idt := Make_Defining_Identifier
(Map_C_BA_Related_Function_Name (S, BA_Body => True));
N := Make_Extern_Entity_Declaration
(Make_Specification_Of_BA_Related_Function (E, BA_Body => True));
N :=
Make_Parameter_Specification
(Make_Defining_Identifier (PN (P_Self)),
Parameter_Type => RE (RE_Task_Id));
Append_Node_To_List (N, Parameter_List);
Append_Node_To_List (N, CTN.Declarations (Current_File));
N := Make_Function_Specification
(Defining_Identifier => Def_Idt,
Parameters => Parameter_List,
Return_Type => New_Node (CTN.K_Void));
declare
BA : Node_Id;
begin
BA := Get_Behavior_Specification (E);
if BANu.Length (BATN.States (BA)) > 1 then
N :=
Make_Extern_Entity_Declaration
(Make_Function_Specification
(Defining_Identifier => Make_Defining_Identifier
(Map_C_BA_Related_Function_Name
(S, States_Initialization => True)),
Parameters => No_List,
Return_Type => New_Node (CTN.K_Void)));
Append_Node_To_List (N,
CTN.Declarations (Current_File));
if Is_To_Make_Init_Sequence (E) then
N := Make_Extern_Entity_Declaration
(Make_Specification_Of_BA_Related_Function
(E, BA_Initialization => True));
Append_Node_To_List (N, CTN.Declarations (Current_File));
Append_Node_To_List (N, CTN.Declarations (Current_File));
end if;
end if;
end;
end if;
......
......@@ -1145,8 +1145,6 @@ package body Ocarina.Backends.PO_HI_C.Activity is
procedure Make_Thread_Behavior_Specification is
N, N1 : Node_Id;
Parameter_List : constant List_Id := New_List (CTN.K_List_Id);
Def_Idt : Node_Id;
begin
-- Add_Include (RH (RH_Subprograms));
......@@ -1161,71 +1159,43 @@ package body Ocarina.Backends.PO_HI_C.Activity is
N := Make_Defining_Identifier (Map_C_Enumerator_Name (S));
Append_Node_To_List (N, Call_Parameters);
N :=
Make_Parameter_Specification
(Make_Defining_Identifier (PN (P_Self)),
Parameter_Type => RE (RE_Task_Id));
Append_Node_To_List (N, Parameter_List);
Def_Idt := Make_Defining_Identifier
(Map_C_BA_Related_Function_Name (S, BA_Body => True));
if P = Thread_Sporadic then
N := Make_Variable_Address
(Make_Defining_Identifier (VN (V_Port)));
Append_Node_To_List (N, Call_Parameters);
N :=
Make_Parameter_Specification
(Make_Defining_Identifier (VN (V_Port)),
Parameter_Type => CTU.Make_Pointer_Type (RE (RE_Port_T)));
Append_Node_To_List (N, Parameter_List);
-- add data subcomponents of the thread to the call_parameters
-- of the procedure <<thread_instance_name>>_ba_body
if not AAU.Is_Empty (Subcomponents (E)) then
N1 := First_Node (Subcomponents (E));
while Present (N1) loop
if AAU.Is_Data (Corresponding_Instance (N1)) then
N :=
Make_Variable_Address
(Map_C_Defining_Identifier (N1));
end if;
-- add data subcomponents of the thread to the call_parameters
-- of the procedure <<thread_instance_name>>_ba_body
Append_Node_To_List (N, Call_Parameters);
if not AAU.Is_Empty (Subcomponents (E)) then
N1 := First_Node (Subcomponents (E));
N :=
Make_Parameter_Specification
(Map_C_Defining_Identifier (N1),
Parameter_Type =>
CTU.Make_Pointer_Type
(Map_C_Data_Type_Designator
(Corresponding_Instance (N1))));
while Present (N1) loop
if AAU.Is_Data (Corresponding_Instance (N1)) then
Append_Node_To_List (N, Parameter_List);
N :=
Make_Variable_Address
(Map_C_Defining_Identifier (N1));
end if;
N1 := Next_Node (N1);
end loop;
end if;
Append_Node_To_List (N, Call_Parameters);
end if;
N1 := Next_Node (N1);
end loop;
end if;
N :=
Make_Extern_Entity_Declaration
(Make_Function_Specification
(Defining_Identifier => Def_Idt,
Parameters => Parameter_List,
Return_Type => New_Node (CTN.K_Void)));
N := Make_Extern_Entity_Declaration
(Make_Specification_Of_BA_Related_Function
(E, BA_Body => True));
Append_Node_To_List (N, CTN.Declarations (Current_File));
N :=
Make_Call_Profile
(Defining_Identifier => Def_Idt,
(Defining_Identifier => Make_Defining_Identifier
(Map_C_BA_Related_Function_Name (S, BA_Body => True)),
Parameters => Call_Parameters);
Append_Node_To_List (N, WStatements);
......@@ -1565,7 +1535,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Append_Node_To_List (N, Statements);
end if;
if P = Thread_Periodic then
if P = Thread_Periodic or else P = Thread_Sporadic then
-- For periodic threads, we force a first wait to ensure
-- synchronized start after initialization. The runtime
-- computes a specific epoch to ensure such start.
......@@ -1595,9 +1565,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
if Impl_Kind = Thread_With_Behavior_Specification then
declare
BA : Node_Id;
Parameter_List : constant List_Id :=
New_List (CTN.K_List_Id);
BA : Node_Id;
begin
BA := Get_Behavior_Specification (E);
if BANu.Length (BATN.States (BA)) > 1 then
......@@ -1623,20 +1591,10 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Parameters => Call_Parameters);
Append_Node_To_List (N, Statements);
N :=
Make_Parameter_Specification
(Make_Defining_Identifier (PN (P_Self)),
Parameter_Type => RE (RE_Task_Id));
Append_Node_To_List (N, Parameter_List);
N :=
Make_Extern_Entity_Declaration
(Make_Function_Specification
(Defining_Identifier => Make_Defining_Identifier
(Map_C_BA_Related_Function_Name
(S, BA_Initialization => True)),
Parameters => Parameter_List,
Return_Type => New_Node (CTN.K_Void)));
(Make_Specification_Of_BA_Related_Function
(E, BA_Initialization => True));
Append_Node_To_List (N,
CTN.Declarations (Current_File));
......
......@@ -1701,9 +1701,14 @@ package body Ocarina.Analyzer.AADL_BA is
then
N := Find_Output_Port_Of_Parent_Component
(Target_Idt, Root, Parent_Component);
elsif Present (Find_Data_Subcomponent_Of_Parent_Component
(Target_Idt, Root, Parent_Component))
then
N := Find_Data_Subcomponent_Of_Parent_Component
(Target_Idt, Root, Parent_Component);
end if;
if not No (N) then
if Present (N) then
BATN.Set_Corresponding_Entity
(BATN.First_Node
(BATN.Idt (Node)), N);
......@@ -2909,6 +2914,11 @@ package body Ocarina.Analyzer.AADL_BA is
then
N := Find_Input_Port_Of_Parent_Component
(Ident, Root, Parent_Component);
elsif Present (Find_Data_Subcomponent_Of_Parent_Component
(Ident, Root, Parent_Component))
then
N := Find_Data_Subcomponent_Of_Parent_Component
(Ident, Root, Parent_Component);
end if;
if Present (N) then
......@@ -3635,6 +3645,11 @@ package body Ocarina.Analyzer.AADL_BA is
Success := False;
end if;
end if;
if Success then
BATN.Set_Corresponding_Entity
(Dispatch_Trigger_Event, Pointed_Node);
end if;
else
Error_Loc (1) := BATN.Loc (Dispatch_Trigger_Event);
......
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