1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1996-2016, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Alloc
; use Alloc
;
27 with Atree
; use Atree
;
28 with Debug
; use Debug
;
29 with Einfo
; use Einfo
;
30 with Nlists
; use Nlists
;
31 with Nmake
; use Nmake
;
33 with Output
; use Output
;
34 with Sem_Aux
; use Sem_Aux
;
35 with Sem_Eval
; use Sem_Eval
;
36 with Sem_Util
; use Sem_Util
;
37 with Sinfo
; use Sinfo
;
38 with Stand
; use Stand
;
39 with Stringt
; use Stringt
;
41 with Tbuild
; use Tbuild
;
42 with Urealp
; use Urealp
;
44 package body Exp_Dbug
is
46 -- The following table is used to queue up the entities passed as
47 -- arguments to Qualify_Entity_Names for later processing when
48 -- Qualify_All_Entity_Names is called.
50 package Name_Qualify_Units
is new Table
.Table
(
51 Table_Component_Type
=> Node_Id
,
52 Table_Index_Type
=> Nat
,
54 Table_Initial
=> Alloc
.Name_Qualify_Units_Initial
,
55 Table_Increment
=> Alloc
.Name_Qualify_Units_Increment
,
56 Table_Name
=> "Name_Qualify_Units");
58 --------------------------------
59 -- Use of Qualification Flags --
60 --------------------------------
62 -- There are two flags used to keep track of qualification of entities
64 -- Has_Fully_Qualified_Name
67 -- The difference between these is as follows. Has_Qualified_Name is
68 -- set to indicate that the name has been qualified as required by the
69 -- spec of this package. As described there, this may involve the full
70 -- qualification for the name, but for some entities, notably procedure
71 -- local variables, this full qualification is not required.
73 -- The flag Has_Fully_Qualified_Name is set if indeed the name has been
74 -- fully qualified in the Ada sense. If Has_Fully_Qualified_Name is set,
75 -- then Has_Qualified_Name is also set, but the other way round is not
78 -- Consider the following example:
85 -- Here B is a procedure local variable, so it does not need fully
86 -- qualification. The flag Has_Qualified_Name will be set on the
87 -- first attempt to qualify B, to indicate that the job is done
88 -- and need not be redone.
90 -- But Y is qualified as x__y, since procedures are always fully
91 -- qualified, so the first time that an attempt is made to qualify
92 -- the name y, it will be replaced by x__y, and both flags are set.
94 -- Why the two flags? Well there are cases where we derive type names
95 -- from object names. As noted in the spec, type names are always
96 -- fully qualified. Suppose for example that the backend has to build
97 -- a padded type for variable B. then it will construct the PAD name
98 -- from B, but it requires full qualification, so the fully qualified
99 -- type name will be x__b___PAD. The two flags allow the circuit for
100 -- building this name to realize efficiently that b needs further
107 -- The string defined here (and its associated length) is used to gather
108 -- the homonym string that will be appended to Name_Buffer when the name
109 -- is complete. Strip_Suffixes appends to this string as does
110 -- Append_Homonym_Number, and Output_Homonym_Numbers_Suffix appends the
111 -- string to the end of Name_Buffer.
113 Homonym_Numbers
: String (1 .. 256);
114 Homonym_Len
: Natural := 0;
116 ----------------------
117 -- Local Procedures --
118 ----------------------
120 procedure Add_Uint_To_Buffer
(U
: Uint
);
121 -- Add image of universal integer to Name_Buffer, updating Name_Len
123 procedure Add_Real_To_Buffer
(U
: Ureal
);
124 -- Add nnn_ddd to Name_Buffer, where nnn and ddd are integer values of
125 -- the normalized numerator and denominator of the given real value.
127 procedure Append_Homonym_Number
(E
: Entity_Id
);
128 -- If the entity E has homonyms in the same scope, then make an entry
129 -- in the Homonym_Numbers array, bumping Homonym_Count accordingly.
131 function Bounds_Match_Size
(E
: Entity_Id
) return Boolean;
132 -- Determine whether the bounds of E match the size of the type. This is
133 -- used to determine whether encoding is required for a discrete type.
135 function Is_Handled_Scale_Factor
(U
: Ureal
) return Boolean;
136 -- The argument U is the Small_Value of a fixed-point type. This function
137 -- determines whether the back-end can handle this scale factor. When it
138 -- cannot, we have to output a GNAT encoding for the corresponding type.
140 procedure Output_Homonym_Numbers_Suffix
;
141 -- If homonym numbers are stored, then output them into Name_Buffer
143 procedure Prepend_String_To_Buffer
(S
: String);
144 -- Prepend given string to the contents of the string buffer, updating
145 -- the value in Name_Len (i.e. string is added at start of buffer).
147 procedure Prepend_Uint_To_Buffer
(U
: Uint
);
148 -- Prepend image of universal integer to Name_Buffer, updating Name_Len
150 procedure Qualify_Entity_Name
(Ent
: Entity_Id
);
151 -- If not already done, replaces the Chars field of the given entity
152 -- with the appropriate fully qualified name.
154 procedure Reset_Buffers
;
155 -- Reset the contents of Name_Buffer and Homonym_Numbers by setting their
156 -- respective lengths to zero.
158 procedure Strip_Suffixes
(BNPE_Suffix_Found
: in out Boolean);
159 -- Given an qualified entity name in Name_Buffer, remove any plain X or
160 -- X{nb} qualification suffix. The contents of Name_Buffer is not changed
161 -- but Name_Len may be adjusted on return to remove the suffix. If a
162 -- BNPE suffix is found and stripped, then BNPE_Suffix_Found is set to
163 -- True. If no suffix is found, then BNPE_Suffix_Found is not modified.
164 -- This routine also searches for a homonym suffix, and if one is found
165 -- it is also stripped, and the entries are added to the global homonym
166 -- list (Homonym_Numbers) so that they can later be put back.
168 ------------------------
169 -- Add_Real_To_Buffer --
170 ------------------------
172 procedure Add_Real_To_Buffer
(U
: Ureal
) is
174 Add_Uint_To_Buffer
(Norm_Num
(U
));
175 Add_Str_To_Name_Buffer
("_");
176 Add_Uint_To_Buffer
(Norm_Den
(U
));
177 end Add_Real_To_Buffer
;
179 ------------------------
180 -- Add_Uint_To_Buffer --
181 ------------------------
183 procedure Add_Uint_To_Buffer
(U
: Uint
) is
186 Add_Uint_To_Buffer
(-U
);
187 Add_Char_To_Name_Buffer
('m');
189 UI_Image
(U
, Decimal
);
190 Add_Str_To_Name_Buffer
(UI_Image_Buffer
(1 .. UI_Image_Length
));
192 end Add_Uint_To_Buffer
;
194 ---------------------------
195 -- Append_Homonym_Number --
196 ---------------------------
198 procedure Append_Homonym_Number
(E
: Entity_Id
) is
200 procedure Add_Nat_To_H
(Nr
: Nat
);
201 -- Little procedure to append Nr to Homonym_Numbers
207 procedure Add_Nat_To_H
(Nr
: Nat
) is
210 Add_Nat_To_H
(Nr
/ 10);
213 Homonym_Len
:= Homonym_Len
+ 1;
214 Homonym_Numbers
(Homonym_Len
) :=
215 Character'Val (Nr
mod 10 + Character'Pos ('0'));
218 -- Start of processing for Append_Homonym_Number
221 if Has_Homonym
(E
) then
223 H
: Entity_Id
:= Homonym
(E
);
227 while Present
(H
) loop
228 if Scope
(H
) = Scope
(E
) then
235 if Homonym_Len
> 0 then
236 Homonym_Len
:= Homonym_Len
+ 1;
237 Homonym_Numbers
(Homonym_Len
) := '_';
243 end Append_Homonym_Number
;
245 -----------------------
246 -- Bounds_Match_Size --
247 -----------------------
249 function Bounds_Match_Size
(E
: Entity_Id
) return Boolean is
253 if not Is_OK_Static_Subtype
(E
) then
256 elsif Is_Integer_Type
(E
)
257 and then Subtypes_Statically_Match
(E
, Base_Type
(E
))
261 -- Here we check if the static bounds match the natural size, which is
262 -- the size passed through with the debugging information. This is the
263 -- Esize rounded up to 8, 16, 32 or 64 as appropriate.
267 Umark
: constant Uintp
.Save_Mark
:= Uintp
.Mark
;
271 if Esize
(E
) <= 8 then
273 elsif Esize
(E
) <= 16 then
275 elsif Esize
(E
) <= 32 then
281 if Is_Modular_Integer_Type
(E
) or else Is_Enumeration_Type
(E
) then
283 Expr_Rep_Value
(Type_Low_Bound
(E
)) = 0
285 2 ** Siz
- Expr_Rep_Value
(Type_High_Bound
(E
)) = 1;
289 Expr_Rep_Value
(Type_Low_Bound
(E
)) + 2 ** (Siz
- 1) = 0
291 2 ** (Siz
- 1) - Expr_Rep_Value
(Type_High_Bound
(E
)) = 1;
298 end Bounds_Match_Size
;
300 --------------------------------
301 -- Debug_Renaming_Declaration --
302 --------------------------------
304 function Debug_Renaming_Declaration
(N
: Node_Id
) return Node_Id
is
305 Loc
: constant Source_Ptr
:= Sloc
(N
);
306 Ent
: constant Node_Id
:= Defining_Entity
(N
);
307 Nam
: constant Node_Id
:= Name
(N
);
313 Enable
: Boolean := Nkind
(N
) = N_Package_Renaming_Declaration
;
314 -- By default, we do not generate an encoding for renaming. This is
315 -- however done (in which case this is set to True) in a few cases:
316 -- - when a package is renamed,
317 -- - when the renaming involves a packed array,
318 -- - when the renaming involves a packed record.
320 procedure Enable_If_Packed_Array
(N
: Node_Id
);
321 -- Enable encoding generation if N is a packed array
323 function Output_Subscript
(N
: Node_Id
; S
: String) return Boolean;
324 -- Outputs a single subscript value as ?nnn (subscript is compile time
325 -- known value with value nnn) or as ?e (subscript is local constant
326 -- with name e), where S supplies the proper string to use for ?.
327 -- Returns False if the subscript is not of an appropriate type to
328 -- output in one of these two forms. The result is prepended to the
329 -- name stored in Name_Buffer.
331 ----------------------------
332 -- Enable_If_Packed_Array --
333 ----------------------------
335 procedure Enable_If_Packed_Array
(N
: Node_Id
) is
336 T
: constant Entity_Id
:= Underlying_Type
(Etype
(N
));
340 Enable
or else (Ekind
(T
) in Array_Kind
341 and then Present
(Packed_Array_Impl_Type
(T
)));
342 end Enable_If_Packed_Array
;
344 ----------------------
345 -- Output_Subscript --
346 ----------------------
348 function Output_Subscript
(N
: Node_Id
; S
: String) return Boolean is
350 if Compile_Time_Known_Value
(N
) then
351 Prepend_Uint_To_Buffer
(Expr_Value
(N
));
353 elsif Nkind
(N
) = N_Identifier
354 and then Scope
(Entity
(N
)) = Scope
(Ent
)
355 and then Ekind
(Entity
(N
)) = E_Constant
357 Prepend_String_To_Buffer
(Get_Name_String
(Chars
(Entity
(N
))));
363 Prepend_String_To_Buffer
(S
);
365 end Output_Subscript
;
367 -- Start of processing for Debug_Renaming_Declaration
370 if not Comes_From_Source
(N
)
371 and then not Needs_Debug_Info
(Ent
)
376 -- Get renamed entity and compute suffix
385 when N_Expanded_Name
=>
387 -- The entity field for an N_Expanded_Name is on the expanded
388 -- name node itself, so we are done here too.
392 when N_Selected_Component
=>
394 First_Bit
: constant Uint
:=
396 (Entity
(Selector_Name
(Ren
)));
402 (Underlying_Type
(Etype
(Prefix
(Ren
))))
403 or else (First_Bit
/= No_Uint
404 and then First_Bit
/= Uint_0
);
407 Prepend_String_To_Buffer
408 (Get_Name_String
(Chars
(Selector_Name
(Ren
))));
409 Prepend_String_To_Buffer
("XR");
412 when N_Indexed_Component
=>
417 Enable_If_Packed_Array
(Prefix
(Ren
));
419 X
:= Last
(Expressions
(Ren
));
420 while Present
(X
) loop
421 if not Output_Subscript
(X
, "XS") then
422 Set_Materialize_Entity
(Ent
);
433 Enable_If_Packed_Array
(Prefix
(Ren
));
434 Typ
:= Etype
(First_Index
(Etype
(Nam
)));
436 if not Output_Subscript
(Type_High_Bound
(Typ
), "XS") then
437 Set_Materialize_Entity
(Ent
);
441 if not Output_Subscript
(Type_Low_Bound
(Typ
), "XL") then
442 Set_Materialize_Entity
(Ent
);
448 when N_Explicit_Dereference
=>
449 Prepend_String_To_Buffer
("XA");
452 -- For now, anything else simply results in no translation
455 Set_Materialize_Entity
(Ent
);
460 -- If we found no reason here to emit an encoding, stop now
463 Set_Materialize_Entity
(Ent
);
467 Prepend_String_To_Buffer
("___XE");
469 -- Include the designation of the form of renaming
472 when N_Object_Renaming_Declaration
=>
473 Prepend_String_To_Buffer
("___XR");
475 when N_Exception_Renaming_Declaration
=>
476 Prepend_String_To_Buffer
("___XRE");
478 when N_Package_Renaming_Declaration
=>
479 Prepend_String_To_Buffer
("___XRP");
485 -- Add the name of the renaming entity to the front
487 Prepend_String_To_Buffer
(Get_Name_String
(Chars
(Ent
)));
489 -- If it is a child unit create a fully qualified name, to disambiguate
490 -- multiple child units with the same name and different parents.
492 if Nkind
(N
) = N_Package_Renaming_Declaration
493 and then Is_Child_Unit
(Ent
)
495 Prepend_String_To_Buffer
("__");
496 Prepend_String_To_Buffer
497 (Get_Name_String
(Chars
(Scope
(Ent
))));
500 -- Create the special object whose name is the debug encoding for the
501 -- renaming declaration.
503 -- For now, the object name contains the suffix encoding for the renamed
504 -- object, but not the name of the leading entity. The object is linked
505 -- the renamed entity using the Debug_Renaming_Link field. Then the
506 -- Qualify_Entity_Name procedure uses this link to create the proper
507 -- fully qualified name.
509 -- The reason we do things this way is that we really need to copy the
510 -- qualification of the renamed entity, and it is really much easier to
511 -- do this after the renamed entity has itself been fully qualified.
513 Obj
:= Make_Defining_Identifier
(Loc
, Chars
=> Name_Enter
);
515 Make_Object_Declaration
(Loc
,
516 Defining_Identifier
=> Obj
,
517 Object_Definition
=> New_Occurrence_Of
518 (Standard_Debug_Renaming_Type
, Loc
));
520 Set_Debug_Renaming_Link
(Obj
, Entity
(Ren
));
522 Set_Debug_Info_Needed
(Obj
);
524 -- The renamed entity may be a temporary, e.g. the result of an
525 -- implicit dereference in an iterator. Indicate that the temporary
526 -- itself requires debug information. If the renamed entity comes
527 -- from source this is a no-op.
529 Set_Debug_Info_Needed
(Entity
(Ren
));
531 -- Mark the object as internal so that it won't be initialized when
532 -- pragma Initialize_Scalars or Normalize_Scalars is in use.
534 Set_Is_Internal
(Obj
);
538 -- If we get an exception, just figure it is a case that we cannot
539 -- successfully handle using our current approach, since this is
540 -- only for debugging, no need to take the compilation with us.
544 return Make_Null_Statement
(Loc
);
545 end Debug_Renaming_Declaration
;
547 -----------------------------
548 -- Is_Handled_Scale_Factor --
549 -----------------------------
551 function Is_Handled_Scale_Factor
(U
: Ureal
) return Boolean is
553 -- Keep in sync with gigi (see E_*_Fixed_Point_Type handling in
554 -- decl.c:gnat_to_gnu_entity).
556 if UI_Eq
(Numerator
(U
), Uint_1
) then
557 if Rbase
(U
) = 2 or else Rbase
(U
) = 10 then
563 (UI_Is_In_Int_Range
(Norm_Num
(U
))
565 UI_Is_In_Int_Range
(Norm_Den
(U
)));
566 end Is_Handled_Scale_Factor
;
568 ----------------------
569 -- Get_Encoded_Name --
570 ----------------------
572 -- Note: see spec for details on encodings
574 procedure Get_Encoded_Name
(E
: Entity_Id
) is
575 Has_Suffix
: Boolean;
578 -- If not generating code, there is no need to create encoded names, and
579 -- problems when the back-end is called to annotate types without full
580 -- code generation. See comments in Get_External_Name for additional
583 -- However we do create encoded names if the back end is active, even
584 -- if Operating_Mode got reset. Otherwise any serious error reported
585 -- by the backend calling Error_Msg changes the Compilation_Mode to
586 -- Check_Semantics, which disables the functionality of this routine,
587 -- causing the generation of spurious additional errors.
589 -- Couldn't we just test Original_Operating_Mode here? ???
591 if Operating_Mode
/= Generate_Code
and then not Generating_Code
then
595 Get_Name_String
(Chars
(E
));
597 -- Nothing to do if we do not have a type
601 -- Or if this is an enumeration base type
603 or else (Is_Enumeration_Type
(E
) and then Is_Base_Type
(E
))
605 -- Or if this is a dummy type for a renaming
607 or else (Name_Len
>= 3 and then
608 Name_Buffer
(Name_Len
- 2 .. Name_Len
) = "_XR")
610 or else (Name_Len
>= 4 and then
611 (Name_Buffer
(Name_Len
- 3 .. Name_Len
) = "_XRE"
613 Name_Buffer
(Name_Len
- 3 .. Name_Len
) = "_XRP"))
615 -- For all these cases, just return the name unchanged
618 Name_Buffer
(Name_Len
+ 1) := ASCII
.NUL
;
624 -- Fixed-point case: generate GNAT encodings when asked to or when we
625 -- know the back-end will not be able to handle the scale factor.
627 if Is_Fixed_Point_Type
(E
)
628 and then (GNAT_Encodings
/= DWARF_GNAT_Encodings_Minimal
629 or else not Is_Handled_Scale_Factor
(Small_Value
(E
)))
631 Get_External_Name
(E
, True, "XF_");
632 Add_Real_To_Buffer
(Delta_Value
(E
));
634 if Small_Value
(E
) /= Delta_Value
(E
) then
635 Add_Str_To_Name_Buffer
("_");
636 Add_Real_To_Buffer
(Small_Value
(E
));
639 -- Discrete case where bounds do not match size. Not necessary if we can
640 -- emit standard DWARF.
642 elsif GNAT_Encodings
/= DWARF_GNAT_Encodings_Minimal
643 and then Is_Discrete_Type
(E
)
644 and then not Bounds_Match_Size
(E
)
647 Lo
: constant Node_Id
:= Type_Low_Bound
(E
);
648 Hi
: constant Node_Id
:= Type_High_Bound
(E
);
650 Lo_Con
: constant Boolean := Compile_Time_Known_Value
(Lo
);
651 Hi_Con
: constant Boolean := Compile_Time_Known_Value
(Hi
);
653 Lo_Discr
: constant Boolean :=
654 Nkind
(Lo
) = N_Identifier
655 and then Ekind
(Entity
(Lo
)) = E_Discriminant
;
657 Hi_Discr
: constant Boolean :=
658 Nkind
(Hi
) = N_Identifier
659 and then Ekind
(Entity
(Hi
)) = E_Discriminant
;
661 Lo_Encode
: constant Boolean := Lo_Con
or Lo_Discr
;
662 Hi_Encode
: constant Boolean := Hi_Con
or Hi_Discr
;
664 Biased
: constant Boolean := Has_Biased_Representation
(E
);
668 Get_External_Name
(E
, True, "XB");
670 Get_External_Name
(E
, True, "XD");
673 if Lo_Encode
or Hi_Encode
then
675 Add_Str_To_Name_Buffer
("_");
679 Add_Str_To_Name_Buffer
("LU_");
681 Add_Str_To_Name_Buffer
("L_");
684 Add_Str_To_Name_Buffer
("U_");
689 Add_Uint_To_Buffer
(Expr_Rep_Value
(Lo
));
691 Get_Name_String_And_Append
(Chars
(Entity
(Lo
)));
694 if Lo_Encode
and Hi_Encode
then
695 Add_Str_To_Name_Buffer
("__");
699 Add_Uint_To_Buffer
(Expr_Rep_Value
(Hi
));
701 Get_Name_String_And_Append
(Chars
(Entity
(Hi
)));
706 -- For all other cases, the encoded name is the normal type name
710 Get_External_Name
(E
);
713 if Debug_Flag_B
and then Has_Suffix
then
714 Write_Str
("**** type ");
715 Write_Name
(Chars
(E
));
716 Write_Str
(" is encoded as ");
717 Write_Str
(Name_Buffer
(1 .. Name_Len
));
721 Name_Buffer
(Name_Len
+ 1) := ASCII
.NUL
;
722 end Get_Encoded_Name
;
724 -----------------------
725 -- Get_External_Name --
726 -----------------------
728 procedure Get_External_Name
730 Has_Suffix
: Boolean := False;
731 Suffix
: String := "")
733 procedure Get_Qualified_Name_And_Append
(Entity
: Entity_Id
);
734 -- Appends fully qualified name of given entity to Name_Buffer
736 -----------------------------------
737 -- Get_Qualified_Name_And_Append --
738 -----------------------------------
740 procedure Get_Qualified_Name_And_Append
(Entity
: Entity_Id
) is
742 -- If the entity is a compilation unit, its scope is Standard,
743 -- there is no outer scope, and the no further qualification
746 -- If the front end has already computed a fully qualified name,
747 -- then it is also the case that no further qualification is
750 if Present
(Scope
(Scope
(Entity
)))
751 and then not Has_Fully_Qualified_Name
(Entity
)
753 Get_Qualified_Name_And_Append
(Scope
(Entity
));
754 Add_Str_To_Name_Buffer
("__");
755 Get_Name_String_And_Append
(Chars
(Entity
));
756 Append_Homonym_Number
(Entity
);
759 Get_Name_String_And_Append
(Chars
(Entity
));
761 end Get_Qualified_Name_And_Append
;
765 E
: Entity_Id
:= Entity
;
767 -- Start of processing for Get_External_Name
770 -- If we are not in code generation mode, this procedure may still be
771 -- called from Back_End (more specifically - from gigi for doing type
772 -- representation annotation or some representation-specific checks).
773 -- But in this mode there is no need to mess with external names.
775 -- Furthermore, the call causes difficulties in this case because the
776 -- string representing the homonym number is not correctly reset as a
777 -- part of the call to Output_Homonym_Numbers_Suffix (which is not
780 if Operating_Mode
/= Generate_Code
then
786 -- If this is a child unit, we want the child
788 if Nkind
(E
) = N_Defining_Program_Unit_Name
then
789 E
:= Defining_Identifier
(Entity
);
792 -- Case of interface name being used
794 if Ekind_In
(E
, E_Constant
,
799 and then Present
(Interface_Name
(E
))
800 and then No
(Address_Clause
(E
))
801 and then not Has_Suffix
803 Add_String_To_Name_Buffer
(Strval
(Interface_Name
(E
)));
805 -- All other cases besides the interface name case
808 -- If this is a library level subprogram (i.e. a subprogram that is a
809 -- compilation unit other than a subunit), then we prepend _ada_ to
810 -- ensure distinctions required as described in the spec.
812 -- Check explicitly for child units, because those are not flagged
813 -- as Compilation_Units by lib. Should they be ???
816 and then (Is_Compilation_Unit
(E
) or Is_Child_Unit
(E
))
817 and then not Has_Suffix
819 Add_Str_To_Name_Buffer
("_ada_");
822 -- If the entity is a subprogram instance that is not a compilation
823 -- unit, generate the name of the original Ada entity, which is the
826 if Is_Generic_Instance
(E
)
827 and then Is_Subprogram
(E
)
828 and then not Is_Compilation_Unit
(Scope
(E
))
829 and then Ekind_In
(Scope
(E
), E_Package
, E_Package_Body
)
830 and then Present
(Related_Instance
(Scope
(E
)))
832 E
:= Related_Instance
(Scope
(E
));
835 Get_Qualified_Name_And_Append
(E
);
839 Add_Str_To_Name_Buffer
("___");
840 Add_Str_To_Name_Buffer
(Suffix
);
843 Name_Buffer
(Name_Len
+ 1) := ASCII
.NUL
;
844 end Get_External_Name
;
846 --------------------------
847 -- Get_Variant_Encoding --
848 --------------------------
850 procedure Get_Variant_Encoding
(V
: Node_Id
) is
853 procedure Choice_Val
(Typ
: Character; Choice
: Node_Id
);
854 -- Output encoded value for a single choice value. Typ is the key
855 -- character ('S', 'F', or 'T') that precedes the choice value.
861 procedure Choice_Val
(Typ
: Character; Choice
: Node_Id
) is
863 if Nkind
(Choice
) = N_Integer_Literal
then
864 Add_Char_To_Name_Buffer
(Typ
);
865 Add_Uint_To_Buffer
(Intval
(Choice
));
867 -- Character literal with no entity present (this is the case
868 -- Standard.Character or Standard.Wide_Character as root type)
870 elsif Nkind
(Choice
) = N_Character_Literal
871 and then No
(Entity
(Choice
))
873 Add_Char_To_Name_Buffer
(Typ
);
874 Add_Uint_To_Buffer
(Char_Literal_Value
(Choice
));
878 Ent
: constant Entity_Id
:= Entity
(Choice
);
881 if Ekind
(Ent
) = E_Enumeration_Literal
then
882 Add_Char_To_Name_Buffer
(Typ
);
883 Add_Uint_To_Buffer
(Enumeration_Rep
(Ent
));
886 pragma Assert
(Ekind
(Ent
) = E_Constant
);
887 Choice_Val
(Typ
, Constant_Value
(Ent
));
893 -- Start of processing for Get_Variant_Encoding
898 Choice
:= First
(Discrete_Choices
(V
));
899 while Present
(Choice
) loop
900 if Nkind
(Choice
) = N_Others_Choice
then
901 Add_Char_To_Name_Buffer
('O');
903 elsif Nkind
(Choice
) = N_Range
then
904 Choice_Val
('R', Low_Bound
(Choice
));
905 Choice_Val
('T', High_Bound
(Choice
));
907 elsif Is_Entity_Name
(Choice
)
908 and then Is_Type
(Entity
(Choice
))
910 Choice_Val
('R', Type_Low_Bound
(Entity
(Choice
)));
911 Choice_Val
('T', Type_High_Bound
(Entity
(Choice
)));
913 elsif Nkind
(Choice
) = N_Subtype_Indication
then
915 Rang
: constant Node_Id
:=
916 Range_Expression
(Constraint
(Choice
));
918 Choice_Val
('R', Low_Bound
(Rang
));
919 Choice_Val
('T', High_Bound
(Rang
));
923 Choice_Val
('S', Choice
);
929 Name_Buffer
(Name_Len
+ 1) := ASCII
.NUL
;
933 VP
: constant Node_Id
:= Parent
(V
); -- Variant_Part
934 CL
: constant Node_Id
:= Parent
(VP
); -- Component_List
935 RD
: constant Node_Id
:= Parent
(CL
); -- Record_Definition
936 FT
: constant Node_Id
:= Parent
(RD
); -- Full_Type_Declaration
939 Write_Str
("**** variant for type ");
940 Write_Name
(Chars
(Defining_Identifier
(FT
)));
941 Write_Str
(" is encoded as ");
942 Write_Str
(Name_Buffer
(1 .. Name_Len
));
946 end Get_Variant_Encoding
;
948 -----------------------------------------
949 -- Build_Subprogram_Instance_Renamings --
950 -----------------------------------------
952 procedure Build_Subprogram_Instance_Renamings
961 E
:= First_Entity
(Wrapper
);
962 while Present
(E
) loop
963 if Nkind
(Parent
(E
)) = N_Object_Declaration
964 and then Is_Elementary_Type
(Etype
(E
))
966 Loc
:= Sloc
(Expression
(Parent
(E
)));
967 Decl
:= Make_Object_Renaming_Declaration
(Loc
,
968 Defining_Identifier
=>
969 Make_Defining_Identifier
(Loc
, Chars
(E
)),
970 Subtype_Mark
=> New_Occurrence_Of
(Etype
(E
), Loc
),
971 Name
=> New_Occurrence_Of
(E
, Loc
));
973 Append
(Decl
, Declarations
(N
));
974 Set_Needs_Debug_Info
(Defining_Identifier
(Decl
));
979 end Build_Subprogram_Instance_Renamings
;
981 ------------------------------------
982 -- Get_Secondary_DT_External_Name --
983 ------------------------------------
985 procedure Get_Secondary_DT_External_Name
987 Ancestor_Typ
: Entity_Id
;
991 Get_External_Name
(Typ
);
993 if Ancestor_Typ
/= Typ
then
995 Len
: constant Natural := Name_Len
;
996 Save_Str
: constant String (1 .. Name_Len
)
997 := Name_Buffer
(1 .. Name_Len
);
999 Get_External_Name
(Ancestor_Typ
);
1001 -- Append the extended name of the ancestor to the
1002 -- extended name of Typ
1004 Name_Buffer
(Len
+ 2 .. Len
+ Name_Len
+ 1) :=
1005 Name_Buffer
(1 .. Name_Len
);
1006 Name_Buffer
(1 .. Len
) := Save_Str
;
1007 Name_Buffer
(Len
+ 1) := '_';
1008 Name_Len
:= Len
+ Name_Len
+ 1;
1012 Add_Nat_To_Name_Buffer
(Suffix_Index
);
1013 end Get_Secondary_DT_External_Name
;
1015 ---------------------------------
1016 -- Make_Packed_Array_Impl_Type_Name --
1017 ---------------------------------
1019 function Make_Packed_Array_Impl_Type_Name
1025 Get_Name_String
(Chars
(Typ
));
1026 Add_Str_To_Name_Buffer
("___XP");
1027 Add_Uint_To_Buffer
(Csize
);
1029 end Make_Packed_Array_Impl_Type_Name
;
1031 -----------------------------------
1032 -- Output_Homonym_Numbers_Suffix --
1033 -----------------------------------
1035 procedure Output_Homonym_Numbers_Suffix
is
1039 if Homonym_Len
> 0 then
1041 -- Check for all 1's, in which case we do not output
1045 exit when Homonym_Numbers
(J
) /= '1';
1047 -- If we reached end of string we do not output
1049 if J
= Homonym_Len
then
1054 exit when Homonym_Numbers
(J
+ 1) /= '_';
1058 -- If we exit the loop then suffix must be output
1060 Add_Str_To_Name_Buffer
("__");
1061 Add_Str_To_Name_Buffer
(Homonym_Numbers
(1 .. Homonym_Len
));
1064 end Output_Homonym_Numbers_Suffix
;
1066 ------------------------------
1067 -- Prepend_String_To_Buffer --
1068 ------------------------------
1070 procedure Prepend_String_To_Buffer
(S
: String) is
1071 N
: constant Integer := S
'Length;
1073 Name_Buffer
(1 + N
.. Name_Len
+ N
) := Name_Buffer
(1 .. Name_Len
);
1074 Name_Buffer
(1 .. N
) := S
;
1075 Name_Len
:= Name_Len
+ N
;
1076 end Prepend_String_To_Buffer
;
1078 ----------------------------
1079 -- Prepend_Uint_To_Buffer --
1080 ----------------------------
1082 procedure Prepend_Uint_To_Buffer
(U
: Uint
) is
1085 Prepend_String_To_Buffer
("m");
1086 Prepend_Uint_To_Buffer
(-U
);
1088 UI_Image
(U
, Decimal
);
1089 Prepend_String_To_Buffer
(UI_Image_Buffer
(1 .. UI_Image_Length
));
1091 end Prepend_Uint_To_Buffer
;
1093 ------------------------------
1094 -- Qualify_All_Entity_Names --
1095 ------------------------------
1097 procedure Qualify_All_Entity_Names
is
1103 for J
in Name_Qualify_Units
.First
.. Name_Qualify_Units
.Last
loop
1104 Nod
:= Name_Qualify_Units
.Table
(J
);
1106 -- When a scoping construct is ignored Ghost, it is rewritten as
1107 -- a null statement. Skip such constructs as they no longer carry
1110 if Nkind
(Nod
) = N_Null_Statement
then
1114 E
:= Defining_Entity
(Nod
);
1116 Qualify_Entity_Name
(E
);
1118 -- Normally entities in the qualification list are scopes, but in the
1119 -- case of a library-level package renaming there is an associated
1120 -- variable that encodes the debugger name and that variable is
1121 -- entered in the list since it occurs in the Aux_Decls list of the
1122 -- compilation and doesn't have a normal scope.
1124 if Ekind
(E
) /= E_Variable
then
1125 Ent
:= First_Entity
(E
);
1126 while Present
(Ent
) loop
1128 Qualify_Entity_Name
(Ent
);
1131 -- There are odd cases where Last_Entity (E) = E. This happens
1132 -- in the case of renaming of packages. This test avoids
1133 -- getting stuck in such cases.
1142 end Qualify_All_Entity_Names
;
1144 -------------------------
1145 -- Qualify_Entity_Name --
1146 -------------------------
1148 procedure Qualify_Entity_Name
(Ent
: Entity_Id
) is
1150 Full_Qualify_Name
: String (1 .. Name_Buffer
'Length);
1151 Full_Qualify_Len
: Natural := 0;
1152 -- Used to accumulate fully qualified name of subprogram
1154 procedure Fully_Qualify_Name
(E
: Entity_Id
);
1155 -- Used to qualify a subprogram or type name, where full
1156 -- qualification up to Standard is always used. Name is set
1157 -- in Full_Qualify_Name with the length in Full_Qualify_Len.
1158 -- Note that this routine does not prepend the _ada_ string
1159 -- required for library subprograms (this is done in the back end).
1161 function Is_BNPE
(S
: Entity_Id
) return Boolean;
1162 -- Determines if S is a BNPE, i.e. Body-Nested Package Entity, which
1163 -- is defined to be a package which is immediately nested within a
1166 function Qualify_Needed
(S
: Entity_Id
) return Boolean;
1167 -- Given a scope, determines if the scope is to be included in the
1168 -- fully qualified name, True if so, False if not. Blocks and loops
1169 -- are excluded from a qualified name.
1171 procedure Set_BNPE_Suffix
(E
: Entity_Id
);
1172 -- Recursive routine to append the BNPE qualification suffix. Works
1173 -- from right to left with E being the current entity in the list.
1174 -- The result does NOT have the trailing n's and trailing b stripped.
1175 -- The caller must do this required stripping.
1177 procedure Set_Entity_Name
(E
: Entity_Id
);
1178 -- Internal recursive routine that does most of the work. This routine
1179 -- leaves the result sitting in Name_Buffer and Name_Len.
1181 BNPE_Suffix_Needed
: Boolean := False;
1182 -- Set true if a body-nested package entity suffix is required
1184 Save_Chars
: constant Name_Id
:= Chars
(Ent
);
1185 -- Save original name
1187 ------------------------
1188 -- Fully_Qualify_Name --
1189 ------------------------
1191 procedure Fully_Qualify_Name
(E
: Entity_Id
) is
1192 Discard
: Boolean := False;
1195 -- Ignore empty entry (can happen in error cases)
1200 -- If this we are qualifying entities local to a generic instance,
1201 -- use the name of the original instantiation, not that of the
1202 -- anonymous subprogram in the wrapper package, so that gdb doesn't
1203 -- have to know about these.
1205 elsif Is_Generic_Instance
(E
)
1206 and then Is_Subprogram
(E
)
1207 and then not Comes_From_Source
(E
)
1208 and then not Is_Compilation_Unit
(Scope
(E
))
1210 Fully_Qualify_Name
(Related_Instance
(Scope
(E
)));
1214 -- If we reached fully qualified name, then just copy it
1216 if Has_Fully_Qualified_Name
(E
) then
1217 Get_Name_String
(Chars
(E
));
1218 Strip_Suffixes
(Discard
);
1219 Full_Qualify_Name
(1 .. Name_Len
) := Name_Buffer
(1 .. Name_Len
);
1220 Full_Qualify_Len
:= Name_Len
;
1221 Set_Has_Fully_Qualified_Name
(Ent
);
1223 -- Case of non-fully qualified name
1226 if Scope
(E
) = Standard_Standard
then
1227 Set_Has_Fully_Qualified_Name
(Ent
);
1229 Fully_Qualify_Name
(Scope
(E
));
1230 Full_Qualify_Name
(Full_Qualify_Len
+ 1) := '_';
1231 Full_Qualify_Name
(Full_Qualify_Len
+ 2) := '_';
1232 Full_Qualify_Len
:= Full_Qualify_Len
+ 2;
1235 if Has_Qualified_Name
(E
) then
1236 Get_Unqualified_Name_String
(Chars
(E
));
1238 Get_Name_String
(Chars
(E
));
1241 -- Here we do one step of the qualification
1244 (Full_Qualify_Len
+ 1 .. Full_Qualify_Len
+ Name_Len
) :=
1245 Name_Buffer
(1 .. Name_Len
);
1246 Full_Qualify_Len
:= Full_Qualify_Len
+ Name_Len
;
1247 Append_Homonym_Number
(E
);
1251 BNPE_Suffix_Needed
:= True;
1253 end Fully_Qualify_Name
;
1259 function Is_BNPE
(S
: Entity_Id
) return Boolean is
1261 return Ekind
(S
) = E_Package
and then Is_Package_Body_Entity
(S
);
1264 --------------------
1265 -- Qualify_Needed --
1266 --------------------
1268 function Qualify_Needed
(S
: Entity_Id
) return Boolean is
1270 -- If we got all the way to Standard, then we have certainly
1271 -- fully qualified the name, so set the flag appropriately,
1272 -- and then return False, since we are most certainly done.
1274 if S
= Standard_Standard
then
1275 Set_Has_Fully_Qualified_Name
(Ent
, True);
1278 -- Otherwise figure out if further qualification is required
1281 return Is_Subprogram
(Ent
)
1282 or else Ekind
(Ent
) = E_Subprogram_Body
1283 or else (Ekind
(S
) /= E_Block
1284 and then Ekind
(S
) /= E_Loop
1285 and then not Is_Dynamic_Scope
(S
));
1289 ---------------------
1290 -- Set_BNPE_Suffix --
1291 ---------------------
1293 procedure Set_BNPE_Suffix
(E
: Entity_Id
) is
1294 S
: constant Entity_Id
:= Scope
(E
);
1297 if Qualify_Needed
(S
) then
1298 Set_BNPE_Suffix
(S
);
1301 Add_Char_To_Name_Buffer
('b');
1303 Add_Char_To_Name_Buffer
('n');
1307 Add_Char_To_Name_Buffer
('X');
1309 end Set_BNPE_Suffix
;
1311 ---------------------
1312 -- Set_Entity_Name --
1313 ---------------------
1315 procedure Set_Entity_Name
(E
: Entity_Id
) is
1316 S
: constant Entity_Id
:= Scope
(E
);
1319 -- If we reach an already qualified name, just take the encoding
1320 -- except that we strip the package body suffixes, since these
1321 -- will be separately put on later.
1323 if Has_Qualified_Name
(E
) then
1324 Get_Name_String_And_Append
(Chars
(E
));
1325 Strip_Suffixes
(BNPE_Suffix_Needed
);
1327 -- If the top level name we are adding is itself fully
1328 -- qualified, then that means that the name that we are
1329 -- preparing for the Fully_Qualify_Name call will also
1330 -- generate a fully qualified name.
1332 if Has_Fully_Qualified_Name
(E
) then
1333 Set_Has_Fully_Qualified_Name
(Ent
);
1336 -- Case where upper level name is not encoded yet
1339 -- Recurse if further qualification required
1341 if Qualify_Needed
(S
) then
1342 Set_Entity_Name
(S
);
1343 Add_Str_To_Name_Buffer
("__");
1346 -- Otherwise get name and note if it is a BNPE
1348 Get_Name_String_And_Append
(Chars
(E
));
1351 BNPE_Suffix_Needed
:= True;
1354 Append_Homonym_Number
(E
);
1356 end Set_Entity_Name
;
1358 -- Start of processing for Qualify_Entity_Name
1361 if Has_Qualified_Name
(Ent
) then
1364 -- In formal verification mode, simply append a suffix for homonyms.
1365 -- We used to qualify entity names as full expansion does, but this was
1366 -- removed as this prevents the verification back-end from using a short
1367 -- name for debugging and user interaction. The verification back-end
1368 -- already takes care of qualifying names when needed. Still mark the
1369 -- name as being qualified, as Qualify_Entity_Name may be called more
1370 -- than once on the same entity.
1372 elsif GNATprove_Mode
then
1373 if Has_Homonym
(Ent
) then
1374 Get_Name_String
(Chars
(Ent
));
1375 Append_Homonym_Number
(Ent
);
1376 Output_Homonym_Numbers_Suffix
;
1377 Set_Chars
(Ent
, Name_Enter
);
1380 Set_Has_Qualified_Name
(Ent
);
1383 -- If the entity is a variable encoding the debug name for an object
1384 -- renaming, then the qualified name of the entity associated with the
1385 -- renamed object can now be incorporated in the debug name.
1387 elsif Ekind
(Ent
) = E_Variable
1388 and then Present
(Debug_Renaming_Link
(Ent
))
1391 Qualify_Entity_Name
(Debug_Renaming_Link
(Ent
));
1392 Get_Name_String
(Chars
(Ent
));
1394 -- Retrieve the now-qualified name of the renamed entity and insert
1395 -- it in the middle of the name, just preceding the suffix encoding
1396 -- describing the renamed object.
1399 Renamed_Id
: constant String :=
1400 Get_Name_String
(Chars
(Debug_Renaming_Link
(Ent
)));
1401 Insert_Len
: constant Integer := Renamed_Id
'Length + 1;
1402 Index
: Natural := Name_Len
- 3;
1405 -- Loop backwards through the name to find the start of the "___"
1406 -- sequence associated with the suffix.
1408 while Index
>= Name_Buffer
'First
1409 and then (Name_Buffer
(Index
+ 1) /= '_'
1410 or else Name_Buffer
(Index
+ 2) /= '_'
1411 or else Name_Buffer
(Index
+ 3) /= '_')
1416 pragma Assert
(Name_Buffer
(Index
+ 1 .. Index
+ 3) = "___");
1418 -- Insert an underscore separator and the entity name just in
1419 -- front of the suffix.
1421 Name_Buffer
(Index
+ 1 + Insert_Len
.. Name_Len
+ Insert_Len
) :=
1422 Name_Buffer
(Index
+ 1 .. Name_Len
);
1423 Name_Buffer
(Index
+ 1) := '_';
1424 Name_Buffer
(Index
+ 2 .. Index
+ Insert_Len
) := Renamed_Id
;
1425 Name_Len
:= Name_Len
+ Insert_Len
;
1428 -- Reset the name of the variable to the new name that includes the
1429 -- name of the renamed entity.
1431 Set_Chars
(Ent
, Name_Enter
);
1433 -- If the entity needs qualification by its scope then develop it
1434 -- here, add the variable's name, and again reset the entity name.
1436 if Qualify_Needed
(Scope
(Ent
)) then
1438 Set_Entity_Name
(Scope
(Ent
));
1439 Add_Str_To_Name_Buffer
("__");
1441 Get_Name_String_And_Append
(Chars
(Ent
));
1443 Set_Chars
(Ent
, Name_Enter
);
1446 Set_Has_Qualified_Name
(Ent
);
1449 elsif Is_Subprogram
(Ent
)
1450 or else Ekind
(Ent
) = E_Subprogram_Body
1451 or else Is_Type
(Ent
)
1453 Fully_Qualify_Name
(Ent
);
1454 Name_Len
:= Full_Qualify_Len
;
1455 Name_Buffer
(1 .. Name_Len
) := Full_Qualify_Name
(1 .. Name_Len
);
1457 -- Qualification needed for enumeration literals when generating C code
1458 -- (to simplify their management in the backend).
1460 elsif Modify_Tree_For_C
1461 and then Ekind
(Ent
) = E_Enumeration_Literal
1462 and then Scope
(Ultimate_Alias
(Ent
)) /= Standard_Standard
1464 Fully_Qualify_Name
(Ent
);
1465 Name_Len
:= Full_Qualify_Len
;
1466 Name_Buffer
(1 .. Name_Len
) := Full_Qualify_Name
(1 .. Name_Len
);
1468 elsif Qualify_Needed
(Scope
(Ent
)) then
1470 Set_Entity_Name
(Ent
);
1473 Set_Has_Qualified_Name
(Ent
);
1475 -- If a variable is hidden by a subsequent loop variable, qualify
1476 -- the name of that loop variable to prevent visibility issues when
1477 -- translating to C. Note that gdb probably never handled properly
1478 -- this accidental hiding, given that loops are not scopes at
1479 -- runtime. We also qualify a name if it hides an outer homonym,
1480 -- and both are declared in blocks.
1482 if Modify_Tree_For_C
and then Ekind
(Ent
) = E_Variable
then
1483 if Present
(Hiding_Loop_Variable
(Ent
)) then
1485 Var
: constant Entity_Id
:= Hiding_Loop_Variable
(Ent
);
1488 Set_Entity_Name
(Var
);
1489 Add_Str_To_Name_Buffer
("L");
1490 Set_Chars
(Var
, Name_Enter
);
1493 elsif Present
(Homonym
(Ent
))
1494 and then Ekind
(Scope
(Ent
)) = E_Block
1495 and then Ekind
(Scope
(Homonym
(Ent
))) = E_Block
1497 Set_Entity_Name
(Ent
);
1498 Add_Str_To_Name_Buffer
("B");
1499 Set_Chars
(Ent
, Name_Enter
);
1506 -- Fall through with a fully qualified name in Name_Buffer/Name_Len
1508 Output_Homonym_Numbers_Suffix
;
1510 -- Add body-nested package suffix if required
1512 if BNPE_Suffix_Needed
1513 and then Ekind
(Ent
) /= E_Enumeration_Literal
1515 Set_BNPE_Suffix
(Ent
);
1517 -- Strip trailing n's and last trailing b as required. note that
1518 -- we know there is at least one b, or no suffix would be generated.
1520 while Name_Buffer
(Name_Len
) = 'n' loop
1521 Name_Len
:= Name_Len
- 1;
1524 Name_Len
:= Name_Len
- 1;
1527 Set_Chars
(Ent
, Name_Enter
);
1528 Set_Has_Qualified_Name
(Ent
);
1530 if Debug_Flag_BB
then
1532 Write_Name
(Save_Chars
);
1533 Write_Str
(" qualified as ");
1534 Write_Name
(Chars
(Ent
));
1537 end Qualify_Entity_Name
;
1539 --------------------------
1540 -- Qualify_Entity_Names --
1541 --------------------------
1543 procedure Qualify_Entity_Names
(N
: Node_Id
) is
1545 Name_Qualify_Units
.Append
(N
);
1546 end Qualify_Entity_Names
;
1552 procedure Reset_Buffers
is
1558 --------------------
1559 -- Strip_Suffixes --
1560 --------------------
1562 procedure Strip_Suffixes
(BNPE_Suffix_Found
: in out Boolean) is
1565 pragma Warnings
(Off
, BNPE_Suffix_Found
);
1566 -- Since this procedure only ever sets the flag
1569 -- Search for and strip BNPE suffix
1571 for J
in reverse 2 .. Name_Len
loop
1572 if Name_Buffer
(J
) = 'X' then
1574 BNPE_Suffix_Found
:= True;
1578 exit when Name_Buffer
(J
) /= 'b' and then Name_Buffer
(J
) /= 'n';
1581 -- Search for and strip homonym numbers suffix
1583 for J
in reverse 2 .. Name_Len
- 2 loop
1584 if Name_Buffer
(J
) = '_'
1585 and then Name_Buffer
(J
+ 1) = '_'
1587 if Name_Buffer
(J
+ 2) in '0' .. '9' then
1588 if Homonym_Len
> 0 then
1589 Homonym_Len
:= Homonym_Len
+ 1;
1590 Homonym_Numbers
(Homonym_Len
) := '-';
1593 SL
:= Name_Len
- (J
+ 1);
1595 Homonym_Numbers
(Homonym_Len
+ 1 .. Homonym_Len
+ SL
) :=
1596 Name_Buffer
(J
+ 2 .. Name_Len
);
1598 Homonym_Len
:= Homonym_Len
+ SL
;