@@ -768,6 +768,8 @@ package body Tree_Walk is
768
768
Make_Pointer_Type (Do_Type_Reference (LHS_Element_Type));
769
769
RHS_Data_Type : constant Irep :=
770
770
Make_Pointer_Type (Do_Type_Reference (RHS_Element_Type));
771
+ LHS_fun_call : constant Irep :=
772
+ Fresh_Var_Symbol_Expr (LHS_Data_Type, " copy_fun_lhs" );
771
773
begin
772
774
if not Can_Get_Array_Index_Type (Name (N)) then
773
775
Report_Unhandled_Node_Empty (N, " Do_Array_Assignment" ,
@@ -836,6 +838,7 @@ package body Tree_Walk is
836
838
837
839
Append_Op (Ret, Make_Code_Function_Call (I_Function => Copy_Func,
838
840
Arguments => Copy_Args,
841
+ Lhs => LHS_fun_call,
839
842
Source_Location => Sloc (N)));
840
843
841
844
return Ret;
@@ -3767,7 +3770,11 @@ package body Tree_Walk is
3767
3770
Set_Iter (Body_Loop, Make_Increment (Counter_Sym, Index_Type, 1 ));
3768
3771
Set_Lhs (Loop_Test, Counter_Sym);
3769
3772
Set_Rhs (Loop_Test, Param_Symbol (Len_Arg));
3773
+ Set_Type (I => Loop_Test,
3774
+ Value => Make_Bool_Type);
3770
3775
Set_Cond (Body_Loop, Loop_Test);
3776
+ Set_Init (I => Body_Loop,
3777
+ Value => Make_Nil (Sloc (RHS_Element_Type)));
3771
3778
3772
3779
Set_Lhs (Loop_Assign,
3773
3780
Make_Pointer_Index (Param_Symbol (Write_Ptr_Arg),
@@ -3831,10 +3838,12 @@ package body Tree_Walk is
3831
3838
Len_Arg : constant Irep := New_Irep (I_Code_Parameter);
3832
3839
Len_Type : constant Irep := Do_Type_Reference (Index_Type);
3833
3840
Func_Symbol : Symbol;
3841
+ Alloc_Symbol : Symbol;
3834
3842
Map_Size_Str : constant String :=
3835
3843
Integer'Image (Integer (Array_Dup_Map.Length));
3836
3844
Func_Name : constant String :=
3837
3845
" __ada_dup_array" & Map_Size_Str (2 .. Map_Size_Str'Last);
3846
+ Alloc_Name : constant String := " __new_array" ;
3838
3847
Array_Copy : constant Irep :=
3839
3848
Fresh_Var_Symbol_Expr (Ptr_Type, " new_array" );
3840
3849
Array_Alloc : constant Irep :=
@@ -3843,6 +3852,9 @@ package body Tree_Walk is
3843
3852
Call_Inst : constant Irep := New_Irep (I_Code_Function_Call);
3844
3853
Call_Args : constant Irep := New_Irep (I_Argument_List);
3845
3854
Return_Inst : constant Irep := New_Irep (I_Code_Return);
3855
+ Lhs_fun_call : constant Irep :=
3856
+ Fresh_Var_Symbol_Expr (Do_Type_Reference (Element_Type),
3857
+ " array_dup_fun_lhs" );
3846
3858
3847
3859
begin
3848
3860
@@ -3866,6 +3878,8 @@ package body Tree_Walk is
3866
3878
Append_Argument (Call_Args, Param_Symbol (Ptr_Arg));
3867
3879
Append_Argument (Call_Args, Param_Symbol (Len_Arg));
3868
3880
Set_Arguments (Call_Inst, Call_Args);
3881
+ Set_Lhs (I => Call_Inst,
3882
+ Value => Lhs_fun_call);
3869
3883
Set_Function (Call_Inst,
3870
3884
Get_Array_Copy_Function (Element_Type,
3871
3885
Element_Type,
@@ -3883,6 +3897,13 @@ package body Tree_Walk is
3883
3897
Func_Symbol.Mode := Intern (" C" );
3884
3898
Func_Symbol.Value := Body_Block;
3885
3899
Global_Symbol_Table.Insert (Intern (Func_Name), Func_Symbol);
3900
+ -- Add allocation function to symbol table
3901
+ Alloc_Symbol.SymType := Func_Type;
3902
+ Alloc_Symbol.Name := Intern (Alloc_Name);
3903
+ Alloc_Symbol.PrettyName := Alloc_Symbol.Name;
3904
+ Alloc_Symbol.BaseName := Alloc_Symbol.Name;
3905
+ Alloc_Symbol.Mode := Intern (" C" );
3906
+ Global_Symbol_Table.Insert (Intern (Alloc_Name), Alloc_Symbol);
3886
3907
3887
3908
-- Record it for the future:
3888
3909
Array_Dup_Map.Replace_Element (Map_Cursor, Symbol_Expr (Func_Symbol));
0 commit comments