From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12167 invoked by alias); 9 May 2009 19:58:21 -0000 Received: (qmail 12077 invoked by uid 22791); 9 May 2009 19:58:19 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_20 X-Spam-Check-By: sourceware.org Received: from mailout04.t-online.de (HELO mailout04.t-online.de) (194.25.134.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 May 2009 19:58:13 +0000 Received: from fwd06.aul.t-online.de by mailout04.sul.t-online.de with smtp id 1M2sg8-0000IA-00; Sat, 09 May 2009 21:57:48 +0200 Received: from [192.168.178.27] (XVKZxrZVZhpCum+Bft8RMwOZvB4DHHcecKwRffJKHrl3P-adHoHAqOusKnIKOCIQCn@[84.156.207.241]) by fwd06.aul.t-online.de with esmtp id 1M2sfv-1ED1NI0; Sat, 9 May 2009 21:57:35 +0200 Subject: Re: [gnat] reuse of ASTs already constructed From: oliver.kellogg@t-online.de (Oliver Kellogg) Reply-To: okellogg@users.sourceforge.net To: Robert Dewar Cc: gcc@gcc.gnu.org In-Reply-To: <1241415395.21122.14.camel@tidbit.site> References: <1239557374.7565.37.camel@tidbit.site> <1240083309.4554.45.camel@tidbit.site> <1240175954.4554.50.camel@tidbit.site> <1241385654.4763.38.camel@tidbit.site> <49FE09D9.4090702@adacore.com> <1241386066.4763.42.camel@tidbit.site> <49FE415A.5050601@adacore.com> <1241415395.21122.14.camel@tidbit.site> Content-Type: multipart/mixed; boundary="=-j/Uq4OonJrKyML6It/+V" Date: Sat, 09 May 2009 20:09:00 -0000 Message-Id: <1241899436.5909.14.camel@tidbit.site> Mime-Version: 1.0 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00242.txt.bz2 --=-j/Uq4OonJrKyML6It/+V Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 767 On 2009-05-04, at 07:36 +0200, Oliver Kellogg wrote: > Robert Dewar wrote: > > > > >>>> How about not doing the name expansion in-place but rather > > >>>> storing the expanded name in an extra node field? > > > > You could have a separate vector for expanded names I suppose ... > > So be it. I will change the code to not overwrite the Name field > with the expanded name but rather store the expanded name in a > data structure separate from the Node. > Luckily, this change was limited to the Exp_Dbug package body. FYI I am appending the diff. The new Q_E_Name array holds the Name_Id for the expanded name of a given entity. The implementation as a fixed array is preliminary and I would appreciate suggestions on a better data structure to use. Oliver --=-j/Uq4OonJrKyML6It/+V Content-Disposition: attachment; filename="exp_dbug.adb.diff" Content-Type: text/x-patch; name="exp_dbug.adb.diff"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 6807 Index: exp_dbug.adb =================================================================== --- exp_dbug.adb (revision 147319) +++ exp_dbug.adb (working copy) @@ -55,6 +55,31 @@ Table_Increment => Alloc.Name_Qualify_Units_Increment, Table_Name => "Name_Qualify_Units"); + -- Qualified Entity Name array is indexed by Entity_Id and + -- returns the Name_Id of the qualified name. + + subtype Q_E_Name_Id is Entity_Id + range Entity_Id'First .. Entity_Id'First + 399999; + + Q_E_Name : array (Q_E_Name_Id) of Name_Id := (others => No_Name); + + function Get_Qualified_Name (E : Entity_Id) return Name_Id; + + function Get_Qualified_Name (E : Entity_Id) return Name_Id is + begin + if Original_Operating_Mode /= Generate_Code then + return Chars (E); + else + pragma Assert (E in Q_E_Name_Id); + if Q_E_Name (E) = No_Name then + -- Write_Str ("Exp_Dbug.Get_Qualified_Name: returning Chars"); + -- Write_Eol; + return Chars (E); + end if; + end if; + return Q_E_Name (E); + end Get_Qualified_Name; + -------------------------------- -- Use of Qualification Flags -- -------------------------------- @@ -82,7 +107,7 @@ -- B : Ddd.Ttt; -- procedure Y is .. - -- Here B is a procedure local variable, so it does not need fully + -- Here B is a procedure local variable, so it does not need full -- qualification. The flag Has_Qualified_Name will be set on the -- first attempt to qualify B, to indicate that the job is done -- and need not be redone. @@ -143,8 +168,8 @@ -- Prepend image of universal integer to Name_Buffer, updating Name_Len procedure Qualify_Entity_Name (Ent : Entity_Id); - -- If not already done, replaces the Chars field of the given entity - -- with the appropriate fully qualified name. + -- If not already done, puts the appropriate fully qualified name in the + -- Q_E_Name array element of the given entity. procedure Strip_Suffixes (BNPE_Suffix_Found : in out Boolean); -- Given an qualified entity name in Name_Buffer, remove any plain X or @@ -512,7 +537,7 @@ return; end if; - Get_Name_String (Chars (E)); + Get_Name_String (Get_Qualified_Name (E)); -- Nothing to do if we do not have a type @@ -619,7 +644,8 @@ if Lo_Con then Add_Uint_To_Buffer (Expr_Rep_Value (Lo)); elsif Lo_Discr then - Get_Name_String_And_Append (Chars (Entity (Lo))); + Get_Name_String_And_Append + (Get_Qualified_Name (Entity (Lo))); end if; if Lo_Encode and Hi_Encode then @@ -629,7 +655,8 @@ if Hi_Con then Add_Uint_To_Buffer (Expr_Rep_Value (Hi)); elsif Hi_Discr then - Get_Name_String_And_Append (Chars (Entity (Hi))); + Get_Name_String_And_Append + (Get_Qualified_Name (Entity (Hi))); end if; end if; end; @@ -670,7 +697,7 @@ procedure Get_Qualified_Name_And_Append (Entity : Entity_Id) is begin -- If the entity is a compilation unit, its scope is Standard, - -- there is no outer scope, and the no further qualification + -- there is no outer scope, and no further qualification -- is required. -- If the front end has already computed a fully qualified name, @@ -682,11 +709,11 @@ then Get_Qualified_Name_And_Append (Scope (Entity)); Add_Str_To_Name_Buffer ("__"); - Get_Name_String_And_Append (Chars (Entity)); + Get_Name_String_And_Append (Get_Qualified_Name (Entity)); Append_Homonym_Number (Entity); else - Get_Name_String_And_Append (Chars (Entity)); + Get_Name_String_And_Append (Get_Qualified_Name (Entity)); end if; end Get_Qualified_Name_And_Append; @@ -935,7 +962,7 @@ return Name_Id is begin - Get_Name_String (Chars (Typ)); + Get_Name_String (Get_Qualified_Name (Typ)); Add_Str_To_Name_Buffer ("___XP"); Add_Uint_To_Buffer (Csize); return Name_Find; @@ -1077,9 +1104,6 @@ BNPE_Suffix_Needed : Boolean := False; -- Set true if a body-nested package entity suffix is required - Save_Chars : constant Name_Id := Chars (Ent); - -- Save original name - ------------------------ -- Fully_Qualify_Name -- ------------------------ @@ -1110,7 +1134,7 @@ -- If we reached fully qualified name, then just copy it if Has_Fully_Qualified_Name (E) then - Get_Name_String (Chars (E)); + Get_Name_String (Get_Qualified_Name (E)); Strip_Suffixes (Discard); Full_Qualify_Name (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); Full_Qualify_Len := Name_Len; @@ -1221,7 +1245,7 @@ -- will be separately put on later. if Has_Qualified_Name (E) then - Get_Name_String_And_Append (Chars (E)); + Get_Name_String_And_Append (Get_Qualified_Name (E)); Strip_Suffixes (BNPE_Suffix_Needed); -- If the top level name we are adding is itself fully @@ -1306,13 +1330,13 @@ Name_Len := Name_Len + Insert_Len; end; - -- Reset the name of the variable to the new name that includes the + -- Store in Q_E_Name the new name that includes the -- name of the renamed entity. - Set_Chars (Ent, Name_Enter); + Q_E_Name (Ent) := Name_Enter; -- If the entity needs qualification by its scope then develop it - -- here, add the variable's name, and again reset the entity name. + -- here, add the variable's name, and store it in Q_E_Name. if Qualify_Needed (Scope (Ent)) then Name_Len := 0; @@ -1321,7 +1345,7 @@ Get_Name_String_And_Append (Chars (Ent)); - Set_Chars (Ent, Name_Enter); + Q_E_Name (Ent) := Name_Enter; end if; Set_Has_Qualified_Name (Ent); @@ -1365,14 +1389,14 @@ Name_Len := Name_Len - 1; end if; - Set_Chars (Ent, Name_Enter); + Q_E_Name (Ent) := Name_Enter; Set_Has_Qualified_Name (Ent); if Debug_Flag_BB then Write_Str ("*** "); - Write_Name (Save_Chars); + Write_Name (Chars (Ent)); Write_Str (" qualified as "); - Write_Name (Chars (Ent)); + Write_Name (Q_E_Name (Ent)); Write_Eol; end if; end Qualify_Entity_Name; --=-j/Uq4OonJrKyML6It/+V--