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#" &
186 "canonical_streams#" &
189 "compile_time_error#" &
190 "compile_time_warning#" &
192 "component_alignment#" &
193 "convention_identifier#" &
197 "elaboration_checks#" &
200 "extensions_allowed#" &
201 "external_name_casing#" &
203 "float_representation#" &
204 "implicit_packing#" &
205 "initialize_scalars#" &
211 "no_strict_aliasing#" &
212 "normalize_scalars#" &
213 "optimize_alignment#" &
216 "priority_specific_dispatching#" &
218 "profile_warnings#" &
219 "propagate_exceptions#" &
222 "restricted_run_time#" &
224 "restriction_warnings#" &
226 "source_file_name#" &
227 "source_file_name_project#" &
230 "suppress_exception_locations#" &
231 "task_dispatching_policy#" &
237 "wide_character_encoding#" &
239 "all_calls_remote#" &
244 "atomic_components#" &
250 "complete_representation#" &
251 "complex_representation#" &
263 "export_exception#" &
266 "export_procedure#" &
268 "export_valued_procedure#" &
270 "finalize_storage_only#" &
272 "implemented_by_entry#" &
274 "import_exception#" &
277 "import_procedure#" &
278 "import_valued_procedure#" &
282 "inspection_point#" &
284 "interrupt_handler#" &
285 "interrupt_priority#" &
286 "java_constructor#" &
291 "linker_constructor#" &
292 "linker_destructor#" &
296 "machine_attribute#" &
309 "preelaborable_initialization#" &
316 "relative_deadline#" &
317 "remote_call_interface#" &
322 "source_reference#" &
323 "static_elaboration_desired#" &
327 "suppress_debug_info#" &
328 "suppress_initialization#" &
336 "unimplemented_unit#" &
337 "universal_aliasing#" &
340 "unreferenced_objects#" &
341 "unreserve_all_interrupts#" &
343 "volatile_components#" &
365 "boolean_entry_barriers#" &
369 "component_size_4#" &
378 "first_optional_parameter#" &
390 "max_entry_queue_depth#" &
391 "max_entry_queue_length#" &
401 "no_dynamic_attachment#" &
402 "no_dynamic_interrupts#" &
404 "no_requeue_statements#" &
405 "no_task_attributes#" &
406 "no_task_attributes_package#" &
411 "result_mechanism#" &
415 "secondary_stack_size#" &
418 "short_descriptor#" &
424 "subunit_file_name#" &
425 "task_stack_size_default#" &
427 "time_slicing_enabled#" &
461 "default_bit_order#" &
479 "has_access_values#" &
480 "has_discriminants#" &
481 "has_tagged_values#" &
493 "machine_mantissa#" &
494 "machine_overflows#" &
496 "machine_rounding#" &
500 "max_size_in_storage_elements#" &
501 "maximum_alignment#" &
513 "passed_by_reference#" &
541 "unbiased_rounding#" &
542 "unchecked_access#" &
543 "unconstrained_array#" &
544 "universal_literal_string#" &
545 "unrestricted_access#" &
587 "inheritance_locking#" &
589 "priority_queuing#" &
590 "edf_across_priorities#" &
591 "fifo_within_priorities#" &
592 "non_preemptive_within_priorities#" &
593 "round_robin_within_priorities#" &
595 "accessibility_check#" &
597 "discriminant_check#" &
599 "elaboration_check#" &
667 "enclosing_entity#" &
668 "exception_information#" &
669 "exception_message#" &
672 "generic_dispatching_constructor#" &
674 "import_largest_value#" &
682 "shift_right_arithmetic#" &
684 "unchecked_conversion#" &
685 "unchecked_deallocation#" &
698 "archive_builder_append_option#" &
705 "builder_switches#" &
708 "config_body_file_name#" &
709 "config_body_file_name_pattern#" &
710 "config_file_switches#" &
711 "config_file_unique#" &
712 "config_spec_file_name#" &
713 "config_spec_file_name_pattern#" &
716 "default_language#" &
717 "default_switches#" &
718 "dependency_driver#" &
719 "dependency_file_kind#" &
720 "dependency_switches#" &
722 "excluded_source_dirs#" &
723 "excluded_source_files#" &
724 "excluded_source_list_file#" &
727 "executable_suffix#" &
729 "externally_built#" &
731 "global_configuration_pragmas#" &
732 "global_config_file#" &
736 "implementation_exceptions#" &
737 "implementation_suffix#" &
738 "include_switches#" &
740 "include_path_file#" &
741 "inherit_source_path#" &
743 "language_processing#" &
747 "library_auto_init#" &
748 "library_auto_init_supported#" &
752 "library_interface#" &
755 "library_major_minor_id_supported#" &
757 "library_partial_linker#" &
758 "library_reference_symbol_file#" &
761 "library_symbol_file#" &
762 "library_symbol_policy#" &
764 "library_version_switches#" &
766 "linker_executable_option#" &
767 "linker_lib_dir_option#" &
768 "linker_lib_name_option#" &
769 "local_config_file#" &
770 "local_configuration_pragmas#" &
771 "locally_removed_files#" &
773 "mapping_file_switches#" &
774 "mapping_spec_suffix#" &
775 "mapping_body_suffix#" &
778 "object_generated#" &
781 "objects_path_file#" &
789 "required_switches#" &
792 "shared_library_minimum_switches#" &
793 "shared_library_prefix#" &
794 "shared_library_suffix#" &
798 "source_list_file#" &
802 "specification_exceptions#" &
803 "specification_suffix#" &
806 "symbolic_link_supported#" &
809 "toolchain_description#" &
810 "toolchain_version#" &
811 "runtime_library_dir#" &
818 ---------------------
819 -- Generated Names --
820 ---------------------
822 -- This section lists the various cases of generated names which are
823 -- built from existing names by adding unique leading and/or trailing
824 -- upper case letters. In some cases these names are built recursively,
825 -- in particular names built from types may be built from types which
826 -- themselves have generated names. In this list, xxx represents an
827 -- existing name to which identifying letters are prepended or appended,
828 -- and a trailing n represents a serial number in an external name that
829 -- has some semantic significance (e.g. the n'th index type of an array).
831 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
832 -- xxxB tag table for tagged type xxx (Exp_Ch3)
833 -- xxxB task body procedure for task xxx (Exp_Ch9)
834 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
835 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
836 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
837 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
838 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
839 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
840 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
841 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
842 -- xxxM master Id value for access type xxx (Exp_Ch3)
843 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
844 -- xxxP parameter record type for entry xxx (Exp_Ch9)
845 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
846 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
847 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
848 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
849 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
850 -- xxxV type for task value record for task xxx (Exp_Ch9)
851 -- xxxX entry index constant (Exp_Ch9)
852 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
853 -- xxxZ size variable for task xxx (Exp_Ch9)
857 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
858 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
859 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
860 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
861 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
862 -- xxxIP initialization procedure for type xxx (Exp_TSS)
863 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
864 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
865 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
866 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
867 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
868 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
869 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
870 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
871 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
872 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
874 -- Implicit type names
876 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
878 -- (Note: this list is not complete or accurate ???)
880 ----------------------
881 -- Get_Attribute_Id --
882 ----------------------
884 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
886 return Attribute_Id'Val (N - First_Attribute_Name);
887 end Get_Attribute_Id;
889 -----------------------
890 -- Get_Convention_Id --
891 -----------------------
893 function Get_Convention_Id (N : Name_Id) return Convention_Id is
896 when Name_Ada => return Convention_Ada;
897 when Name_Assembler => return Convention_Assembler;
898 when Name_C => return Convention_C;
899 when Name_CIL => return Convention_CIL;
900 when Name_COBOL => return Convention_COBOL;
901 when Name_CPP => return Convention_CPP;
902 when Name_Fortran => return Convention_Fortran;
903 when Name_Intrinsic => return Convention_Intrinsic;
904 when Name_Java => return Convention_Java;
905 when Name_Stdcall => return Convention_Stdcall;
906 when Name_Stubbed => return Convention_Stubbed;
908 -- If no direct match, then we must have a convention
909 -- identifier pragma that has specified this name.
912 for J in 1 .. Convention_Identifiers.Last loop
913 if N = Convention_Identifiers.Table (J).Name then
914 return Convention_Identifiers.Table (J).Convention;
920 end Get_Convention_Id;
922 -------------------------
923 -- Get_Convention_Name --
924 -------------------------
926 function Get_Convention_Name (C : Convention_Id) return Name_Id is
929 when Convention_Ada => return Name_Ada;
930 when Convention_Assembler => return Name_Assembler;
931 when Convention_C => return Name_C;
932 when Convention_CIL => return Name_CIL;
933 when Convention_COBOL => return Name_COBOL;
934 when Convention_CPP => return Name_CPP;
935 when Convention_Entry => return Name_Entry;
936 when Convention_Fortran => return Name_Fortran;
937 when Convention_Intrinsic => return Name_Intrinsic;
938 when Convention_Java => return Name_Java;
939 when Convention_Protected => return Name_Protected;
940 when Convention_Stdcall => return Name_Stdcall;
941 when Convention_Stubbed => return Name_Stubbed;
943 end Get_Convention_Name;
945 ---------------------------
946 -- Get_Locking_Policy_Id --
947 ---------------------------
949 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
951 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
952 end Get_Locking_Policy_Id;
958 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
960 if N = Name_AST_Entry then
961 return Pragma_AST_Entry;
962 elsif N = Name_Fast_Math then
963 return Pragma_Fast_Math;
964 elsif N = Name_Interface then
965 return Pragma_Interface;
966 elsif N = Name_Priority then
967 return Pragma_Priority;
968 elsif N = Name_Relative_Deadline then
969 return Pragma_Relative_Deadline;
970 elsif N = Name_Storage_Size then
971 return Pragma_Storage_Size;
972 elsif N = Name_Storage_Unit then
973 return Pragma_Storage_Unit;
974 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
975 return Unknown_Pragma;
977 return Pragma_Id'Val (N - First_Pragma_Name);
981 ---------------------------
982 -- Get_Queuing_Policy_Id --
983 ---------------------------
985 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
987 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
988 end Get_Queuing_Policy_Id;
990 ------------------------------------
991 -- Get_Task_Dispatching_Policy_Id --
992 ------------------------------------
994 function Get_Task_Dispatching_Policy_Id
995 (N : Name_Id) return Task_Dispatching_Policy_Id
998 return Task_Dispatching_Policy_Id'Val
999 (N - First_Task_Dispatching_Policy_Name);
1000 end Get_Task_Dispatching_Policy_Id;
1006 procedure Initialize is
1008 Discard_Name : Name_Id;
1011 P_Index := Preset_Names'First;
1014 while Preset_Names (P_Index) /= '#' loop
1015 Name_Len := Name_Len + 1;
1016 Name_Buffer (Name_Len) := Preset_Names (P_Index);
1017 P_Index := P_Index + 1;
1020 -- We do the Name_Find call to enter the name into the table, but
1021 -- we don't need to do anything with the result, since we already
1022 -- initialized all the preset names to have the right value (we
1023 -- are depending on the order of the names and Preset_Names).
1025 Discard_Name := Name_Find;
1026 P_Index := P_Index + 1;
1027 exit when Preset_Names (P_Index) = '#';
1030 -- Make sure that number of names in standard table is correct. If
1031 -- this check fails, run utility program XSNAMES to construct a new
1032 -- properly matching version of the body.
1034 pragma Assert (Discard_Name = Last_Predefined_Name);
1036 -- Initialize the convention identifiers table with the standard
1037 -- set of synonyms that we recognize for conventions.
1039 Convention_Identifiers.Init;
1041 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
1042 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
1044 Convention_Identifiers.Append ((Name_Default, Convention_C));
1045 Convention_Identifiers.Append ((Name_External, Convention_C));
1047 Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
1049 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
1050 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
1053 -----------------------
1054 -- Is_Attribute_Name --
1055 -----------------------
1057 function Is_Attribute_Name (N : Name_Id) return Boolean is
1059 return N in First_Attribute_Name .. Last_Attribute_Name;
1060 end Is_Attribute_Name;
1062 ----------------------------------
1063 -- Is_Configuration_Pragma_Name --
1064 ----------------------------------
1066 function Is_Configuration_Pragma_Name (N : Name_Id) return Boolean is
1068 return N in First_Pragma_Name .. Last_Configuration_Pragma_Name
1069 or else N = Name_Fast_Math;
1070 end Is_Configuration_Pragma_Name;
1072 ------------------------
1073 -- Is_Convention_Name --
1074 ------------------------
1076 function Is_Convention_Name (N : Name_Id) return Boolean is
1078 -- Check if this is one of the standard conventions
1080 if N in First_Convention_Name .. Last_Convention_Name
1085 -- Otherwise check if it is in convention identifier table
1088 for J in 1 .. Convention_Identifiers.Last loop
1089 if N = Convention_Identifiers.Table (J).Name then
1096 end Is_Convention_Name;
1098 ------------------------------
1099 -- Is_Entity_Attribute_Name --
1100 ------------------------------
1102 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
1104 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
1105 end Is_Entity_Attribute_Name;
1107 --------------------------------
1108 -- Is_Function_Attribute_Name --
1109 --------------------------------
1111 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
1114 First_Renamable_Function_Attribute ..
1115 Last_Renamable_Function_Attribute;
1116 end Is_Function_Attribute_Name;
1118 ---------------------
1119 -- Is_Keyword_Name --
1120 ---------------------
1122 function Is_Keyword_Name (N : Name_Id) return Boolean is
1124 return Get_Name_Table_Byte (N) /= 0
1125 and then (Ada_Version >= Ada_95
1126 or else N not in Ada_95_Reserved_Words)
1127 and then (Ada_Version >= Ada_05
1128 or else N not in Ada_2005_Reserved_Words);
1129 end Is_Keyword_Name;
1131 ----------------------------
1132 -- Is_Locking_Policy_Name --
1133 ----------------------------
1135 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1137 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1138 end Is_Locking_Policy_Name;
1140 -----------------------------
1141 -- Is_Operator_Symbol_Name --
1142 -----------------------------
1144 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1146 return N in First_Operator_Name .. Last_Operator_Name;
1147 end Is_Operator_Symbol_Name;
1149 --------------------
1150 -- Is_Pragma_Name --
1151 --------------------
1153 function Is_Pragma_Name (N : Name_Id) return Boolean is
1155 return N in First_Pragma_Name .. Last_Pragma_Name
1156 or else N = Name_AST_Entry
1157 or else N = Name_Fast_Math
1158 or else N = Name_Interface
1159 or else N = Name_Relative_Deadline
1160 or else N = Name_Priority
1161 or else N = Name_Storage_Size
1162 or else N = Name_Storage_Unit;
1165 ---------------------------------
1166 -- Is_Procedure_Attribute_Name --
1167 ---------------------------------
1169 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1171 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1172 end Is_Procedure_Attribute_Name;
1174 ----------------------------
1175 -- Is_Queuing_Policy_Name --
1176 ----------------------------
1178 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1180 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1181 end Is_Queuing_Policy_Name;
1183 -------------------------------------
1184 -- Is_Task_Dispatching_Policy_Name --
1185 -------------------------------------
1187 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1189 return N in First_Task_Dispatching_Policy_Name ..
1190 Last_Task_Dispatching_Policy_Name;
1191 end Is_Task_Dispatching_Policy_Name;
1193 ----------------------------
1194 -- Is_Type_Attribute_Name --
1195 ----------------------------
1197 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1199 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1200 end Is_Type_Attribute_Name;
1202 ----------------------------------
1203 -- Record_Convention_Identifier --
1204 ----------------------------------
1206 procedure Record_Convention_Identifier
1208 Convention : Convention_Id)
1211 Convention_Identifiers.Append ((Id, Convention));
1212 end Record_Convention_Identifier;