1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2002, 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 :=
68 "_address_resolver#" &
78 "_local_final_list#" &
101 "_ras_dereference#" &
123 "finalization_root#" &
131 "get_active_partition_id#" &
132 "get_rci_package_receiver#" &
136 "partition_interface#" &
165 "component_alignment#" &
166 "convention_identifier#" &
168 "elaboration_checks#" &
171 "extensions_allowed#" &
172 "external_name_casing#" &
173 "float_representation#" &
174 "initialize_scalars#" &
179 "normalize_scalars#" &
181 "propagate_exceptions#" &
184 "restricted_run_time#" &
187 "source_file_name#" &
190 "task_dispatching_policy#" &
196 "all_calls_remote#" &
201 "atomic_components#" &
205 "complex_representation#" &
217 "export_exception#" &
220 "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#" &
246 "machine_attribute#" &
260 "remote_call_interface#" &
265 "source_reference#" &
269 "suppress_debug_info#" &
270 "suppress_initialization#" &
278 "unimplemented_unit#" &
281 "unreserve_all_interrupts#" &
283 "volatile_components#" &
304 "component_size_4#" &
312 "first_optional_parameter#" &
334 "result_mechanism#" &
342 "subunit_file_name#" &
343 "task_stack_size_default#" &
345 "time_slicing_enabled#" &
377 "default_bit_order#" &
392 "has_discriminants#" &
403 "machine_mantissa#" &
404 "machine_overflows#" &
409 "max_size_in_storage_elements#" &
410 "maximum_alignment#" &
420 "passed_by_reference#" &
443 "unbiased_rounding#" &
444 "unchecked_access#" &
445 "universal_literal_string#" &
446 "unrestricted_access#" &
484 "inheritance_locking#" &
486 "priority_queuing#" &
487 "fifo_within_priorities#" &
489 "accessibility_check#" &
490 "discriminant_check#" &
492 "elaboration_check#" &
560 "enclosing_entity#" &
561 "exception_information#" &
562 "exception_message#" &
566 "import_largest_value#" &
574 "shift_right_arithmetic#" &
576 "unchecked_conversion#" &
577 "unchecked_deallocation#" &
589 "default_switches#" &
596 "implementation_exceptions#" &
597 "implementation_suffix#" &
600 "library_elaboration#" &
611 "source_list_file#" &
613 "specification_exceptions#" &
614 "specification_suffix#" &
618 ---------------------
619 -- Generated Names --
620 ---------------------
622 -- This section lists the various cases of generated names which are
623 -- built from existing names by adding unique leading and/or trailing
624 -- upper case letters. In some cases these names are built recursively,
625 -- in particular names built from types may be built from types which
626 -- themselves have generated names. In this list, xxx represents an
627 -- existing name to which identifying letters are prepended or appended,
628 -- and a trailing n represents a serial number in an external name that
629 -- has some semantic significance (e.g. the n'th index type of an array).
631 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
632 -- xxxB tag table for tagged type xxx (Exp_Ch3)
633 -- xxxB task body procedure for task xxx (Exp_Ch9)
634 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
635 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
636 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
637 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
638 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
639 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
640 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
641 -- xxxI initialization procedure for type xxx (Exp_Ch3)
642 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
643 -- xxxM master Id value for access type xxx (Exp_Ch3)
644 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
645 -- xxxP parameter record type for entry xxx (Exp_Ch9)
646 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
647 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
648 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
649 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
650 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
651 -- xxxV type for task value record for task xxx (Exp_Ch9)
652 -- xxxX entry index constant (Exp_Ch9)
653 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
654 -- xxxZ size variable for task xxx (Exp_Ch9)
656 -- Implicit type names
658 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
660 -- (Note: this list is not complete or accurate ???)
662 ----------------------
663 -- Get_Attribute_Id --
664 ----------------------
666 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
668 return Attribute_Id'Val (N - First_Attribute_Name);
669 end Get_Attribute_Id;
675 function Get_Check_Id (N : Name_Id) return Check_Id is
677 return Check_Id'Val (N - First_Check_Name);
680 -----------------------
681 -- Get_Convention_Id --
682 -----------------------
684 function Get_Convention_Id (N : Name_Id) return Convention_Id is
687 when Name_Ada => return Convention_Ada;
688 when Name_Assembler => return Convention_Assembler;
689 when Name_C => return Convention_C;
690 when Name_COBOL => return Convention_COBOL;
691 when Name_CPP => return Convention_CPP;
692 when Name_Fortran => return Convention_Fortran;
693 when Name_Intrinsic => return Convention_Intrinsic;
694 when Name_Java => return Convention_Java;
695 when Name_Stdcall => return Convention_Stdcall;
696 when Name_Stubbed => return Convention_Stubbed;
699 for J in 1 .. Convention_Identifiers.Last loop
700 if N = Convention_Identifiers.Table (J).Name then
701 return Convention_Identifiers.Table (J).Convention;
707 end Get_Convention_Id;
709 ---------------------------
710 -- Get_Locking_Policy_Id --
711 ---------------------------
713 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
715 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
716 end Get_Locking_Policy_Id;
722 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
724 if N = Name_AST_Entry then
725 return Pragma_AST_Entry;
726 elsif N = Name_Storage_Size then
727 return Pragma_Storage_Size;
728 elsif N = Name_Storage_Unit then
729 return Pragma_Storage_Unit;
731 return Pragma_Id'Val (N - First_Pragma_Name);
735 ---------------------------
736 -- Get_Queuing_Policy_Id --
737 ---------------------------
739 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
741 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
742 end Get_Queuing_Policy_Id;
744 ------------------------------------
745 -- Get_Task_Dispatching_Policy_Id --
746 ------------------------------------
748 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
749 return Task_Dispatching_Policy_Id is
751 return Task_Dispatching_Policy_Id'Val
752 (N - First_Task_Dispatching_Policy_Name);
753 end Get_Task_Dispatching_Policy_Id;
759 procedure Initialize is
761 Discard_Name : Name_Id;
764 P_Index := Preset_Names'First;
769 while Preset_Names (P_Index) /= '#' loop
770 Name_Len := Name_Len + 1;
771 Name_Buffer (Name_Len) := Preset_Names (P_Index);
772 P_Index := P_Index + 1;
775 -- We do the Name_Find call to enter the name into the table, but
776 -- we don't need to do anything with the result, since we already
777 -- initialized all the preset names to have the right value (we
778 -- are depending on the order of the names and Preset_Names).
780 Discard_Name := Name_Find;
781 P_Index := P_Index + 1;
782 exit when Preset_Names (P_Index) = '#';
785 -- Make sure that number of names in standard table is correct. If
786 -- this check fails, run utility program XSNAMES to construct a new
787 -- properly matching version of the body.
789 pragma Assert (Discard_Name = Last_Predefined_Name);
791 -- Initialize the convention identifiers table with the standard
792 -- set of synonyms that we recognize for conventions.
794 Convention_Identifiers.Init;
796 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
797 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
799 Convention_Identifiers.Append ((Name_Default, Convention_C));
800 Convention_Identifiers.Append ((Name_External, Convention_C));
802 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
803 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
806 -----------------------
807 -- Is_Attribute_Name --
808 -----------------------
810 function Is_Attribute_Name (N : Name_Id) return Boolean is
812 return N in First_Attribute_Name .. Last_Attribute_Name;
813 end Is_Attribute_Name;
819 function Is_Check_Name (N : Name_Id) return Boolean is
821 return N in First_Check_Name .. Last_Check_Name;
824 ------------------------
825 -- Is_Convention_Name --
826 ------------------------
828 function Is_Convention_Name (N : Name_Id) return Boolean is
830 if N in First_Convention_Name .. Last_Convention_Name
836 for J in 1 .. Convention_Identifiers.Last loop
837 if N = Convention_Identifiers.Table (J).Name then
844 end Is_Convention_Name;
846 ------------------------------
847 -- Is_Entity_Attribute_Name --
848 ------------------------------
850 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
852 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
853 end Is_Entity_Attribute_Name;
855 --------------------------------
856 -- Is_Function_Attribute_Name --
857 --------------------------------
859 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
862 First_Renamable_Function_Attribute ..
863 Last_Renamable_Function_Attribute;
864 end Is_Function_Attribute_Name;
866 ----------------------------
867 -- Is_Locking_Policy_Name --
868 ----------------------------
870 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
872 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
873 end Is_Locking_Policy_Name;
875 -----------------------------
876 -- Is_Operator_Symbol_Name --
877 -----------------------------
879 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
881 return N in First_Operator_Name .. Last_Operator_Name;
882 end Is_Operator_Symbol_Name;
888 function Is_Pragma_Name (N : Name_Id) return Boolean is
890 return N in First_Pragma_Name .. Last_Pragma_Name
891 or else N = Name_AST_Entry
892 or else N = Name_Storage_Size
893 or else N = Name_Storage_Unit;
896 ---------------------------------
897 -- Is_Procedure_Attribute_Name --
898 ---------------------------------
900 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
902 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
903 end Is_Procedure_Attribute_Name;
905 ----------------------------
906 -- Is_Queuing_Policy_Name --
907 ----------------------------
909 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
911 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
912 end Is_Queuing_Policy_Name;
914 -------------------------------------
915 -- Is_Task_Dispatching_Policy_Name --
916 -------------------------------------
918 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
920 return N in First_Task_Dispatching_Policy_Name ..
921 Last_Task_Dispatching_Policy_Name;
922 end Is_Task_Dispatching_Policy_Name;
924 ----------------------------
925 -- Is_Type_Attribute_Name --
926 ----------------------------
928 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
930 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
931 end Is_Type_Attribute_Name;
933 ----------------------------------
934 -- Record_Convention_Identifier --
935 ----------------------------------
937 procedure Record_Convention_Identifier
939 Convention : Convention_Id)
942 Convention_Identifiers.Append ((Id, Convention));
943 end Record_Convention_Identifier;