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_timed_select#" &
97 "_disp_get_task_id#" &
121 "exception_traces#" &
123 "finalization_root#" &
125 "most_recent_exception#" &
130 "wide_wide_text_io#" &
136 "get_active_partition_id#" &
137 "get_rci_package_receiver#" &
138 "get_rci_package_ref#" &
142 "partition_interface#" &
181 "assertion_policy#" &
184 "compile_time_error#" &
185 "compile_time_warning#" &
186 "component_alignment#" &
187 "convention_identifier#" &
191 "elaboration_checks#" &
194 "extensions_allowed#" &
195 "external_name_casing#" &
196 "float_representation#" &
197 "implicit_packing#" &
198 "initialize_scalars#" &
204 "no_strict_aliasing#" &
205 "normalize_scalars#" &
208 "priority_specific_dispatching#" &
210 "profile_warnings#" &
211 "propagate_exceptions#" &
214 "restricted_run_time#" &
216 "restriction_warnings#" &
218 "source_file_name#" &
219 "source_file_name_project#" &
222 "suppress_exception_locations#" &
223 "task_dispatching_policy#" &
229 "wide_character_encoding#" &
231 "all_calls_remote#" &
236 "atomic_components#" &
241 "complete_representation#" &
242 "complex_representation#" &
254 "export_exception#" &
257 "export_procedure#" &
259 "export_valued_procedure#" &
261 "finalize_storage_only#" &
264 "import_exception#" &
267 "import_procedure#" &
268 "import_valued_procedure#" &
272 "inspection_point#" &
274 "interrupt_handler#" &
275 "interrupt_priority#" &
276 "java_constructor#" &
281 "linker_constructor#" &
282 "linker_destructor#" &
286 "machine_attribute#" &
297 "preelaborable_initialization#" &
304 "remote_call_interface#" &
309 "source_reference#" &
310 "static_elaboration_desired#" &
314 "suppress_debug_info#" &
315 "suppress_initialization#" &
323 "unimplemented_unit#" &
324 "universal_aliasing#" &
326 "unreferenced_objects#" &
327 "unreserve_all_interrupts#" &
329 "volatile_components#" &
350 "boolean_entry_barriers#" &
355 "component_size_4#" &
364 "first_optional_parameter#" &
376 "max_entry_queue_depth#" &
377 "max_entry_queue_length#" &
387 "no_dynamic_attachment#" &
388 "no_dynamic_interrupts#" &
390 "no_requeue_statements#" &
391 "no_task_attributes#" &
392 "no_task_attributes_package#" &
397 "result_mechanism#" &
401 "secondary_stack_size#" &
409 "subunit_file_name#" &
410 "task_stack_size_default#" &
412 "time_slicing_enabled#" &
446 "default_bit_order#" &
462 "has_access_values#" &
463 "has_discriminants#" &
474 "machine_mantissa#" &
475 "machine_overflows#" &
477 "machine_rounding#" &
481 "max_size_in_storage_elements#" &
482 "maximum_alignment#" &
493 "passed_by_reference#" &
520 "unbiased_rounding#" &
521 "unchecked_access#" &
522 "unconstrained_array#" &
523 "universal_literal_string#" &
524 "unrestricted_access#" &
566 "inheritance_locking#" &
568 "priority_queuing#" &
569 "edf_across_priorities#" &
570 "fifo_within_priorities#" &
571 "non_preemptive_within_priorities#" &
572 "round_robin_within_priorities#" &
574 "accessibility_check#" &
576 "discriminant_check#" &
578 "elaboration_check#" &
646 "enclosing_entity#" &
647 "exception_information#" &
648 "exception_message#" &
651 "generic_dispatching_constructor#" &
653 "import_largest_value#" &
661 "shift_right_arithmetic#" &
663 "unchecked_conversion#" &
664 "unchecked_deallocation#" &
682 "builder_switches#" &
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_language#" &
693 "default_switches#" &
694 "dependency_driver#" &
695 "dependency_file_kind#" &
696 "dependency_switches#" &
700 "executable_suffix#" &
702 "externally_built#" &
704 "global_configuration_pragmas#" &
705 "global_config_file#" &
709 "implementation_exceptions#" &
710 "implementation_suffix#" &
713 "include_path_file#" &
715 "language_processing#" &
718 "library_auto_init#" &
719 "library_auto_init_supported#" &
723 "library_interface#" &
726 "library_major_minor_id_supported#" &
728 "library_partial_linker#" &
729 "library_reference_symbol_file#" &
732 "library_symbol_file#" &
733 "library_symbol_policy#" &
735 "library_version_switches#" &
737 "linker_executable_option#" &
738 "linker_lib_dir_option#" &
739 "linker_lib_name_option#" &
740 "local_config_file#" &
741 "local_configuration_pragmas#" &
742 "locally_removed_files#" &
743 "mapping_file_switches#" &
744 "mapping_spec_suffix#" &
745 "mapping_body_suffix#" &
749 "objects_path_file#" &
756 "removed_source_dirs#" &
757 "required_switches#" &
760 "shared_library_minimum_switches#" &
761 "shared_library_prefix#" &
762 "shared_library_suffix#" &
766 "source_list_file#" &
770 "specification_exceptions#" &
771 "specification_suffix#" &
774 "symbolic_link_supported#" &
775 "toolchain_description#" &
776 "toolchain_version#" &
783 ---------------------
784 -- Generated Names --
785 ---------------------
787 -- This section lists the various cases of generated names which are
788 -- built from existing names by adding unique leading and/or trailing
789 -- upper case letters. In some cases these names are built recursively,
790 -- in particular names built from types may be built from types which
791 -- themselves have generated names. In this list, xxx represents an
792 -- existing name to which identifying letters are prepended or appended,
793 -- and a trailing n represents a serial number in an external name that
794 -- has some semantic significance (e.g. the n'th index type of an array).
796 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
797 -- xxxB tag table for tagged type xxx (Exp_Ch3)
798 -- xxxB task body procedure for task xxx (Exp_Ch9)
799 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
800 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
801 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
802 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
803 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
804 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
805 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
806 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
807 -- xxxM master Id value for access type xxx (Exp_Ch3)
808 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
809 -- xxxP parameter record type for entry xxx (Exp_Ch9)
810 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
811 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
812 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
813 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
814 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
815 -- xxxV type for task value record for task xxx (Exp_Ch9)
816 -- xxxX entry index constant (Exp_Ch9)
817 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
818 -- xxxZ size variable for task xxx (Exp_Ch9)
822 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
823 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
824 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
825 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
826 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
827 -- xxxIP initialization procedure for type xxx (Exp_TSS)
828 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
829 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
830 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
831 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
832 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
833 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
834 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
835 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
836 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
837 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
839 -- Implicit type names
841 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
843 -- (Note: this list is not complete or accurate ???)
845 ----------------------
846 -- Get_Attribute_Id --
847 ----------------------
849 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
851 return Attribute_Id'Val (N - First_Attribute_Name);
852 end Get_Attribute_Id;
854 -----------------------
855 -- Get_Convention_Id --
856 -----------------------
858 function Get_Convention_Id (N : Name_Id) return Convention_Id is
861 when Name_Ada => return Convention_Ada;
862 when Name_Assembler => return Convention_Assembler;
863 when Name_C => return Convention_C;
864 when Name_CIL => return Convention_CIL;
865 when Name_COBOL => return Convention_COBOL;
866 when Name_CPP => return Convention_CPP;
867 when Name_Fortran => return Convention_Fortran;
868 when Name_Intrinsic => return Convention_Intrinsic;
869 when Name_Java => return Convention_Java;
870 when Name_Stdcall => return Convention_Stdcall;
871 when Name_Stubbed => return Convention_Stubbed;
873 -- If no direct match, then we must have a convention
874 -- identifier pragma that has specified this name.
877 for J in 1 .. Convention_Identifiers.Last loop
878 if N = Convention_Identifiers.Table (J).Name then
879 return Convention_Identifiers.Table (J).Convention;
885 end Get_Convention_Id;
887 -------------------------
888 -- Get_Convention_Name --
889 -------------------------
891 function Get_Convention_Name (C : Convention_Id) return Name_Id is
894 when Convention_Ada => return Name_Ada;
895 when Convention_Assembler => return Name_Assembler;
896 when Convention_C => return Name_C;
897 when Convention_CIL => return Name_CIL;
898 when Convention_COBOL => return Name_COBOL;
899 when Convention_CPP => return Name_CPP;
900 when Convention_Entry => return Name_Entry;
901 when Convention_Fortran => return Name_Fortran;
902 when Convention_Intrinsic => return Name_Intrinsic;
903 when Convention_Java => return Name_Java;
904 when Convention_Protected => return Name_Protected;
905 when Convention_Stdcall => return Name_Stdcall;
906 when Convention_Stubbed => return Name_Stubbed;
908 end Get_Convention_Name;
910 ---------------------------
911 -- Get_Locking_Policy_Id --
912 ---------------------------
914 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
916 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
917 end Get_Locking_Policy_Id;
923 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
925 if N = Name_AST_Entry then
926 return Pragma_AST_Entry;
927 elsif N = Name_Interface then
928 return Pragma_Interface;
929 elsif N = Name_Priority then
930 return Pragma_Priority;
931 elsif N = Name_Storage_Size then
932 return Pragma_Storage_Size;
933 elsif N = Name_Storage_Unit then
934 return Pragma_Storage_Unit;
935 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
936 return Unknown_Pragma;
938 return Pragma_Id'Val (N - First_Pragma_Name);
942 ---------------------------
943 -- Get_Queuing_Policy_Id --
944 ---------------------------
946 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
948 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
949 end Get_Queuing_Policy_Id;
951 ------------------------------------
952 -- Get_Task_Dispatching_Policy_Id --
953 ------------------------------------
955 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
956 return Task_Dispatching_Policy_Id is
958 return Task_Dispatching_Policy_Id'Val
959 (N - First_Task_Dispatching_Policy_Name);
960 end Get_Task_Dispatching_Policy_Id;
966 procedure Initialize is
968 Discard_Name : Name_Id;
971 P_Index := Preset_Names'First;
976 while Preset_Names (P_Index) /= '#' loop
977 Name_Len := Name_Len + 1;
978 Name_Buffer (Name_Len) := Preset_Names (P_Index);
979 P_Index := P_Index + 1;
982 -- We do the Name_Find call to enter the name into the table, but
983 -- we don't need to do anything with the result, since we already
984 -- initialized all the preset names to have the right value (we
985 -- are depending on the order of the names and Preset_Names).
987 Discard_Name := Name_Find;
988 P_Index := P_Index + 1;
989 exit when Preset_Names (P_Index) = '#';
992 -- Make sure that number of names in standard table is correct. If
993 -- this check fails, run utility program XSNAMES to construct a new
994 -- properly matching version of the body.
996 pragma Assert (Discard_Name = Last_Predefined_Name);
998 -- Initialize the convention identifiers table with the standard
999 -- set of synonyms that we recognize for conventions.
1001 Convention_Identifiers.Init;
1003 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
1004 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
1006 Convention_Identifiers.Append ((Name_Default, Convention_C));
1007 Convention_Identifiers.Append ((Name_External, Convention_C));
1009 Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
1011 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
1012 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
1015 -----------------------
1016 -- Is_Attribute_Name --
1017 -----------------------
1019 function Is_Attribute_Name (N : Name_Id) return Boolean is
1021 return N in First_Attribute_Name .. Last_Attribute_Name;
1022 end Is_Attribute_Name;
1024 ------------------------
1025 -- Is_Convention_Name --
1026 ------------------------
1028 function Is_Convention_Name (N : Name_Id) return Boolean is
1030 -- Check if this is one of the standard conventions
1032 if N in First_Convention_Name .. Last_Convention_Name
1037 -- Otherwise check if it is in convention identifier table
1040 for J in 1 .. Convention_Identifiers.Last loop
1041 if N = Convention_Identifiers.Table (J).Name then
1048 end Is_Convention_Name;
1050 ------------------------------
1051 -- Is_Entity_Attribute_Name --
1052 ------------------------------
1054 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
1056 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
1057 end Is_Entity_Attribute_Name;
1059 --------------------------------
1060 -- Is_Function_Attribute_Name --
1061 --------------------------------
1063 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
1066 First_Renamable_Function_Attribute ..
1067 Last_Renamable_Function_Attribute;
1068 end Is_Function_Attribute_Name;
1070 ---------------------
1071 -- Is_Keyword_Name --
1072 ---------------------
1074 function Is_Keyword_Name (N : Name_Id) return Boolean is
1076 return Get_Name_Table_Byte (N) /= 0
1077 and then (Ada_Version >= Ada_95
1078 or else N not in Ada_95_Reserved_Words)
1079 and then (Ada_Version >= Ada_05
1080 or else N not in Ada_2005_Reserved_Words);
1081 end Is_Keyword_Name;
1083 ----------------------------
1084 -- Is_Locking_Policy_Name --
1085 ----------------------------
1087 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1089 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1090 end Is_Locking_Policy_Name;
1092 -----------------------------
1093 -- Is_Operator_Symbol_Name --
1094 -----------------------------
1096 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1098 return N in First_Operator_Name .. Last_Operator_Name;
1099 end Is_Operator_Symbol_Name;
1101 --------------------
1102 -- Is_Pragma_Name --
1103 --------------------
1105 function Is_Pragma_Name (N : Name_Id) return Boolean is
1107 return N in First_Pragma_Name .. Last_Pragma_Name
1108 or else N = Name_AST_Entry
1109 or else N = Name_Interface
1110 or else N = Name_Priority
1111 or else N = Name_Storage_Size
1112 or else N = Name_Storage_Unit;
1115 ---------------------------------
1116 -- Is_Procedure_Attribute_Name --
1117 ---------------------------------
1119 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1121 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1122 end Is_Procedure_Attribute_Name;
1124 ----------------------------
1125 -- Is_Queuing_Policy_Name --
1126 ----------------------------
1128 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1130 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1131 end Is_Queuing_Policy_Name;
1133 -------------------------------------
1134 -- Is_Task_Dispatching_Policy_Name --
1135 -------------------------------------
1137 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1139 return N in First_Task_Dispatching_Policy_Name ..
1140 Last_Task_Dispatching_Policy_Name;
1141 end Is_Task_Dispatching_Policy_Name;
1143 ----------------------------
1144 -- Is_Type_Attribute_Name --
1145 ----------------------------
1147 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1149 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1150 end Is_Type_Attribute_Name;
1152 ----------------------------------
1153 -- Record_Convention_Identifier --
1154 ----------------------------------
1156 procedure Record_Convention_Identifier
1158 Convention : Convention_Id)
1161 Convention_Identifiers.Append ((Id, Convention));
1162 end Record_Convention_Identifier;