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 ------------------------------------------------------------------------------
37 package body Snames is
39 -- Table used to record convention identifiers
41 type Convention_Id_Entry is record
43 Convention : Convention_Id;
46 package Convention_Identifiers is new Table.Table (
47 Table_Component_Type => Convention_Id_Entry,
48 Table_Index_Type => Int,
51 Table_Increment => 200,
52 Table_Name => "Name_Convention_Identifiers");
54 -- Table of names to be set by Initialize. Each name is terminated by a
55 -- single #, and the end of the list is marked by a null entry, i.e. by
56 -- two # marks in succession. Note that the table does not include the
57 -- entries for a-z, since these are initialized by Namet itself.
59 Preset_Names : constant String :=
77 "_local_final_list#" &
92 "_disp_asynchronous_select#" &
93 "_disp_conditional_select#" &
94 "_disp_get_prim_op_kind#" &
95 "_disp_timed_select#" &
96 "_disp_get_task_id#" &
120 "exception_traces#" &
122 "finalization_root#" &
124 "most_recent_exception#" &
129 "wide_wide_text_io#" &
135 "get_active_partition_id#" &
136 "get_rci_package_receiver#" &
137 "get_rci_package_ref#" &
141 "partition_interface#" &
180 "assertion_policy#" &
182 "compile_time_error#" &
183 "compile_time_warning#" &
184 "component_alignment#" &
185 "convention_identifier#" &
189 "elaboration_checks#" &
192 "extensions_allowed#" &
193 "external_name_casing#" &
194 "float_representation#" &
195 "initialize_scalars#" &
201 "no_strict_aliasing#" &
202 "normalize_scalars#" &
205 "priority_specific_dispatching#" &
207 "profile_warnings#" &
208 "propagate_exceptions#" &
211 "restricted_run_time#" &
213 "restriction_warnings#" &
215 "source_file_name#" &
216 "source_file_name_project#" &
219 "suppress_exception_locations#" &
220 "task_dispatching_policy#" &
226 "wide_character_encoding#" &
228 "all_calls_remote#" &
233 "atomic_components#" &
238 "complete_representation#" &
239 "complex_representation#" &
251 "export_exception#" &
254 "export_procedure#" &
256 "export_valued_procedure#" &
258 "finalize_storage_only#" &
261 "import_exception#" &
264 "import_procedure#" &
265 "import_valued_procedure#" &
269 "inspection_point#" &
271 "interrupt_handler#" &
272 "interrupt_priority#" &
273 "java_constructor#" &
278 "linker_constructor#" &
279 "linker_destructor#" &
283 "machine_attribute#" &
294 "preelaborable_initialization#" &
301 "remote_call_interface#" &
306 "source_reference#" &
307 "static_elaboration_desired#" &
311 "suppress_debug_info#" &
312 "suppress_initialization#" &
320 "unimplemented_unit#" &
321 "universal_aliasing#" &
323 "unreferenced_objects#" &
324 "unreserve_all_interrupts#" &
326 "volatile_components#" &
347 "boolean_entry_barriers#" &
352 "component_size_4#" &
361 "first_optional_parameter#" &
373 "max_entry_queue_depth#" &
374 "max_entry_queue_length#" &
384 "no_dynamic_attachment#" &
385 "no_dynamic_interrupts#" &
387 "no_requeue_statements#" &
388 "no_task_attributes#" &
389 "no_task_attributes_package#" &
394 "result_mechanism#" &
398 "secondary_stack_size#" &
406 "subunit_file_name#" &
407 "task_stack_size_default#" &
409 "time_slicing_enabled#" &
443 "default_bit_order#" &
458 "has_access_values#" &
459 "has_discriminants#" &
470 "machine_mantissa#" &
471 "machine_overflows#" &
473 "machine_rounding#" &
477 "max_size_in_storage_elements#" &
478 "maximum_alignment#" &
489 "passed_by_reference#" &
516 "unbiased_rounding#" &
517 "unchecked_access#" &
518 "unconstrained_array#" &
519 "universal_literal_string#" &
520 "unrestricted_access#" &
562 "inheritance_locking#" &
564 "priority_queuing#" &
565 "edf_across_priorities#" &
566 "fifo_within_priorities#" &
567 "non_preemptive_within_priorities#" &
568 "round_robin_within_priorities#" &
570 "accessibility_check#" &
572 "discriminant_check#" &
574 "elaboration_check#" &
642 "enclosing_entity#" &
643 "exception_information#" &
644 "exception_message#" &
647 "generic_dispatching_constructor#" &
649 "import_largest_value#" &
657 "shift_right_arithmetic#" &
659 "unchecked_conversion#" &
660 "unchecked_deallocation#" &
679 "builder_switches#" &
683 "compiler_pic_option#" &
684 "compute_dependency#" &
685 "config_body_file_name#" &
686 "config_body_file_name_pattern#" &
687 "config_file_switches#" &
688 "config_file_unique#" &
689 "config_spec_file_name#" &
690 "config_spec_file_name_pattern#" &
692 "default_builder_switches#" &
693 "default_global_compiler_switches#" &
694 "default_language#" &
696 "default_minimum_linker_options#" &
697 "default_switches#" &
698 "dependency_file_kind#" &
699 "dependency_option#" &
702 "executable_suffix#" &
704 "externally_built#" &
706 "global_compiler_switches#" &
707 "global_configuration_pragmas#" &
708 "global_config_file#" &
712 "implementation_exceptions#" &
713 "implementation_suffix#" &
716 "include_path_file#" &
718 "language_processing#" &
721 "library_auto_init#" &
722 "library_auto_init_supported#" &
726 "library_interface#" &
729 "library_major_minor_id_supported#" &
731 "library_partial_linker#" &
732 "library_reference_symbol_file#" &
735 "library_symbol_file#" &
736 "library_symbol_policy#" &
738 "library_version_options#" &
740 "linker_executable_option#" &
741 "linker_lib_dir_option#" &
742 "linker_lib_name_option#" &
743 "local_config_file#" &
744 "local_configuration_pragmas#" &
745 "locally_removed_files#" &
746 "mapping_file_switches#" &
747 "mapping_spec_suffix#" &
748 "mapping_body_suffix#" &
750 "minimum_binder_options#" &
751 "minimum_compiler_options#" &
752 "minimum_linker_options#" &
755 "objects_path_file#" &
762 "shared_library_minimum_options#" &
763 "shared_library_prefix#" &
764 "shared_library_suffix#" &
768 "source_list_file#" &
772 "specification_exceptions#" &
773 "specification_suffix#" &
776 "symbolic_link_supported#" &
777 "toolchain_description#" &
778 "toolchain_version#" &
785 ---------------------
786 -- Generated Names --
787 ---------------------
789 -- This section lists the various cases of generated names which are
790 -- built from existing names by adding unique leading and/or trailing
791 -- upper case letters. In some cases these names are built recursively,
792 -- in particular names built from types may be built from types which
793 -- themselves have generated names. In this list, xxx represents an
794 -- existing name to which identifying letters are prepended or appended,
795 -- and a trailing n represents a serial number in an external name that
796 -- has some semantic significance (e.g. the n'th index type of an array).
798 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
799 -- xxxB tag table for tagged type xxx (Exp_Ch3)
800 -- xxxB task body procedure for task xxx (Exp_Ch9)
801 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
802 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
803 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
804 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
805 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
806 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
807 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
808 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
809 -- xxxM master Id value for access type xxx (Exp_Ch3)
810 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
811 -- xxxP parameter record type for entry xxx (Exp_Ch9)
812 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
813 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
814 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
815 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
816 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
817 -- xxxV type for task value record for task xxx (Exp_Ch9)
818 -- xxxX entry index constant (Exp_Ch9)
819 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
820 -- xxxZ size variable for task xxx (Exp_Ch9)
824 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
825 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
826 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
827 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
828 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
829 -- xxxIP initialization procedure for type xxx (Exp_TSS)
830 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
831 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
832 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
833 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
834 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
835 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
836 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
837 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
838 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
839 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
841 -- Implicit type names
843 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
845 -- (Note: this list is not complete or accurate ???)
847 ----------------------
848 -- Get_Attribute_Id --
849 ----------------------
851 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
853 return Attribute_Id'Val (N - First_Attribute_Name);
854 end Get_Attribute_Id;
860 function Get_Check_Id (N : Name_Id) return Check_Id is
862 return Check_Id'Val (N - First_Check_Name);
865 -----------------------
866 -- Get_Convention_Id --
867 -----------------------
869 function Get_Convention_Id (N : Name_Id) return Convention_Id is
872 when Name_Ada => return Convention_Ada;
873 when Name_Assembler => return Convention_Assembler;
874 when Name_C => return Convention_C;
875 when Name_CIL => return Convention_CIL;
876 when Name_COBOL => return Convention_COBOL;
877 when Name_CPP => return Convention_CPP;
878 when Name_Fortran => return Convention_Fortran;
879 when Name_Intrinsic => return Convention_Intrinsic;
880 when Name_Java => return Convention_Java;
881 when Name_Stdcall => return Convention_Stdcall;
882 when Name_Stubbed => return Convention_Stubbed;
884 -- If no direct match, then we must have a convention
885 -- identifier pragma that has specified this name.
888 for J in 1 .. Convention_Identifiers.Last loop
889 if N = Convention_Identifiers.Table (J).Name then
890 return Convention_Identifiers.Table (J).Convention;
896 end Get_Convention_Id;
898 -------------------------
899 -- Get_Convention_Name --
900 -------------------------
902 function Get_Convention_Name (C : Convention_Id) return Name_Id is
905 when Convention_Ada => return Name_Ada;
906 when Convention_Assembler => return Name_Assembler;
907 when Convention_C => return Name_C;
908 when Convention_CIL => return Name_CIL;
909 when Convention_COBOL => return Name_COBOL;
910 when Convention_CPP => return Name_CPP;
911 when Convention_Entry => return Name_Entry;
912 when Convention_Fortran => return Name_Fortran;
913 when Convention_Intrinsic => return Name_Intrinsic;
914 when Convention_Java => return Name_Java;
915 when Convention_Protected => return Name_Protected;
916 when Convention_Stdcall => return Name_Stdcall;
917 when Convention_Stubbed => return Name_Stubbed;
919 end Get_Convention_Name;
921 ---------------------------
922 -- Get_Locking_Policy_Id --
923 ---------------------------
925 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
927 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
928 end Get_Locking_Policy_Id;
934 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
936 if N = Name_AST_Entry then
937 return Pragma_AST_Entry;
938 elsif N = Name_Interface then
939 return Pragma_Interface;
940 elsif N = Name_Priority then
941 return Pragma_Priority;
942 elsif N = Name_Storage_Size then
943 return Pragma_Storage_Size;
944 elsif N = Name_Storage_Unit then
945 return Pragma_Storage_Unit;
946 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
947 return Unknown_Pragma;
949 return Pragma_Id'Val (N - First_Pragma_Name);
953 ---------------------------
954 -- Get_Queuing_Policy_Id --
955 ---------------------------
957 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
959 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
960 end Get_Queuing_Policy_Id;
962 ------------------------------------
963 -- Get_Task_Dispatching_Policy_Id --
964 ------------------------------------
966 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
967 return Task_Dispatching_Policy_Id is
969 return Task_Dispatching_Policy_Id'Val
970 (N - First_Task_Dispatching_Policy_Name);
971 end Get_Task_Dispatching_Policy_Id;
977 procedure Initialize is
979 Discard_Name : Name_Id;
982 P_Index := Preset_Names'First;
987 while Preset_Names (P_Index) /= '#' loop
988 Name_Len := Name_Len + 1;
989 Name_Buffer (Name_Len) := Preset_Names (P_Index);
990 P_Index := P_Index + 1;
993 -- We do the Name_Find call to enter the name into the table, but
994 -- we don't need to do anything with the result, since we already
995 -- initialized all the preset names to have the right value (we
996 -- are depending on the order of the names and Preset_Names).
998 Discard_Name := Name_Find;
999 P_Index := P_Index + 1;
1000 exit when Preset_Names (P_Index) = '#';
1003 -- Make sure that number of names in standard table is correct. If
1004 -- this check fails, run utility program XSNAMES to construct a new
1005 -- properly matching version of the body.
1007 pragma Assert (Discard_Name = Last_Predefined_Name);
1009 -- Initialize the convention identifiers table with the standard
1010 -- set of synonyms that we recognize for conventions.
1012 Convention_Identifiers.Init;
1014 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
1015 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
1017 Convention_Identifiers.Append ((Name_Default, Convention_C));
1018 Convention_Identifiers.Append ((Name_External, Convention_C));
1020 Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
1022 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
1023 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
1026 -----------------------
1027 -- Is_Attribute_Name --
1028 -----------------------
1030 function Is_Attribute_Name (N : Name_Id) return Boolean is
1032 return N in First_Attribute_Name .. Last_Attribute_Name;
1033 end Is_Attribute_Name;
1039 function Is_Check_Name (N : Name_Id) return Boolean is
1041 return N in First_Check_Name .. Last_Check_Name;
1044 ------------------------
1045 -- Is_Convention_Name --
1046 ------------------------
1048 function Is_Convention_Name (N : Name_Id) return Boolean is
1050 -- Check if this is one of the standard conventions
1052 if N in First_Convention_Name .. Last_Convention_Name
1057 -- Otherwise check if it is in convention identifier table
1060 for J in 1 .. Convention_Identifiers.Last loop
1061 if N = Convention_Identifiers.Table (J).Name then
1068 end Is_Convention_Name;
1070 ------------------------------
1071 -- Is_Entity_Attribute_Name --
1072 ------------------------------
1074 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
1076 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
1077 end Is_Entity_Attribute_Name;
1079 --------------------------------
1080 -- Is_Function_Attribute_Name --
1081 --------------------------------
1083 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
1086 First_Renamable_Function_Attribute ..
1087 Last_Renamable_Function_Attribute;
1088 end Is_Function_Attribute_Name;
1090 ---------------------
1091 -- Is_Keyword_Name --
1092 ---------------------
1094 function Is_Keyword_Name (N : Name_Id) return Boolean is
1096 return Get_Name_Table_Byte (N) /= 0
1097 and then (Ada_Version >= Ada_95
1098 or else N not in Ada_95_Reserved_Words)
1099 and then (Ada_Version >= Ada_05
1100 or else N not in Ada_2005_Reserved_Words);
1101 end Is_Keyword_Name;
1103 ----------------------------
1104 -- Is_Locking_Policy_Name --
1105 ----------------------------
1107 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1109 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1110 end Is_Locking_Policy_Name;
1112 -----------------------------
1113 -- Is_Operator_Symbol_Name --
1114 -----------------------------
1116 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1118 return N in First_Operator_Name .. Last_Operator_Name;
1119 end Is_Operator_Symbol_Name;
1121 --------------------
1122 -- Is_Pragma_Name --
1123 --------------------
1125 function Is_Pragma_Name (N : Name_Id) return Boolean is
1127 return N in First_Pragma_Name .. Last_Pragma_Name
1128 or else N = Name_AST_Entry
1129 or else N = Name_Interface
1130 or else N = Name_Priority
1131 or else N = Name_Storage_Size
1132 or else N = Name_Storage_Unit;
1135 ---------------------------------
1136 -- Is_Procedure_Attribute_Name --
1137 ---------------------------------
1139 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1141 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1142 end Is_Procedure_Attribute_Name;
1144 ----------------------------
1145 -- Is_Queuing_Policy_Name --
1146 ----------------------------
1148 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1150 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1151 end Is_Queuing_Policy_Name;
1153 -------------------------------------
1154 -- Is_Task_Dispatching_Policy_Name --
1155 -------------------------------------
1157 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1159 return N in First_Task_Dispatching_Policy_Name ..
1160 Last_Task_Dispatching_Policy_Name;
1161 end Is_Task_Dispatching_Policy_Name;
1163 ----------------------------
1164 -- Is_Type_Attribute_Name --
1165 ----------------------------
1167 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1169 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1170 end Is_Type_Attribute_Name;
1172 ----------------------------------
1173 -- Record_Convention_Identifier --
1174 ----------------------------------
1176 procedure Record_Convention_Identifier
1178 Convention : Convention_Id)
1181 Convention_Identifiers.Append ((Id, Convention));
1182 end Record_Convention_Identifier;