1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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#" &
116 "finalization_root#" &
122 "wide_wide_text_io#" &
128 "get_active_partition_id#" &
129 "get_rci_package_receiver#" &
130 "get_rci_package_ref#" &
134 "partition_interface#" &
173 "compile_time_warning#" &
174 "component_alignment#" &
175 "convention_identifier#" &
178 "elaboration_checks#" &
180 "explicit_overriding#" &
182 "extensions_allowed#" &
183 "external_name_casing#" &
184 "float_representation#" &
185 "initialize_scalars#" &
191 "no_strict_aliasing#" &
192 "normalize_scalars#" &
195 "persistent_object#" &
197 "profile_warnings#" &
198 "propagate_exceptions#" &
201 "restricted_run_time#" &
203 "restriction_warnings#" &
205 "source_file_name#" &
206 "source_file_name_project#" &
209 "suppress_exception_locations#" &
210 "task_dispatching_policy#" &
217 "all_calls_remote#" &
222 "atomic_components#" &
226 "complex_representation#" &
238 "export_exception#" &
241 "export_procedure#" &
243 "export_valued_procedure#" &
245 "finalize_storage_only#" &
248 "import_exception#" &
251 "import_procedure#" &
252 "import_valued_procedure#" &
256 "inspection_point#" &
258 "interrupt_handler#" &
259 "interrupt_priority#" &
260 "java_constructor#" &
268 "machine_attribute#" &
275 "optional_overriding#" &
284 "remote_call_interface#" &
289 "source_reference#" &
293 "suppress_debug_info#" &
294 "suppress_initialization#" &
303 "unimplemented_unit#" &
305 "unreserve_all_interrupts#" &
307 "volatile_components#" &
325 "boolean_entry_barriers#" &
329 "component_size_4#" &
337 "first_optional_parameter#" &
347 "max_entry_queue_depth#" &
348 "max_entry_queue_length#" &
357 "no_dynamic_attachment#" &
358 "no_dynamic_interrupts#" &
360 "no_requeue_statements#" &
361 "no_task_attributes#" &
362 "no_task_attributes_package#" &
367 "result_mechanism#" &
371 "secondary_stack_size#" &
378 "subunit_file_name#" &
379 "task_stack_size_default#" &
381 "time_slicing_enabled#" &
414 "default_bit_order#" &
429 "has_access_values#" &
430 "has_discriminants#" &
441 "machine_mantissa#" &
442 "machine_overflows#" &
447 "max_size_in_storage_elements#" &
448 "maximum_alignment#" &
459 "passed_by_reference#" &
485 "unbiased_rounding#" &
486 "unchecked_access#" &
487 "unconstrained_array#" &
488 "universal_literal_string#" &
489 "unrestricted_access#" &
530 "inheritance_locking#" &
532 "priority_queuing#" &
533 "fifo_within_priorities#" &
535 "accessibility_check#" &
536 "discriminant_check#" &
538 "elaboration_check#" &
605 "enclosing_entity#" &
606 "exception_information#" &
607 "exception_message#" &
611 "import_largest_value#" &
619 "shift_right_arithmetic#" &
621 "unchecked_conversion#" &
622 "unchecked_deallocation#" &
639 "compute_dependency#" &
642 "default_switches#" &
643 "dependency_option#" &
646 "executable_suffix#" &
648 "externally_built#" &
650 "global_configuration_pragmas#" &
654 "implementation_exceptions#" &
655 "implementation_suffix#" &
657 "language_processing#" &
660 "library_auto_init#" &
662 "library_interface#" &
666 "library_reference_symbol_file#" &
668 "library_symbol_file#" &
669 "library_symbol_policy#" &
672 "local_configuration_pragmas#" &
673 "locally_removed_files#" &
682 "source_list_file#" &
686 "specification_exceptions#" &
687 "specification_suffix#" &
695 ---------------------
696 -- Generated Names --
697 ---------------------
699 -- This section lists the various cases of generated names which are
700 -- built from existing names by adding unique leading and/or trailing
701 -- upper case letters. In some cases these names are built recursively,
702 -- in particular names built from types may be built from types which
703 -- themselves have generated names. In this list, xxx represents an
704 -- existing name to which identifying letters are prepended or appended,
705 -- and a trailing n represents a serial number in an external name that
706 -- has some semantic significance (e.g. the n'th index type of an array).
708 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
709 -- xxxB tag table for tagged type xxx (Exp_Ch3)
710 -- xxxB task body procedure for task xxx (Exp_Ch9)
711 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
712 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
713 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
714 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
715 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
716 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
717 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
718 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
719 -- xxxM master Id value for access type xxx (Exp_Ch3)
720 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
721 -- xxxP parameter record type for entry xxx (Exp_Ch9)
722 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
723 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
724 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
725 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
726 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
727 -- xxxV type for task value record for task xxx (Exp_Ch9)
728 -- xxxX entry index constant (Exp_Ch9)
729 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
730 -- xxxZ size variable for task xxx (Exp_Ch9)
734 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
735 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
736 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
737 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
738 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
739 -- xxxIP initialization procedure for type xxx (Exp_TSS)
740 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
741 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
742 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
743 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
744 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
745 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
746 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
747 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
748 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
749 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
751 -- Implicit type names
753 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
755 -- (Note: this list is not complete or accurate ???)
757 ----------------------
758 -- Get_Attribute_Id --
759 ----------------------
761 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
763 return Attribute_Id
'Val (N
- First_Attribute_Name
);
764 end Get_Attribute_Id
;
770 function Get_Check_Id
(N
: Name_Id
) return Check_Id
is
772 return Check_Id
'Val (N
- First_Check_Name
);
775 -----------------------
776 -- Get_Convention_Id --
777 -----------------------
779 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
782 when Name_Ada
=> return Convention_Ada
;
783 when Name_Assembler
=> return Convention_Assembler
;
784 when Name_C
=> return Convention_C
;
785 when Name_COBOL
=> return Convention_COBOL
;
786 when Name_CPP
=> return Convention_CPP
;
787 when Name_Fortran
=> return Convention_Fortran
;
788 when Name_Intrinsic
=> return Convention_Intrinsic
;
789 when Name_Java
=> return Convention_Java
;
790 when Name_Stdcall
=> return Convention_Stdcall
;
791 when Name_Stubbed
=> return Convention_Stubbed
;
793 -- If no direct match, then we must have a convention
794 -- identifier pragma that has specified this name.
797 for J
in 1 .. Convention_Identifiers
.Last
loop
798 if N
= Convention_Identifiers
.Table
(J
).Name
then
799 return Convention_Identifiers
.Table
(J
).Convention
;
805 end Get_Convention_Id
;
807 ---------------------------
808 -- Get_Locking_Policy_Id --
809 ---------------------------
811 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
813 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
814 end Get_Locking_Policy_Id
;
820 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
822 if N
= Name_AST_Entry
then
823 return Pragma_AST_Entry
;
824 elsif N
= Name_Interface
then
825 return Pragma_Interface
;
826 elsif N
= Name_Storage_Size
then
827 return Pragma_Storage_Size
;
828 elsif N
= Name_Storage_Unit
then
829 return Pragma_Storage_Unit
;
830 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
831 return Unknown_Pragma
;
833 return Pragma_Id
'Val (N
- First_Pragma_Name
);
837 ---------------------------
838 -- Get_Queuing_Policy_Id --
839 ---------------------------
841 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
843 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
844 end Get_Queuing_Policy_Id
;
846 ------------------------------------
847 -- Get_Task_Dispatching_Policy_Id --
848 ------------------------------------
850 function Get_Task_Dispatching_Policy_Id
(N
: Name_Id
)
851 return Task_Dispatching_Policy_Id
is
853 return Task_Dispatching_Policy_Id
'Val
854 (N
- First_Task_Dispatching_Policy_Name
);
855 end Get_Task_Dispatching_Policy_Id
;
861 procedure Initialize
is
863 Discard_Name
: Name_Id
;
866 P_Index
:= Preset_Names
'First;
871 while Preset_Names
(P_Index
) /= '#' loop
872 Name_Len
:= Name_Len
+ 1;
873 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
874 P_Index
:= P_Index
+ 1;
877 -- We do the Name_Find call to enter the name into the table, but
878 -- we don't need to do anything with the result, since we already
879 -- initialized all the preset names to have the right value (we
880 -- are depending on the order of the names and Preset_Names).
882 Discard_Name
:= Name_Find
;
883 P_Index
:= P_Index
+ 1;
884 exit when Preset_Names
(P_Index
) = '#';
887 -- Make sure that number of names in standard table is correct. If
888 -- this check fails, run utility program XSNAMES to construct a new
889 -- properly matching version of the body.
891 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
893 -- Initialize the convention identifiers table with the standard
894 -- set of synonyms that we recognize for conventions.
896 Convention_Identifiers
.Init
;
898 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
899 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
901 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
902 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
904 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
905 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
908 -----------------------
909 -- Is_Attribute_Name --
910 -----------------------
912 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
914 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
915 end Is_Attribute_Name
;
921 function Is_Check_Name
(N
: Name_Id
) return Boolean is
923 return N
in First_Check_Name
.. Last_Check_Name
;
926 ------------------------
927 -- Is_Convention_Name --
928 ------------------------
930 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
932 -- Check if this is one of the standard conventions
934 if N
in First_Convention_Name
.. Last_Convention_Name
939 -- Otherwise check if it is in convention identifier table
942 for J
in 1 .. Convention_Identifiers
.Last
loop
943 if N
= Convention_Identifiers
.Table
(J
).Name
then
950 end Is_Convention_Name
;
952 ------------------------------
953 -- Is_Entity_Attribute_Name --
954 ------------------------------
956 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
958 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
959 end Is_Entity_Attribute_Name
;
961 --------------------------------
962 -- Is_Function_Attribute_Name --
963 --------------------------------
965 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
968 First_Renamable_Function_Attribute
..
969 Last_Renamable_Function_Attribute
;
970 end Is_Function_Attribute_Name
;
972 ----------------------------
973 -- Is_Locking_Policy_Name --
974 ----------------------------
976 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
978 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
979 end Is_Locking_Policy_Name
;
981 -----------------------------
982 -- Is_Operator_Symbol_Name --
983 -----------------------------
985 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
987 return N
in First_Operator_Name
.. Last_Operator_Name
;
988 end Is_Operator_Symbol_Name
;
994 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
996 return N
in First_Pragma_Name
.. Last_Pragma_Name
997 or else N
= Name_AST_Entry
998 or else N
= Name_Interface
999 or else N
= Name_Storage_Size
1000 or else N
= Name_Storage_Unit
;
1003 ---------------------------------
1004 -- Is_Procedure_Attribute_Name --
1005 ---------------------------------
1007 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
1009 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1010 end Is_Procedure_Attribute_Name
;
1012 ----------------------------
1013 -- Is_Queuing_Policy_Name --
1014 ----------------------------
1016 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1018 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1019 end Is_Queuing_Policy_Name
;
1021 -------------------------------------
1022 -- Is_Task_Dispatching_Policy_Name --
1023 -------------------------------------
1025 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1027 return N
in First_Task_Dispatching_Policy_Name
..
1028 Last_Task_Dispatching_Policy_Name
;
1029 end Is_Task_Dispatching_Policy_Name
;
1031 ----------------------------
1032 -- Is_Type_Attribute_Name --
1033 ----------------------------
1035 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1037 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1038 end Is_Type_Attribute_Name
;
1040 ----------------------------------
1041 -- Record_Convention_Identifier --
1042 ----------------------------------
1044 procedure Record_Convention_Identifier
1046 Convention
: Convention_Id
)
1049 Convention_Identifiers
.Append
((Id
, Convention
));
1050 end Record_Convention_Identifier
;