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#" &
663 "compute_dependency#" &
666 "default_switches#" &
667 "dependency_option#" &
670 "executable_suffix#" &
672 "externally_built#" &
674 "global_configuration_pragmas#" &
678 "implementation_exceptions#" &
679 "implementation_suffix#" &
681 "language_processing#" &
685 "library_auto_init#" &
687 "library_interface#" &
691 "library_reference_symbol_file#" &
693 "library_symbol_file#" &
694 "library_symbol_policy#" &
697 "local_configuration_pragmas#" &
698 "locally_removed_files#" &
707 "source_list_file#" &
711 "specification_exceptions#" &
712 "specification_suffix#" &
720 ---------------------
721 -- Generated Names --
722 ---------------------
724 -- This section lists the various cases of generated names which are
725 -- built from existing names by adding unique leading and/or trailing
726 -- upper case letters. In some cases these names are built recursively,
727 -- in particular names built from types may be built from types which
728 -- themselves have generated names. In this list, xxx represents an
729 -- existing name to which identifying letters are prepended or appended,
730 -- and a trailing n represents a serial number in an external name that
731 -- has some semantic significance (e.g. the n'th index type of an array).
733 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
734 -- xxxB tag table for tagged type xxx (Exp_Ch3)
735 -- xxxB task body procedure for task xxx (Exp_Ch9)
736 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
737 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
738 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
739 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
740 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
741 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
742 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
743 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
744 -- xxxM master Id value for access type xxx (Exp_Ch3)
745 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
746 -- xxxP parameter record type for entry xxx (Exp_Ch9)
747 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
748 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
749 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
750 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
751 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
752 -- xxxV type for task value record for task xxx (Exp_Ch9)
753 -- xxxX entry index constant (Exp_Ch9)
754 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
755 -- xxxZ size variable for task xxx (Exp_Ch9)
759 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
760 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
761 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
762 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
763 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
764 -- xxxIP initialization procedure for type xxx (Exp_TSS)
765 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
766 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
767 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
768 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
769 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
770 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
771 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
772 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
773 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
774 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
776 -- Implicit type names
778 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
780 -- (Note: this list is not complete or accurate ???)
782 ----------------------
783 -- Get_Attribute_Id --
784 ----------------------
786 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
788 return Attribute_Id'Val (N - First_Attribute_Name);
789 end Get_Attribute_Id;
795 function Get_Check_Id (N : Name_Id) return Check_Id is
797 return Check_Id'Val (N - First_Check_Name);
800 -----------------------
801 -- Get_Convention_Id --
802 -----------------------
804 function Get_Convention_Id (N : Name_Id) return Convention_Id is
807 when Name_Ada => return Convention_Ada;
808 when Name_Assembler => return Convention_Assembler;
809 when Name_C => return Convention_C;
810 when Name_COBOL => return Convention_COBOL;
811 when Name_CPP => return Convention_CPP;
812 when Name_Fortran => return Convention_Fortran;
813 when Name_Intrinsic => return Convention_Intrinsic;
814 when Name_Java => return Convention_Java;
815 when Name_Stdcall => return Convention_Stdcall;
816 when Name_Stubbed => return Convention_Stubbed;
818 -- If no direct match, then we must have a convention
819 -- identifier pragma that has specified this name.
822 for J in 1 .. Convention_Identifiers.Last loop
823 if N = Convention_Identifiers.Table (J).Name then
824 return Convention_Identifiers.Table (J).Convention;
830 end Get_Convention_Id;
832 ---------------------------
833 -- Get_Locking_Policy_Id --
834 ---------------------------
836 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
838 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
839 end Get_Locking_Policy_Id;
845 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
847 if N = Name_AST_Entry then
848 return Pragma_AST_Entry;
849 elsif N = Name_Interface then
850 return Pragma_Interface;
851 elsif N = Name_Storage_Size then
852 return Pragma_Storage_Size;
853 elsif N = Name_Storage_Unit then
854 return Pragma_Storage_Unit;
855 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
856 return Unknown_Pragma;
858 return Pragma_Id'Val (N - First_Pragma_Name);
862 ---------------------------
863 -- Get_Queuing_Policy_Id --
864 ---------------------------
866 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
868 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
869 end Get_Queuing_Policy_Id;
871 ------------------------------------
872 -- Get_Task_Dispatching_Policy_Id --
873 ------------------------------------
875 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
876 return Task_Dispatching_Policy_Id is
878 return Task_Dispatching_Policy_Id'Val
879 (N - First_Task_Dispatching_Policy_Name);
880 end Get_Task_Dispatching_Policy_Id;
886 procedure Initialize is
888 Discard_Name : Name_Id;
891 P_Index := Preset_Names'First;
896 while Preset_Names (P_Index) /= '#' loop
897 Name_Len := Name_Len + 1;
898 Name_Buffer (Name_Len) := Preset_Names (P_Index);
899 P_Index := P_Index + 1;
902 -- We do the Name_Find call to enter the name into the table, but
903 -- we don't need to do anything with the result, since we already
904 -- initialized all the preset names to have the right value (we
905 -- are depending on the order of the names and Preset_Names).
907 Discard_Name := Name_Find;
908 P_Index := P_Index + 1;
909 exit when Preset_Names (P_Index) = '#';
912 -- Make sure that number of names in standard table is correct. If
913 -- this check fails, run utility program XSNAMES to construct a new
914 -- properly matching version of the body.
916 pragma Assert (Discard_Name = Last_Predefined_Name);
918 -- Initialize the convention identifiers table with the standard
919 -- set of synonyms that we recognize for conventions.
921 Convention_Identifiers.Init;
923 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
924 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
926 Convention_Identifiers.Append ((Name_Default, Convention_C));
927 Convention_Identifiers.Append ((Name_External, Convention_C));
929 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
930 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
933 -----------------------
934 -- Is_Attribute_Name --
935 -----------------------
937 function Is_Attribute_Name (N : Name_Id) return Boolean is
939 return N in First_Attribute_Name .. Last_Attribute_Name;
940 end Is_Attribute_Name;
946 function Is_Check_Name (N : Name_Id) return Boolean is
948 return N in First_Check_Name .. Last_Check_Name;
951 ------------------------
952 -- Is_Convention_Name --
953 ------------------------
955 function Is_Convention_Name (N : Name_Id) return Boolean is
957 -- Check if this is one of the standard conventions
959 if N in First_Convention_Name .. Last_Convention_Name
964 -- Otherwise check if it is in convention identifier table
967 for J in 1 .. Convention_Identifiers.Last loop
968 if N = Convention_Identifiers.Table (J).Name then
975 end Is_Convention_Name;
977 ------------------------------
978 -- Is_Entity_Attribute_Name --
979 ------------------------------
981 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
983 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
984 end Is_Entity_Attribute_Name;
986 --------------------------------
987 -- Is_Function_Attribute_Name --
988 --------------------------------
990 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
993 First_Renamable_Function_Attribute ..
994 Last_Renamable_Function_Attribute;
995 end Is_Function_Attribute_Name;
997 ---------------------
998 -- Is_Keyword_Name --
999 ---------------------
1001 function Is_Keyword_Name (N : Name_Id) return Boolean is
1003 return Get_Name_Table_Byte (N) /= 0
1004 and then (Ada_Version >= Ada_95
1005 or else N not in Ada_95_Reserved_Words)
1006 and then (Ada_Version >= Ada_05
1007 or else N not in Ada_2005_Reserved_Words);
1008 end Is_Keyword_Name;
1010 ----------------------------
1011 -- Is_Locking_Policy_Name --
1012 ----------------------------
1014 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1016 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1017 end Is_Locking_Policy_Name;
1019 -----------------------------
1020 -- Is_Operator_Symbol_Name --
1021 -----------------------------
1023 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1025 return N in First_Operator_Name .. Last_Operator_Name;
1026 end Is_Operator_Symbol_Name;
1028 --------------------
1029 -- Is_Pragma_Name --
1030 --------------------
1032 function Is_Pragma_Name (N : Name_Id) return Boolean is
1034 return N in First_Pragma_Name .. Last_Pragma_Name
1035 or else N = Name_AST_Entry
1036 or else N = Name_Interface
1037 or else N = Name_Storage_Size
1038 or else N = Name_Storage_Unit;
1041 ---------------------------------
1042 -- Is_Procedure_Attribute_Name --
1043 ---------------------------------
1045 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1047 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1048 end Is_Procedure_Attribute_Name;
1050 ----------------------------
1051 -- Is_Queuing_Policy_Name --
1052 ----------------------------
1054 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1056 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1057 end Is_Queuing_Policy_Name;
1059 -------------------------------------
1060 -- Is_Task_Dispatching_Policy_Name --
1061 -------------------------------------
1063 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1065 return N in First_Task_Dispatching_Policy_Name ..
1066 Last_Task_Dispatching_Policy_Name;
1067 end Is_Task_Dispatching_Policy_Name;
1069 ----------------------------
1070 -- Is_Type_Attribute_Name --
1071 ----------------------------
1073 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1075 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1076 end Is_Type_Attribute_Name;
1078 ----------------------------------
1079 -- Record_Convention_Identifier --
1080 ----------------------------------
1082 procedure Record_Convention_Identifier
1084 Convention : Convention_Id)
1087 Convention_Identifiers.Append ((Id, Convention));
1088 end Record_Convention_Identifier;