1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2002, Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 ------------------------------------------------------------------------------
35 with Namet
; use Namet
;
38 package body Snames
is
40 -- Table used to record convention identifiers
42 type Convention_Id_Entry
is record
44 Convention
: Convention_Id
;
47 package Convention_Identifiers
is new Table
.Table
(
48 Table_Component_Type
=> Convention_Id_Entry
,
49 Table_Index_Type
=> Int
,
52 Table_Increment
=> 200,
53 Table_Name
=> "Name_Convention_Identifiers");
55 -- Table of names to be set by Initialize. Each name is terminated by a
56 -- single #, and the end of the list is marked by a null entry, i.e. by
57 -- two # marks in succession. Note that the table does not include the
58 -- entries for a-z, since these are initialized by Namet itself.
60 Preset_Names
: constant String :=
69 "_address_resolver#" &
79 "_local_final_list#" &
102 "_ras_dereference#" &
124 "finalization_root#" &
132 "get_active_partition_id#" &
133 "get_rci_package_receiver#" &
137 "partition_interface#" &
166 "component_alignment#" &
167 "convention_identifier#" &
169 "elaboration_checks#" &
172 "extensions_allowed#" &
173 "external_name_casing#" &
174 "float_representation#" &
175 "initialize_scalars#" &
180 "normalize_scalars#" &
182 "propagate_exceptions#" &
185 "restricted_run_time#" &
188 "source_file_name#" &
191 "task_dispatching_policy#" &
197 "all_calls_remote#" &
202 "atomic_components#" &
206 "complex_representation#" &
218 "export_exception#" &
221 "export_procedure#" &
222 "export_valued_procedure#" &
224 "finalize_storage_only#" &
227 "import_exception#" &
230 "import_procedure#" &
231 "import_valued_procedure#" &
235 "inspection_point#" &
238 "interrupt_handler#" &
239 "interrupt_priority#" &
240 "java_constructor#" &
247 "machine_attribute#" &
261 "remote_call_interface#" &
266 "source_reference#" &
270 "suppress_debug_info#" &
271 "suppress_initialization#" &
279 "unimplemented_unit#" &
282 "unreserve_all_interrupts#" &
284 "volatile_components#" &
305 "component_size_4#" &
313 "first_optional_parameter#" &
335 "result_mechanism#" &
343 "subunit_file_name#" &
344 "task_stack_size_default#" &
346 "time_slicing_enabled#" &
378 "default_bit_order#" &
393 "has_discriminants#" &
404 "machine_mantissa#" &
405 "machine_overflows#" &
410 "max_size_in_storage_elements#" &
411 "maximum_alignment#" &
421 "passed_by_reference#" &
444 "unbiased_rounding#" &
445 "unchecked_access#" &
446 "universal_literal_string#" &
447 "unrestricted_access#" &
485 "inheritance_locking#" &
487 "priority_queuing#" &
488 "fifo_within_priorities#" &
490 "accessibility_check#" &
491 "discriminant_check#" &
493 "elaboration_check#" &
561 "enclosing_entity#" &
562 "exception_information#" &
563 "exception_message#" &
567 "import_largest_value#" &
575 "shift_right_arithmetic#" &
577 "unchecked_conversion#" &
578 "unchecked_deallocation#" &
590 "default_switches#" &
597 "implementation_exceptions#" &
598 "implementation_suffix#" &
601 "library_elaboration#" &
612 "source_list_file#" &
614 "specification_exceptions#" &
615 "specification_suffix#" &
619 ---------------------
620 -- Generated Names --
621 ---------------------
623 -- This section lists the various cases of generated names which are
624 -- built from existing names by adding unique leading and/or trailing
625 -- upper case letters. In some cases these names are built recursively,
626 -- in particular names built from types may be built from types which
627 -- themselves have generated names. In this list, xxx represents an
628 -- existing name to which identifying letters are prepended or appended,
629 -- and a trailing n represents a serial number in an external name that
630 -- has some semantic significance (e.g. the n'th index type of an array).
632 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
633 -- xxxB tag table for tagged type xxx (Exp_Ch3)
634 -- xxxB task body procedure for task xxx (Exp_Ch9)
635 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
636 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
637 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
638 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
639 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
640 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
641 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
642 -- xxxI initialization procedure for type xxx (Exp_Ch3)
643 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
644 -- xxxM master Id value for access type xxx (Exp_Ch3)
645 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
646 -- xxxP parameter record type for entry xxx (Exp_Ch9)
647 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
648 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
649 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
650 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
651 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
652 -- xxxV type for task value record for task xxx (Exp_Ch9)
653 -- xxxX entry index constant (Exp_Ch9)
654 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
655 -- xxxZ size variable for task xxx (Exp_Ch9)
657 -- Implicit type names
659 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
661 -- (Note: this list is not complete or accurate ???)
663 ----------------------
664 -- Get_Attribute_Id --
665 ----------------------
667 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
669 return Attribute_Id
'Val (N
- First_Attribute_Name
);
670 end Get_Attribute_Id
;
676 function Get_Check_Id
(N
: Name_Id
) return Check_Id
is
678 return Check_Id
'Val (N
- First_Check_Name
);
681 -----------------------
682 -- Get_Convention_Id --
683 -----------------------
685 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
688 when Name_Ada
=> return Convention_Ada
;
689 when Name_Assembler
=> return Convention_Assembler
;
690 when Name_C
=> return Convention_C
;
691 when Name_COBOL
=> return Convention_COBOL
;
692 when Name_CPP
=> return Convention_CPP
;
693 when Name_Fortran
=> return Convention_Fortran
;
694 when Name_Intrinsic
=> return Convention_Intrinsic
;
695 when Name_Java
=> return Convention_Java
;
696 when Name_Stdcall
=> return Convention_Stdcall
;
697 when Name_Stubbed
=> return Convention_Stubbed
;
700 for J
in 1 .. Convention_Identifiers
.Last
loop
701 if N
= Convention_Identifiers
.Table
(J
).Name
then
702 return Convention_Identifiers
.Table
(J
).Convention
;
708 end Get_Convention_Id
;
710 ---------------------------
711 -- Get_Locking_Policy_Id --
712 ---------------------------
714 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
716 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
717 end Get_Locking_Policy_Id
;
723 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
725 if N
= Name_AST_Entry
then
726 return Pragma_AST_Entry
;
727 elsif N
= Name_Storage_Size
then
728 return Pragma_Storage_Size
;
729 elsif N
= Name_Storage_Unit
then
730 return Pragma_Storage_Unit
;
732 return Pragma_Id
'Val (N
- First_Pragma_Name
);
736 ---------------------------
737 -- Get_Queuing_Policy_Id --
738 ---------------------------
740 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
742 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
743 end Get_Queuing_Policy_Id
;
745 ------------------------------------
746 -- Get_Task_Dispatching_Policy_Id --
747 ------------------------------------
749 function Get_Task_Dispatching_Policy_Id
(N
: Name_Id
)
750 return Task_Dispatching_Policy_Id
is
752 return Task_Dispatching_Policy_Id
'Val
753 (N
- First_Task_Dispatching_Policy_Name
);
754 end Get_Task_Dispatching_Policy_Id
;
760 procedure Initialize
is
762 Discard_Name
: Name_Id
;
765 P_Index
:= Preset_Names
'First;
770 while Preset_Names
(P_Index
) /= '#' loop
771 Name_Len
:= Name_Len
+ 1;
772 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
773 P_Index
:= P_Index
+ 1;
776 -- We do the Name_Find call to enter the name into the table, but
777 -- we don't need to do anything with the result, since we already
778 -- initialized all the preset names to have the right value (we
779 -- are depending on the order of the names and Preset_Names).
781 Discard_Name
:= Name_Find
;
782 P_Index
:= P_Index
+ 1;
783 exit when Preset_Names
(P_Index
) = '#';
786 -- Make sure that number of names in standard table is correct. If
787 -- this check fails, run utility program XSNAMES to construct a new
788 -- properly matching version of the body.
790 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
792 -- Initialize the convention identifiers table with the standard
793 -- set of synonyms that we recognize for conventions.
795 Convention_Identifiers
.Init
;
797 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
798 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
800 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
801 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
803 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
804 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
807 -----------------------
808 -- Is_Attribute_Name --
809 -----------------------
811 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
813 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
814 end Is_Attribute_Name
;
820 function Is_Check_Name
(N
: Name_Id
) return Boolean is
822 return N
in First_Check_Name
.. Last_Check_Name
;
825 ------------------------
826 -- Is_Convention_Name --
827 ------------------------
829 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
831 if N
in First_Convention_Name
.. Last_Convention_Name
837 for J
in 1 .. Convention_Identifiers
.Last
loop
838 if N
= Convention_Identifiers
.Table
(J
).Name
then
845 end Is_Convention_Name
;
847 ------------------------------
848 -- Is_Entity_Attribute_Name --
849 ------------------------------
851 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
853 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
854 end Is_Entity_Attribute_Name
;
856 --------------------------------
857 -- Is_Function_Attribute_Name --
858 --------------------------------
860 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
863 First_Renamable_Function_Attribute
..
864 Last_Renamable_Function_Attribute
;
865 end Is_Function_Attribute_Name
;
867 ----------------------------
868 -- Is_Locking_Policy_Name --
869 ----------------------------
871 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
873 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
874 end Is_Locking_Policy_Name
;
876 -----------------------------
877 -- Is_Operator_Symbol_Name --
878 -----------------------------
880 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
882 return N
in First_Operator_Name
.. Last_Operator_Name
;
883 end Is_Operator_Symbol_Name
;
889 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
891 return N
in First_Pragma_Name
.. Last_Pragma_Name
892 or else N
= Name_AST_Entry
893 or else N
= Name_Storage_Size
894 or else N
= Name_Storage_Unit
;
897 ---------------------------------
898 -- Is_Procedure_Attribute_Name --
899 ---------------------------------
901 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
903 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
904 end Is_Procedure_Attribute_Name
;
906 ----------------------------
907 -- Is_Queuing_Policy_Name --
908 ----------------------------
910 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
912 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
913 end Is_Queuing_Policy_Name
;
915 -------------------------------------
916 -- Is_Task_Dispatching_Policy_Name --
917 -------------------------------------
919 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
921 return N
in First_Task_Dispatching_Policy_Name
..
922 Last_Task_Dispatching_Policy_Name
;
923 end Is_Task_Dispatching_Policy_Name
;
925 ----------------------------
926 -- Is_Type_Attribute_Name --
927 ----------------------------
929 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
931 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
932 end Is_Type_Attribute_Name
;
934 ----------------------------------
935 -- Record_Convention_Identifier --
936 ----------------------------------
938 procedure Record_Convention_Identifier
940 Convention
: Convention_Id
)
943 Convention_Identifiers
.Append
((Id
, Convention
));
944 end Record_Convention_Identifier
;