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#" &
187 "component_alignment#" &
188 "convention_identifier#" &
192 "elaboration_checks#" &
195 "extensions_allowed#" &
196 "external_name_casing#" &
197 "float_representation#" &
198 "implicit_packing#" &
199 "initialize_scalars#" &
205 "no_strict_aliasing#" &
206 "normalize_scalars#" &
209 "priority_specific_dispatching#" &
211 "profile_warnings#" &
212 "propagate_exceptions#" &
215 "restricted_run_time#" &
217 "restriction_warnings#" &
219 "source_file_name#" &
220 "source_file_name_project#" &
223 "suppress_exception_locations#" &
224 "task_dispatching_policy#" &
230 "wide_character_encoding#" &
232 "all_calls_remote#" &
237 "atomic_components#" &
242 "complete_representation#" &
243 "complex_representation#" &
255 "export_exception#" &
258 "export_procedure#" &
260 "export_valued_procedure#" &
262 "finalize_storage_only#" &
265 "import_exception#" &
268 "import_procedure#" &
269 "import_valued_procedure#" &
273 "inspection_point#" &
275 "interrupt_handler#" &
276 "interrupt_priority#" &
277 "java_constructor#" &
282 "linker_constructor#" &
283 "linker_destructor#" &
287 "machine_attribute#" &
298 "preelaborable_initialization#" &
305 "remote_call_interface#" &
310 "source_reference#" &
311 "static_elaboration_desired#" &
315 "suppress_debug_info#" &
316 "suppress_initialization#" &
324 "unimplemented_unit#" &
325 "universal_aliasing#" &
327 "unreferenced_objects#" &
328 "unreserve_all_interrupts#" &
330 "volatile_components#" &
351 "boolean_entry_barriers#" &
356 "component_size_4#" &
365 "first_optional_parameter#" &
377 "max_entry_queue_depth#" &
378 "max_entry_queue_length#" &
388 "no_dynamic_attachment#" &
389 "no_dynamic_interrupts#" &
391 "no_requeue_statements#" &
392 "no_task_attributes#" &
393 "no_task_attributes_package#" &
398 "result_mechanism#" &
402 "secondary_stack_size#" &
410 "subunit_file_name#" &
411 "task_stack_size_default#" &
413 "time_slicing_enabled#" &
447 "default_bit_order#" &
463 "has_access_values#" &
464 "has_discriminants#" &
475 "machine_mantissa#" &
476 "machine_overflows#" &
478 "machine_rounding#" &
482 "max_size_in_storage_elements#" &
483 "maximum_alignment#" &
494 "passed_by_reference#" &
521 "unbiased_rounding#" &
522 "unchecked_access#" &
523 "unconstrained_array#" &
524 "universal_literal_string#" &
525 "unrestricted_access#" &
567 "inheritance_locking#" &
569 "priority_queuing#" &
570 "edf_across_priorities#" &
571 "fifo_within_priorities#" &
572 "non_preemptive_within_priorities#" &
573 "round_robin_within_priorities#" &
575 "accessibility_check#" &
577 "discriminant_check#" &
579 "elaboration_check#" &
647 "enclosing_entity#" &
648 "exception_information#" &
649 "exception_message#" &
652 "generic_dispatching_constructor#" &
654 "import_largest_value#" &
662 "shift_right_arithmetic#" &
664 "unchecked_conversion#" &
665 "unchecked_deallocation#" &
683 "builder_switches#" &
686 "config_body_file_name#" &
687 "config_body_file_name_pattern#" &
688 "config_file_switches#" &
689 "config_file_unique#" &
690 "config_spec_file_name#" &
691 "config_spec_file_name_pattern#" &
693 "default_language#" &
694 "default_switches#" &
695 "dependency_driver#" &
696 "dependency_file_kind#" &
697 "dependency_switches#" &
699 "excluded_source_dirs#" &
700 "excluded_source_files#" &
703 "executable_suffix#" &
705 "externally_built#" &
707 "global_configuration_pragmas#" &
708 "global_config_file#" &
712 "implementation_exceptions#" &
713 "implementation_suffix#" &
714 "include_switches#" &
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_switches#" &
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#" &
752 "objects_path_file#" &
759 "required_switches#" &
762 "shared_library_minimum_switches#" &
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#" &
779 "runtime_library_dir#" &
786 ---------------------
787 -- Generated Names --
788 ---------------------
790 -- This section lists the various cases of generated names which are
791 -- built from existing names by adding unique leading and/or trailing
792 -- upper case letters. In some cases these names are built recursively,
793 -- in particular names built from types may be built from types which
794 -- themselves have generated names. In this list, xxx represents an
795 -- existing name to which identifying letters are prepended or appended,
796 -- and a trailing n represents a serial number in an external name that
797 -- has some semantic significance (e.g. the n'th index type of an array).
799 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
800 -- xxxB tag table for tagged type xxx (Exp_Ch3)
801 -- xxxB task body procedure for task xxx (Exp_Ch9)
802 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
803 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
804 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
805 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
806 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
807 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
808 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
809 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
810 -- xxxM master Id value for access type xxx (Exp_Ch3)
811 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
812 -- xxxP parameter record type for entry xxx (Exp_Ch9)
813 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
814 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
815 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
816 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
817 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
818 -- xxxV type for task value record for task xxx (Exp_Ch9)
819 -- xxxX entry index constant (Exp_Ch9)
820 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
821 -- xxxZ size variable for task xxx (Exp_Ch9)
825 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
826 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
827 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
828 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
829 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
830 -- xxxIP initialization procedure for type xxx (Exp_TSS)
831 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
832 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
833 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
834 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
835 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
836 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
837 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
838 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
839 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
840 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
842 -- Implicit type names
844 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
846 -- (Note: this list is not complete or accurate ???)
848 ----------------------
849 -- Get_Attribute_Id --
850 ----------------------
852 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
854 return Attribute_Id'Val (N - First_Attribute_Name);
855 end Get_Attribute_Id;
857 -----------------------
858 -- Get_Convention_Id --
859 -----------------------
861 function Get_Convention_Id (N : Name_Id) return Convention_Id is
864 when Name_Ada => return Convention_Ada;
865 when Name_Assembler => return Convention_Assembler;
866 when Name_C => return Convention_C;
867 when Name_CIL => return Convention_CIL;
868 when Name_COBOL => return Convention_COBOL;
869 when Name_CPP => return Convention_CPP;
870 when Name_Fortran => return Convention_Fortran;
871 when Name_Intrinsic => return Convention_Intrinsic;
872 when Name_Java => return Convention_Java;
873 when Name_Stdcall => return Convention_Stdcall;
874 when Name_Stubbed => return Convention_Stubbed;
876 -- If no direct match, then we must have a convention
877 -- identifier pragma that has specified this name.
880 for J in 1 .. Convention_Identifiers.Last loop
881 if N = Convention_Identifiers.Table (J).Name then
882 return Convention_Identifiers.Table (J).Convention;
888 end Get_Convention_Id;
890 -------------------------
891 -- Get_Convention_Name --
892 -------------------------
894 function Get_Convention_Name (C : Convention_Id) return Name_Id is
897 when Convention_Ada => return Name_Ada;
898 when Convention_Assembler => return Name_Assembler;
899 when Convention_C => return Name_C;
900 when Convention_CIL => return Name_CIL;
901 when Convention_COBOL => return Name_COBOL;
902 when Convention_CPP => return Name_CPP;
903 when Convention_Entry => return Name_Entry;
904 when Convention_Fortran => return Name_Fortran;
905 when Convention_Intrinsic => return Name_Intrinsic;
906 when Convention_Java => return Name_Java;
907 when Convention_Protected => return Name_Protected;
908 when Convention_Stdcall => return Name_Stdcall;
909 when Convention_Stubbed => return Name_Stubbed;
911 end Get_Convention_Name;
913 ---------------------------
914 -- Get_Locking_Policy_Id --
915 ---------------------------
917 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
919 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
920 end Get_Locking_Policy_Id;
926 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
928 if N = Name_AST_Entry then
929 return Pragma_AST_Entry;
930 elsif N = Name_Interface then
931 return Pragma_Interface;
932 elsif N = Name_Priority then
933 return Pragma_Priority;
934 elsif N = Name_Storage_Size then
935 return Pragma_Storage_Size;
936 elsif N = Name_Storage_Unit then
937 return Pragma_Storage_Unit;
938 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
939 return Unknown_Pragma;
941 return Pragma_Id'Val (N - First_Pragma_Name);
945 ---------------------------
946 -- Get_Queuing_Policy_Id --
947 ---------------------------
949 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
951 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
952 end Get_Queuing_Policy_Id;
954 ------------------------------------
955 -- Get_Task_Dispatching_Policy_Id --
956 ------------------------------------
958 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
959 return Task_Dispatching_Policy_Id is
961 return Task_Dispatching_Policy_Id'Val
962 (N - First_Task_Dispatching_Policy_Name);
963 end Get_Task_Dispatching_Policy_Id;
969 procedure Initialize is
971 Discard_Name : Name_Id;
974 P_Index := Preset_Names'First;
979 while Preset_Names (P_Index) /= '#' loop
980 Name_Len := Name_Len + 1;
981 Name_Buffer (Name_Len) := Preset_Names (P_Index);
982 P_Index := P_Index + 1;
985 -- We do the Name_Find call to enter the name into the table, but
986 -- we don't need to do anything with the result, since we already
987 -- initialized all the preset names to have the right value (we
988 -- are depending on the order of the names and Preset_Names).
990 Discard_Name := Name_Find;
991 P_Index := P_Index + 1;
992 exit when Preset_Names (P_Index) = '#';
995 -- Make sure that number of names in standard table is correct. If
996 -- this check fails, run utility program XSNAMES to construct a new
997 -- properly matching version of the body.
999 pragma Assert (Discard_Name = Last_Predefined_Name);
1001 -- Initialize the convention identifiers table with the standard
1002 -- set of synonyms that we recognize for conventions.
1004 Convention_Identifiers.Init;
1006 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
1007 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
1009 Convention_Identifiers.Append ((Name_Default, Convention_C));
1010 Convention_Identifiers.Append ((Name_External, Convention_C));
1012 Convention_Identifiers.Append ((Name_C_Plus_Plus, Convention_CPP));
1014 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
1015 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
1018 -----------------------
1019 -- Is_Attribute_Name --
1020 -----------------------
1022 function Is_Attribute_Name (N : Name_Id) return Boolean is
1024 return N in First_Attribute_Name .. Last_Attribute_Name;
1025 end Is_Attribute_Name;
1027 ------------------------
1028 -- Is_Convention_Name --
1029 ------------------------
1031 function Is_Convention_Name (N : Name_Id) return Boolean is
1033 -- Check if this is one of the standard conventions
1035 if N in First_Convention_Name .. Last_Convention_Name
1040 -- Otherwise check if it is in convention identifier table
1043 for J in 1 .. Convention_Identifiers.Last loop
1044 if N = Convention_Identifiers.Table (J).Name then
1051 end Is_Convention_Name;
1053 ------------------------------
1054 -- Is_Entity_Attribute_Name --
1055 ------------------------------
1057 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
1059 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
1060 end Is_Entity_Attribute_Name;
1062 --------------------------------
1063 -- Is_Function_Attribute_Name --
1064 --------------------------------
1066 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
1069 First_Renamable_Function_Attribute ..
1070 Last_Renamable_Function_Attribute;
1071 end Is_Function_Attribute_Name;
1073 ---------------------
1074 -- Is_Keyword_Name --
1075 ---------------------
1077 function Is_Keyword_Name (N : Name_Id) return Boolean is
1079 return Get_Name_Table_Byte (N) /= 0
1080 and then (Ada_Version >= Ada_95
1081 or else N not in Ada_95_Reserved_Words)
1082 and then (Ada_Version >= Ada_05
1083 or else N not in Ada_2005_Reserved_Words);
1084 end Is_Keyword_Name;
1086 ----------------------------
1087 -- Is_Locking_Policy_Name --
1088 ----------------------------
1090 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1092 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1093 end Is_Locking_Policy_Name;
1095 -----------------------------
1096 -- Is_Operator_Symbol_Name --
1097 -----------------------------
1099 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1101 return N in First_Operator_Name .. Last_Operator_Name;
1102 end Is_Operator_Symbol_Name;
1104 --------------------
1105 -- Is_Pragma_Name --
1106 --------------------
1108 function Is_Pragma_Name (N : Name_Id) return Boolean is
1110 return N in First_Pragma_Name .. Last_Pragma_Name
1111 or else N = Name_AST_Entry
1112 or else N = Name_Interface
1113 or else N = Name_Priority
1114 or else N = Name_Storage_Size
1115 or else N = Name_Storage_Unit;
1118 ---------------------------------
1119 -- Is_Procedure_Attribute_Name --
1120 ---------------------------------
1122 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1124 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1125 end Is_Procedure_Attribute_Name;
1127 ----------------------------
1128 -- Is_Queuing_Policy_Name --
1129 ----------------------------
1131 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1133 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1134 end Is_Queuing_Policy_Name;
1136 -------------------------------------
1137 -- Is_Task_Dispatching_Policy_Name --
1138 -------------------------------------
1140 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1142 return N in First_Task_Dispatching_Policy_Name ..
1143 Last_Task_Dispatching_Policy_Name;
1144 end Is_Task_Dispatching_Policy_Name;
1146 ----------------------------
1147 -- Is_Type_Attribute_Name --
1148 ----------------------------
1150 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1152 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1153 end Is_Type_Attribute_Name;
1155 ----------------------------------
1156 -- Record_Convention_Identifier --
1157 ----------------------------------
1159 procedure Record_Convention_Identifier
1161 Convention : Convention_Id)
1164 Convention_Identifiers.Append ((Id, Convention));
1165 end Record_Convention_Identifier;