diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-01-18 20:48:19 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-01-20 07:40:53 +0100 |
commit | 06d4264963b8a9b60da7bd87543360424ad3eb23 (patch) | |
tree | 6e954ab99658f5a704973a7b2a1fb66f5c57f565 /src | |
parent | d4a1785b2f6ed8998088b4a1d674801336cd4cb5 (diff) | |
download | ghdl-06d4264963b8a9b60da7bd87543360424ad3eb23.tar.gz ghdl-06d4264963b8a9b60da7bd87543360424ad3eb23.tar.bz2 ghdl-06d4264963b8a9b60da7bd87543360424ad3eb23.zip |
evaluation: remove use of Nam_Buffer.
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/evaluation.adb | 118 | ||||
-rw-r--r-- | src/vhdl/evaluation.ads | 7 | ||||
-rw-r--r-- | src/vhdl/sem_names.adb | 22 |
3 files changed, 61 insertions, 86 deletions
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index 67e3b1ebe..d528a3789 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -1941,30 +1941,32 @@ package body Evaluation is -- LRM08 5.7 String representations -- - [...] otherwise, the string representation is the sequence of -- characters in the identifier that is the given value. - -- FIXME: extended identifier. - Image (Id); - if Nam_Buffer (1) /= '\' then - Append_String8_String (Nam_Buffer (1 .. Nam_Length)); - Len := Nam_Length; - else - declare - Skip : Boolean; - C : Character; - begin - Len := 0; - Skip := False; - for I in 2 .. Nam_Length - 1 loop - if Skip then - Skip := False; - else - C := Nam_Buffer (I); - Append_String8_Char (C); - Skip := C = '\'; - Len := Len + 1; - end if; - end loop; - end; - end if; + declare + Img : constant String := Image (Id); + begin + if Img (Img'First) /= '\' then + Append_String8_String (Img); + Len := Img'Length; + else + declare + Skip : Boolean; + C : Character; + begin + Len := 0; + Skip := False; + for I in Img'First + 1 .. Img'Last - 1 loop + if Skip then + Skip := False; + else + C := Img (I); + Append_String8_Char (C); + Skip := C = '\'; + Len := Len + 1; + end if; + end loop; + end; + end if; + end; end if; return Build_String (Image_Id, Nat32 (Len), Orig); end Eval_Enum_To_String; @@ -2700,14 +2702,15 @@ package body Evaluation is when Iir_Kind_Simple_Name_Attribute => declare use Str_Table; + Img : constant String := + Image (Get_Simple_Name_Identifier (Expr)); Id : String8_Id; begin Id := Create_String8; - Image (Get_Simple_Name_Identifier (Expr)); - for I in 1 .. Nam_Length loop - Append_String8_Char (Nam_Buffer (I)); + for I in Img'Range loop + Append_String8_Char (Img (I)); end loop; - return Build_String (Id, Nat32 (Nam_Length), Expr); + return Build_String (Id, Nat32 (Img'Length), Expr); end; when Iir_Kind_Null_Literal => @@ -3500,63 +3503,33 @@ package body Evaluation is end case; end Eval_Is_Eq; - procedure Eval_Operator_Symbol_Name (Id : Name_Id) - is + function Eval_Operator_Symbol_Name (Id : Name_Id) return String is begin - Image (Id); - Nam_Buffer (2 .. Nam_Length + 1) := Nam_Buffer (1 .. Nam_Length); - Nam_Buffer (1) := '"'; --" - Nam_Length := Nam_Length + 2; - Nam_Buffer (Nam_Length) := '"'; --" + return '"' & Image (Id) & '"'; end Eval_Operator_Symbol_Name; - procedure Eval_Simple_Name (Id : Name_Id) - is + function Eval_Simple_Name (Id : Name_Id) return String is begin -- LRM 14.1 -- E'SIMPLE_NAME -- Result: [...] but with apostrophes (in the case of a character -- literal) if Is_Character (Id) then - Nam_Buffer (1) := '''; - Nam_Buffer (2) := Get_Character (Id); - Nam_Buffer (3) := '''; - Nam_Length := 3; - return; + return ''' & Get_Character (Id) & '''; end if; case Id is when Std_Names.Name_Word_Operators | Std_Names.Name_First_Operator .. Std_Names.Name_Last_Operator => - Eval_Operator_Symbol_Name (Id); - return; + return Eval_Operator_Symbol_Name (Id); when Std_Names.Name_Xnor | Std_Names.Name_Shift_Operators => if Flags.Vhdl_Std > Vhdl_87 then - Eval_Operator_Symbol_Name (Id); - return; + return Eval_Operator_Symbol_Name (Id); end if; when others => null; end case; - Image (Id); --- if Name_Buffer (1) = '\' then --- declare --- I : Natural; --- begin --- I := 2; --- while I <= Name_Length loop --- if Name_Buffer (I) = '\' then --- Name_Length := Name_Length + 1; --- Name_Buffer (I + 1 .. Name_Length) := --- Name_Buffer (I .. Name_Length - 1); --- I := I + 1; --- end if; --- I := I + 1; --- end loop; --- Name_Length := Name_Length + 1; --- Name_Buffer (Name_Length) := '\'; --- end; --- end if; + return Image (Id); end Eval_Simple_Name; package body String_Utils is @@ -3669,11 +3642,9 @@ package body Evaluation is procedure Path_Add_Type_Name (Atype : Iir) is - Adecl : Iir; + Adecl : constant Iir := Get_Type_Declarator (Atype); begin - Adecl := Get_Type_Declarator (Atype); - Image (Get_Identifier (Adecl)); - Path_Add (Nam_Buffer (1 .. Nam_Length)); + Path_Add (Image (Get_Identifier (Adecl))); end Path_Add_Type_Name; procedure Path_Add_Signature (Subprg : Iir) @@ -3700,12 +3671,13 @@ package body Evaluation is Path_Add ("]"); end Path_Add_Signature; - procedure Path_Add_Name (N : Iir) is + procedure Path_Add_Name (N : Iir) + is + Img : constant String := Eval_Simple_Name (Get_Identifier (N)); begin - Eval_Simple_Name (Get_Identifier (N)); - if Nam_Buffer (1) /= 'P' then + if Img (Img'First) /= 'P' then -- Skip anonymous processes. - Path_Add (Nam_Buffer (1 .. Nam_Length)); + Path_Add (Img); end if; end Path_Add_Name; diff --git a/src/vhdl/evaluation.ads b/src/vhdl/evaluation.ads index 12f7a7b77..05feac652 100644 --- a/src/vhdl/evaluation.ads +++ b/src/vhdl/evaluation.ads @@ -166,10 +166,9 @@ package Evaluation is function Eval_Value_Attribute (Value : String; Atype : Iir; Orig : Iir) return Iir; - -- Store into NAME_BUFFER, NAME_LENGTH the simple name, character literal - -- or operator sumbol of ID, using the same format as SIMPLE_NAME - -- attribute. - procedure Eval_Simple_Name (Id : Name_Id); + -- Return the simple name, character literal or operator sumbol of ID, + -- using the same format as SIMPLE_NAME attribute. + function Eval_Simple_Name (Id : Name_Id) return String; -- Compare two string literals (of same length). type Compare_Type is (Compare_Lt, Compare_Eq, Compare_Gt); diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb index 45c5638ca..dd2851899 100644 --- a/src/vhdl/sem_names.adb +++ b/src/vhdl/sem_names.adb @@ -3578,15 +3578,19 @@ package body Sem_Names is case Get_Identifier (Attr) is when Name_Simple_Name => - Res := Create_Iir (Iir_Kind_Simple_Name_Attribute); - Eval_Simple_Name (Get_Identifier (Prefix)); - Set_Simple_Name_Identifier (Res, Name_Table.Get_Identifier); - Attr_Type := Create_Unidim_Array_By_Length - (String_Type_Definition, - Iir_Int64 (Name_Table.Nam_Length), - Attr); - Set_Simple_Name_Subtype (Res, Attr_Type); - Set_Expr_Staticness (Res, Locally); + declare + Id : constant Name_Id := Name_Table.Get_Identifier + (Eval_Simple_Name (Get_Identifier (Prefix))); + begin + Res := Create_Iir (Iir_Kind_Simple_Name_Attribute); + Set_Simple_Name_Identifier (Res, Id); + Attr_Type := Create_Unidim_Array_By_Length + (String_Type_Definition, + Iir_Int64 (Name_Table.Get_Name_Length (Id)), + Attr); + Set_Simple_Name_Subtype (Res, Attr_Type); + Set_Expr_Staticness (Res, Locally); + end; when Name_Path_Name => Res := Create_Iir (Iir_Kind_Path_Name_Attribute); |