Commit 7600dca4 authored by Julien's avatar Julien

Fix subprogram calls for shared data

Fixes #49
parent 5fbcffdf
...@@ -1951,113 +1951,111 @@ package body Ocarina.Backends.C_Common.Mapping is ...@@ -1951,113 +1951,111 @@ package body Ocarina.Backends.C_Common.Mapping is
-- mapped in the case of pure call sequence subprogram because -- mapped in the case of pure call sequence subprogram because
-- they are used only to close the access chain. -- they are used only to close the access chain.
if Get_Subprogram_Kind (S) /= Subprogram_Pure_Call_Sequence then if not AINU.Is_Empty (Features (S)) then
if not AINU.Is_Empty (Features (S)) then F := AIN.First_Node (Features (S));
F := AIN.First_Node (Features (S));
while Present (F) loop
if Kind (F) = K_Subcomponent_Access_Instance then
case Get_Required_Data_Access (Corresponding_Instance (F)) is
when Access_Read_Only =>
Mode := Mode_In;
when Access_Write_Only =>
Mode := Mode_Out;
when Access_Read_Write =>
Mode := Mode_Inout;
when Access_None =>
-- By default, we allow read/write access
Mode := Mode_Inout;
when others =>
Display_Located_Error
(AIN.Loc (F),
"Unsupported required access",
Fatal => True);
end case;
D := Corresponding_Instance (F);
case Get_Data_Representation (D) is
when Data_Integer |
Data_Boolean |
Data_Float |
Data_Fixed |
Data_Struct |
Data_String |
Data_Wide_String |
Data_Character |
Data_Wide_Character |
Data_Array =>
-- If the data component is a simple data
-- component (not a structure), we simply add a
-- parameter with the computed mode and with a
-- type mapped from the data component.
if Mode = Mode_In then
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (F),
Parameter_Type =>
Map_C_Data_Type_Designator (D));
else
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (F),
Parameter_Type =>
CTU.Make_Pointer_Type
(Map_C_Data_Type_Designator (D)));
end if;
CTU.Append_Node_To_List (Param, Profile); while Present (F) loop
if Kind (F) = K_Subcomponent_Access_Instance then
when Data_With_Accessors => case Get_Required_Data_Access (Corresponding_Instance (F)) is
-- If the data component is a complex data when Access_Read_Only =>
-- component (which has subcomponents), we add a Mode := Mode_In;
-- parameter with the computed mode and with a when Access_Write_Only =>
-- type mapped from each subcomponent type. Mode := Mode_Out;
when Access_Read_Write =>
Field := AIN.First_Node (Subcomponents (D)); Mode := Mode_Inout;
when Access_None =>
while Present (Field) loop -- By default, we allow read/write access
if AINU.Is_Data Mode := Mode_Inout;
(Corresponding_Instance (Field)) when others =>
then Display_Located_Error
if Mode = Mode_In then (AIN.Loc (F),
Param := "Unsupported required access",
CTU.Make_Parameter_Specification Fatal => True);
(Defining_Identifier => end case;
Map_C_Defining_Identifier (Field),
Parameter_Type =>
Map_C_Data_Type_Designator
(Corresponding_Instance (Field)));
else
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (Field),
Parameter_Type =>
Make_Pointer_Type
(Map_C_Data_Type_Designator
(Corresponding_Instance
(Field))));
end if;
CTU.Append_Node_To_List (Param, Profile);
end if;
Field := AIN.Next_Node (Field);
end loop;
when others => D := Corresponding_Instance (F);
Display_Located_Error
(AIN.Loc (F),
"Unsupported data type",
Fatal => True);
end case;
end if;
F := AIN.Next_Node (F); case Get_Data_Representation (D) is
end loop; when Data_Integer |
end if; Data_Boolean |
Data_Float |
Data_Fixed |
Data_Struct |
Data_String |
Data_Wide_String |
Data_Character |
Data_Wide_Character |
Data_Array =>
-- If the data component is a simple data
-- component (not a structure), we simply add a
-- parameter with the computed mode and with a
-- type mapped from the data component.
if Mode = Mode_In then
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (F),
Parameter_Type =>
Map_C_Data_Type_Designator (D));
else
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (F),
Parameter_Type =>
CTU.Make_Pointer_Type
(Map_C_Data_Type_Designator (D)));
end if;
CTU.Append_Node_To_List (Param, Profile);
when Data_With_Accessors =>
-- If the data component is a complex data
-- component (which has subcomponents), we add a
-- parameter with the computed mode and with a
-- type mapped from each subcomponent type.
Field := AIN.First_Node (Subcomponents (D));
while Present (Field) loop
if AINU.Is_Data
(Corresponding_Instance (Field))
then
if Mode = Mode_In then
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (Field),
Parameter_Type =>
Map_C_Data_Type_Designator
(Corresponding_Instance (Field)));
else
Param :=
CTU.Make_Parameter_Specification
(Defining_Identifier =>
Map_C_Defining_Identifier (Field),
Parameter_Type =>
Make_Pointer_Type
(Map_C_Data_Type_Designator
(Corresponding_Instance
(Field))));
end if;
CTU.Append_Node_To_List (Param, Profile);
end if;
Field := AIN.Next_Node (Field);
end loop;
when others =>
Display_Located_Error
(AIN.Loc (F),
"Unsupported data type",
Fatal => True);
end case;
end if;
F := AIN.Next_Node (F);
end loop;
end if; end if;
N := N :=
......
...@@ -1627,7 +1627,6 @@ package body Ocarina.Backends.C_Tree.Nutils is ...@@ -1627,7 +1627,6 @@ package body Ocarina.Backends.C_Tree.Nutils is
N : Node_Id; N : Node_Id;
F : Node_Id; F : Node_Id;
M : Node_Id; M : Node_Id;
Owner : Node_Id;
Declaration : Node_Id; Declaration : Node_Id;
Data_Accessed : Node_Id; Data_Accessed : Node_Id;
Hybrid : constant Boolean := Hybrid : constant Boolean :=
...@@ -1933,15 +1932,6 @@ package body Ocarina.Backends.C_Tree.Nutils is ...@@ -1933,15 +1932,6 @@ package body Ocarina.Backends.C_Tree.Nutils is
N := Message_Comment ("Invoking method"); N := Message_Comment ("Invoking method");
CTU.Append_Node_To_List (N, Statements); CTU.Append_Node_To_List (N, Statements);
Owner := Get_Actual_Owner (Spg_Call);
N :=
Make_Variable_Address
(CTN.Defining_Identifier
(CTN.Object_Node (Backend_Node (Identifier (Owner)))));
Append_Node_To_List (N, Call_Profile);
-- The name of the called subprogram is deduced from the -- The name of the called subprogram is deduced from the
-- corresponding subprogram spec instance (last element -- corresponding subprogram spec instance (last element
-- of the 'Path' list) and from the actual data component -- of the 'Path' list) and from the actual data component
......
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