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;