diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-05-27 17:50:12 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-05-28 17:47:48 +0200 |
commit | 691d4875f0710e0603a7ae563600f9a6c041c6d6 (patch) | |
tree | 529071dca47189003ebc87cc6e1c6afd5e12b975 /src/vhdl/translate/trans-chap7.adb | |
parent | 58756712b9465c24e1d2a198e5a03aae7ebbf774 (diff) | |
download | ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.tar.gz ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.tar.bz2 ghdl-691d4875f0710e0603a7ae563600f9a6c041c6d6.zip |
ortho: add a length parameter to start_array_aggr.
Diffstat (limited to 'src/vhdl/translate/trans-chap7.adb')
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index 32c8b8537..016132a29 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -266,7 +266,9 @@ package body Trans.Chap7 is Res : O_Cnode; begin Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False); - Start_Array_Aggr (List, Get_Ortho_Type (Aggr_Type, Mode_Value)); + Start_Array_Aggr + (List, Get_Ortho_Type (Aggr_Type, Mode_Value), + Unsigned_32 (Chap3.Get_Static_Array_Length (Aggr_Type))); Translate_Static_Array_Aggregate_1 (List, Aggr, Aggr_Type, 1); Finish_Array_Aggr (List, Res); @@ -283,7 +285,9 @@ package body Trans.Chap7 is Res : O_Cnode; begin Chap3.Translate_Anonymous_Subtype_Definition (Aggr_Type, False); - Start_Array_Aggr (List, Get_Ortho_Type (Aggr_Type, Mode_Value)); + Start_Array_Aggr (List, + Get_Ortho_Type (Aggr_Type, Mode_Value), + Unsigned_32 (Get_Nbr_Elements (El_List))); for I in Flist_First .. Flist_Last (El_List) loop El := Get_Nth_Element (El_List, I); @@ -306,7 +310,9 @@ package body Trans.Chap7 is Chap3.Translate_Anonymous_Subtype_Definition (Lit_Type, False); Arr_Type := Get_Ortho_Type (Lit_Type, Mode_Value); - Start_Array_Aggr (List, Arr_Type); + Start_Array_Aggr + (List, Arr_Type, + Unsigned_32 (Chap3.Get_Static_Array_Length (Lit_Type))); Translate_Static_String_Literal8_Inner (List, Str, Element_Type); @@ -318,12 +324,13 @@ package body Trans.Chap7 is -- The type of the literal element is ELEMENT_TYPE, and the ortho type -- of the string (a constrained array type) is STR_TYPE. function Create_String_Literal_Var_Inner - (Str : Iir; Element_Type : Iir; Str_Type : O_Tnode) return Var_Type + (Str : Iir; Element_Type : Iir; Arr_Type : O_Tnode) return Var_Type is Val_Aggr : O_Array_Aggr_List; Res : O_Cnode; begin - Start_Array_Aggr (Val_Aggr, Str_Type); + Start_Array_Aggr + (Val_Aggr, Arr_Type, Unsigned_32 (Get_String_Length (Str))); case Get_Kind (Str) is when Iir_Kind_String_Literal8 => Translate_Static_String_Literal8_Inner @@ -334,7 +341,7 @@ package body Trans.Chap7 is Finish_Array_Aggr (Val_Aggr, Res); return Create_Global_Const - (Create_Uniq_Identifier, Str_Type, O_Storage_Private, Res); + (Create_Uniq_Identifier, Arr_Type, O_Storage_Private, Res); end Create_String_Literal_Var_Inner; -- Create a variable (constant) for string or bit string literal STR. @@ -344,11 +351,7 @@ package body Trans.Chap7 is Arr_Type : O_Tnode; begin -- Create the string value. - Arr_Type := New_Constrained_Array_Type - (Get_Info (Str_Type).B.Base_Type (Mode_Value), - New_Unsigned_Literal (Ghdl_Index_Type, - Unsigned_64 (Get_String_Length (Str)))); - + Arr_Type := Get_Info (Str_Type).B.Base_Type (Mode_Value); return Create_String_Literal_Var_Inner (Str, Get_Element_Subtype (Str_Type), Arr_Type); end Create_String_Literal_Var; @@ -445,7 +448,8 @@ package body Trans.Chap7 is begin Chap3.Translate_Anonymous_Subtype_Definition (Str_Type, False); - Start_Array_Aggr (List, Get_Ortho_Type (Str_Type, Mode_Value)); + Start_Array_Aggr + (List, Get_Ortho_Type (Str_Type, Mode_Value), Img'Length); for I in Img'Range loop Lit := Get_Nth_Element (Literal_List, Character'Pos (Img (I))); @@ -2913,9 +2917,6 @@ package body Trans.Chap7 is -- Type of the unconstrained array type. Arr_Type : O_Tnode; - -- Type of the constrained array type. - Str_Type : O_Tnode; - Cst : Var_Type; Var_I : O_Dnode; Label : O_Snode; @@ -2928,9 +2929,7 @@ package body Trans.Chap7 is Arr_Type := New_Array_Type (Get_Ortho_Type (Expr_Type, Mode_Value), Ghdl_Index_Type); New_Type_Decl (Create_Uniq_Identifier, Arr_Type); - Str_Type := New_Constrained_Array_Type - (Arr_Type, New_Index_Lit (Unsigned_64 (Len))); - Cst := Create_String_Literal_Var_Inner (Aggr, Expr_Type, Str_Type); + Cst := Create_String_Literal_Var_Inner (Aggr, Expr_Type, Arr_Type); -- Copy it. Open_Temp; |