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#" &
116 "finalization_root#" &
127 "get_active_partition_id#" &
128 "get_rci_package_receiver#" &
129 "get_rci_package_ref#" &
133 "partition_interface#" &
170 "compile_time_warning#" &
171 "component_alignment#" &
172 "convention_identifier#" &
174 "elaboration_checks#" &
176 "explicit_overriding#" &
178 "extensions_allowed#" &
179 "external_name_casing#" &
180 "float_representation#" &
181 "initialize_scalars#" &
187 "no_strict_aliasing#" &
188 "normalize_scalars#" &
191 "persistent_object#" &
193 "propagate_exceptions#" &
196 "restricted_run_time#" &
198 "restriction_warnings#" &
200 "source_file_name#" &
201 "source_file_name_project#" &
204 "suppress_exception_locations#" &
205 "task_dispatching_policy#" &
212 "all_calls_remote#" &
217 "atomic_components#" &
221 "complex_representation#" &
233 "export_exception#" &
236 "export_procedure#" &
238 "export_valued_procedure#" &
240 "finalize_storage_only#" &
243 "import_exception#" &
246 "import_procedure#" &
247 "import_valued_procedure#" &
251 "inspection_point#" &
254 "interrupt_handler#" &
255 "interrupt_priority#" &
256 "java_constructor#" &
264 "machine_attribute#" &
271 "optional_overriding#" &
281 "remote_call_interface#" &
286 "source_reference#" &
290 "suppress_debug_info#" &
291 "suppress_initialization#" &
300 "unimplemented_unit#" &
302 "unreserve_all_interrupts#" &
304 "volatile_components#" &
322 "boolean_entry_barriers#" &
326 "component_size_4#" &
334 "first_optional_parameter#" &
344 "max_entry_queue_depth#" &
355 "no_dynamic_interrupts#" &
357 "no_task_attributes#" &
359 "result_mechanism#" &
363 "secondary_stack_size#" &
369 "subunit_file_name#" &
370 "task_stack_size_default#" &
372 "time_slicing_enabled#" &
405 "default_bit_order#" &
420 "has_discriminants#" &
431 "machine_mantissa#" &
432 "machine_overflows#" &
437 "max_size_in_storage_elements#" &
438 "maximum_alignment#" &
448 "passed_by_reference#" &
473 "unbiased_rounding#" &
474 "unchecked_access#" &
475 "unconstrained_array#" &
476 "universal_literal_string#" &
477 "unrestricted_access#" &
515 "inheritance_locking#" &
517 "priority_queuing#" &
518 "fifo_within_priorities#" &
520 "accessibility_check#" &
521 "discriminant_check#" &
523 "elaboration_check#" &
591 "enclosing_entity#" &
592 "exception_information#" &
593 "exception_message#" &
597 "import_largest_value#" &
605 "shift_right_arithmetic#" &
607 "unchecked_conversion#" &
608 "unchecked_deallocation#" &
622 "default_switches#" &
625 "executable_suffix#" &
628 "global_configuration_pragmas#" &
632 "implementation_exceptions#" &
633 "implementation_suffix#" &
636 "library_auto_init#" &
638 "library_interface#" &
642 "library_reference_symbol_file#" &
644 "library_symbol_file#" &
645 "library_symbol_policy#" &
648 "local_configuration_pragmas#" &
649 "locally_removed_files#" &
657 "source_list_file#" &
661 "specification_exceptions#" &
662 "specification_suffix#" &
667 ---------------------
668 -- Generated Names --
669 ---------------------
671 -- This section lists the various cases of generated names which are
672 -- built from existing names by adding unique leading and/or trailing
673 -- upper case letters. In some cases these names are built recursively,
674 -- in particular names built from types may be built from types which
675 -- themselves have generated names. In this list, xxx represents an
676 -- existing name to which identifying letters are prepended or appended,
677 -- and a trailing n represents a serial number in an external name that
678 -- has some semantic significance (e.g. the n'th index type of an array).
680 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
681 -- xxxB tag table for tagged type xxx (Exp_Ch3)
682 -- xxxB task body procedure for task xxx (Exp_Ch9)
683 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
684 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
685 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
686 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
687 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
688 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
689 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
690 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
691 -- xxxM master Id value for access type xxx (Exp_Ch3)
692 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
693 -- xxxP parameter record type for entry xxx (Exp_Ch9)
694 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
695 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
696 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
697 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
698 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
699 -- xxxV type for task value record for task xxx (Exp_Ch9)
700 -- xxxX entry index constant (Exp_Ch9)
701 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
702 -- xxxZ size variable for task xxx (Exp_Ch9)
706 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
707 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
708 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
709 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
710 -- xxxIP initialization procedure for type xxx (Exp_TSS)
711 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
712 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
713 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
714 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
715 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
716 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
717 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
718 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
720 -- Implicit type names
722 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
724 -- (Note: this list is not complete or accurate ???)
726 ----------------------
727 -- Get_Attribute_Id --
728 ----------------------
730 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
732 return Attribute_Id'Val (N - First_Attribute_Name);
733 end Get_Attribute_Id;
739 function Get_Check_Id (N : Name_Id) return Check_Id is
741 return Check_Id'Val (N - First_Check_Name);
744 -----------------------
745 -- Get_Convention_Id --
746 -----------------------
748 function Get_Convention_Id (N : Name_Id) return Convention_Id is
751 when Name_Ada => return Convention_Ada;
752 when Name_Assembler => return Convention_Assembler;
753 when Name_C => return Convention_C;
754 when Name_COBOL => return Convention_COBOL;
755 when Name_CPP => return Convention_CPP;
756 when Name_Fortran => return Convention_Fortran;
757 when Name_Intrinsic => return Convention_Intrinsic;
758 when Name_Java => return Convention_Java;
759 when Name_Stdcall => return Convention_Stdcall;
760 when Name_Stubbed => return Convention_Stubbed;
762 -- If no direct match, then we must have a convention
763 -- identifier pragma that has specified this name.
766 for J in 1 .. Convention_Identifiers.Last loop
767 if N = Convention_Identifiers.Table (J).Name then
768 return Convention_Identifiers.Table (J).Convention;
774 end Get_Convention_Id;
776 ---------------------------
777 -- Get_Locking_Policy_Id --
778 ---------------------------
780 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
782 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
783 end Get_Locking_Policy_Id;
789 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
791 if N = Name_AST_Entry then
792 return Pragma_AST_Entry;
793 elsif N = Name_Storage_Size then
794 return Pragma_Storage_Size;
795 elsif N = Name_Storage_Unit then
796 return Pragma_Storage_Unit;
797 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
798 return Unknown_Pragma;
800 return Pragma_Id'Val (N - First_Pragma_Name);
804 ---------------------------
805 -- Get_Queuing_Policy_Id --
806 ---------------------------
808 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
810 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
811 end Get_Queuing_Policy_Id;
813 ------------------------------------
814 -- Get_Task_Dispatching_Policy_Id --
815 ------------------------------------
817 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
818 return Task_Dispatching_Policy_Id is
820 return Task_Dispatching_Policy_Id'Val
821 (N - First_Task_Dispatching_Policy_Name);
822 end Get_Task_Dispatching_Policy_Id;
828 procedure Initialize is
830 Discard_Name : Name_Id;
833 P_Index := Preset_Names'First;
838 while Preset_Names (P_Index) /= '#' loop
839 Name_Len := Name_Len + 1;
840 Name_Buffer (Name_Len) := Preset_Names (P_Index);
841 P_Index := P_Index + 1;
844 -- We do the Name_Find call to enter the name into the table, but
845 -- we don't need to do anything with the result, since we already
846 -- initialized all the preset names to have the right value (we
847 -- are depending on the order of the names and Preset_Names).
849 Discard_Name := Name_Find;
850 P_Index := P_Index + 1;
851 exit when Preset_Names (P_Index) = '#';
854 -- Make sure that number of names in standard table is correct. If
855 -- this check fails, run utility program XSNAMES to construct a new
856 -- properly matching version of the body.
858 pragma Assert (Discard_Name = Last_Predefined_Name);
860 -- Initialize the convention identifiers table with the standard
861 -- set of synonyms that we recognize for conventions.
863 Convention_Identifiers.Init;
865 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
866 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
868 Convention_Identifiers.Append ((Name_Default, Convention_C));
869 Convention_Identifiers.Append ((Name_External, Convention_C));
871 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
872 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
875 -----------------------
876 -- Is_Attribute_Name --
877 -----------------------
879 function Is_Attribute_Name (N : Name_Id) return Boolean is
881 return N in First_Attribute_Name .. Last_Attribute_Name;
882 end Is_Attribute_Name;
888 function Is_Check_Name (N : Name_Id) return Boolean is
890 return N in First_Check_Name .. Last_Check_Name;
893 ------------------------
894 -- Is_Convention_Name --
895 ------------------------
897 function Is_Convention_Name (N : Name_Id) return Boolean is
899 -- Check if this is one of the standard conventions
901 if N in First_Convention_Name .. Last_Convention_Name
906 -- Otherwise check if it is in convention identifier table
909 for J in 1 .. Convention_Identifiers.Last loop
910 if N = Convention_Identifiers.Table (J).Name then
917 end Is_Convention_Name;
919 ------------------------------
920 -- Is_Entity_Attribute_Name --
921 ------------------------------
923 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
925 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
926 end Is_Entity_Attribute_Name;
928 --------------------------------
929 -- Is_Function_Attribute_Name --
930 --------------------------------
932 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
935 First_Renamable_Function_Attribute ..
936 Last_Renamable_Function_Attribute;
937 end Is_Function_Attribute_Name;
939 ----------------------------
940 -- Is_Locking_Policy_Name --
941 ----------------------------
943 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
945 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
946 end Is_Locking_Policy_Name;
948 -----------------------------
949 -- Is_Operator_Symbol_Name --
950 -----------------------------
952 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
954 return N in First_Operator_Name .. Last_Operator_Name;
955 end Is_Operator_Symbol_Name;
961 function Is_Pragma_Name (N : Name_Id) return Boolean is
963 return N in First_Pragma_Name .. Last_Pragma_Name
964 or else N = Name_AST_Entry
965 or else N = Name_Storage_Size
966 or else N = Name_Storage_Unit;
969 ---------------------------------
970 -- Is_Procedure_Attribute_Name --
971 ---------------------------------
973 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
975 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
976 end Is_Procedure_Attribute_Name;
978 ----------------------------
979 -- Is_Queuing_Policy_Name --
980 ----------------------------
982 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
984 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
985 end Is_Queuing_Policy_Name;
987 -------------------------------------
988 -- Is_Task_Dispatching_Policy_Name --
989 -------------------------------------
991 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
993 return N in First_Task_Dispatching_Policy_Name ..
994 Last_Task_Dispatching_Policy_Name;
995 end Is_Task_Dispatching_Policy_Name;
997 ----------------------------
998 -- Is_Type_Attribute_Name --
999 ----------------------------
1001 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1003 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1004 end Is_Type_Attribute_Name;
1006 ----------------------------------
1007 -- Record_Convention_Identifier --
1008 ----------------------------------
1010 procedure Record_Convention_Identifier
1012 Convention : Convention_Id)
1015 Convention_Identifiers.Append ((Id, Convention));
1016 end Record_Convention_Identifier;