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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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#" &
92 "_disp_asynchronous_select#" &
93 "_disp_conditional_select#" &
94 "_disp_get_prim_op_kind#" &
95 "_disp_timed_select#" &
96 "_disp_get_task_id#" &
121 "finalization_root#" &
127 "wide_wide_text_io#" &
133 "get_active_partition_id#" &
134 "get_rci_package_receiver#" &
135 "get_rci_package_ref#" &
139 "partition_interface#" &
177 "assertion_policy#" &
179 "compile_time_warning#" &
180 "component_alignment#" &
181 "convention_identifier#" &
185 "elaboration_checks#" &
187 "explicit_overriding#" &
189 "extensions_allowed#" &
190 "external_name_casing#" &
191 "float_representation#" &
192 "initialize_scalars#" &
198 "no_strict_aliasing#" &
199 "normalize_scalars#" &
203 "profile_warnings#" &
204 "propagate_exceptions#" &
207 "restricted_run_time#" &
209 "restriction_warnings#" &
211 "source_file_name#" &
212 "source_file_name_project#" &
215 "suppress_exception_locations#" &
216 "task_dispatching_policy#" &
223 "all_calls_remote#" &
228 "atomic_components#" &
232 "complete_representation#" &
233 "complex_representation#" &
245 "export_exception#" &
248 "export_procedure#" &
250 "export_valued_procedure#" &
252 "finalize_storage_only#" &
255 "import_exception#" &
258 "import_procedure#" &
259 "import_valued_procedure#" &
263 "inspection_point#" &
265 "interrupt_handler#" &
266 "interrupt_priority#" &
267 "java_constructor#" &
272 "linker_constructor#" &
273 "linker_destructor#" &
277 "machine_attribute#" &
284 "optional_overriding#" &
295 "remote_call_interface#" &
300 "source_reference#" &
304 "suppress_debug_info#" &
305 "suppress_initialization#" &
314 "unimplemented_unit#" &
316 "unreserve_all_interrupts#" &
318 "volatile_components#" &
337 "boolean_entry_barriers#" &
342 "component_size_4#" &
351 "first_optional_parameter#" &
363 "max_entry_queue_depth#" &
364 "max_entry_queue_length#" &
374 "no_dynamic_attachment#" &
375 "no_dynamic_interrupts#" &
377 "no_requeue_statements#" &
378 "no_task_attributes#" &
379 "no_task_attributes_package#" &
384 "result_mechanism#" &
388 "secondary_stack_size#" &
396 "subunit_file_name#" &
397 "task_stack_size_default#" &
399 "time_slicing_enabled#" &
433 "default_bit_order#" &
448 "has_access_values#" &
449 "has_discriminants#" &
460 "machine_mantissa#" &
461 "machine_overflows#" &
463 "machine_rounding#" &
467 "max_size_in_storage_elements#" &
468 "maximum_alignment#" &
479 "passed_by_reference#" &
505 "unbiased_rounding#" &
506 "unchecked_access#" &
507 "unconstrained_array#" &
508 "universal_literal_string#" &
509 "unrestricted_access#" &
550 "inheritance_locking#" &
552 "priority_queuing#" &
553 "fifo_within_priorities#" &
555 "accessibility_check#" &
556 "discriminant_check#" &
558 "elaboration_check#" &
625 "enclosing_entity#" &
626 "exception_information#" &
627 "exception_message#" &
630 "generic_dispatching_constructor#" &
632 "import_largest_value#" &
640 "shift_right_arithmetic#" &
642 "unchecked_conversion#" &
643 "unchecked_deallocation#" &
661 "compute_dependency#" &
664 "default_switches#" &
665 "dependency_option#" &
668 "executable_suffix#" &
670 "externally_built#" &
672 "global_configuration_pragmas#" &
676 "implementation_exceptions#" &
677 "implementation_suffix#" &
679 "language_processing#" &
683 "library_auto_init#" &
685 "library_interface#" &
689 "library_reference_symbol_file#" &
691 "library_symbol_file#" &
692 "library_symbol_policy#" &
695 "local_configuration_pragmas#" &
696 "locally_removed_files#" &
705 "source_list_file#" &
709 "specification_exceptions#" &
710 "specification_suffix#" &
718 ---------------------
719 -- Generated Names --
720 ---------------------
722 -- This section lists the various cases of generated names which are
723 -- built from existing names by adding unique leading and/or trailing
724 -- upper case letters. In some cases these names are built recursively,
725 -- in particular names built from types may be built from types which
726 -- themselves have generated names. In this list, xxx represents an
727 -- existing name to which identifying letters are prepended or appended,
728 -- and a trailing n represents a serial number in an external name that
729 -- has some semantic significance (e.g. the n'th index type of an array).
731 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
732 -- xxxB tag table for tagged type xxx (Exp_Ch3)
733 -- xxxB task body procedure for task xxx (Exp_Ch9)
734 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
735 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
736 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
737 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
738 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
739 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
740 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
741 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
742 -- xxxM master Id value for access type xxx (Exp_Ch3)
743 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
744 -- xxxP parameter record type for entry xxx (Exp_Ch9)
745 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
746 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
747 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
748 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
749 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
750 -- xxxV type for task value record for task xxx (Exp_Ch9)
751 -- xxxX entry index constant (Exp_Ch9)
752 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
753 -- xxxZ size variable for task xxx (Exp_Ch9)
757 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
758 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
759 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
760 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
761 -- xxxFA PolyORB/DSA From_Any converter for type xxx (Exp_TSS)
762 -- xxxIP initialization procedure for type xxx (Exp_TSS)
763 -- xxxRA RAS type access routine for type xxx (Exp_TSS)
764 -- xxxRD RAS type dereference routine for type xxx (Exp_TSS)
765 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
766 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
767 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
768 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
769 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
770 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
771 -- xxxTA PolyORB/DSA To_Any converter for type xxx (Exp_TSS)
772 -- xxxTC PolyORB/DSA Typecode for type xxx (Exp_TSS)
774 -- Implicit type names
776 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
778 -- (Note: this list is not complete or accurate ???)
780 ----------------------
781 -- Get_Attribute_Id --
782 ----------------------
784 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
786 return Attribute_Id
'Val (N
- First_Attribute_Name
);
787 end Get_Attribute_Id
;
793 function Get_Check_Id
(N
: Name_Id
) return Check_Id
is
795 return Check_Id
'Val (N
- First_Check_Name
);
798 -----------------------
799 -- Get_Convention_Id --
800 -----------------------
802 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
805 when Name_Ada
=> return Convention_Ada
;
806 when Name_Assembler
=> return Convention_Assembler
;
807 when Name_C
=> return Convention_C
;
808 when Name_COBOL
=> return Convention_COBOL
;
809 when Name_CPP
=> return Convention_CPP
;
810 when Name_Fortran
=> return Convention_Fortran
;
811 when Name_Intrinsic
=> return Convention_Intrinsic
;
812 when Name_Java
=> return Convention_Java
;
813 when Name_Stdcall
=> return Convention_Stdcall
;
814 when Name_Stubbed
=> return Convention_Stubbed
;
816 -- If no direct match, then we must have a convention
817 -- identifier pragma that has specified this name.
820 for J
in 1 .. Convention_Identifiers
.Last
loop
821 if N
= Convention_Identifiers
.Table
(J
).Name
then
822 return Convention_Identifiers
.Table
(J
).Convention
;
828 end Get_Convention_Id
;
830 ---------------------------
831 -- Get_Locking_Policy_Id --
832 ---------------------------
834 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
836 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
837 end Get_Locking_Policy_Id
;
843 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
845 if N
= Name_AST_Entry
then
846 return Pragma_AST_Entry
;
847 elsif N
= Name_Interface
then
848 return Pragma_Interface
;
849 elsif N
= Name_Storage_Size
then
850 return Pragma_Storage_Size
;
851 elsif N
= Name_Storage_Unit
then
852 return Pragma_Storage_Unit
;
853 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
854 return Unknown_Pragma
;
856 return Pragma_Id
'Val (N
- First_Pragma_Name
);
860 ---------------------------
861 -- Get_Queuing_Policy_Id --
862 ---------------------------
864 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
866 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
867 end Get_Queuing_Policy_Id
;
869 ------------------------------------
870 -- Get_Task_Dispatching_Policy_Id --
871 ------------------------------------
873 function Get_Task_Dispatching_Policy_Id
(N
: Name_Id
)
874 return Task_Dispatching_Policy_Id
is
876 return Task_Dispatching_Policy_Id
'Val
877 (N
- First_Task_Dispatching_Policy_Name
);
878 end Get_Task_Dispatching_Policy_Id
;
884 procedure Initialize
is
886 Discard_Name
: Name_Id
;
889 P_Index
:= Preset_Names
'First;
894 while Preset_Names
(P_Index
) /= '#' loop
895 Name_Len
:= Name_Len
+ 1;
896 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
897 P_Index
:= P_Index
+ 1;
900 -- We do the Name_Find call to enter the name into the table, but
901 -- we don't need to do anything with the result, since we already
902 -- initialized all the preset names to have the right value (we
903 -- are depending on the order of the names and Preset_Names).
905 Discard_Name
:= Name_Find
;
906 P_Index
:= P_Index
+ 1;
907 exit when Preset_Names
(P_Index
) = '#';
910 -- Make sure that number of names in standard table is correct. If
911 -- this check fails, run utility program XSNAMES to construct a new
912 -- properly matching version of the body.
914 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
916 -- Initialize the convention identifiers table with the standard
917 -- set of synonyms that we recognize for conventions.
919 Convention_Identifiers
.Init
;
921 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
922 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
924 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
925 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
927 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
928 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
931 -----------------------
932 -- Is_Attribute_Name --
933 -----------------------
935 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
937 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
938 end Is_Attribute_Name
;
944 function Is_Check_Name
(N
: Name_Id
) return Boolean is
946 return N
in First_Check_Name
.. Last_Check_Name
;
949 ------------------------
950 -- Is_Convention_Name --
951 ------------------------
953 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
955 -- Check if this is one of the standard conventions
957 if N
in First_Convention_Name
.. Last_Convention_Name
962 -- Otherwise check if it is in convention identifier table
965 for J
in 1 .. Convention_Identifiers
.Last
loop
966 if N
= Convention_Identifiers
.Table
(J
).Name
then
973 end Is_Convention_Name
;
975 ------------------------------
976 -- Is_Entity_Attribute_Name --
977 ------------------------------
979 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
981 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
982 end Is_Entity_Attribute_Name
;
984 --------------------------------
985 -- Is_Function_Attribute_Name --
986 --------------------------------
988 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
991 First_Renamable_Function_Attribute
..
992 Last_Renamable_Function_Attribute
;
993 end Is_Function_Attribute_Name
;
995 ----------------------------
996 -- Is_Locking_Policy_Name --
997 ----------------------------
999 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
1001 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
1002 end Is_Locking_Policy_Name
;
1004 -----------------------------
1005 -- Is_Operator_Symbol_Name --
1006 -----------------------------
1008 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
1010 return N
in First_Operator_Name
.. Last_Operator_Name
;
1011 end Is_Operator_Symbol_Name
;
1013 --------------------
1014 -- Is_Pragma_Name --
1015 --------------------
1017 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
1019 return N
in First_Pragma_Name
.. Last_Pragma_Name
1020 or else N
= Name_AST_Entry
1021 or else N
= Name_Interface
1022 or else N
= Name_Storage_Size
1023 or else N
= Name_Storage_Unit
;
1026 ---------------------------------
1027 -- Is_Procedure_Attribute_Name --
1028 ---------------------------------
1030 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
1032 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1033 end Is_Procedure_Attribute_Name
;
1035 ----------------------------
1036 -- Is_Queuing_Policy_Name --
1037 ----------------------------
1039 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1041 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1042 end Is_Queuing_Policy_Name
;
1044 -------------------------------------
1045 -- Is_Task_Dispatching_Policy_Name --
1046 -------------------------------------
1048 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1050 return N
in First_Task_Dispatching_Policy_Name
..
1051 Last_Task_Dispatching_Policy_Name
;
1052 end Is_Task_Dispatching_Policy_Name
;
1054 ----------------------------
1055 -- Is_Type_Attribute_Name --
1056 ----------------------------
1058 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1060 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1061 end Is_Type_Attribute_Name
;
1063 ----------------------------------
1064 -- Record_Convention_Identifier --
1065 ----------------------------------
1067 procedure Record_Convention_Identifier
1069 Convention
: Convention_Id
)
1072 Convention_Identifiers
.Append
((Id
, Convention
));
1073 end Record_Convention_Identifier
;