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#" &
345 "max_entry_queue_length#" &
356 "no_dynamic_attachment#" &
357 "no_dynamic_interrupts#" &
359 "no_requeue_statements#" &
360 "no_task_attributes#" &
361 "no_task_attributes_package#" &
363 "result_mechanism#" &
367 "secondary_stack_size#" &
374 "subunit_file_name#" &
375 "task_stack_size_default#" &
377 "time_slicing_enabled#" &
410 "default_bit_order#" &
425 "has_discriminants#" &
436 "machine_mantissa#" &
437 "machine_overflows#" &
442 "max_size_in_storage_elements#" &
443 "maximum_alignment#" &
453 "passed_by_reference#" &
478 "unbiased_rounding#" &
479 "unchecked_access#" &
480 "unconstrained_array#" &
481 "universal_literal_string#" &
482 "unrestricted_access#" &
520 "inheritance_locking#" &
522 "priority_queuing#" &
523 "fifo_within_priorities#" &
525 "accessibility_check#" &
526 "discriminant_check#" &
528 "elaboration_check#" &
596 "enclosing_entity#" &
597 "exception_information#" &
598 "exception_message#" &
602 "import_largest_value#" &
610 "shift_right_arithmetic#" &
612 "unchecked_conversion#" &
613 "unchecked_deallocation#" &
627 "default_switches#" &
630 "executable_suffix#" &
633 "global_configuration_pragmas#" &
637 "implementation_exceptions#" &
638 "implementation_suffix#" &
641 "library_auto_init#" &
643 "library_interface#" &
647 "library_reference_symbol_file#" &
649 "library_symbol_file#" &
650 "library_symbol_policy#" &
653 "local_configuration_pragmas#" &
654 "locally_removed_files#" &
662 "source_list_file#" &
666 "specification_exceptions#" &
667 "specification_suffix#" &
672 ---------------------
673 -- Generated Names --
674 ---------------------
676 -- This section lists the various cases of generated names which are
677 -- built from existing names by adding unique leading and/or trailing
678 -- upper case letters. In some cases these names are built recursively,
679 -- in particular names built from types may be built from types which
680 -- themselves have generated names. In this list, xxx represents an
681 -- existing name to which identifying letters are prepended or appended,
682 -- and a trailing n represents a serial number in an external name that
683 -- has some semantic significance (e.g. the n'th index type of an array).
685 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
686 -- xxxB tag table for tagged type xxx (Exp_Ch3)
687 -- xxxB task body procedure for task xxx (Exp_Ch9)
688 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
689 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
690 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
691 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
692 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
693 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
694 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
695 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
696 -- xxxM master Id value for access type xxx (Exp_Ch3)
697 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
698 -- xxxP parameter record type for entry xxx (Exp_Ch9)
699 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
700 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
701 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
702 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
703 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
704 -- xxxV type for task value record for task xxx (Exp_Ch9)
705 -- xxxX entry index constant (Exp_Ch9)
706 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
707 -- xxxZ size variable for task xxx (Exp_Ch9)
711 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
712 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
713 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
714 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
715 -- xxxIP initialization procedure for type xxx (Exp_TSS)
716 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
717 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
718 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
719 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
720 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
721 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
722 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
723 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
725 -- Implicit type names
727 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
729 -- (Note: this list is not complete or accurate ???)
731 ----------------------
732 -- Get_Attribute_Id --
733 ----------------------
735 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
737 return Attribute_Id'Val (N - First_Attribute_Name);
738 end Get_Attribute_Id;
744 function Get_Check_Id (N : Name_Id) return Check_Id is
746 return Check_Id'Val (N - First_Check_Name);
749 -----------------------
750 -- Get_Convention_Id --
751 -----------------------
753 function Get_Convention_Id (N : Name_Id) return Convention_Id is
756 when Name_Ada => return Convention_Ada;
757 when Name_Assembler => return Convention_Assembler;
758 when Name_C => return Convention_C;
759 when Name_COBOL => return Convention_COBOL;
760 when Name_CPP => return Convention_CPP;
761 when Name_Fortran => return Convention_Fortran;
762 when Name_Intrinsic => return Convention_Intrinsic;
763 when Name_Java => return Convention_Java;
764 when Name_Stdcall => return Convention_Stdcall;
765 when Name_Stubbed => return Convention_Stubbed;
767 -- If no direct match, then we must have a convention
768 -- identifier pragma that has specified this name.
771 for J in 1 .. Convention_Identifiers.Last loop
772 if N = Convention_Identifiers.Table (J).Name then
773 return Convention_Identifiers.Table (J).Convention;
779 end Get_Convention_Id;
781 ---------------------------
782 -- Get_Locking_Policy_Id --
783 ---------------------------
785 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
787 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
788 end Get_Locking_Policy_Id;
794 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
796 if N = Name_AST_Entry then
797 return Pragma_AST_Entry;
798 elsif N = Name_Storage_Size then
799 return Pragma_Storage_Size;
800 elsif N = Name_Storage_Unit then
801 return Pragma_Storage_Unit;
802 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
803 return Unknown_Pragma;
805 return Pragma_Id'Val (N - First_Pragma_Name);
809 ---------------------------
810 -- Get_Queuing_Policy_Id --
811 ---------------------------
813 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
815 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
816 end Get_Queuing_Policy_Id;
818 ------------------------------------
819 -- Get_Task_Dispatching_Policy_Id --
820 ------------------------------------
822 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
823 return Task_Dispatching_Policy_Id is
825 return Task_Dispatching_Policy_Id'Val
826 (N - First_Task_Dispatching_Policy_Name);
827 end Get_Task_Dispatching_Policy_Id;
833 procedure Initialize is
835 Discard_Name : Name_Id;
838 P_Index := Preset_Names'First;
843 while Preset_Names (P_Index) /= '#' loop
844 Name_Len := Name_Len + 1;
845 Name_Buffer (Name_Len) := Preset_Names (P_Index);
846 P_Index := P_Index + 1;
849 -- We do the Name_Find call to enter the name into the table, but
850 -- we don't need to do anything with the result, since we already
851 -- initialized all the preset names to have the right value (we
852 -- are depending on the order of the names and Preset_Names).
854 Discard_Name := Name_Find;
855 P_Index := P_Index + 1;
856 exit when Preset_Names (P_Index) = '#';
859 -- Make sure that number of names in standard table is correct. If
860 -- this check fails, run utility program XSNAMES to construct a new
861 -- properly matching version of the body.
863 pragma Assert (Discard_Name = Last_Predefined_Name);
865 -- Initialize the convention identifiers table with the standard
866 -- set of synonyms that we recognize for conventions.
868 Convention_Identifiers.Init;
870 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
871 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
873 Convention_Identifiers.Append ((Name_Default, Convention_C));
874 Convention_Identifiers.Append ((Name_External, Convention_C));
876 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
877 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
880 -----------------------
881 -- Is_Attribute_Name --
882 -----------------------
884 function Is_Attribute_Name (N : Name_Id) return Boolean is
886 return N in First_Attribute_Name .. Last_Attribute_Name;
887 end Is_Attribute_Name;
893 function Is_Check_Name (N : Name_Id) return Boolean is
895 return N in First_Check_Name .. Last_Check_Name;
898 ------------------------
899 -- Is_Convention_Name --
900 ------------------------
902 function Is_Convention_Name (N : Name_Id) return Boolean is
904 -- Check if this is one of the standard conventions
906 if N in First_Convention_Name .. Last_Convention_Name
911 -- Otherwise check if it is in convention identifier table
914 for J in 1 .. Convention_Identifiers.Last loop
915 if N = Convention_Identifiers.Table (J).Name then
922 end Is_Convention_Name;
924 ------------------------------
925 -- Is_Entity_Attribute_Name --
926 ------------------------------
928 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
930 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
931 end Is_Entity_Attribute_Name;
933 --------------------------------
934 -- Is_Function_Attribute_Name --
935 --------------------------------
937 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
940 First_Renamable_Function_Attribute ..
941 Last_Renamable_Function_Attribute;
942 end Is_Function_Attribute_Name;
944 ----------------------------
945 -- Is_Locking_Policy_Name --
946 ----------------------------
948 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
950 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
951 end Is_Locking_Policy_Name;
953 -----------------------------
954 -- Is_Operator_Symbol_Name --
955 -----------------------------
957 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
959 return N in First_Operator_Name .. Last_Operator_Name;
960 end Is_Operator_Symbol_Name;
966 function Is_Pragma_Name (N : Name_Id) return Boolean is
968 return N in First_Pragma_Name .. Last_Pragma_Name
969 or else N = Name_AST_Entry
970 or else N = Name_Storage_Size
971 or else N = Name_Storage_Unit;
974 ---------------------------------
975 -- Is_Procedure_Attribute_Name --
976 ---------------------------------
978 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
980 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
981 end Is_Procedure_Attribute_Name;
983 ----------------------------
984 -- Is_Queuing_Policy_Name --
985 ----------------------------
987 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
989 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
990 end Is_Queuing_Policy_Name;
992 -------------------------------------
993 -- Is_Task_Dispatching_Policy_Name --
994 -------------------------------------
996 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
998 return N in First_Task_Dispatching_Policy_Name ..
999 Last_Task_Dispatching_Policy_Name;
1000 end Is_Task_Dispatching_Policy_Name;
1002 ----------------------------
1003 -- Is_Type_Attribute_Name --
1004 ----------------------------
1006 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1008 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1009 end Is_Type_Attribute_Name;
1011 ----------------------------------
1012 -- Record_Convention_Identifier --
1013 ----------------------------------
1015 procedure Record_Convention_Identifier
1017 Convention : Convention_Id)
1020 Convention_Identifiers.Append ((Id, Convention));
1021 end Record_Convention_Identifier;