Commit 2ce57e3a authored by julien.delange's avatar julien.delange
Browse files

* handle data declared in a process that have a

   Concurrency_Control_Protocol property. Interpret them
   as a mutex/semaphore and generate a simple protected variable



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@1251 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 32ad3474
......@@ -328,7 +328,10 @@ package body Ocarina.Backends.C_Common.Types is
Type_Source_Name : Name_Id;
Actual_Data_Size : Unsigned_Long_Long;
Struct_Members : constant List_Id := New_List
(CTN.K_Enumeration_Literals);
Protected_Struct_Members : constant List_Id := New_List
(CTN.K_Enumeration_Literals);
begin
if No (Get_Handling (E, By_Name, H_C_Type_Spec)) then
if Get_Current_Backend_Kind = PolyORB_HI_C then
......@@ -478,10 +481,6 @@ package body Ocarina.Backends.C_Common.Types is
when Data_Struct | Data_With_Accessors =>
declare
Struct_Members : constant List_Id := New_List
(CTN.K_Enumeration_Literals);
Protected_Struct_Members : constant List_Id := New_List
(CTN.K_Enumeration_Literals);
C : Node_Id := No_Node;
begin
if No (Subcomponents (E)) then
......@@ -689,6 +688,49 @@ package body Ocarina.Backends.C_Common.Types is
False),
True);
end if;
elsif Get_Concurrency_Protocol (E) =
Concurrency_Protected_Access then
-- Protected type that does not have struct members.
-- This piece of code is made to handle declaration
-- such as:
-- data implementation foo.i
-- *** NOTHING ***
-- properties
-- Concurrency_Control_Protocol => Protected_Access;
-- end foo.i;
-- Other protected objects are data components that have
-- subprogram accesses.
Append_Node_To_List
(Make_Member_Declaration
(Used_Type => RE (RE_Protected_T),
Defining_Identifier =>
Make_Defining_Identifier
(MN (M_Protected_Id))),
Protected_Struct_Members);
if not Is_Empty (Struct_Members) then
S := CTN.First_Node (Struct_Members);
while Present (S) loop
Append_Node_To_List
(S, Protected_Struct_Members);
S := CTN.Next_Node (S);
end loop;
end if;
N := Make_Full_Type_Declaration
(Defining_Identifier =>
Map_C_Defining_Identifier (E),
Type_Definition =>
Make_Struct_Aggregate
(Members =>
Protected_Struct_Members));
Append_Node_To_List
(N, CTN.Declarations (Current_File));
else
Display_Located_Error
(Loc (E), "unspecified data representation",
......@@ -806,9 +848,7 @@ package body Ocarina.Backends.C_Common.Types is
-- Visit the component instance corresponding to the
-- subcomponent S.
if not AINU.Is_Data (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
......
......@@ -1485,9 +1485,6 @@ package body Ocarina.Backends.PO_HI_C.Activity is
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if AAU.Is_Data (Corresponding_Instance (S)) then
N := Make_Variable_Declaration
......@@ -1496,7 +1493,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
(Corresponding_Instance (S)));
Append_Node_To_List
(N,
(Make_Extern_Entity_Declaration (N),
CTN.Declarations (Current_File));
Bind_AADL_To_Object (Identifier (S), N);
......@@ -1517,19 +1514,17 @@ package body Ocarina.Backends.PO_HI_C.Activity is
N := Make_Extern_Entity_Declaration (N);
Append_Node_To_List
(N, CTN.Declarations (CTN.Subprograms_Source (U)));
end if;
S := Next_Node (S);
end loop;
end if;
N := Make_Variable_Declaration
(Map_C_Defining_Identifier (S),
Map_C_Data_Type_Designator
(Corresponding_Instance (S)));
if not AAU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
N := Make_Extern_Entity_Declaration (N);
Append_Node_To_List
(N, CTN.Declarations (CTN.Main_Source (U)));
else
-- Visit the component instance corresponding to
-- the subcomponent S.
while Present (S) loop
if not AAU.Is_Data (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
......
......@@ -314,6 +314,14 @@ package body Ocarina.Backends.PO_HI_C.Main is
Add_Include (RH (RH_Types));
N := Make_Variable_Declaration
(Map_C_Defining_Identifier (S),
Map_C_Data_Type_Designator
(Corresponding_Instance (S)));
Append_Node_To_List
(N, CTN.Declarations (Current_File));
N := Make_Expression
(Left_Expr =>
Make_Member_Designator
......
......@@ -150,6 +150,7 @@ module Ocarina::ME_REAL::REAL_Tree::Nodes {
interface Range_Declaration : Node_Id {
Node_Id Variable_Ref; // Var_Reference
Node_Id Range_Variable; // Element
Node_Id Range_Expression; // Element
Node_Id Range_Set; // Set_Expression
};
......
......@@ -1398,6 +1398,7 @@ package body Ocarina.FE_REAL.Parser is
-- We pass the sothat
Scan_Token (T_Sothat);
if Token = T_Error then
DPE (PC_Single_Set_Declaration, T_Sothat);
return No_Node;
......@@ -1409,6 +1410,7 @@ package body Ocarina.FE_REAL.Parser is
if No (Set_Def) then
return No_Node;
end if;
Set_Selection_Expression (Set_Decl, Set_Def);
-- We read the right brace (exit of set declaration)
......@@ -1599,6 +1601,7 @@ package body Ocarina.FE_REAL.Parser is
Identifier : Node_Id;
Elem : Node_Id;
Set_Expr : Node_Id;
Expr : Node_Id := No_Node;
begin
Range_Decl := New_Node (K_Range_Declaration, Token_Location);
......@@ -1635,6 +1638,11 @@ package body Ocarina.FE_REAL.Parser is
return No_Node;
end if;
if Next_Token = T_Sothat then
Scan_Token (T_Sothat);
Expr := P_Expression;
end if;
-- Scan 'do'
Scan_Token (T_Do);
......@@ -1643,6 +1651,7 @@ package body Ocarina.FE_REAL.Parser is
return No_Node;
end if;
Set_Range_Expression (Range_Decl, Expr);
Set_Range_Variable (Range_Decl, Elem);
Set_Range_Set (Range_Decl, Set_Expr);
Set_Variable_Ref (Range_Decl,
......@@ -1864,17 +1873,21 @@ package body Ocarina.FE_REAL.Parser is
Success : Boolean := True;
State : Location;
begin
Buffer := From;
if To /= No_Location then
Buffer.EOF := To.Last_Pos;
end if;
Restore_Lexer (Buffer);
Set_Theorems (Root, New_List (K_List_Id, From));
Scan_Token;
while Token = T_Theorem loop
N := P_Theorem;
Skip_To_Theorem_End (Success);
if No (N) or else not Success then
......@@ -1883,6 +1896,7 @@ package body Ocarina.FE_REAL.Parser is
Success := False;
exit;
end if;
Append_Node_To_List (N, Theorems (Root));
-- Pass to the next theorem
......
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