diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-06-06 20:35:31 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-06-08 18:20:24 +0200 |
commit | 26800bcded59eb5a71e784251a07b8f4336dd889 (patch) | |
tree | d11fd0fe5358cf3cf54e98cf9382fe22f515de4b /src/vhdl/evaluation.adb | |
parent | 2acef3b08a36328d00b8249f003bc7185ad1cb40 (diff) | |
download | ghdl-26800bcded59eb5a71e784251a07b8f4336dd889.tar.gz ghdl-26800bcded59eb5a71e784251a07b8f4336dd889.tar.bz2 ghdl-26800bcded59eb5a71e784251a07b8f4336dd889.zip |
evaluation: handle to_string for arrays.
Fix #598
Diffstat (limited to 'src/vhdl/evaluation.adb')
-rw-r--r-- | src/vhdl/evaluation.adb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index 603f8af21..89d56634e 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -688,6 +688,36 @@ package body Evaluation is when Iir_Predefined_Integer_To_String => return Eval_Integer_Image (Get_Value (Operand), Orig); + when Iir_Predefined_Array_Char_To_String => + -- LRM08 5.7 String representation + -- - For a given value that is of a one-dimensional array type + -- whose element type is a character type that contains only + -- character literals, the string representation has the same + -- length as the given value. Each element of the string + -- representation is the same character literal as the matching + -- element of the given value. + declare + Saggr : Iir; + Lits : Iir_Flist; + El : Iir; + C : Character; + String_Id : String8_Id; + Len : Natural; + begin + Saggr := Eval_String_Literal (Operand); + Lits := Get_Simple_Aggregate_List (Saggr); + Len := Get_Nbr_Elements (Lits); + String_Id := Str_Table.Create_String8; + for I in Flist_First .. Flist_Last (Lits) loop + El := Get_Nth_Element (Lits, I); + C := Get_Character (Get_Identifier (El)); + Str_Table.Append_String8_Char (C); + end loop; + Free_Eval_String_Literal (Saggr, Operand); + + return Build_String (String_Id, Nat32 (Len), Orig); + end; + when Iir_Predefined_Vector_Minimum | Iir_Predefined_Vector_Maximum => -- LRM08 5.3.2.4 Predefined operations on array types |