1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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#" &
118 "finalization_root#" &
129 "get_active_partition_id#" &
130 "get_rci_package_receiver#" &
131 "get_rci_package_ref#" &
135 "partition_interface#" &
174 "compile_time_warning#" &
175 "component_alignment#" &
176 "convention_identifier#" &
179 "elaboration_checks#" &
181 "explicit_overriding#" &
183 "extensions_allowed#" &
184 "external_name_casing#" &
185 "float_representation#" &
186 "initialize_scalars#" &
192 "no_strict_aliasing#" &
193 "normalize_scalars#" &
196 "persistent_object#" &
198 "profile_warnings#" &
199 "propagate_exceptions#" &
202 "restricted_run_time#" &
204 "restriction_warnings#" &
206 "source_file_name#" &
207 "source_file_name_project#" &
210 "suppress_exception_locations#" &
211 "task_dispatching_policy#" &
218 "all_calls_remote#" &
223 "atomic_components#" &
227 "complex_representation#" &
239 "export_exception#" &
242 "export_procedure#" &
244 "export_valued_procedure#" &
246 "finalize_storage_only#" &
249 "import_exception#" &
252 "import_procedure#" &
253 "import_valued_procedure#" &
257 "inspection_point#" &
260 "interrupt_handler#" &
261 "interrupt_priority#" &
262 "java_constructor#" &
270 "machine_attribute#" &
277 "optional_overriding#" &
287 "remote_call_interface#" &
292 "source_reference#" &
296 "suppress_debug_info#" &
297 "suppress_initialization#" &
306 "unimplemented_unit#" &
308 "unreserve_all_interrupts#" &
310 "volatile_components#" &
328 "boolean_entry_barriers#" &
332 "component_size_4#" &
340 "first_optional_parameter#" &
350 "max_entry_queue_depth#" &
351 "max_entry_queue_length#" &
362 "no_dynamic_attachment#" &
363 "no_dynamic_interrupts#" &
365 "no_requeue_statements#" &
366 "no_task_attributes#" &
367 "no_task_attributes_package#" &
369 "result_mechanism#" &
373 "secondary_stack_size#" &
380 "subunit_file_name#" &
381 "task_stack_size_default#" &
383 "time_slicing_enabled#" &
416 "default_bit_order#" &
431 "has_access_values#" &
432 "has_discriminants#" &
443 "machine_mantissa#" &
444 "machine_overflows#" &
449 "max_size_in_storage_elements#" &
450 "maximum_alignment#" &
460 "passed_by_reference#" &
485 "unbiased_rounding#" &
486 "unchecked_access#" &
487 "unconstrained_array#" &
488 "universal_literal_string#" &
489 "unrestricted_access#" &
527 "inheritance_locking#" &
529 "priority_queuing#" &
530 "fifo_within_priorities#" &
532 "accessibility_check#" &
533 "discriminant_check#" &
535 "elaboration_check#" &
603 "enclosing_entity#" &
604 "exception_information#" &
605 "exception_message#" &
609 "import_largest_value#" &
617 "shift_right_arithmetic#" &
619 "unchecked_conversion#" &
620 "unchecked_deallocation#" &
637 "compute_dependency#" &
640 "default_switches#" &
641 "dependency_option#" &
644 "executable_suffix#" &
646 "externally_built#" &
648 "global_configuration_pragmas#" &
652 "implementation_exceptions#" &
653 "implementation_suffix#" &
655 "language_processing#" &
658 "library_auto_init#" &
660 "library_interface#" &
664 "library_reference_symbol_file#" &
666 "library_symbol_file#" &
667 "library_symbol_policy#" &
670 "local_configuration_pragmas#" &
671 "locally_removed_files#" &
680 "source_list_file#" &
684 "specification_exceptions#" &
685 "specification_suffix#" &
690 ---------------------
691 -- Generated Names --
692 ---------------------
694 -- This section lists the various cases of generated names which are
695 -- built from existing names by adding unique leading and/or trailing
696 -- upper case letters. In some cases these names are built recursively,
697 -- in particular names built from types may be built from types which
698 -- themselves have generated names. In this list, xxx represents an
699 -- existing name to which identifying letters are prepended or appended,
700 -- and a trailing n represents a serial number in an external name that
701 -- has some semantic significance (e.g. the n'th index type of an array).
703 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
704 -- xxxB tag table for tagged type xxx (Exp_Ch3)
705 -- xxxB task body procedure for task xxx (Exp_Ch9)
706 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
707 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
708 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
709 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
710 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
711 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
712 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
713 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
714 -- xxxM master Id value for access type xxx (Exp_Ch3)
715 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
716 -- xxxP parameter record type for entry xxx (Exp_Ch9)
717 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
718 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
719 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
720 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
721 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
722 -- xxxV type for task value record for task xxx (Exp_Ch9)
723 -- xxxX entry index constant (Exp_Ch9)
724 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
725 -- xxxZ size variable for task xxx (Exp_Ch9)
729 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
730 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
731 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
732 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
733 -- xxxIP initialization procedure for type xxx (Exp_TSS)
734 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
735 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
736 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
737 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
738 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
739 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
740 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
741 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
743 -- Implicit type names
745 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
747 -- (Note: this list is not complete or accurate ???)
749 ----------------------
750 -- Get_Attribute_Id --
751 ----------------------
753 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
755 return Attribute_Id'Val (N - First_Attribute_Name);
756 end Get_Attribute_Id;
762 function Get_Check_Id (N : Name_Id) return Check_Id is
764 return Check_Id'Val (N - First_Check_Name);
767 -----------------------
768 -- Get_Convention_Id --
769 -----------------------
771 function Get_Convention_Id (N : Name_Id) return Convention_Id is
774 when Name_Ada => return Convention_Ada;
775 when Name_Assembler => return Convention_Assembler;
776 when Name_C => return Convention_C;
777 when Name_COBOL => return Convention_COBOL;
778 when Name_CPP => return Convention_CPP;
779 when Name_Fortran => return Convention_Fortran;
780 when Name_Intrinsic => return Convention_Intrinsic;
781 when Name_Java => return Convention_Java;
782 when Name_Stdcall => return Convention_Stdcall;
783 when Name_Stubbed => return Convention_Stubbed;
785 -- If no direct match, then we must have a convention
786 -- identifier pragma that has specified this name.
789 for J in 1 .. Convention_Identifiers.Last loop
790 if N = Convention_Identifiers.Table (J).Name then
791 return Convention_Identifiers.Table (J).Convention;
797 end Get_Convention_Id;
799 ---------------------------
800 -- Get_Locking_Policy_Id --
801 ---------------------------
803 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
805 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
806 end Get_Locking_Policy_Id;
812 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
814 if N = Name_AST_Entry then
815 return Pragma_AST_Entry;
816 elsif N = Name_Storage_Size then
817 return Pragma_Storage_Size;
818 elsif N = Name_Storage_Unit then
819 return Pragma_Storage_Unit;
820 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
821 return Unknown_Pragma;
823 return Pragma_Id'Val (N - First_Pragma_Name);
827 ---------------------------
828 -- Get_Queuing_Policy_Id --
829 ---------------------------
831 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
833 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
834 end Get_Queuing_Policy_Id;
836 ------------------------------------
837 -- Get_Task_Dispatching_Policy_Id --
838 ------------------------------------
840 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
841 return Task_Dispatching_Policy_Id is
843 return Task_Dispatching_Policy_Id'Val
844 (N - First_Task_Dispatching_Policy_Name);
845 end Get_Task_Dispatching_Policy_Id;
851 procedure Initialize is
853 Discard_Name : Name_Id;
856 P_Index := Preset_Names'First;
861 while Preset_Names (P_Index) /= '#' loop
862 Name_Len := Name_Len + 1;
863 Name_Buffer (Name_Len) := Preset_Names (P_Index);
864 P_Index := P_Index + 1;
867 -- We do the Name_Find call to enter the name into the table, but
868 -- we don't need to do anything with the result, since we already
869 -- initialized all the preset names to have the right value (we
870 -- are depending on the order of the names and Preset_Names).
872 Discard_Name := Name_Find;
873 P_Index := P_Index + 1;
874 exit when Preset_Names (P_Index) = '#';
877 -- Make sure that number of names in standard table is correct. If
878 -- this check fails, run utility program XSNAMES to construct a new
879 -- properly matching version of the body.
881 pragma Assert (Discard_Name = Last_Predefined_Name);
883 -- Initialize the convention identifiers table with the standard
884 -- set of synonyms that we recognize for conventions.
886 Convention_Identifiers.Init;
888 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
889 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
891 Convention_Identifiers.Append ((Name_Default, Convention_C));
892 Convention_Identifiers.Append ((Name_External, Convention_C));
894 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
895 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
898 -----------------------
899 -- Is_Attribute_Name --
900 -----------------------
902 function Is_Attribute_Name (N : Name_Id) return Boolean is
904 return N in First_Attribute_Name .. Last_Attribute_Name;
905 end Is_Attribute_Name;
911 function Is_Check_Name (N : Name_Id) return Boolean is
913 return N in First_Check_Name .. Last_Check_Name;
916 ------------------------
917 -- Is_Convention_Name --
918 ------------------------
920 function Is_Convention_Name (N : Name_Id) return Boolean is
922 -- Check if this is one of the standard conventions
924 if N in First_Convention_Name .. Last_Convention_Name
929 -- Otherwise check if it is in convention identifier table
932 for J in 1 .. Convention_Identifiers.Last loop
933 if N = Convention_Identifiers.Table (J).Name then
940 end Is_Convention_Name;
942 ------------------------------
943 -- Is_Entity_Attribute_Name --
944 ------------------------------
946 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
948 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
949 end Is_Entity_Attribute_Name;
951 --------------------------------
952 -- Is_Function_Attribute_Name --
953 --------------------------------
955 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
958 First_Renamable_Function_Attribute ..
959 Last_Renamable_Function_Attribute;
960 end Is_Function_Attribute_Name;
962 ----------------------------
963 -- Is_Locking_Policy_Name --
964 ----------------------------
966 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
968 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
969 end Is_Locking_Policy_Name;
971 -----------------------------
972 -- Is_Operator_Symbol_Name --
973 -----------------------------
975 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
977 return N in First_Operator_Name .. Last_Operator_Name;
978 end Is_Operator_Symbol_Name;
984 function Is_Pragma_Name (N : Name_Id) return Boolean is
986 return N in First_Pragma_Name .. Last_Pragma_Name
987 or else N = Name_AST_Entry
988 or else N = Name_Storage_Size
989 or else N = Name_Storage_Unit;
992 ---------------------------------
993 -- Is_Procedure_Attribute_Name --
994 ---------------------------------
996 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
998 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
999 end Is_Procedure_Attribute_Name;
1001 ----------------------------
1002 -- Is_Queuing_Policy_Name --
1003 ----------------------------
1005 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1007 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1008 end Is_Queuing_Policy_Name;
1010 -------------------------------------
1011 -- Is_Task_Dispatching_Policy_Name --
1012 -------------------------------------
1014 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1016 return N in First_Task_Dispatching_Policy_Name ..
1017 Last_Task_Dispatching_Policy_Name;
1018 end Is_Task_Dispatching_Policy_Name;
1020 ----------------------------
1021 -- Is_Type_Attribute_Name --
1022 ----------------------------
1024 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1026 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1027 end Is_Type_Attribute_Name;
1029 ----------------------------------
1030 -- Record_Convention_Identifier --
1031 ----------------------------------
1033 procedure Record_Convention_Identifier
1035 Convention : Convention_Id)
1038 Convention_Identifiers.Append ((Id, Convention));
1039 end Record_Convention_Identifier;