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#" &
209 "optimize_alignment#" &
212 "priority_specific_dispatching#" &
214 "profile_warnings#" &
215 "propagate_exceptions#" &
218 "restricted_run_time#" &
220 "restriction_warnings#" &
222 "source_file_name#" &
223 "source_file_name_project#" &
226 "suppress_exception_locations#" &
227 "task_dispatching_policy#" &
233 "wide_character_encoding#" &
235 "all_calls_remote#" &
240 "atomic_components#" &
245 "complete_representation#" &
246 "complex_representation#" &
258 "export_exception#" &
261 "export_procedure#" &
263 "export_valued_procedure#" &
265 "finalize_storage_only#" &
267 "implemented_by_entry#" &
269 "import_exception#" &
272 "import_procedure#" &
273 "import_valued_procedure#" &
277 "inspection_point#" &
279 "interrupt_handler#" &
280 "interrupt_priority#" &
281 "java_constructor#" &
286 "linker_constructor#" &
287 "linker_destructor#" &
291 "machine_attribute#" &
302 "preelaborable_initialization#" &
309 "remote_call_interface#" &
314 "source_reference#" &
315 "static_elaboration_desired#" &
319 "suppress_debug_info#" &
320 "suppress_initialization#" &
328 "unimplemented_unit#" &
329 "universal_aliasing#" &
332 "unreferenced_objects#" &
333 "unreserve_all_interrupts#" &
335 "volatile_components#" &
356 "boolean_entry_barriers#" &
361 "component_size_4#" &
370 "first_optional_parameter#" &
382 "max_entry_queue_depth#" &
383 "max_entry_queue_length#" &
393 "no_dynamic_attachment#" &
394 "no_dynamic_interrupts#" &
396 "no_requeue_statements#" &
397 "no_task_attributes#" &
398 "no_task_attributes_package#" &
403 "result_mechanism#" &
407 "secondary_stack_size#" &
415 "subunit_file_name#" &
416 "task_stack_size_default#" &
418 "time_slicing_enabled#" &
452 "default_bit_order#" &
469 "has_access_values#" &
470 "has_discriminants#" &
481 "machine_mantissa#" &
482 "machine_overflows#" &
484 "machine_rounding#" &
488 "max_size_in_storage_elements#" &
489 "maximum_alignment#" &
501 "passed_by_reference#" &
528 "unbiased_rounding#" &
529 "unchecked_access#" &
530 "unconstrained_array#" &
531 "universal_literal_string#" &
532 "unrestricted_access#" &
574 "inheritance_locking#" &
576 "priority_queuing#" &
577 "edf_across_priorities#" &
578 "fifo_within_priorities#" &
579 "round_robin_within_priorities#" &
581 "accessibility_check#" &
583 "discriminant_check#" &
585 "elaboration_check#" &
653 "enclosing_entity#" &
654 "exception_information#" &
655 "exception_message#" &
658 "generic_dispatching_constructor#" &
660 "import_largest_value#" &
668 "shift_right_arithmetic#" &
670 "unchecked_conversion#" &
671 "unchecked_deallocation#" &
689 "builder_switches#" &
692 "config_body_file_name#" &
693 "config_body_file_name_pattern#" &
694 "config_file_switches#" &
695 "config_file_unique#" &
696 "config_spec_file_name#" &
697 "config_spec_file_name_pattern#" &
699 "default_language#" &
700 "default_switches#" &
701 "dependency_driver#" &
702 "dependency_file_kind#" &
703 "dependency_switches#" &
705 "excluded_source_dirs#" &
706 "excluded_source_files#" &
709 "executable_suffix#" &
711 "externally_built#" &
713 "global_configuration_pragmas#" &
714 "global_config_file#" &
718 "implementation_exceptions#" &
719 "implementation_suffix#" &
720 "include_switches#" &
722 "include_path_file#" &
724 "language_processing#" &
727 "library_auto_init#" &
728 "library_auto_init_supported#" &
732 "library_interface#" &
735 "library_major_minor_id_supported#" &
737 "library_partial_linker#" &
738 "library_reference_symbol_file#" &
741 "library_symbol_file#" &
742 "library_symbol_policy#" &
744 "library_version_switches#" &
746 "linker_executable_option#" &
747 "linker_lib_dir_option#" &
748 "linker_lib_name_option#" &
749 "local_config_file#" &
750 "local_configuration_pragmas#" &
751 "locally_removed_files#" &
752 "mapping_file_switches#" &
753 "mapping_spec_suffix#" &
754 "mapping_body_suffix#" &
758 "objects_path_file#" &
765 "required_switches#" &
768 "shared_library_minimum_switches#" &
769 "shared_library_prefix#" &
770 "shared_library_suffix#" &
774 "source_list_file#" &
778 "specification_exceptions#" &
779 "specification_suffix#" &
782 "symbolic_link_supported#" &
785 "toolchain_description#" &
786 "toolchain_version#" &
787 "runtime_library_dir#" &
794 ---------------------
795 -- Generated Names --
796 ---------------------
798 -- This section lists the various cases of generated names which are
799 -- built from existing names by adding unique leading and/or trailing
800 -- upper case letters. In some cases these names are built recursively,
801 -- in particular names built from types may be built from types which
802 -- themselves have generated names. In this list, xxx represents an
803 -- existing name to which identifying letters are prepended or appended,
804 -- and a trailing n represents a serial number in an external name that
805 -- has some semantic significance (e.g. the n'th index type of an array).
807 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
808 -- xxxB tag table for tagged type xxx (Exp_Ch3)
809 -- xxxB task body procedure for task xxx (Exp_Ch9)
810 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
811 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
812 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
813 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
814 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
815 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
816 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
817 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
818 -- xxxM master Id value for access type xxx (Exp_Ch3)
819 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
820 -- xxxP parameter record type for entry xxx (Exp_Ch9)
821 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
822 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
823 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
824 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
825 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
826 -- xxxV type for task value record for task xxx (Exp_Ch9)
827 -- xxxX entry index constant (Exp_Ch9)
828 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
829 -- xxxZ size variable for task xxx (Exp_Ch9)
833 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
834 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
835 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
836 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
837 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
838 -- xxxIP initialization procedure for type xxx (Exp_TSS)
839 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
840 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
841 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
842 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
843 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
844 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
845 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
846 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
847 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
848 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
850 -- Implicit type names
852 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
854 -- (Note: this list is not complete or accurate ???)
856 ----------------------
857 -- Get_Attribute_Id --
858 ----------------------
860 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
862 return Attribute_Id'Val (N - First_Attribute_Name);
863 end Get_Attribute_Id;
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_Fast_Math then
939 return Pragma_Fast_Math;
940 elsif N = Name_Interface then
941 return Pragma_Interface;
942 elsif N = Name_Priority then
943 return Pragma_Priority;
944 elsif N = Name_Storage_Size then
945 return Pragma_Storage_Size;
946 elsif N = Name_Storage_Unit then
947 return Pragma_Storage_Unit;
948 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
949 return Unknown_Pragma;
951 return Pragma_Id'Val (N - First_Pragma_Name);
955 ---------------------------
956 -- Get_Queuing_Policy_Id --
957 ---------------------------
959 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
961 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
962 end Get_Queuing_Policy_Id;
964 ------------------------------------
965 -- Get_Task_Dispatching_Policy_Id --
966 ------------------------------------
968 function Get_Task_Dispatching_Policy_Id
969 (N : Name_Id) return Task_Dispatching_Policy_Id
972 return Task_Dispatching_Policy_Id'Val
973 (N - First_Task_Dispatching_Policy_Name);
974 end Get_Task_Dispatching_Policy_Id;
980 procedure Initialize is
982 Discard_Name : Name_Id;
985 P_Index := Preset_Names'First;
988 while Preset_Names (P_Index) /= '#' loop
989 Name_Len := Name_Len + 1;
990 Name_Buffer (Name_Len) := Preset_Names (P_Index);
991 P_Index := P_Index + 1;
994 -- We do the Name_Find call to enter the name into the table, but
995 -- we don't need to do anything with the result, since we already
996 -- initialized all the preset names to have the right value (we
997 -- are depending on the order of the names and Preset_Names).
999 Discard_Name := Name_Find;
1000 P_Index := P_Index + 1;
1001 exit when Preset_Names (P_Index) = '#';
1004 -- Make sure that number of names in standard table is correct. If
1005 -- this check fails, run utility program XSNAMES to construct a new
1006 -- properly matching version of the body.
1008 pragma Assert (Discard_Name = Last_Predefined_Name);
1010 -- Initialize the convention identifiers table with the standard
1011 -- set of synonyms that we recognize for conventions.
1013 Convention_Identifiers.Init;
1015 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
1016 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
1018 Convention_Identifiers.Append ((Name_Default, Convention_C));
1019 Convention_Identifiers.Append ((Name_External, Convention_C));
1021 Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
1023 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
1024 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
1027 -----------------------
1028 -- Is_Attribute_Name --
1029 -----------------------
1031 function Is_Attribute_Name (N : Name_Id) return Boolean is
1033 return N in First_Attribute_Name .. Last_Attribute_Name;
1034 end Is_Attribute_Name;
1036 ----------------------------------
1037 -- Is_Configuration_Pragma_Name --
1038 ----------------------------------
1040 function Is_Configuration_Pragma_Name (N : Name_Id) return Boolean is
1042 return N in First_Pragma_Name .. Last_Configuration_Pragma_Name
1043 or else N = Name_Fast_Math;
1044 end Is_Configuration_Pragma_Name;
1046 ------------------------
1047 -- Is_Convention_Name --
1048 ------------------------
1050 function Is_Convention_Name (N : Name_Id) return Boolean is
1052 -- Check if this is one of the standard conventions
1054 if N in First_Convention_Name .. Last_Convention_Name
1059 -- Otherwise check if it is in convention identifier table
1062 for J in 1 .. Convention_Identifiers.Last loop
1063 if N = Convention_Identifiers.Table (J).Name then
1070 end Is_Convention_Name;
1072 ------------------------------
1073 -- Is_Entity_Attribute_Name --
1074 ------------------------------
1076 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
1078 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
1079 end Is_Entity_Attribute_Name;
1081 --------------------------------
1082 -- Is_Function_Attribute_Name --
1083 --------------------------------
1085 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
1088 First_Renamable_Function_Attribute ..
1089 Last_Renamable_Function_Attribute;
1090 end Is_Function_Attribute_Name;
1092 ---------------------
1093 -- Is_Keyword_Name --
1094 ---------------------
1096 function Is_Keyword_Name (N : Name_Id) return Boolean is
1098 return Get_Name_Table_Byte (N) /= 0
1099 and then (Ada_Version >= Ada_95
1100 or else N not in Ada_95_Reserved_Words)
1101 and then (Ada_Version >= Ada_05
1102 or else N not in Ada_2005_Reserved_Words);
1103 end Is_Keyword_Name;
1105 ----------------------------
1106 -- Is_Locking_Policy_Name --
1107 ----------------------------
1109 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1111 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1112 end Is_Locking_Policy_Name;
1114 -----------------------------
1115 -- Is_Operator_Symbol_Name --
1116 -----------------------------
1118 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1120 return N in First_Operator_Name .. Last_Operator_Name;
1121 end Is_Operator_Symbol_Name;
1123 --------------------
1124 -- Is_Pragma_Name --
1125 --------------------
1127 function Is_Pragma_Name (N : Name_Id) return Boolean is
1129 return N in First_Pragma_Name .. Last_Pragma_Name
1130 or else N = Name_AST_Entry
1131 or else N = Name_Fast_Math
1132 or else N = Name_Interface
1133 or else N = Name_Priority
1134 or else N = Name_Storage_Size
1135 or else N = Name_Storage_Unit;
1138 ---------------------------------
1139 -- Is_Procedure_Attribute_Name --
1140 ---------------------------------
1142 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1144 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1145 end Is_Procedure_Attribute_Name;
1147 ----------------------------
1148 -- Is_Queuing_Policy_Name --
1149 ----------------------------
1151 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1153 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1154 end Is_Queuing_Policy_Name;
1156 -------------------------------------
1157 -- Is_Task_Dispatching_Policy_Name --
1158 -------------------------------------
1160 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1162 return N in First_Task_Dispatching_Policy_Name ..
1163 Last_Task_Dispatching_Policy_Name;
1164 end Is_Task_Dispatching_Policy_Name;
1166 ----------------------------
1167 -- Is_Type_Attribute_Name --
1168 ----------------------------
1170 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1172 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1173 end Is_Type_Attribute_Name;
1175 ----------------------------------
1176 -- Record_Convention_Identifier --
1177 ----------------------------------
1179 procedure Record_Convention_Identifier
1181 Convention : Convention_Id)
1184 Convention_Identifiers.Append ((Id, Convention));
1185 end Record_Convention_Identifier;