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#" &
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#" &
181 "assertion_policy#" &
182 "assume_no_invalid_values#" &
186 "compile_time_error#" &
187 "compile_time_warning#" &
189 "component_alignment#" &
190 "convention_identifier#" &
194 "elaboration_checks#" &
197 "extensions_allowed#" &
198 "external_name_casing#" &
200 "float_representation#" &
201 "implicit_packing#" &
202 "initialize_scalars#" &
208 "no_strict_aliasing#" &
209 "normalize_scalars#" &
210 "optimize_alignment#" &
213 "priority_specific_dispatching#" &
215 "profile_warnings#" &
216 "propagate_exceptions#" &
219 "restricted_run_time#" &
221 "restriction_warnings#" &
223 "source_file_name#" &
224 "source_file_name_project#" &
227 "suppress_exception_locations#" &
228 "task_dispatching_policy#" &
234 "wide_character_encoding#" &
236 "all_calls_remote#" &
241 "atomic_components#" &
247 "complete_representation#" &
248 "complex_representation#" &
260 "export_exception#" &
263 "export_procedure#" &
265 "export_valued_procedure#" &
267 "finalize_storage_only#" &
269 "implemented_by_entry#" &
271 "import_exception#" &
274 "import_procedure#" &
275 "import_valued_procedure#" &
279 "inspection_point#" &
281 "interrupt_handler#" &
282 "interrupt_priority#" &
283 "java_constructor#" &
288 "linker_constructor#" &
289 "linker_destructor#" &
293 "machine_attribute#" &
306 "preelaborable_initialization#" &
313 "relative_deadline#" &
314 "remote_call_interface#" &
319 "source_reference#" &
320 "static_elaboration_desired#" &
324 "suppress_debug_info#" &
325 "suppress_initialization#" &
333 "unimplemented_unit#" &
334 "universal_aliasing#" &
337 "unreferenced_objects#" &
338 "unreserve_all_interrupts#" &
340 "volatile_components#" &
362 "boolean_entry_barriers#" &
366 "component_size_4#" &
375 "first_optional_parameter#" &
387 "max_entry_queue_depth#" &
388 "max_entry_queue_length#" &
398 "no_dynamic_attachment#" &
399 "no_dynamic_interrupts#" &
401 "no_requeue_statements#" &
402 "no_task_attributes#" &
403 "no_task_attributes_package#" &
408 "result_mechanism#" &
412 "secondary_stack_size#" &
415 "short_descriptor#" &
421 "subunit_file_name#" &
422 "task_stack_size_default#" &
424 "time_slicing_enabled#" &
458 "default_bit_order#" &
476 "has_access_values#" &
477 "has_discriminants#" &
478 "has_tagged_values#" &
490 "machine_mantissa#" &
491 "machine_overflows#" &
493 "machine_rounding#" &
497 "max_size_in_storage_elements#" &
498 "maximum_alignment#" &
510 "passed_by_reference#" &
538 "unbiased_rounding#" &
539 "unchecked_access#" &
540 "unconstrained_array#" &
541 "universal_literal_string#" &
542 "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_compilation_switches#" &
732 "global_configuration_pragmas#" &
733 "global_config_file#" &
737 "implementation_exceptions#" &
738 "implementation_suffix#" &
739 "include_switches#" &
741 "include_path_file#" &
742 "inherit_source_path#" &
744 "language_processing#" &
748 "library_auto_init#" &
749 "library_auto_init_supported#" &
753 "library_interface#" &
756 "library_major_minor_id_supported#" &
758 "library_partial_linker#" &
759 "library_reference_symbol_file#" &
762 "library_symbol_file#" &
763 "library_symbol_policy#" &
765 "library_version_switches#" &
767 "linker_executable_option#" &
768 "linker_lib_dir_option#" &
769 "linker_lib_name_option#" &
770 "local_config_file#" &
771 "local_configuration_pragmas#" &
772 "locally_removed_files#" &
774 "mapping_file_switches#" &
775 "mapping_spec_suffix#" &
776 "mapping_body_suffix#" &
779 "object_generated#" &
782 "objects_path_file#" &
790 "required_switches#" &
793 "shared_library_minimum_switches#" &
794 "shared_library_prefix#" &
795 "shared_library_suffix#" &
799 "source_list_file#" &
803 "specification_exceptions#" &
804 "specification_suffix#" &
807 "symbolic_link_supported#" &
810 "toolchain_description#" &
811 "toolchain_version#" &
812 "runtime_library_dir#" &
819 ---------------------
820 -- Generated Names --
821 ---------------------
823 -- This section lists the various cases of generated names which are
824 -- built from existing names by adding unique leading and/or trailing
825 -- upper case letters. In some cases these names are built recursively,
826 -- in particular names built from types may be built from types which
827 -- themselves have generated names. In this list, xxx represents an
828 -- existing name to which identifying letters are prepended or appended,
829 -- and a trailing n represents a serial number in an external name that
830 -- has some semantic significance (e.g. the n'th index type of an array).
832 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
833 -- xxxB tag table for tagged type xxx (Exp_Ch3)
834 -- xxxB task body procedure for task xxx (Exp_Ch9)
835 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
836 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
837 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
838 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
839 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
840 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
841 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
842 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
843 -- xxxM master Id value for access type xxx (Exp_Ch3)
844 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
845 -- xxxP parameter record type for entry xxx (Exp_Ch9)
846 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
847 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
848 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
849 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
850 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
851 -- xxxV type for task value record for task xxx (Exp_Ch9)
852 -- xxxX entry index constant (Exp_Ch9)
853 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
854 -- xxxZ size variable for task xxx (Exp_Ch9)
858 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
859 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
860 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
861 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
862 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
863 -- xxxIP initialization procedure for type xxx (Exp_TSS)
864 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
865 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
866 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
867 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
868 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
869 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
870 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
871 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
872 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
873 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
875 -- Implicit type names
877 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
879 -- (Note: this list is not complete or accurate ???)
881 ----------------------
882 -- Get_Attribute_Id --
883 ----------------------
885 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
887 return Attribute_Id
'Val (N
- First_Attribute_Name
);
888 end Get_Attribute_Id
;
890 -----------------------
891 -- Get_Convention_Id --
892 -----------------------
894 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
897 when Name_Ada
=> return Convention_Ada
;
898 when Name_Assembler
=> return Convention_Assembler
;
899 when Name_C
=> return Convention_C
;
900 when Name_CIL
=> return Convention_CIL
;
901 when Name_COBOL
=> return Convention_COBOL
;
902 when Name_CPP
=> return Convention_CPP
;
903 when Name_Fortran
=> return Convention_Fortran
;
904 when Name_Intrinsic
=> return Convention_Intrinsic
;
905 when Name_Java
=> return Convention_Java
;
906 when Name_Stdcall
=> return Convention_Stdcall
;
907 when Name_Stubbed
=> return Convention_Stubbed
;
909 -- If no direct match, then we must have a convention
910 -- identifier pragma that has specified this name.
913 for J
in 1 .. Convention_Identifiers
.Last
loop
914 if N
= Convention_Identifiers
.Table
(J
).Name
then
915 return Convention_Identifiers
.Table
(J
).Convention
;
921 end Get_Convention_Id
;
923 -------------------------
924 -- Get_Convention_Name --
925 -------------------------
927 function Get_Convention_Name
(C
: Convention_Id
) return Name_Id
is
930 when Convention_Ada
=> return Name_Ada
;
931 when Convention_Assembler
=> return Name_Assembler
;
932 when Convention_C
=> return Name_C
;
933 when Convention_CIL
=> return Name_CIL
;
934 when Convention_COBOL
=> return Name_COBOL
;
935 when Convention_CPP
=> return Name_CPP
;
936 when Convention_Entry
=> return Name_Entry
;
937 when Convention_Fortran
=> return Name_Fortran
;
938 when Convention_Intrinsic
=> return Name_Intrinsic
;
939 when Convention_Java
=> return Name_Java
;
940 when Convention_Protected
=> return Name_Protected
;
941 when Convention_Stdcall
=> return Name_Stdcall
;
942 when Convention_Stubbed
=> return Name_Stubbed
;
944 end Get_Convention_Name
;
946 ---------------------------
947 -- Get_Locking_Policy_Id --
948 ---------------------------
950 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
952 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
953 end Get_Locking_Policy_Id
;
959 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
961 if N
= Name_AST_Entry
then
962 return Pragma_AST_Entry
;
963 elsif N
= Name_Fast_Math
then
964 return Pragma_Fast_Math
;
965 elsif N
= Name_Interface
then
966 return Pragma_Interface
;
967 elsif N
= Name_Priority
then
968 return Pragma_Priority
;
969 elsif N
= Name_Relative_Deadline
then
970 return Pragma_Relative_Deadline
;
971 elsif N
= Name_Storage_Size
then
972 return Pragma_Storage_Size
;
973 elsif N
= Name_Storage_Unit
then
974 return Pragma_Storage_Unit
;
975 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
976 return Unknown_Pragma
;
978 return Pragma_Id
'Val (N
- First_Pragma_Name
);
982 ---------------------------
983 -- Get_Queuing_Policy_Id --
984 ---------------------------
986 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
988 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
989 end Get_Queuing_Policy_Id
;
991 ------------------------------------
992 -- Get_Task_Dispatching_Policy_Id --
993 ------------------------------------
995 function Get_Task_Dispatching_Policy_Id
996 (N
: Name_Id
) return Task_Dispatching_Policy_Id
999 return Task_Dispatching_Policy_Id
'Val
1000 (N
- First_Task_Dispatching_Policy_Name
);
1001 end Get_Task_Dispatching_Policy_Id
;
1007 procedure Initialize
is
1009 Discard_Name
: Name_Id
;
1012 P_Index
:= Preset_Names
'First;
1015 while Preset_Names
(P_Index
) /= '#' loop
1016 Name_Len
:= Name_Len
+ 1;
1017 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
1018 P_Index
:= P_Index
+ 1;
1021 -- We do the Name_Find call to enter the name into the table, but
1022 -- we don't need to do anything with the result, since we already
1023 -- initialized all the preset names to have the right value (we
1024 -- are depending on the order of the names and Preset_Names).
1026 Discard_Name
:= Name_Find
;
1027 P_Index
:= P_Index
+ 1;
1028 exit when Preset_Names
(P_Index
) = '#';
1031 -- Make sure that number of names in standard table is correct. If
1032 -- this check fails, run utility program XSNAMES to construct a new
1033 -- properly matching version of the body.
1035 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
1037 -- Initialize the convention identifiers table with the standard
1038 -- set of synonyms that we recognize for conventions.
1040 Convention_Identifiers
.Init
;
1042 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
1043 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
1045 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
1046 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
1048 Convention_Identifiers
.Append
((Name_C_Plus_Plus
, Convention_CPP
));
1050 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
1051 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
1054 -----------------------
1055 -- Is_Attribute_Name --
1056 -----------------------
1058 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
1060 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
1061 end Is_Attribute_Name
;
1063 ----------------------------------
1064 -- Is_Configuration_Pragma_Name --
1065 ----------------------------------
1067 function Is_Configuration_Pragma_Name
(N
: Name_Id
) return Boolean is
1069 return N
in First_Pragma_Name
.. Last_Configuration_Pragma_Name
1070 or else N
= Name_Fast_Math
;
1071 end Is_Configuration_Pragma_Name
;
1073 ------------------------
1074 -- Is_Convention_Name --
1075 ------------------------
1077 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
1079 -- Check if this is one of the standard conventions
1081 if N
in First_Convention_Name
.. Last_Convention_Name
1086 -- Otherwise check if it is in convention identifier table
1089 for J
in 1 .. Convention_Identifiers
.Last
loop
1090 if N
= Convention_Identifiers
.Table
(J
).Name
then
1097 end Is_Convention_Name
;
1099 ------------------------------
1100 -- Is_Entity_Attribute_Name --
1101 ------------------------------
1103 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
1105 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
1106 end Is_Entity_Attribute_Name
;
1108 --------------------------------
1109 -- Is_Function_Attribute_Name --
1110 --------------------------------
1112 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
1115 First_Renamable_Function_Attribute
..
1116 Last_Renamable_Function_Attribute
;
1117 end Is_Function_Attribute_Name
;
1119 ---------------------
1120 -- Is_Keyword_Name --
1121 ---------------------
1123 function Is_Keyword_Name
(N
: Name_Id
) return Boolean is
1125 return Get_Name_Table_Byte
(N
) /= 0
1126 and then (Ada_Version
>= Ada_95
1127 or else N
not in Ada_95_Reserved_Words
)
1128 and then (Ada_Version
>= Ada_05
1129 or else N
not in Ada_2005_Reserved_Words
);
1130 end Is_Keyword_Name
;
1132 ----------------------------
1133 -- Is_Locking_Policy_Name --
1134 ----------------------------
1136 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
1138 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
1139 end Is_Locking_Policy_Name
;
1141 -----------------------------
1142 -- Is_Operator_Symbol_Name --
1143 -----------------------------
1145 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
1147 return N
in First_Operator_Name
.. Last_Operator_Name
;
1148 end Is_Operator_Symbol_Name
;
1150 --------------------
1151 -- Is_Pragma_Name --
1152 --------------------
1154 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
1156 return N
in First_Pragma_Name
.. Last_Pragma_Name
1157 or else N
= Name_AST_Entry
1158 or else N
= Name_Fast_Math
1159 or else N
= Name_Interface
1160 or else N
= Name_Relative_Deadline
1161 or else N
= Name_Priority
1162 or else N
= Name_Storage_Size
1163 or else N
= Name_Storage_Unit
;
1166 ---------------------------------
1167 -- Is_Procedure_Attribute_Name --
1168 ---------------------------------
1170 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
1172 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1173 end Is_Procedure_Attribute_Name
;
1175 ----------------------------
1176 -- Is_Queuing_Policy_Name --
1177 ----------------------------
1179 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1181 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1182 end Is_Queuing_Policy_Name
;
1184 -------------------------------------
1185 -- Is_Task_Dispatching_Policy_Name --
1186 -------------------------------------
1188 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1190 return N
in First_Task_Dispatching_Policy_Name
..
1191 Last_Task_Dispatching_Policy_Name
;
1192 end Is_Task_Dispatching_Policy_Name
;
1194 ----------------------------
1195 -- Is_Type_Attribute_Name --
1196 ----------------------------
1198 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1200 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1201 end Is_Type_Attribute_Name
;
1203 ----------------------------------
1204 -- Record_Convention_Identifier --
1205 ----------------------------------
1207 procedure Record_Convention_Identifier
1209 Convention
: Convention_Id
)
1212 Convention_Identifiers
.Append
((Id
, Convention
));
1213 end Record_Convention_Identifier
;