1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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;
37 package body Snames is
39 -- Table used to record convention identifiers
41 type Convention_Id_Entry is record
43 Convention : Convention_Id;
46 package Convention_Identifiers is new Table.Table (
47 Table_Component_Type => Convention_Id_Entry,
48 Table_Index_Type => Int,
51 Table_Increment => 200,
52 Table_Name => "Name_Convention_Identifiers");
54 -- Table of names to be set by Initialize. Each name is terminated by a
55 -- single #, and the end of the list is marked by a null entry, i.e. by
56 -- two # marks in succession. Note that the table does not include the
57 -- entries for a-z, since these are initialized by Namet itself.
59 Preset_Names : constant String :=
77 "_local_final_list#" &
92 "_disp_asynchronous_select#" &
93 "_disp_conditional_select#" &
94 "_disp_get_prim_op_kind#" &
95 "_disp_timed_select#" &
120 "finalization_root#" &
126 "wide_wide_text_io#" &
132 "get_active_partition_id#" &
133 "get_rci_package_receiver#" &
134 "get_rci_package_ref#" &
138 "partition_interface#" &
176 "assertion_policy#" &
178 "compile_time_warning#" &
179 "component_alignment#" &
180 "convention_identifier#" &
184 "elaboration_checks#" &
186 "explicit_overriding#" &
188 "extensions_allowed#" &
189 "external_name_casing#" &
190 "float_representation#" &
191 "initialize_scalars#" &
197 "no_strict_aliasing#" &
198 "normalize_scalars#" &
202 "profile_warnings#" &
203 "propagate_exceptions#" &
206 "restricted_run_time#" &
208 "restriction_warnings#" &
210 "source_file_name#" &
211 "source_file_name_project#" &
214 "suppress_exception_locations#" &
215 "task_dispatching_policy#" &
222 "all_calls_remote#" &
227 "atomic_components#" &
231 "complex_representation#" &
243 "export_exception#" &
246 "export_procedure#" &
248 "export_valued_procedure#" &
250 "finalize_storage_only#" &
253 "import_exception#" &
256 "import_procedure#" &
257 "import_valued_procedure#" &
261 "inspection_point#" &
263 "interrupt_handler#" &
264 "interrupt_priority#" &
265 "java_constructor#" &
270 "linker_constructor#" &
271 "linker_destructor#" &
275 "machine_attribute#" &
282 "optional_overriding#" &
293 "remote_call_interface#" &
298 "source_reference#" &
302 "suppress_debug_info#" &
303 "suppress_initialization#" &
312 "unimplemented_unit#" &
314 "unreserve_all_interrupts#" &
316 "volatile_components#" &
335 "boolean_entry_barriers#" &
340 "component_size_4#" &
349 "first_optional_parameter#" &
361 "max_entry_queue_depth#" &
362 "max_entry_queue_length#" &
372 "no_dynamic_attachment#" &
373 "no_dynamic_interrupts#" &
375 "no_requeue_statements#" &
376 "no_task_attributes#" &
377 "no_task_attributes_package#" &
382 "result_mechanism#" &
386 "secondary_stack_size#" &
394 "subunit_file_name#" &
395 "task_stack_size_default#" &
397 "time_slicing_enabled#" &
431 "default_bit_order#" &
446 "has_access_values#" &
447 "has_discriminants#" &
458 "machine_mantissa#" &
459 "machine_overflows#" &
464 "max_size_in_storage_elements#" &
465 "maximum_alignment#" &
476 "passed_by_reference#" &
502 "unbiased_rounding#" &
503 "unchecked_access#" &
504 "unconstrained_array#" &
505 "universal_literal_string#" &
506 "unrestricted_access#" &
547 "inheritance_locking#" &
549 "priority_queuing#" &
550 "fifo_within_priorities#" &
552 "accessibility_check#" &
553 "discriminant_check#" &
555 "elaboration_check#" &
622 "enclosing_entity#" &
623 "exception_information#" &
624 "exception_message#" &
627 "generic_dispatching_constructor#" &
629 "import_largest_value#" &
637 "shift_right_arithmetic#" &
639 "unchecked_conversion#" &
640 "unchecked_deallocation#" &
657 "compute_dependency#" &
660 "default_switches#" &
661 "dependency_option#" &
664 "executable_suffix#" &
666 "externally_built#" &
668 "global_configuration_pragmas#" &
672 "implementation_exceptions#" &
673 "implementation_suffix#" &
675 "language_processing#" &
678 "library_auto_init#" &
680 "library_interface#" &
684 "library_reference_symbol_file#" &
686 "library_symbol_file#" &
687 "library_symbol_policy#" &
690 "local_configuration_pragmas#" &
691 "locally_removed_files#" &
700 "source_list_file#" &
704 "specification_exceptions#" &
705 "specification_suffix#" &
713 ---------------------
714 -- Generated Names --
715 ---------------------
717 -- This section lists the various cases of generated names which are
718 -- built from existing names by adding unique leading and/or trailing
719 -- upper case letters. In some cases these names are built recursively,
720 -- in particular names built from types may be built from types which
721 -- themselves have generated names. In this list, xxx represents an
722 -- existing name to which identifying letters are prepended or appended,
723 -- and a trailing n represents a serial number in an external name that
724 -- has some semantic significance (e.g. the n'th index type of an array).
726 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
727 -- xxxB tag table for tagged type xxx (Exp_Ch3)
728 -- xxxB task body procedure for task xxx (Exp_Ch9)
729 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
730 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
731 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
732 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
733 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
734 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
735 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
736 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
737 -- xxxM master Id value for access type xxx (Exp_Ch3)
738 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
739 -- xxxP parameter record type for entry xxx (Exp_Ch9)
740 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
741 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
742 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
743 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
744 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
745 -- xxxV type for task value record for task xxx (Exp_Ch9)
746 -- xxxX entry index constant (Exp_Ch9)
747 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
748 -- xxxZ size variable for task xxx (Exp_Ch9)
752 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
753 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
754 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
755 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
756 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
757 -- xxxIP initialization procedure for type xxx (Exp_TSS)
758 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
759 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
760 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
761 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
762 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
763 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
764 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
765 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
766 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
767 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
769 -- Implicit type names
771 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
773 -- (Note: this list is not complete or accurate ???)
775 ----------------------
776 -- Get_Attribute_Id --
777 ----------------------
779 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
781 return Attribute_Id'Val (N - First_Attribute_Name);
782 end Get_Attribute_Id;
788 function Get_Check_Id (N : Name_Id) return Check_Id is
790 return Check_Id'Val (N - First_Check_Name);
793 -----------------------
794 -- Get_Convention_Id --
795 -----------------------
797 function Get_Convention_Id (N : Name_Id) return Convention_Id is
800 when Name_Ada => return Convention_Ada;
801 when Name_Assembler => return Convention_Assembler;
802 when Name_C => return Convention_C;
803 when Name_COBOL => return Convention_COBOL;
804 when Name_CPP => return Convention_CPP;
805 when Name_Fortran => return Convention_Fortran;
806 when Name_Intrinsic => return Convention_Intrinsic;
807 when Name_Java => return Convention_Java;
808 when Name_Stdcall => return Convention_Stdcall;
809 when Name_Stubbed => return Convention_Stubbed;
811 -- If no direct match, then we must have a convention
812 -- identifier pragma that has specified this name.
815 for J in 1 .. Convention_Identifiers.Last loop
816 if N = Convention_Identifiers.Table (J).Name then
817 return Convention_Identifiers.Table (J).Convention;
823 end Get_Convention_Id;
825 ---------------------------
826 -- Get_Locking_Policy_Id --
827 ---------------------------
829 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
831 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
832 end Get_Locking_Policy_Id;
838 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
840 if N = Name_AST_Entry then
841 return Pragma_AST_Entry;
842 elsif N = Name_Interface then
843 return Pragma_Interface;
844 elsif N = Name_Storage_Size then
845 return Pragma_Storage_Size;
846 elsif N = Name_Storage_Unit then
847 return Pragma_Storage_Unit;
848 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
849 return Unknown_Pragma;
851 return Pragma_Id'Val (N - First_Pragma_Name);
855 ---------------------------
856 -- Get_Queuing_Policy_Id --
857 ---------------------------
859 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
861 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
862 end Get_Queuing_Policy_Id;
864 ------------------------------------
865 -- Get_Task_Dispatching_Policy_Id --
866 ------------------------------------
868 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
869 return Task_Dispatching_Policy_Id is
871 return Task_Dispatching_Policy_Id'Val
872 (N - First_Task_Dispatching_Policy_Name);
873 end Get_Task_Dispatching_Policy_Id;
879 procedure Initialize is
881 Discard_Name : Name_Id;
884 P_Index := Preset_Names'First;
889 while Preset_Names (P_Index) /= '#' loop
890 Name_Len := Name_Len + 1;
891 Name_Buffer (Name_Len) := Preset_Names (P_Index);
892 P_Index := P_Index + 1;
895 -- We do the Name_Find call to enter the name into the table, but
896 -- we don't need to do anything with the result, since we already
897 -- initialized all the preset names to have the right value (we
898 -- are depending on the order of the names and Preset_Names).
900 Discard_Name := Name_Find;
901 P_Index := P_Index + 1;
902 exit when Preset_Names (P_Index) = '#';
905 -- Make sure that number of names in standard table is correct. If
906 -- this check fails, run utility program XSNAMES to construct a new
907 -- properly matching version of the body.
909 pragma Assert (Discard_Name = Last_Predefined_Name);
911 -- Initialize the convention identifiers table with the standard
912 -- set of synonyms that we recognize for conventions.
914 Convention_Identifiers.Init;
916 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
917 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
919 Convention_Identifiers.Append ((Name_Default, Convention_C));
920 Convention_Identifiers.Append ((Name_External, Convention_C));
922 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
923 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
926 -----------------------
927 -- Is_Attribute_Name --
928 -----------------------
930 function Is_Attribute_Name (N : Name_Id) return Boolean is
932 return N in First_Attribute_Name .. Last_Attribute_Name;
933 end Is_Attribute_Name;
939 function Is_Check_Name (N : Name_Id) return Boolean is
941 return N in First_Check_Name .. Last_Check_Name;
944 ------------------------
945 -- Is_Convention_Name --
946 ------------------------
948 function Is_Convention_Name (N : Name_Id) return Boolean is
950 -- Check if this is one of the standard conventions
952 if N in First_Convention_Name .. Last_Convention_Name
957 -- Otherwise check if it is in convention identifier table
960 for J in 1 .. Convention_Identifiers.Last loop
961 if N = Convention_Identifiers.Table (J).Name then
968 end Is_Convention_Name;
970 ------------------------------
971 -- Is_Entity_Attribute_Name --
972 ------------------------------
974 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
976 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
977 end Is_Entity_Attribute_Name;
979 --------------------------------
980 -- Is_Function_Attribute_Name --
981 --------------------------------
983 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
986 First_Renamable_Function_Attribute ..
987 Last_Renamable_Function_Attribute;
988 end Is_Function_Attribute_Name;
990 ----------------------------
991 -- Is_Locking_Policy_Name --
992 ----------------------------
994 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
996 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
997 end Is_Locking_Policy_Name;
999 -----------------------------
1000 -- Is_Operator_Symbol_Name --
1001 -----------------------------
1003 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1005 return N in First_Operator_Name .. Last_Operator_Name;
1006 end Is_Operator_Symbol_Name;
1008 --------------------
1009 -- Is_Pragma_Name --
1010 --------------------
1012 function Is_Pragma_Name (N : Name_Id) return Boolean is
1014 return N in First_Pragma_Name .. Last_Pragma_Name
1015 or else N = Name_AST_Entry
1016 or else N = Name_Interface
1017 or else N = Name_Storage_Size
1018 or else N = Name_Storage_Unit;
1021 ---------------------------------
1022 -- Is_Procedure_Attribute_Name --
1023 ---------------------------------
1025 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1027 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1028 end Is_Procedure_Attribute_Name;
1030 ----------------------------
1031 -- Is_Queuing_Policy_Name --
1032 ----------------------------
1034 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1036 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1037 end Is_Queuing_Policy_Name;
1039 -------------------------------------
1040 -- Is_Task_Dispatching_Policy_Name --
1041 -------------------------------------
1043 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1045 return N in First_Task_Dispatching_Policy_Name ..
1046 Last_Task_Dispatching_Policy_Name;
1047 end Is_Task_Dispatching_Policy_Name;
1049 ----------------------------
1050 -- Is_Type_Attribute_Name --
1051 ----------------------------
1053 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1055 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1056 end Is_Type_Attribute_Name;
1058 ----------------------------------
1059 -- Record_Convention_Identifier --
1060 ----------------------------------
1062 procedure Record_Convention_Identifier
1064 Convention : Convention_Id)
1067 Convention_Identifiers.Append ((Id, Convention));
1068 end Record_Convention_Identifier;