1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, 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 ------------------------------------------------------------------------------
34 with Namet
; use Namet
;
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#" &
122 "finalization_root#" &
128 "wide_wide_text_io#" &
134 "get_active_partition_id#" &
135 "get_rci_package_receiver#" &
136 "get_rci_package_ref#" &
140 "partition_interface#" &
179 "assertion_policy#" &
181 "compile_time_warning#" &
182 "component_alignment#" &
183 "convention_identifier#" &
187 "elaboration_checks#" &
189 "explicit_overriding#" &
191 "extensions_allowed#" &
192 "external_name_casing#" &
193 "float_representation#" &
194 "initialize_scalars#" &
200 "no_strict_aliasing#" &
201 "normalize_scalars#" &
204 "priority_specific_dispatching#" &
206 "profile_warnings#" &
207 "propagate_exceptions#" &
210 "restricted_run_time#" &
212 "restriction_warnings#" &
214 "source_file_name#" &
215 "source_file_name_project#" &
218 "suppress_exception_locations#" &
219 "task_dispatching_policy#" &
225 "wide_character_encoding#" &
227 "all_calls_remote#" &
232 "atomic_components#" &
236 "complete_representation#" &
237 "complex_representation#" &
249 "export_exception#" &
252 "export_procedure#" &
254 "export_valued_procedure#" &
256 "finalize_storage_only#" &
259 "import_exception#" &
262 "import_procedure#" &
263 "import_valued_procedure#" &
267 "inspection_point#" &
269 "interrupt_handler#" &
270 "interrupt_priority#" &
271 "java_constructor#" &
276 "linker_constructor#" &
277 "linker_destructor#" &
281 "machine_attribute#" &
288 "optional_overriding#" &
292 "preelaborable_initialization#" &
299 "remote_call_interface#" &
304 "source_reference#" &
308 "suppress_debug_info#" &
309 "suppress_initialization#" &
318 "unimplemented_unit#" &
320 "unreserve_all_interrupts#" &
322 "volatile_components#" &
341 "boolean_entry_barriers#" &
346 "component_size_4#" &
355 "first_optional_parameter#" &
367 "max_entry_queue_depth#" &
368 "max_entry_queue_length#" &
378 "no_dynamic_attachment#" &
379 "no_dynamic_interrupts#" &
381 "no_requeue_statements#" &
382 "no_task_attributes#" &
383 "no_task_attributes_package#" &
388 "result_mechanism#" &
392 "secondary_stack_size#" &
400 "subunit_file_name#" &
401 "task_stack_size_default#" &
403 "time_slicing_enabled#" &
437 "default_bit_order#" &
452 "has_access_values#" &
453 "has_discriminants#" &
464 "machine_mantissa#" &
465 "machine_overflows#" &
467 "machine_rounding#" &
471 "max_size_in_storage_elements#" &
472 "maximum_alignment#" &
483 "passed_by_reference#" &
510 "unbiased_rounding#" &
511 "unchecked_access#" &
512 "unconstrained_array#" &
513 "universal_literal_string#" &
514 "unrestricted_access#" &
556 "inheritance_locking#" &
558 "priority_queuing#" &
559 "edf_across_priorities#" &
560 "fifo_within_priorities#" &
561 "non_preemptive_within_priorities#" &
562 "round_robin_within_priorities#" &
564 "accessibility_check#" &
566 "discriminant_check#" &
568 "elaboration_check#" &
636 "enclosing_entity#" &
637 "exception_information#" &
638 "exception_message#" &
641 "generic_dispatching_constructor#" &
643 "import_largest_value#" &
651 "shift_right_arithmetic#" &
653 "unchecked_conversion#" &
654 "unchecked_deallocation#" &
674 "compiler_pic_option#" &
675 "compute_dependency#" &
676 "config_body_file_name#" &
677 "config_body_file_name_pattern#" &
678 "config_file_switches#" &
679 "config_file_unique#" &
680 "config_spec_file_name#" &
681 "config_spec_file_name_pattern#" &
683 "default_builder_switches#" &
684 "default_global_compiler_switches#" &
685 "default_language#" &
687 "default_switches#" &
688 "dependency_file_kind#" &
689 "dependency_option#" &
692 "executable_suffix#" &
694 "externally_built#" &
696 "global_compiler_switches#" &
697 "global_configuration_pragmas#" &
701 "implementation_exceptions#" &
702 "implementation_suffix#" &
705 "include_path_file#" &
707 "language_processing#" &
711 "library_auto_init#" &
713 "library_interface#" &
717 "library_reference_symbol_file#" &
719 "library_symbol_file#" &
720 "library_symbol_policy#" &
723 "linker_executable_option#" &
724 "linker_lib_dir_option#" &
725 "linker_lib_name_option#" &
726 "local_configuration_pragmas#" &
727 "locally_removed_files#" &
728 "mapping_file_switches#" &
739 "source_list_file#" &
743 "specification_exceptions#" &
744 "specification_suffix#" &
752 ---------------------
753 -- Generated Names --
754 ---------------------
756 -- This section lists the various cases of generated names which are
757 -- built from existing names by adding unique leading and/or trailing
758 -- upper case letters. In some cases these names are built recursively,
759 -- in particular names built from types may be built from types which
760 -- themselves have generated names. In this list, xxx represents an
761 -- existing name to which identifying letters are prepended or appended,
762 -- and a trailing n represents a serial number in an external name that
763 -- has some semantic significance (e.g. the n'th index type of an array).
765 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
766 -- xxxB tag table for tagged type xxx (Exp_Ch3)
767 -- xxxB task body procedure for task xxx (Exp_Ch9)
768 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
769 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
770 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
771 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
772 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
773 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
774 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
775 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
776 -- xxxM master Id value for access type xxx (Exp_Ch3)
777 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
778 -- xxxP parameter record type for entry xxx (Exp_Ch9)
779 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
780 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
781 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
782 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
783 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
784 -- xxxV type for task value record for task xxx (Exp_Ch9)
785 -- xxxX entry index constant (Exp_Ch9)
786 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
787 -- xxxZ size variable for task xxx (Exp_Ch9)
791 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
792 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
793 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
794 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
795 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
796 -- xxxIP initialization procedure for type xxx (Exp_TSS)
797 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
798 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
799 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
800 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
801 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
802 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
803 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
804 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
805 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
806 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
808 -- Implicit type names
810 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
812 -- (Note: this list is not complete or accurate ???)
814 ----------------------
815 -- Get_Attribute_Id --
816 ----------------------
818 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
820 return Attribute_Id
'Val (N
- First_Attribute_Name
);
821 end Get_Attribute_Id
;
827 function Get_Check_Id
(N
: Name_Id
) return Check_Id
is
829 return Check_Id
'Val (N
- First_Check_Name
);
832 -----------------------
833 -- Get_Convention_Id --
834 -----------------------
836 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
839 when Name_Ada
=> return Convention_Ada
;
840 when Name_Assembler
=> return Convention_Assembler
;
841 when Name_C
=> return Convention_C
;
842 when Name_COBOL
=> return Convention_COBOL
;
843 when Name_CPP
=> return Convention_CPP
;
844 when Name_Fortran
=> return Convention_Fortran
;
845 when Name_Intrinsic
=> return Convention_Intrinsic
;
846 when Name_Java
=> return Convention_Java
;
847 when Name_Stdcall
=> return Convention_Stdcall
;
848 when Name_Stubbed
=> return Convention_Stubbed
;
850 -- If no direct match, then we must have a convention
851 -- identifier pragma that has specified this name.
854 for J
in 1 .. Convention_Identifiers
.Last
loop
855 if N
= Convention_Identifiers
.Table
(J
).Name
then
856 return Convention_Identifiers
.Table
(J
).Convention
;
862 end Get_Convention_Id
;
864 -------------------------
865 -- Get_Convention_Name --
866 -------------------------
868 function Get_Convention_Name
(C
: Convention_Id
) return Name_Id
is
871 when Convention_Ada
=> return Name_Ada
;
872 when Convention_Assembler
=> return Name_Assembler
;
873 when Convention_C
=> return Name_C
;
874 when Convention_COBOL
=> return Name_COBOL
;
875 when Convention_CPP
=> return Name_CPP
;
876 when Convention_Entry
=> return Name_Entry
;
877 when Convention_Fortran
=> return Name_Fortran
;
878 when Convention_Intrinsic
=> return Name_Intrinsic
;
879 when Convention_Java
=> return Name_Java
;
880 when Convention_Protected
=> return Name_Protected
;
881 when Convention_Stdcall
=> return Name_Stdcall
;
882 when Convention_Stubbed
=> return Name_Stubbed
;
884 end Get_Convention_Name
;
886 ---------------------------
887 -- Get_Locking_Policy_Id --
888 ---------------------------
890 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
892 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
893 end Get_Locking_Policy_Id
;
899 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
901 if N
= Name_AST_Entry
then
902 return Pragma_AST_Entry
;
903 elsif N
= Name_Interface
then
904 return Pragma_Interface
;
905 elsif N
= Name_Priority
then
906 return Pragma_Priority
;
907 elsif N
= Name_Storage_Size
then
908 return Pragma_Storage_Size
;
909 elsif N
= Name_Storage_Unit
then
910 return Pragma_Storage_Unit
;
911 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
912 return Unknown_Pragma
;
914 return Pragma_Id
'Val (N
- First_Pragma_Name
);
918 ---------------------------
919 -- Get_Queuing_Policy_Id --
920 ---------------------------
922 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
924 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
925 end Get_Queuing_Policy_Id
;
927 ------------------------------------
928 -- Get_Task_Dispatching_Policy_Id --
929 ------------------------------------
931 function Get_Task_Dispatching_Policy_Id
(N
: Name_Id
)
932 return Task_Dispatching_Policy_Id
is
934 return Task_Dispatching_Policy_Id
'Val
935 (N
- First_Task_Dispatching_Policy_Name
);
936 end Get_Task_Dispatching_Policy_Id
;
942 procedure Initialize
is
944 Discard_Name
: Name_Id
;
947 P_Index
:= Preset_Names
'First;
952 while Preset_Names
(P_Index
) /= '#' loop
953 Name_Len
:= Name_Len
+ 1;
954 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
955 P_Index
:= P_Index
+ 1;
958 -- We do the Name_Find call to enter the name into the table, but
959 -- we don't need to do anything with the result, since we already
960 -- initialized all the preset names to have the right value (we
961 -- are depending on the order of the names and Preset_Names).
963 Discard_Name
:= Name_Find
;
964 P_Index
:= P_Index
+ 1;
965 exit when Preset_Names
(P_Index
) = '#';
968 -- Make sure that number of names in standard table is correct. If
969 -- this check fails, run utility program XSNAMES to construct a new
970 -- properly matching version of the body.
972 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
974 -- Initialize the convention identifiers table with the standard
975 -- set of synonyms that we recognize for conventions.
977 Convention_Identifiers
.Init
;
979 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
980 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
982 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
983 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
985 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
986 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
989 -----------------------
990 -- Is_Attribute_Name --
991 -----------------------
993 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
995 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
996 end Is_Attribute_Name
;
1002 function Is_Check_Name
(N
: Name_Id
) return Boolean is
1004 return N
in First_Check_Name
.. Last_Check_Name
;
1007 ------------------------
1008 -- Is_Convention_Name --
1009 ------------------------
1011 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
1013 -- Check if this is one of the standard conventions
1015 if N
in First_Convention_Name
.. Last_Convention_Name
1020 -- Otherwise check if it is in convention identifier table
1023 for J
in 1 .. Convention_Identifiers
.Last
loop
1024 if N
= Convention_Identifiers
.Table
(J
).Name
then
1031 end Is_Convention_Name
;
1033 ------------------------------
1034 -- Is_Entity_Attribute_Name --
1035 ------------------------------
1037 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
1039 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
1040 end Is_Entity_Attribute_Name
;
1042 --------------------------------
1043 -- Is_Function_Attribute_Name --
1044 --------------------------------
1046 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
1049 First_Renamable_Function_Attribute
..
1050 Last_Renamable_Function_Attribute
;
1051 end Is_Function_Attribute_Name
;
1053 ---------------------
1054 -- Is_Keyword_Name --
1055 ---------------------
1057 function Is_Keyword_Name
(N
: Name_Id
) return Boolean is
1059 return Get_Name_Table_Byte
(N
) /= 0
1060 and then (Ada_Version
>= Ada_95
1061 or else N
not in Ada_95_Reserved_Words
)
1062 and then (Ada_Version
>= Ada_05
1063 or else N
not in Ada_2005_Reserved_Words
);
1064 end Is_Keyword_Name
;
1066 ----------------------------
1067 -- Is_Locking_Policy_Name --
1068 ----------------------------
1070 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
1072 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
1073 end Is_Locking_Policy_Name
;
1075 -----------------------------
1076 -- Is_Operator_Symbol_Name --
1077 -----------------------------
1079 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
1081 return N
in First_Operator_Name
.. Last_Operator_Name
;
1082 end Is_Operator_Symbol_Name
;
1084 --------------------
1085 -- Is_Pragma_Name --
1086 --------------------
1088 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
1090 return N
in First_Pragma_Name
.. Last_Pragma_Name
1091 or else N
= Name_AST_Entry
1092 or else N
= Name_Interface
1093 or else N
= Name_Priority
1094 or else N
= Name_Storage_Size
1095 or else N
= Name_Storage_Unit
;
1098 ---------------------------------
1099 -- Is_Procedure_Attribute_Name --
1100 ---------------------------------
1102 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
1104 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1105 end Is_Procedure_Attribute_Name
;
1107 ----------------------------
1108 -- Is_Queuing_Policy_Name --
1109 ----------------------------
1111 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1113 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1114 end Is_Queuing_Policy_Name
;
1116 -------------------------------------
1117 -- Is_Task_Dispatching_Policy_Name --
1118 -------------------------------------
1120 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1122 return N
in First_Task_Dispatching_Policy_Name
..
1123 Last_Task_Dispatching_Policy_Name
;
1124 end Is_Task_Dispatching_Policy_Name
;
1126 ----------------------------
1127 -- Is_Type_Attribute_Name --
1128 ----------------------------
1130 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1132 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1133 end Is_Type_Attribute_Name
;
1135 ----------------------------------
1136 -- Record_Convention_Identifier --
1137 ----------------------------------
1139 procedure Record_Convention_Identifier
1141 Convention
: Convention_Id
)
1144 Convention_Identifiers
.Append
((Id
, Convention
));
1145 end Record_Convention_Identifier
;