1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
36 with Types
; use Types
;
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 :=
78 "_local_final_list#" &
93 "_disp_asynchronous_select#" &
94 "_disp_conditional_select#" &
95 "_disp_get_prim_op_kind#" &
96 "_disp_get_task_id#" &
98 "_disp_timed_select#" &
122 "exception_traces#" &
124 "finalization_root#" &
126 "most_recent_exception#" &
131 "wide_wide_text_io#" &
137 "get_active_partition_id#" &
138 "get_rci_package_receiver#" &
139 "get_rci_package_ref#" &
143 "partition_interface#" &
182 "assertion_policy#" &
185 "compile_time_error#" &
186 "compile_time_warning#" &
188 "component_alignment#" &
189 "convention_identifier#" &
193 "elaboration_checks#" &
196 "extensions_allowed#" &
197 "external_name_casing#" &
199 "float_representation#" &
200 "implicit_packing#" &
201 "initialize_scalars#" &
207 "no_strict_aliasing#" &
208 "normalize_scalars#" &
211 "priority_specific_dispatching#" &
213 "profile_warnings#" &
214 "propagate_exceptions#" &
217 "restricted_run_time#" &
219 "restriction_warnings#" &
221 "source_file_name#" &
222 "source_file_name_project#" &
225 "suppress_exception_locations#" &
226 "task_dispatching_policy#" &
232 "wide_character_encoding#" &
234 "all_calls_remote#" &
239 "atomic_components#" &
244 "complete_representation#" &
245 "complex_representation#" &
257 "export_exception#" &
260 "export_procedure#" &
262 "export_valued_procedure#" &
264 "finalize_storage_only#" &
266 "implemented_by_entry#" &
268 "import_exception#" &
271 "import_procedure#" &
272 "import_valued_procedure#" &
276 "inspection_point#" &
278 "interrupt_handler#" &
279 "interrupt_priority#" &
280 "java_constructor#" &
285 "linker_constructor#" &
286 "linker_destructor#" &
290 "machine_attribute#" &
301 "preelaborable_initialization#" &
308 "remote_call_interface#" &
313 "source_reference#" &
314 "static_elaboration_desired#" &
318 "suppress_debug_info#" &
319 "suppress_initialization#" &
327 "unimplemented_unit#" &
328 "universal_aliasing#" &
331 "unreferenced_objects#" &
332 "unreserve_all_interrupts#" &
334 "volatile_components#" &
355 "boolean_entry_barriers#" &
360 "component_size_4#" &
369 "first_optional_parameter#" &
381 "max_entry_queue_depth#" &
382 "max_entry_queue_length#" &
392 "no_dynamic_attachment#" &
393 "no_dynamic_interrupts#" &
395 "no_requeue_statements#" &
396 "no_task_attributes#" &
397 "no_task_attributes_package#" &
402 "result_mechanism#" &
406 "secondary_stack_size#" &
414 "subunit_file_name#" &
415 "task_stack_size_default#" &
417 "time_slicing_enabled#" &
451 "default_bit_order#" &
468 "has_access_values#" &
469 "has_discriminants#" &
480 "machine_mantissa#" &
481 "machine_overflows#" &
483 "machine_rounding#" &
487 "max_size_in_storage_elements#" &
488 "maximum_alignment#" &
499 "passed_by_reference#" &
526 "unbiased_rounding#" &
527 "unchecked_access#" &
528 "unconstrained_array#" &
529 "universal_literal_string#" &
530 "unrestricted_access#" &
572 "inheritance_locking#" &
574 "priority_queuing#" &
575 "edf_across_priorities#" &
576 "fifo_within_priorities#" &
577 "round_robin_within_priorities#" &
579 "accessibility_check#" &
581 "discriminant_check#" &
583 "elaboration_check#" &
651 "enclosing_entity#" &
652 "exception_information#" &
653 "exception_message#" &
656 "generic_dispatching_constructor#" &
658 "import_largest_value#" &
666 "shift_right_arithmetic#" &
668 "unchecked_conversion#" &
669 "unchecked_deallocation#" &
687 "builder_switches#" &
690 "config_body_file_name#" &
691 "config_body_file_name_pattern#" &
692 "config_file_switches#" &
693 "config_file_unique#" &
694 "config_spec_file_name#" &
695 "config_spec_file_name_pattern#" &
697 "default_language#" &
698 "default_switches#" &
699 "dependency_driver#" &
700 "dependency_file_kind#" &
701 "dependency_switches#" &
703 "excluded_source_dirs#" &
704 "excluded_source_files#" &
707 "executable_suffix#" &
709 "externally_built#" &
711 "global_configuration_pragmas#" &
712 "global_config_file#" &
716 "implementation_exceptions#" &
717 "implementation_suffix#" &
718 "include_switches#" &
720 "include_path_file#" &
722 "language_processing#" &
725 "library_auto_init#" &
726 "library_auto_init_supported#" &
730 "library_interface#" &
733 "library_major_minor_id_supported#" &
735 "library_partial_linker#" &
736 "library_reference_symbol_file#" &
739 "library_symbol_file#" &
740 "library_symbol_policy#" &
742 "library_version_switches#" &
744 "linker_executable_option#" &
745 "linker_lib_dir_option#" &
746 "linker_lib_name_option#" &
747 "local_config_file#" &
748 "local_configuration_pragmas#" &
749 "locally_removed_files#" &
750 "mapping_file_switches#" &
751 "mapping_spec_suffix#" &
752 "mapping_body_suffix#" &
756 "objects_path_file#" &
763 "required_switches#" &
766 "shared_library_minimum_switches#" &
767 "shared_library_prefix#" &
768 "shared_library_suffix#" &
772 "source_list_file#" &
776 "specification_exceptions#" &
777 "specification_suffix#" &
780 "symbolic_link_supported#" &
781 "toolchain_description#" &
782 "toolchain_version#" &
783 "runtime_library_dir#" &
790 ---------------------
791 -- Generated Names --
792 ---------------------
794 -- This section lists the various cases of generated names which are
795 -- built from existing names by adding unique leading and/or trailing
796 -- upper case letters. In some cases these names are built recursively,
797 -- in particular names built from types may be built from types which
798 -- themselves have generated names. In this list, xxx represents an
799 -- existing name to which identifying letters are prepended or appended,
800 -- and a trailing n represents a serial number in an external name that
801 -- has some semantic significance (e.g. the n'th index type of an array).
803 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
804 -- xxxB tag table for tagged type xxx (Exp_Ch3)
805 -- xxxB task body procedure for task xxx (Exp_Ch9)
806 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
807 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
808 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
809 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
810 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
811 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
812 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
813 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
814 -- xxxM master Id value for access type xxx (Exp_Ch3)
815 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
816 -- xxxP parameter record type for entry xxx (Exp_Ch9)
817 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
818 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
819 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
820 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
821 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
822 -- xxxV type for task value record for task xxx (Exp_Ch9)
823 -- xxxX entry index constant (Exp_Ch9)
824 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
825 -- xxxZ size variable for task xxx (Exp_Ch9)
829 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
830 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
831 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
832 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
833 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
834 -- xxxIP initialization procedure for type xxx (Exp_TSS)
835 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
836 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
837 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
838 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
839 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
840 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
841 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
842 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
843 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
844 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
846 -- Implicit type names
848 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
850 -- (Note: this list is not complete or accurate ???)
852 ----------------------
853 -- Get_Attribute_Id --
854 ----------------------
856 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
858 return Attribute_Id
'Val (N
- First_Attribute_Name
);
859 end Get_Attribute_Id
;
861 -----------------------
862 -- Get_Convention_Id --
863 -----------------------
865 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
868 when Name_Ada
=> return Convention_Ada
;
869 when Name_Assembler
=> return Convention_Assembler
;
870 when Name_C
=> return Convention_C
;
871 when Name_CIL
=> return Convention_CIL
;
872 when Name_COBOL
=> return Convention_COBOL
;
873 when Name_CPP
=> return Convention_CPP
;
874 when Name_Fortran
=> return Convention_Fortran
;
875 when Name_Intrinsic
=> return Convention_Intrinsic
;
876 when Name_Java
=> return Convention_Java
;
877 when Name_Stdcall
=> return Convention_Stdcall
;
878 when Name_Stubbed
=> return Convention_Stubbed
;
880 -- If no direct match, then we must have a convention
881 -- identifier pragma that has specified this name.
884 for J
in 1 .. Convention_Identifiers
.Last
loop
885 if N
= Convention_Identifiers
.Table
(J
).Name
then
886 return Convention_Identifiers
.Table
(J
).Convention
;
892 end Get_Convention_Id
;
894 -------------------------
895 -- Get_Convention_Name --
896 -------------------------
898 function Get_Convention_Name
(C
: Convention_Id
) return Name_Id
is
901 when Convention_Ada
=> return Name_Ada
;
902 when Convention_Assembler
=> return Name_Assembler
;
903 when Convention_C
=> return Name_C
;
904 when Convention_CIL
=> return Name_CIL
;
905 when Convention_COBOL
=> return Name_COBOL
;
906 when Convention_CPP
=> return Name_CPP
;
907 when Convention_Entry
=> return Name_Entry
;
908 when Convention_Fortran
=> return Name_Fortran
;
909 when Convention_Intrinsic
=> return Name_Intrinsic
;
910 when Convention_Java
=> return Name_Java
;
911 when Convention_Protected
=> return Name_Protected
;
912 when Convention_Stdcall
=> return Name_Stdcall
;
913 when Convention_Stubbed
=> return Name_Stubbed
;
915 end Get_Convention_Name
;
917 ---------------------------
918 -- Get_Locking_Policy_Id --
919 ---------------------------
921 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
923 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
924 end Get_Locking_Policy_Id
;
930 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
932 if N
= Name_AST_Entry
then
933 return Pragma_AST_Entry
;
934 elsif N
= Name_Fast_Math
then
935 return Pragma_Fast_Math
;
936 elsif N
= Name_Interface
then
937 return Pragma_Interface
;
938 elsif N
= Name_Priority
then
939 return Pragma_Priority
;
940 elsif N
= Name_Storage_Size
then
941 return Pragma_Storage_Size
;
942 elsif N
= Name_Storage_Unit
then
943 return Pragma_Storage_Unit
;
944 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
945 return Unknown_Pragma
;
947 return Pragma_Id
'Val (N
- First_Pragma_Name
);
951 ---------------------------
952 -- Get_Queuing_Policy_Id --
953 ---------------------------
955 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
957 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
958 end Get_Queuing_Policy_Id
;
960 ------------------------------------
961 -- Get_Task_Dispatching_Policy_Id --
962 ------------------------------------
964 function Get_Task_Dispatching_Policy_Id
965 (N
: Name_Id
) return Task_Dispatching_Policy_Id
968 return Task_Dispatching_Policy_Id
'Val
969 (N
- First_Task_Dispatching_Policy_Name
);
970 end Get_Task_Dispatching_Policy_Id
;
976 procedure Initialize
is
978 Discard_Name
: Name_Id
;
981 P_Index
:= Preset_Names
'First;
984 while Preset_Names
(P_Index
) /= '#' loop
985 Name_Len
:= Name_Len
+ 1;
986 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
987 P_Index
:= P_Index
+ 1;
990 -- We do the Name_Find call to enter the name into the table, but
991 -- we don't need to do anything with the result, since we already
992 -- initialized all the preset names to have the right value (we
993 -- are depending on the order of the names and Preset_Names).
995 Discard_Name
:= Name_Find
;
996 P_Index
:= P_Index
+ 1;
997 exit when Preset_Names
(P_Index
) = '#';
1000 -- Make sure that number of names in standard table is correct. If
1001 -- this check fails, run utility program XSNAMES to construct a new
1002 -- properly matching version of the body.
1004 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
1006 -- Initialize the convention identifiers table with the standard
1007 -- set of synonyms that we recognize for conventions.
1009 Convention_Identifiers
.Init
;
1011 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
1012 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
1014 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
1015 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
1017 Convention_Identifiers
.Append
((Name_C_Plus_Plus
, Convention_CPP
));
1019 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
1020 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
1023 -----------------------
1024 -- Is_Attribute_Name --
1025 -----------------------
1027 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
1029 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
1030 end Is_Attribute_Name
;
1032 ----------------------------------
1033 -- Is_Configuration_Pragma_Name --
1034 ----------------------------------
1036 function Is_Configuration_Pragma_Name
(N
: Name_Id
) return Boolean is
1038 return N
in First_Pragma_Name
.. Last_Configuration_Pragma_Name
1039 or else N
= Name_Fast_Math
;
1040 end Is_Configuration_Pragma_Name
;
1042 ------------------------
1043 -- Is_Convention_Name --
1044 ------------------------
1046 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
1048 -- Check if this is one of the standard conventions
1050 if N
in First_Convention_Name
.. Last_Convention_Name
1055 -- Otherwise check if it is in convention identifier table
1058 for J
in 1 .. Convention_Identifiers
.Last
loop
1059 if N
= Convention_Identifiers
.Table
(J
).Name
then
1066 end Is_Convention_Name
;
1068 ------------------------------
1069 -- Is_Entity_Attribute_Name --
1070 ------------------------------
1072 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
1074 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
1075 end Is_Entity_Attribute_Name
;
1077 --------------------------------
1078 -- Is_Function_Attribute_Name --
1079 --------------------------------
1081 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
1084 First_Renamable_Function_Attribute
..
1085 Last_Renamable_Function_Attribute
;
1086 end Is_Function_Attribute_Name
;
1088 ---------------------
1089 -- Is_Keyword_Name --
1090 ---------------------
1092 function Is_Keyword_Name
(N
: Name_Id
) return Boolean is
1094 return Get_Name_Table_Byte
(N
) /= 0
1095 and then (Ada_Version
>= Ada_95
1096 or else N
not in Ada_95_Reserved_Words
)
1097 and then (Ada_Version
>= Ada_05
1098 or else N
not in Ada_2005_Reserved_Words
);
1099 end Is_Keyword_Name
;
1101 ----------------------------
1102 -- Is_Locking_Policy_Name --
1103 ----------------------------
1105 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
1107 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
1108 end Is_Locking_Policy_Name
;
1110 -----------------------------
1111 -- Is_Operator_Symbol_Name --
1112 -----------------------------
1114 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
1116 return N
in First_Operator_Name
.. Last_Operator_Name
;
1117 end Is_Operator_Symbol_Name
;
1119 --------------------
1120 -- Is_Pragma_Name --
1121 --------------------
1123 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
1125 return N
in First_Pragma_Name
.. Last_Pragma_Name
1126 or else N
= Name_AST_Entry
1127 or else N
= Name_Fast_Math
1128 or else N
= Name_Interface
1129 or else N
= Name_Priority
1130 or else N
= Name_Storage_Size
1131 or else N
= Name_Storage_Unit
;
1134 ---------------------------------
1135 -- Is_Procedure_Attribute_Name --
1136 ---------------------------------
1138 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
1140 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1141 end Is_Procedure_Attribute_Name
;
1143 ----------------------------
1144 -- Is_Queuing_Policy_Name --
1145 ----------------------------
1147 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1149 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1150 end Is_Queuing_Policy_Name
;
1152 -------------------------------------
1153 -- Is_Task_Dispatching_Policy_Name --
1154 -------------------------------------
1156 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1158 return N
in First_Task_Dispatching_Policy_Name
..
1159 Last_Task_Dispatching_Policy_Name
;
1160 end Is_Task_Dispatching_Policy_Name
;
1162 ----------------------------
1163 -- Is_Type_Attribute_Name --
1164 ----------------------------
1166 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1168 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1169 end Is_Type_Attribute_Name
;
1171 ----------------------------------
1172 -- Record_Convention_Identifier --
1173 ----------------------------------
1175 procedure Record_Convention_Identifier
1177 Convention
: Convention_Id
)
1180 Convention_Identifiers
.Append
((Id
, Convention
));
1181 end Record_Convention_Identifier
;