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 :=
76 "_local_final_list#" &
113 "finalization_root#" &
121 "get_active_partition_id#" &
122 "get_rci_package_receiver#" &
126 "partition_interface#" &
155 "compile_time_warning#" &
156 "component_alignment#" &
157 "convention_identifier#" &
159 "elaboration_checks#" &
161 "explicit_overriding#" &
163 "extensions_allowed#" &
164 "external_name_casing#" &
165 "float_representation#" &
166 "initialize_scalars#" &
172 "normalize_scalars#" &
175 "persistent_object#" &
176 "propagate_exceptions#" &
179 "restricted_run_time#" &
181 "restriction_warnings#" &
183 "source_file_name#" &
184 "source_file_name_project#" &
187 "suppress_exception_locations#" &
188 "task_dispatching_policy#" &
195 "all_calls_remote#" &
200 "atomic_components#" &
204 "complex_representation#" &
216 "export_exception#" &
219 "export_procedure#" &
221 "export_valued_procedure#" &
223 "finalize_storage_only#" &
226 "import_exception#" &
229 "import_procedure#" &
230 "import_valued_procedure#" &
234 "inspection_point#" &
237 "interrupt_handler#" &
238 "interrupt_priority#" &
239 "java_constructor#" &
247 "machine_attribute#" &
254 "optional_overriding#" &
264 "remote_call_interface#" &
269 "source_reference#" &
273 "suppress_debug_info#" &
274 "suppress_initialization#" &
283 "unimplemented_unit#" &
285 "unreserve_all_interrupts#" &
287 "volatile_components#" &
308 "component_size_4#" &
316 "first_optional_parameter#" &
338 "no_task_attributes#" &
340 "result_mechanism#" &
344 "secondary_stack_size#" &
350 "subunit_file_name#" &
351 "task_stack_size_default#" &
353 "time_slicing_enabled#" &
386 "default_bit_order#" &
401 "has_discriminants#" &
412 "machine_mantissa#" &
413 "machine_overflows#" &
418 "max_size_in_storage_elements#" &
419 "maximum_alignment#" &
429 "passed_by_reference#" &
454 "unbiased_rounding#" &
455 "unchecked_access#" &
456 "unconstrained_array#" &
457 "universal_literal_string#" &
458 "unrestricted_access#" &
496 "inheritance_locking#" &
498 "priority_queuing#" &
499 "fifo_within_priorities#" &
501 "accessibility_check#" &
502 "discriminant_check#" &
504 "elaboration_check#" &
572 "enclosing_entity#" &
573 "exception_information#" &
574 "exception_message#" &
578 "import_largest_value#" &
586 "shift_right_arithmetic#" &
588 "unchecked_conversion#" &
589 "unchecked_deallocation#" &
603 "default_switches#" &
606 "executable_suffix#" &
609 "global_configuration_pragmas#" &
613 "implementation_exceptions#" &
614 "implementation_suffix#" &
617 "library_auto_init#" &
619 "library_interface#" &
623 "library_reference_symbol_file#" &
625 "library_symbol_file#" &
626 "library_symbol_policy#" &
629 "local_configuration_pragmas#" &
630 "locally_removed_files#" &
638 "source_list_file#" &
642 "specification_exceptions#" &
643 "specification_suffix#" &
648 ---------------------
649 -- Generated Names --
650 ---------------------
652 -- This section lists the various cases of generated names which are
653 -- built from existing names by adding unique leading and/or trailing
654 -- upper case letters. In some cases these names are built recursively,
655 -- in particular names built from types may be built from types which
656 -- themselves have generated names. In this list, xxx represents an
657 -- existing name to which identifying letters are prepended or appended,
658 -- and a trailing n represents a serial number in an external name that
659 -- has some semantic significance (e.g. the n'th index type of an array).
661 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
662 -- xxxB tag table for tagged type xxx (Exp_Ch3)
663 -- xxxB task body procedure for task xxx (Exp_Ch9)
664 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
665 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
666 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
667 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
668 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
669 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
670 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
671 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
672 -- xxxM master Id value for access type xxx (Exp_Ch3)
673 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
674 -- xxxP parameter record type for entry xxx (Exp_Ch9)
675 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
676 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
677 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
678 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
679 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
680 -- xxxV type for task value record for task xxx (Exp_Ch9)
681 -- xxxX entry index constant (Exp_Ch9)
682 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
683 -- xxxZ size variable for task xxx (Exp_Ch9)
687 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
688 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
689 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
690 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
691 -- xxxIP initialization procedure for type xxx (Exp_TSS)
692 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
693 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
694 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
695 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
696 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
697 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
698 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
699 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
701 -- Implicit type names
703 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
705 -- (Note: this list is not complete or accurate ???)
707 ----------------------
708 -- Get_Attribute_Id --
709 ----------------------
711 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
713 return Attribute_Id'Val (N - First_Attribute_Name);
714 end Get_Attribute_Id;
720 function Get_Check_Id (N : Name_Id) return Check_Id is
722 return Check_Id'Val (N - First_Check_Name);
725 -----------------------
726 -- Get_Convention_Id --
727 -----------------------
729 function Get_Convention_Id (N : Name_Id) return Convention_Id is
732 when Name_Ada => return Convention_Ada;
733 when Name_Assembler => return Convention_Assembler;
734 when Name_C => return Convention_C;
735 when Name_COBOL => return Convention_COBOL;
736 when Name_CPP => return Convention_CPP;
737 when Name_Fortran => return Convention_Fortran;
738 when Name_Intrinsic => return Convention_Intrinsic;
739 when Name_Java => return Convention_Java;
740 when Name_Stdcall => return Convention_Stdcall;
741 when Name_Stubbed => return Convention_Stubbed;
743 -- If no direct match, then we must have a convention
744 -- identifier pragma that has specified this name.
747 for J in 1 .. Convention_Identifiers.Last loop
748 if N = Convention_Identifiers.Table (J).Name then
749 return Convention_Identifiers.Table (J).Convention;
755 end Get_Convention_Id;
757 ---------------------------
758 -- Get_Locking_Policy_Id --
759 ---------------------------
761 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
763 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
764 end Get_Locking_Policy_Id;
770 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
772 if N = Name_AST_Entry then
773 return Pragma_AST_Entry;
774 elsif N = Name_Storage_Size then
775 return Pragma_Storage_Size;
776 elsif N = Name_Storage_Unit then
777 return Pragma_Storage_Unit;
778 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
779 return Unknown_Pragma;
781 return Pragma_Id'Val (N - First_Pragma_Name);
785 ---------------------------
786 -- Get_Queuing_Policy_Id --
787 ---------------------------
789 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
791 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
792 end Get_Queuing_Policy_Id;
794 ------------------------------------
795 -- Get_Task_Dispatching_Policy_Id --
796 ------------------------------------
798 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
799 return Task_Dispatching_Policy_Id is
801 return Task_Dispatching_Policy_Id'Val
802 (N - First_Task_Dispatching_Policy_Name);
803 end Get_Task_Dispatching_Policy_Id;
809 procedure Initialize is
811 Discard_Name : Name_Id;
814 P_Index := Preset_Names'First;
819 while Preset_Names (P_Index) /= '#' loop
820 Name_Len := Name_Len + 1;
821 Name_Buffer (Name_Len) := Preset_Names (P_Index);
822 P_Index := P_Index + 1;
825 -- We do the Name_Find call to enter the name into the table, but
826 -- we don't need to do anything with the result, since we already
827 -- initialized all the preset names to have the right value (we
828 -- are depending on the order of the names and Preset_Names).
830 Discard_Name := Name_Find;
831 P_Index := P_Index + 1;
832 exit when Preset_Names (P_Index) = '#';
835 -- Make sure that number of names in standard table is correct. If
836 -- this check fails, run utility program XSNAMES to construct a new
837 -- properly matching version of the body.
839 pragma Assert (Discard_Name = Last_Predefined_Name);
841 -- Initialize the convention identifiers table with the standard
842 -- set of synonyms that we recognize for conventions.
844 Convention_Identifiers.Init;
846 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
847 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
849 Convention_Identifiers.Append ((Name_Default, Convention_C));
850 Convention_Identifiers.Append ((Name_External, Convention_C));
852 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
853 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
856 -----------------------
857 -- Is_Attribute_Name --
858 -----------------------
860 function Is_Attribute_Name (N : Name_Id) return Boolean is
862 return N in First_Attribute_Name .. Last_Attribute_Name;
863 end Is_Attribute_Name;
869 function Is_Check_Name (N : Name_Id) return Boolean is
871 return N in First_Check_Name .. Last_Check_Name;
874 ------------------------
875 -- Is_Convention_Name --
876 ------------------------
878 function Is_Convention_Name (N : Name_Id) return Boolean is
880 -- Check if this is one of the standard conventions
882 if N in First_Convention_Name .. Last_Convention_Name
887 -- Otherwise check if it is in convention identifier table
890 for J in 1 .. Convention_Identifiers.Last loop
891 if N = Convention_Identifiers.Table (J).Name then
898 end Is_Convention_Name;
900 ------------------------------
901 -- Is_Entity_Attribute_Name --
902 ------------------------------
904 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
906 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
907 end Is_Entity_Attribute_Name;
909 --------------------------------
910 -- Is_Function_Attribute_Name --
911 --------------------------------
913 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
916 First_Renamable_Function_Attribute ..
917 Last_Renamable_Function_Attribute;
918 end Is_Function_Attribute_Name;
920 ----------------------------
921 -- Is_Locking_Policy_Name --
922 ----------------------------
924 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
926 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
927 end Is_Locking_Policy_Name;
929 -----------------------------
930 -- Is_Operator_Symbol_Name --
931 -----------------------------
933 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
935 return N in First_Operator_Name .. Last_Operator_Name;
936 end Is_Operator_Symbol_Name;
942 function Is_Pragma_Name (N : Name_Id) return Boolean is
944 return N in First_Pragma_Name .. Last_Pragma_Name
945 or else N = Name_AST_Entry
946 or else N = Name_Storage_Size
947 or else N = Name_Storage_Unit;
950 ---------------------------------
951 -- Is_Procedure_Attribute_Name --
952 ---------------------------------
954 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
956 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
957 end Is_Procedure_Attribute_Name;
959 ----------------------------
960 -- Is_Queuing_Policy_Name --
961 ----------------------------
963 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
965 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
966 end Is_Queuing_Policy_Name;
968 -------------------------------------
969 -- Is_Task_Dispatching_Policy_Name --
970 -------------------------------------
972 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
974 return N in First_Task_Dispatching_Policy_Name ..
975 Last_Task_Dispatching_Policy_Name;
976 end Is_Task_Dispatching_Policy_Name;
978 ----------------------------
979 -- Is_Type_Attribute_Name --
980 ----------------------------
982 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
984 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
985 end Is_Type_Attribute_Name;
987 ----------------------------------
988 -- Record_Convention_Identifier --
989 ----------------------------------
991 procedure Record_Convention_Identifier
993 Convention : Convention_Id)
996 Convention_Identifiers.Append ((Id, Convention));
997 end Record_Convention_Identifier;