1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2008, 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#" &
84 "_relative_deadline#" &
96 "_disp_asynchronous_select#" &
97 "_disp_conditional_select#" &
98 "_disp_get_prim_op_kind#" &
99 "_disp_get_task_id#" &
101 "_disp_timed_select#" &
125 "exception_traces#" &
127 "finalization_root#" &
129 "most_recent_exception#" &
134 "wide_wide_text_io#" &
140 "get_active_partition_id#" &
141 "get_rci_package_receiver#" &
142 "get_rci_package_ref#" &
146 "partition_interface#" &
184 "assertion_policy#" &
188 "compile_time_error#" &
189 "compile_time_warning#" &
191 "component_alignment#" &
192 "convention_identifier#" &
196 "elaboration_checks#" &
199 "extensions_allowed#" &
200 "external_name_casing#" &
202 "float_representation#" &
203 "implicit_packing#" &
204 "initialize_scalars#" &
210 "no_strict_aliasing#" &
211 "normalize_scalars#" &
212 "optimize_alignment#" &
215 "priority_specific_dispatching#" &
217 "profile_warnings#" &
218 "propagate_exceptions#" &
221 "restricted_run_time#" &
223 "restriction_warnings#" &
225 "source_file_name#" &
226 "source_file_name_project#" &
229 "suppress_exception_locations#" &
230 "task_dispatching_policy#" &
236 "wide_character_encoding#" &
238 "all_calls_remote#" &
243 "atomic_components#" &
249 "complete_representation#" &
250 "complex_representation#" &
262 "export_exception#" &
265 "export_procedure#" &
267 "export_valued_procedure#" &
269 "finalize_storage_only#" &
271 "implemented_by_entry#" &
273 "import_exception#" &
276 "import_procedure#" &
277 "import_valued_procedure#" &
281 "inspection_point#" &
283 "interrupt_handler#" &
284 "interrupt_priority#" &
285 "java_constructor#" &
290 "linker_constructor#" &
291 "linker_destructor#" &
295 "machine_attribute#" &
308 "preelaborable_initialization#" &
315 "relative_deadline#" &
316 "remote_call_interface#" &
321 "source_reference#" &
322 "static_elaboration_desired#" &
326 "suppress_debug_info#" &
327 "suppress_initialization#" &
335 "unimplemented_unit#" &
336 "universal_aliasing#" &
339 "unreferenced_objects#" &
340 "unreserve_all_interrupts#" &
342 "volatile_components#" &
364 "boolean_entry_barriers#" &
368 "component_size_4#" &
377 "first_optional_parameter#" &
389 "max_entry_queue_depth#" &
390 "max_entry_queue_length#" &
400 "no_dynamic_attachment#" &
401 "no_dynamic_interrupts#" &
403 "no_requeue_statements#" &
404 "no_task_attributes#" &
405 "no_task_attributes_package#" &
410 "result_mechanism#" &
414 "secondary_stack_size#" &
422 "subunit_file_name#" &
423 "task_stack_size_default#" &
425 "time_slicing_enabled#" &
459 "default_bit_order#" &
477 "has_access_values#" &
478 "has_discriminants#" &
479 "has_tagged_values#" &
491 "machine_mantissa#" &
492 "machine_overflows#" &
494 "machine_rounding#" &
498 "max_size_in_storage_elements#" &
499 "maximum_alignment#" &
511 "passed_by_reference#" &
539 "unbiased_rounding#" &
540 "unchecked_access#" &
541 "unconstrained_array#" &
542 "universal_literal_string#" &
543 "unrestricted_access#" &
585 "inheritance_locking#" &
587 "priority_queuing#" &
588 "edf_across_priorities#" &
589 "fifo_within_priorities#" &
590 "non_preemptive_within_priorities#" &
591 "round_robin_within_priorities#" &
593 "accessibility_check#" &
595 "discriminant_check#" &
597 "elaboration_check#" &
665 "enclosing_entity#" &
666 "exception_information#" &
667 "exception_message#" &
670 "generic_dispatching_constructor#" &
672 "import_largest_value#" &
680 "shift_right_arithmetic#" &
682 "unchecked_conversion#" &
683 "unchecked_deallocation#" &
696 "archive_builder_append_option#" &
703 "builder_switches#" &
706 "config_body_file_name#" &
707 "config_body_file_name_pattern#" &
708 "config_file_switches#" &
709 "config_file_unique#" &
710 "config_spec_file_name#" &
711 "config_spec_file_name_pattern#" &
714 "default_language#" &
715 "default_switches#" &
716 "dependency_driver#" &
717 "dependency_file_kind#" &
718 "dependency_switches#" &
720 "excluded_source_dirs#" &
721 "excluded_source_files#" &
722 "excluded_source_list_file#" &
725 "executable_suffix#" &
727 "externally_built#" &
729 "global_configuration_pragmas#" &
730 "global_config_file#" &
734 "implementation_exceptions#" &
735 "implementation_suffix#" &
736 "include_switches#" &
738 "include_path_file#" &
739 "inherit_source_path#" &
741 "language_processing#" &
745 "library_auto_init#" &
746 "library_auto_init_supported#" &
750 "library_interface#" &
753 "library_major_minor_id_supported#" &
755 "library_partial_linker#" &
756 "library_reference_symbol_file#" &
759 "library_symbol_file#" &
760 "library_symbol_policy#" &
762 "library_version_switches#" &
764 "linker_executable_option#" &
765 "linker_lib_dir_option#" &
766 "linker_lib_name_option#" &
767 "local_config_file#" &
768 "local_configuration_pragmas#" &
769 "locally_removed_files#" &
771 "mapping_file_switches#" &
772 "mapping_spec_suffix#" &
773 "mapping_body_suffix#" &
776 "object_generated#" &
779 "objects_path_file#" &
786 "required_switches#" &
789 "shared_library_minimum_switches#" &
790 "shared_library_prefix#" &
791 "shared_library_suffix#" &
795 "source_list_file#" &
799 "specification_exceptions#" &
800 "specification_suffix#" &
803 "symbolic_link_supported#" &
806 "toolchain_description#" &
807 "toolchain_version#" &
808 "runtime_library_dir#" &
815 ---------------------
816 -- Generated Names --
817 ---------------------
819 -- This section lists the various cases of generated names which are
820 -- built from existing names by adding unique leading and/or trailing
821 -- upper case letters. In some cases these names are built recursively,
822 -- in particular names built from types may be built from types which
823 -- themselves have generated names. In this list, xxx represents an
824 -- existing name to which identifying letters are prepended or appended,
825 -- and a trailing n represents a serial number in an external name that
826 -- has some semantic significance (e.g. the n'th index type of an array).
828 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
829 -- xxxB tag table for tagged type xxx (Exp_Ch3)
830 -- xxxB task body procedure for task xxx (Exp_Ch9)
831 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
832 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
833 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
834 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
835 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
836 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
837 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
838 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
839 -- xxxM master Id value for access type xxx (Exp_Ch3)
840 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
841 -- xxxP parameter record type for entry xxx (Exp_Ch9)
842 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
843 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
844 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
845 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
846 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
847 -- xxxV type for task value record for task xxx (Exp_Ch9)
848 -- xxxX entry index constant (Exp_Ch9)
849 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
850 -- xxxZ size variable for task xxx (Exp_Ch9)
854 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
855 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
856 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
857 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
858 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
859 -- xxxIP initialization procedure for type xxx (Exp_TSS)
860 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
861 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
862 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
863 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
864 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
865 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
866 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
867 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
868 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
869 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
871 -- Implicit type names
873 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
875 -- (Note: this list is not complete or accurate ???)
877 ----------------------
878 -- Get_Attribute_Id --
879 ----------------------
881 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
883 return Attribute_Id
'Val (N
- First_Attribute_Name
);
884 end Get_Attribute_Id
;
886 -----------------------
887 -- Get_Convention_Id --
888 -----------------------
890 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
893 when Name_Ada
=> return Convention_Ada
;
894 when Name_Assembler
=> return Convention_Assembler
;
895 when Name_C
=> return Convention_C
;
896 when Name_CIL
=> return Convention_CIL
;
897 when Name_COBOL
=> return Convention_COBOL
;
898 when Name_CPP
=> return Convention_CPP
;
899 when Name_Fortran
=> return Convention_Fortran
;
900 when Name_Intrinsic
=> return Convention_Intrinsic
;
901 when Name_Java
=> return Convention_Java
;
902 when Name_Stdcall
=> return Convention_Stdcall
;
903 when Name_Stubbed
=> return Convention_Stubbed
;
905 -- If no direct match, then we must have a convention
906 -- identifier pragma that has specified this name.
909 for J
in 1 .. Convention_Identifiers
.Last
loop
910 if N
= Convention_Identifiers
.Table
(J
).Name
then
911 return Convention_Identifiers
.Table
(J
).Convention
;
917 end Get_Convention_Id
;
919 -------------------------
920 -- Get_Convention_Name --
921 -------------------------
923 function Get_Convention_Name
(C
: Convention_Id
) return Name_Id
is
926 when Convention_Ada
=> return Name_Ada
;
927 when Convention_Assembler
=> return Name_Assembler
;
928 when Convention_C
=> return Name_C
;
929 when Convention_CIL
=> return Name_CIL
;
930 when Convention_COBOL
=> return Name_COBOL
;
931 when Convention_CPP
=> return Name_CPP
;
932 when Convention_Entry
=> return Name_Entry
;
933 when Convention_Fortran
=> return Name_Fortran
;
934 when Convention_Intrinsic
=> return Name_Intrinsic
;
935 when Convention_Java
=> return Name_Java
;
936 when Convention_Protected
=> return Name_Protected
;
937 when Convention_Stdcall
=> return Name_Stdcall
;
938 when Convention_Stubbed
=> return Name_Stubbed
;
940 end Get_Convention_Name
;
942 ---------------------------
943 -- Get_Locking_Policy_Id --
944 ---------------------------
946 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
948 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
949 end Get_Locking_Policy_Id
;
955 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
957 if N
= Name_AST_Entry
then
958 return Pragma_AST_Entry
;
959 elsif N
= Name_Fast_Math
then
960 return Pragma_Fast_Math
;
961 elsif N
= Name_Interface
then
962 return Pragma_Interface
;
963 elsif N
= Name_Priority
then
964 return Pragma_Priority
;
965 elsif N
= Name_Relative_Deadline
then
966 return Pragma_Relative_Deadline
;
967 elsif N
= Name_Storage_Size
then
968 return Pragma_Storage_Size
;
969 elsif N
= Name_Storage_Unit
then
970 return Pragma_Storage_Unit
;
971 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
972 return Unknown_Pragma
;
974 return Pragma_Id
'Val (N
- First_Pragma_Name
);
978 ---------------------------
979 -- Get_Queuing_Policy_Id --
980 ---------------------------
982 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
984 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
985 end Get_Queuing_Policy_Id
;
987 ------------------------------------
988 -- Get_Task_Dispatching_Policy_Id --
989 ------------------------------------
991 function Get_Task_Dispatching_Policy_Id
992 (N
: Name_Id
) return Task_Dispatching_Policy_Id
995 return Task_Dispatching_Policy_Id
'Val
996 (N
- First_Task_Dispatching_Policy_Name
);
997 end Get_Task_Dispatching_Policy_Id
;
1003 procedure Initialize
is
1005 Discard_Name
: Name_Id
;
1008 P_Index
:= Preset_Names
'First;
1011 while Preset_Names
(P_Index
) /= '#' loop
1012 Name_Len
:= Name_Len
+ 1;
1013 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
1014 P_Index
:= P_Index
+ 1;
1017 -- We do the Name_Find call to enter the name into the table, but
1018 -- we don't need to do anything with the result, since we already
1019 -- initialized all the preset names to have the right value (we
1020 -- are depending on the order of the names and Preset_Names).
1022 Discard_Name
:= Name_Find
;
1023 P_Index
:= P_Index
+ 1;
1024 exit when Preset_Names
(P_Index
) = '#';
1027 -- Make sure that number of names in standard table is correct. If
1028 -- this check fails, run utility program XSNAMES to construct a new
1029 -- properly matching version of the body.
1031 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
1033 -- Initialize the convention identifiers table with the standard
1034 -- set of synonyms that we recognize for conventions.
1036 Convention_Identifiers
.Init
;
1038 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
1039 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
1041 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
1042 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
1044 Convention_Identifiers
.Append
((Name_C_Plus_Plus
, Convention_CPP
));
1046 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
1047 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
1050 -----------------------
1051 -- Is_Attribute_Name --
1052 -----------------------
1054 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
1056 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
1057 end Is_Attribute_Name
;
1059 ----------------------------------
1060 -- Is_Configuration_Pragma_Name --
1061 ----------------------------------
1063 function Is_Configuration_Pragma_Name
(N
: Name_Id
) return Boolean is
1065 return N
in First_Pragma_Name
.. Last_Configuration_Pragma_Name
1066 or else N
= Name_Fast_Math
;
1067 end Is_Configuration_Pragma_Name
;
1069 ------------------------
1070 -- Is_Convention_Name --
1071 ------------------------
1073 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
1075 -- Check if this is one of the standard conventions
1077 if N
in First_Convention_Name
.. Last_Convention_Name
1082 -- Otherwise check if it is in convention identifier table
1085 for J
in 1 .. Convention_Identifiers
.Last
loop
1086 if N
= Convention_Identifiers
.Table
(J
).Name
then
1093 end Is_Convention_Name
;
1095 ------------------------------
1096 -- Is_Entity_Attribute_Name --
1097 ------------------------------
1099 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
1101 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
1102 end Is_Entity_Attribute_Name
;
1104 --------------------------------
1105 -- Is_Function_Attribute_Name --
1106 --------------------------------
1108 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
1111 First_Renamable_Function_Attribute
..
1112 Last_Renamable_Function_Attribute
;
1113 end Is_Function_Attribute_Name
;
1115 ---------------------
1116 -- Is_Keyword_Name --
1117 ---------------------
1119 function Is_Keyword_Name
(N
: Name_Id
) return Boolean is
1121 return Get_Name_Table_Byte
(N
) /= 0
1122 and then (Ada_Version
>= Ada_95
1123 or else N
not in Ada_95_Reserved_Words
)
1124 and then (Ada_Version
>= Ada_05
1125 or else N
not in Ada_2005_Reserved_Words
);
1126 end Is_Keyword_Name
;
1128 ----------------------------
1129 -- Is_Locking_Policy_Name --
1130 ----------------------------
1132 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
1134 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
1135 end Is_Locking_Policy_Name
;
1137 -----------------------------
1138 -- Is_Operator_Symbol_Name --
1139 -----------------------------
1141 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
1143 return N
in First_Operator_Name
.. Last_Operator_Name
;
1144 end Is_Operator_Symbol_Name
;
1146 --------------------
1147 -- Is_Pragma_Name --
1148 --------------------
1150 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
1152 return N
in First_Pragma_Name
.. Last_Pragma_Name
1153 or else N
= Name_AST_Entry
1154 or else N
= Name_Fast_Math
1155 or else N
= Name_Interface
1156 or else N
= Name_Relative_Deadline
1157 or else N
= Name_Priority
1158 or else N
= Name_Storage_Size
1159 or else N
= Name_Storage_Unit
;
1162 ---------------------------------
1163 -- Is_Procedure_Attribute_Name --
1164 ---------------------------------
1166 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
1168 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1169 end Is_Procedure_Attribute_Name
;
1171 ----------------------------
1172 -- Is_Queuing_Policy_Name --
1173 ----------------------------
1175 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1177 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1178 end Is_Queuing_Policy_Name
;
1180 -------------------------------------
1181 -- Is_Task_Dispatching_Policy_Name --
1182 -------------------------------------
1184 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1186 return N
in First_Task_Dispatching_Policy_Name
..
1187 Last_Task_Dispatching_Policy_Name
;
1188 end Is_Task_Dispatching_Policy_Name
;
1190 ----------------------------
1191 -- Is_Type_Attribute_Name --
1192 ----------------------------
1194 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1196 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1197 end Is_Type_Attribute_Name
;
1199 ----------------------------------
1200 -- Record_Convention_Identifier --
1201 ----------------------------------
1203 procedure Record_Convention_Identifier
1205 Convention
: Convention_Id
)
1208 Convention_Identifiers
.Append
((Id
, Convention
));
1209 end Record_Convention_Identifier
;