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#" &
205 "profile_warnings#" &
206 "propagate_exceptions#" &
209 "restricted_run_time#" &
211 "restriction_warnings#" &
213 "source_file_name#" &
214 "source_file_name_project#" &
217 "suppress_exception_locations#" &
218 "task_dispatching_policy#" &
225 "all_calls_remote#" &
230 "atomic_components#" &
234 "complete_representation#" &
235 "complex_representation#" &
247 "export_exception#" &
250 "export_procedure#" &
252 "export_valued_procedure#" &
254 "finalize_storage_only#" &
257 "import_exception#" &
260 "import_procedure#" &
261 "import_valued_procedure#" &
265 "inspection_point#" &
267 "interrupt_handler#" &
268 "interrupt_priority#" &
269 "java_constructor#" &
274 "linker_constructor#" &
275 "linker_destructor#" &
279 "machine_attribute#" &
286 "optional_overriding#" &
297 "remote_call_interface#" &
302 "source_reference#" &
306 "suppress_debug_info#" &
307 "suppress_initialization#" &
316 "unimplemented_unit#" &
318 "unreserve_all_interrupts#" &
320 "volatile_components#" &
339 "boolean_entry_barriers#" &
344 "component_size_4#" &
353 "first_optional_parameter#" &
365 "max_entry_queue_depth#" &
366 "max_entry_queue_length#" &
376 "no_dynamic_attachment#" &
377 "no_dynamic_interrupts#" &
379 "no_requeue_statements#" &
380 "no_task_attributes#" &
381 "no_task_attributes_package#" &
386 "result_mechanism#" &
390 "secondary_stack_size#" &
398 "subunit_file_name#" &
399 "task_stack_size_default#" &
401 "time_slicing_enabled#" &
435 "default_bit_order#" &
450 "has_access_values#" &
451 "has_discriminants#" &
462 "machine_mantissa#" &
463 "machine_overflows#" &
465 "machine_rounding#" &
469 "max_size_in_storage_elements#" &
470 "maximum_alignment#" &
481 "passed_by_reference#" &
507 "unbiased_rounding#" &
508 "unchecked_access#" &
509 "unconstrained_array#" &
510 "universal_literal_string#" &
511 "unrestricted_access#" &
552 "inheritance_locking#" &
554 "priority_queuing#" &
555 "fifo_within_priorities#" &
557 "accessibility_check#" &
558 "discriminant_check#" &
560 "elaboration_check#" &
627 "enclosing_entity#" &
628 "exception_information#" &
629 "exception_message#" &
632 "generic_dispatching_constructor#" &
634 "import_largest_value#" &
642 "shift_right_arithmetic#" &
644 "unchecked_conversion#" &
645 "unchecked_deallocation#" &
665 "compiler_pic_option#" &
666 "compute_dependency#" &
667 "config_body_file_name#" &
668 "config_body_file_name_pattern#" &
669 "config_file_switches#" &
670 "config_file_unique#" &
671 "config_spec_file_name#" &
672 "config_spec_file_name_pattern#" &
674 "default_builder_switches#" &
675 "default_global_compiler_switches#" &
676 "default_language#" &
678 "default_switches#" &
679 "dependency_file_kind#" &
680 "dependency_option#" &
683 "executable_suffix#" &
685 "externally_built#" &
687 "global_compiler_switches#" &
688 "global_configuration_pragmas#" &
692 "implementation_exceptions#" &
693 "implementation_suffix#" &
696 "include_path_file#" &
698 "language_processing#" &
702 "library_auto_init#" &
704 "library_interface#" &
708 "library_reference_symbol_file#" &
710 "library_symbol_file#" &
711 "library_symbol_policy#" &
714 "linker_executable_option#" &
715 "linker_lib_dir_option#" &
716 "linker_lib_name_option#" &
717 "local_configuration_pragmas#" &
718 "locally_removed_files#" &
719 "mapping_file_switches#" &
730 "source_list_file#" &
734 "specification_exceptions#" &
735 "specification_suffix#" &
743 ---------------------
744 -- Generated Names --
745 ---------------------
747 -- This section lists the various cases of generated names which are
748 -- built from existing names by adding unique leading and/or trailing
749 -- upper case letters. In some cases these names are built recursively,
750 -- in particular names built from types may be built from types which
751 -- themselves have generated names. In this list, xxx represents an
752 -- existing name to which identifying letters are prepended or appended,
753 -- and a trailing n represents a serial number in an external name that
754 -- has some semantic significance (e.g. the n'th index type of an array).
756 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
757 -- xxxB tag table for tagged type xxx (Exp_Ch3)
758 -- xxxB task body procedure for task xxx (Exp_Ch9)
759 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
760 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
761 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
762 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
763 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
764 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
765 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
766 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
767 -- xxxM master Id value for access type xxx (Exp_Ch3)
768 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
769 -- xxxP parameter record type for entry xxx (Exp_Ch9)
770 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
771 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
772 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
773 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
774 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
775 -- xxxV type for task value record for task xxx (Exp_Ch9)
776 -- xxxX entry index constant (Exp_Ch9)
777 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
778 -- xxxZ size variable for task xxx (Exp_Ch9)
782 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
783 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
784 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
785 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
786 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
787 -- xxxIP initialization procedure for type xxx (Exp_TSS)
788 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
789 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
790 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
791 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
792 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
793 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
794 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
795 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
796 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
797 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
799 -- Implicit type names
801 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
803 -- (Note: this list is not complete or accurate ???)
805 ----------------------
806 -- Get_Attribute_Id --
807 ----------------------
809 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
811 return Attribute_Id'Val (N - First_Attribute_Name);
812 end Get_Attribute_Id;
818 function Get_Check_Id (N : Name_Id) return Check_Id is
820 return Check_Id'Val (N - First_Check_Name);
823 -----------------------
824 -- Get_Convention_Id --
825 -----------------------
827 function Get_Convention_Id (N : Name_Id) return Convention_Id is
830 when Name_Ada => return Convention_Ada;
831 when Name_Assembler => return Convention_Assembler;
832 when Name_C => return Convention_C;
833 when Name_COBOL => return Convention_COBOL;
834 when Name_CPP => return Convention_CPP;
835 when Name_Fortran => return Convention_Fortran;
836 when Name_Intrinsic => return Convention_Intrinsic;
837 when Name_Java => return Convention_Java;
838 when Name_Stdcall => return Convention_Stdcall;
839 when Name_Stubbed => return Convention_Stubbed;
841 -- If no direct match, then we must have a convention
842 -- identifier pragma that has specified this name.
845 for J in 1 .. Convention_Identifiers.Last loop
846 if N = Convention_Identifiers.Table (J).Name then
847 return Convention_Identifiers.Table (J).Convention;
853 end Get_Convention_Id;
855 ---------------------------
856 -- Get_Locking_Policy_Id --
857 ---------------------------
859 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
861 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
862 end Get_Locking_Policy_Id;
868 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
870 if N = Name_AST_Entry then
871 return Pragma_AST_Entry;
872 elsif N = Name_Interface then
873 return Pragma_Interface;
874 elsif N = Name_Storage_Size then
875 return Pragma_Storage_Size;
876 elsif N = Name_Storage_Unit then
877 return Pragma_Storage_Unit;
878 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
879 return Unknown_Pragma;
881 return Pragma_Id'Val (N - First_Pragma_Name);
885 ---------------------------
886 -- Get_Queuing_Policy_Id --
887 ---------------------------
889 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
891 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
892 end Get_Queuing_Policy_Id;
894 ------------------------------------
895 -- Get_Task_Dispatching_Policy_Id --
896 ------------------------------------
898 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
899 return Task_Dispatching_Policy_Id is
901 return Task_Dispatching_Policy_Id'Val
902 (N - First_Task_Dispatching_Policy_Name);
903 end Get_Task_Dispatching_Policy_Id;
909 procedure Initialize is
911 Discard_Name : Name_Id;
914 P_Index := Preset_Names'First;
919 while Preset_Names (P_Index) /= '#' loop
920 Name_Len := Name_Len + 1;
921 Name_Buffer (Name_Len) := Preset_Names (P_Index);
922 P_Index := P_Index + 1;
925 -- We do the Name_Find call to enter the name into the table, but
926 -- we don't need to do anything with the result, since we already
927 -- initialized all the preset names to have the right value (we
928 -- are depending on the order of the names and Preset_Names).
930 Discard_Name := Name_Find;
931 P_Index := P_Index + 1;
932 exit when Preset_Names (P_Index) = '#';
935 -- Make sure that number of names in standard table is correct. If
936 -- this check fails, run utility program XSNAMES to construct a new
937 -- properly matching version of the body.
939 pragma Assert (Discard_Name = Last_Predefined_Name);
941 -- Initialize the convention identifiers table with the standard
942 -- set of synonyms that we recognize for conventions.
944 Convention_Identifiers.Init;
946 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
947 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
949 Convention_Identifiers.Append ((Name_Default, Convention_C));
950 Convention_Identifiers.Append ((Name_External, Convention_C));
952 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
953 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
956 -----------------------
957 -- Is_Attribute_Name --
958 -----------------------
960 function Is_Attribute_Name (N : Name_Id) return Boolean is
962 return N in First_Attribute_Name .. Last_Attribute_Name;
963 end Is_Attribute_Name;
969 function Is_Check_Name (N : Name_Id) return Boolean is
971 return N in First_Check_Name .. Last_Check_Name;
974 ------------------------
975 -- Is_Convention_Name --
976 ------------------------
978 function Is_Convention_Name (N : Name_Id) return Boolean is
980 -- Check if this is one of the standard conventions
982 if N in First_Convention_Name .. Last_Convention_Name
987 -- Otherwise check if it is in convention identifier table
990 for J in 1 .. Convention_Identifiers.Last loop
991 if N = Convention_Identifiers.Table (J).Name then
998 end Is_Convention_Name;
1000 ------------------------------
1001 -- Is_Entity_Attribute_Name --
1002 ------------------------------
1004 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
1006 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
1007 end Is_Entity_Attribute_Name;
1009 --------------------------------
1010 -- Is_Function_Attribute_Name --
1011 --------------------------------
1013 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
1016 First_Renamable_Function_Attribute ..
1017 Last_Renamable_Function_Attribute;
1018 end Is_Function_Attribute_Name;
1020 ---------------------
1021 -- Is_Keyword_Name --
1022 ---------------------
1024 function Is_Keyword_Name (N : Name_Id) return Boolean is
1026 return Get_Name_Table_Byte (N) /= 0
1027 and then (Ada_Version >= Ada_95
1028 or else N not in Ada_95_Reserved_Words)
1029 and then (Ada_Version >= Ada_05
1030 or else N not in Ada_2005_Reserved_Words);
1031 end Is_Keyword_Name;
1033 ----------------------------
1034 -- Is_Locking_Policy_Name --
1035 ----------------------------
1037 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1039 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1040 end Is_Locking_Policy_Name;
1042 -----------------------------
1043 -- Is_Operator_Symbol_Name --
1044 -----------------------------
1046 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1048 return N in First_Operator_Name .. Last_Operator_Name;
1049 end Is_Operator_Symbol_Name;
1051 --------------------
1052 -- Is_Pragma_Name --
1053 --------------------
1055 function Is_Pragma_Name (N : Name_Id) return Boolean is
1057 return N in First_Pragma_Name .. Last_Pragma_Name
1058 or else N = Name_AST_Entry
1059 or else N = Name_Interface
1060 or else N = Name_Storage_Size
1061 or else N = Name_Storage_Unit;
1064 ---------------------------------
1065 -- Is_Procedure_Attribute_Name --
1066 ---------------------------------
1068 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1070 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1071 end Is_Procedure_Attribute_Name;
1073 ----------------------------
1074 -- Is_Queuing_Policy_Name --
1075 ----------------------------
1077 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1079 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1080 end Is_Queuing_Policy_Name;
1082 -------------------------------------
1083 -- Is_Task_Dispatching_Policy_Name --
1084 -------------------------------------
1086 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1088 return N in First_Task_Dispatching_Policy_Name ..
1089 Last_Task_Dispatching_Policy_Name;
1090 end Is_Task_Dispatching_Policy_Name;
1092 ----------------------------
1093 -- Is_Type_Attribute_Name --
1094 ----------------------------
1096 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1098 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1099 end Is_Type_Attribute_Name;
1101 ----------------------------------
1102 -- Record_Convention_Identifier --
1103 ----------------------------------
1105 procedure Record_Convention_Identifier
1107 Convention : Convention_Id)
1110 Convention_Identifiers.Append ((Id, Convention));
1111 end Record_Convention_Identifier;