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 :=
77 "_local_final_list#" &
118 "finalization_root#" &
129 "get_active_partition_id#" &
130 "get_rci_package_receiver#" &
131 "get_rci_package_ref#" &
135 "partition_interface#" &
174 "compile_time_warning#" &
175 "component_alignment#" &
176 "convention_identifier#" &
179 "elaboration_checks#" &
181 "explicit_overriding#" &
183 "extensions_allowed#" &
184 "external_name_casing#" &
185 "float_representation#" &
186 "initialize_scalars#" &
192 "no_strict_aliasing#" &
193 "normalize_scalars#" &
196 "persistent_object#" &
198 "profile_warnings#" &
199 "propagate_exceptions#" &
202 "restricted_run_time#" &
204 "restriction_warnings#" &
206 "source_file_name#" &
207 "source_file_name_project#" &
210 "suppress_exception_locations#" &
211 "task_dispatching_policy#" &
218 "all_calls_remote#" &
223 "atomic_components#" &
227 "complex_representation#" &
239 "export_exception#" &
242 "export_procedure#" &
244 "export_valued_procedure#" &
246 "finalize_storage_only#" &
249 "import_exception#" &
252 "import_procedure#" &
253 "import_valued_procedure#" &
257 "inspection_point#" &
260 "interrupt_handler#" &
261 "interrupt_priority#" &
262 "java_constructor#" &
270 "machine_attribute#" &
277 "optional_overriding#" &
287 "remote_call_interface#" &
292 "source_reference#" &
296 "suppress_debug_info#" &
297 "suppress_initialization#" &
306 "unimplemented_unit#" &
308 "unreserve_all_interrupts#" &
310 "volatile_components#" &
328 "boolean_entry_barriers#" &
332 "component_size_4#" &
340 "first_optional_parameter#" &
350 "max_entry_queue_depth#" &
351 "max_entry_queue_length#" &
360 "no_dynamic_attachment#" &
361 "no_dynamic_interrupts#" &
363 "no_requeue_statements#" &
364 "no_task_attributes#" &
365 "no_task_attributes_package#" &
370 "result_mechanism#" &
374 "secondary_stack_size#" &
381 "subunit_file_name#" &
382 "task_stack_size_default#" &
384 "time_slicing_enabled#" &
417 "default_bit_order#" &
432 "has_access_values#" &
433 "has_discriminants#" &
444 "machine_mantissa#" &
445 "machine_overflows#" &
450 "max_size_in_storage_elements#" &
451 "maximum_alignment#" &
462 "passed_by_reference#" &
487 "unbiased_rounding#" &
488 "unchecked_access#" &
489 "unconstrained_array#" &
490 "universal_literal_string#" &
491 "unrestricted_access#" &
529 "inheritance_locking#" &
531 "priority_queuing#" &
532 "fifo_within_priorities#" &
534 "accessibility_check#" &
535 "discriminant_check#" &
537 "elaboration_check#" &
604 "enclosing_entity#" &
605 "exception_information#" &
606 "exception_message#" &
610 "import_largest_value#" &
618 "shift_right_arithmetic#" &
620 "unchecked_conversion#" &
621 "unchecked_deallocation#" &
638 "compute_dependency#" &
641 "default_switches#" &
642 "dependency_option#" &
645 "executable_suffix#" &
647 "externally_built#" &
649 "global_configuration_pragmas#" &
653 "implementation_exceptions#" &
654 "implementation_suffix#" &
656 "language_processing#" &
659 "library_auto_init#" &
661 "library_interface#" &
665 "library_reference_symbol_file#" &
667 "library_symbol_file#" &
668 "library_symbol_policy#" &
671 "local_configuration_pragmas#" &
672 "locally_removed_files#" &
681 "source_list_file#" &
685 "specification_exceptions#" &
686 "specification_suffix#" &
691 ---------------------
692 -- Generated Names --
693 ---------------------
695 -- This section lists the various cases of generated names which are
696 -- built from existing names by adding unique leading and/or trailing
697 -- upper case letters. In some cases these names are built recursively,
698 -- in particular names built from types may be built from types which
699 -- themselves have generated names. In this list, xxx represents an
700 -- existing name to which identifying letters are prepended or appended,
701 -- and a trailing n represents a serial number in an external name that
702 -- has some semantic significance (e.g. the n'th index type of an array).
704 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
705 -- xxxB tag table for tagged type xxx (Exp_Ch3)
706 -- xxxB task body procedure for task xxx (Exp_Ch9)
707 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
708 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
709 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
710 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
711 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
712 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
713 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
714 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
715 -- xxxM master Id value for access type xxx (Exp_Ch3)
716 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
717 -- xxxP parameter record type for entry xxx (Exp_Ch9)
718 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
719 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
720 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
721 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
722 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
723 -- xxxV type for task value record for task xxx (Exp_Ch9)
724 -- xxxX entry index constant (Exp_Ch9)
725 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
726 -- xxxZ size variable for task xxx (Exp_Ch9)
730 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
731 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
732 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
733 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
734 -- xxxIP initialization procedure for type xxx (Exp_TSS)
735 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
736 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
737 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
738 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
739 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
740 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
741 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
742 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
744 -- Implicit type names
746 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
748 -- (Note: this list is not complete or accurate ???)
750 ----------------------
751 -- Get_Attribute_Id --
752 ----------------------
754 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
756 return Attribute_Id
'Val (N
- First_Attribute_Name
);
757 end Get_Attribute_Id
;
763 function Get_Check_Id
(N
: Name_Id
) return Check_Id
is
765 return Check_Id
'Val (N
- First_Check_Name
);
768 -----------------------
769 -- Get_Convention_Id --
770 -----------------------
772 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
775 when Name_Ada
=> return Convention_Ada
;
776 when Name_Assembler
=> return Convention_Assembler
;
777 when Name_C
=> return Convention_C
;
778 when Name_COBOL
=> return Convention_COBOL
;
779 when Name_CPP
=> return Convention_CPP
;
780 when Name_Fortran
=> return Convention_Fortran
;
781 when Name_Intrinsic
=> return Convention_Intrinsic
;
782 when Name_Java
=> return Convention_Java
;
783 when Name_Stdcall
=> return Convention_Stdcall
;
784 when Name_Stubbed
=> return Convention_Stubbed
;
786 -- If no direct match, then we must have a convention
787 -- identifier pragma that has specified this name.
790 for J
in 1 .. Convention_Identifiers
.Last
loop
791 if N
= Convention_Identifiers
.Table
(J
).Name
then
792 return Convention_Identifiers
.Table
(J
).Convention
;
798 end Get_Convention_Id
;
800 ---------------------------
801 -- Get_Locking_Policy_Id --
802 ---------------------------
804 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
806 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
807 end Get_Locking_Policy_Id
;
813 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
815 if N
= Name_AST_Entry
then
816 return Pragma_AST_Entry
;
817 elsif N
= Name_Storage_Size
then
818 return Pragma_Storage_Size
;
819 elsif N
= Name_Storage_Unit
then
820 return Pragma_Storage_Unit
;
821 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
822 return Unknown_Pragma
;
824 return Pragma_Id
'Val (N
- First_Pragma_Name
);
828 ---------------------------
829 -- Get_Queuing_Policy_Id --
830 ---------------------------
832 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
834 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
835 end Get_Queuing_Policy_Id
;
837 ------------------------------------
838 -- Get_Task_Dispatching_Policy_Id --
839 ------------------------------------
841 function Get_Task_Dispatching_Policy_Id
(N
: Name_Id
)
842 return Task_Dispatching_Policy_Id
is
844 return Task_Dispatching_Policy_Id
'Val
845 (N
- First_Task_Dispatching_Policy_Name
);
846 end Get_Task_Dispatching_Policy_Id
;
852 procedure Initialize
is
854 Discard_Name
: Name_Id
;
857 P_Index
:= Preset_Names
'First;
862 while Preset_Names
(P_Index
) /= '#' loop
863 Name_Len
:= Name_Len
+ 1;
864 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
865 P_Index
:= P_Index
+ 1;
868 -- We do the Name_Find call to enter the name into the table, but
869 -- we don't need to do anything with the result, since we already
870 -- initialized all the preset names to have the right value (we
871 -- are depending on the order of the names and Preset_Names).
873 Discard_Name
:= Name_Find
;
874 P_Index
:= P_Index
+ 1;
875 exit when Preset_Names
(P_Index
) = '#';
878 -- Make sure that number of names in standard table is correct. If
879 -- this check fails, run utility program XSNAMES to construct a new
880 -- properly matching version of the body.
882 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
884 -- Initialize the convention identifiers table with the standard
885 -- set of synonyms that we recognize for conventions.
887 Convention_Identifiers
.Init
;
889 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
890 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
892 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
893 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
895 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
896 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
899 -----------------------
900 -- Is_Attribute_Name --
901 -----------------------
903 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
905 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
906 end Is_Attribute_Name
;
912 function Is_Check_Name
(N
: Name_Id
) return Boolean is
914 return N
in First_Check_Name
.. Last_Check_Name
;
917 ------------------------
918 -- Is_Convention_Name --
919 ------------------------
921 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
923 -- Check if this is one of the standard conventions
925 if N
in First_Convention_Name
.. Last_Convention_Name
930 -- Otherwise check if it is in convention identifier table
933 for J
in 1 .. Convention_Identifiers
.Last
loop
934 if N
= Convention_Identifiers
.Table
(J
).Name
then
941 end Is_Convention_Name
;
943 ------------------------------
944 -- Is_Entity_Attribute_Name --
945 ------------------------------
947 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
949 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
950 end Is_Entity_Attribute_Name
;
952 --------------------------------
953 -- Is_Function_Attribute_Name --
954 --------------------------------
956 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
959 First_Renamable_Function_Attribute
..
960 Last_Renamable_Function_Attribute
;
961 end Is_Function_Attribute_Name
;
963 ----------------------------
964 -- Is_Locking_Policy_Name --
965 ----------------------------
967 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
969 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
970 end Is_Locking_Policy_Name
;
972 -----------------------------
973 -- Is_Operator_Symbol_Name --
974 -----------------------------
976 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
978 return N
in First_Operator_Name
.. Last_Operator_Name
;
979 end Is_Operator_Symbol_Name
;
985 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
987 return N
in First_Pragma_Name
.. Last_Pragma_Name
988 or else N
= Name_AST_Entry
989 or else N
= Name_Storage_Size
990 or else N
= Name_Storage_Unit
;
993 ---------------------------------
994 -- Is_Procedure_Attribute_Name --
995 ---------------------------------
997 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
999 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
1000 end Is_Procedure_Attribute_Name
;
1002 ----------------------------
1003 -- Is_Queuing_Policy_Name --
1004 ----------------------------
1006 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
1008 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
1009 end Is_Queuing_Policy_Name
;
1011 -------------------------------------
1012 -- Is_Task_Dispatching_Policy_Name --
1013 -------------------------------------
1015 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1017 return N
in First_Task_Dispatching_Policy_Name
..
1018 Last_Task_Dispatching_Policy_Name
;
1019 end Is_Task_Dispatching_Policy_Name
;
1021 ----------------------------
1022 -- Is_Type_Attribute_Name --
1023 ----------------------------
1025 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1027 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1028 end Is_Type_Attribute_Name
;
1030 ----------------------------------
1031 -- Record_Convention_Identifier --
1032 ----------------------------------
1034 procedure Record_Convention_Identifier
1036 Convention
: Convention_Id
)
1039 Convention_Identifiers
.Append
((Id
, Convention
));
1040 end Record_Convention_Identifier
;