diff --git a/src/backends/ocarina-backends-c_common-mapping.adb b/src/backends/ocarina-backends-c_common-mapping.adb index a720b0e5073c4edfdd004a24dda9aa99b3fbec5d..217f4ad6b55e4add66de8bd2b4ea9be0f982d4a7 100644 --- a/src/backends/ocarina-backends-c_common-mapping.adb +++ b/src/backends/ocarina-backends-c_common-mapping.adb @@ -1951,113 +1951,111 @@ package body Ocarina.Backends.C_Common.Mapping is -- mapped in the case of pure call sequence subprogram because -- 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 - 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; + if not AINU.Is_Empty (Features (S)) then + F := AIN.First_Node (Features (S)); - 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; + 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; - when others => - Display_Located_Error - (AIN.Loc (F), - "Unsupported data type", - Fatal => True); - end case; - end if; + D := Corresponding_Instance (F); - F := AIN.Next_Node (F); - end loop; - end if; + 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); + + 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; N := diff --git a/src/backends/ocarina-backends-c_tree-nutils.adb b/src/backends/ocarina-backends-c_tree-nutils.adb index c2ec3db2d3962e0ec25b6e540e6912191a5bbf3c..9fa5c2454ad2dd322287714661cc5347d23d26f3 100644 --- a/src/backends/ocarina-backends-c_tree-nutils.adb +++ b/src/backends/ocarina-backends-c_tree-nutils.adb @@ -1627,7 +1627,6 @@ package body Ocarina.Backends.C_Tree.Nutils is N : Node_Id; F : Node_Id; M : Node_Id; - Owner : Node_Id; Declaration : Node_Id; Data_Accessed : Node_Id; Hybrid : constant Boolean := @@ -1933,15 +1932,6 @@ package body Ocarina.Backends.C_Tree.Nutils is N := Message_Comment ("Invoking method"); 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 -- corresponding subprogram spec instance (last element -- of the 'Path' list) and from the actual data component