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#" &
117 "finalization_root#" &
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#" &
259 "interrupt_handler#" &
260 "interrupt_priority#" &
261 "java_constructor#" &
269 "machine_attribute#" &
276 "optional_overriding#" &
286 "remote_call_interface#" &
291 "source_reference#" &
295 "suppress_debug_info#" &
296 "suppress_initialization#" &
305 "unimplemented_unit#" &
307 "unreserve_all_interrupts#" &
309 "volatile_components#" &
327 "boolean_entry_barriers#" &
331 "component_size_4#" &
339 "first_optional_parameter#" &
349 "max_entry_queue_depth#" &
350 "max_entry_queue_length#" &
361 "no_dynamic_attachment#" &
362 "no_dynamic_interrupts#" &
364 "no_requeue_statements#" &
365 "no_task_attributes#" &
366 "no_task_attributes_package#" &
368 "result_mechanism#" &
372 "secondary_stack_size#" &
379 "subunit_file_name#" &
380 "task_stack_size_default#" &
382 "time_slicing_enabled#" &
415 "default_bit_order#" &
430 "has_access_values#" &
431 "has_discriminants#" &
442 "machine_mantissa#" &
443 "machine_overflows#" &
448 "max_size_in_storage_elements#" &
449 "maximum_alignment#" &
459 "passed_by_reference#" &
484 "unbiased_rounding#" &
485 "unchecked_access#" &
486 "unconstrained_array#" &
487 "universal_literal_string#" &
488 "unrestricted_access#" &
526 "inheritance_locking#" &
528 "priority_queuing#" &
529 "fifo_within_priorities#" &
531 "accessibility_check#" &
532 "discriminant_check#" &
534 "elaboration_check#" &
602 "enclosing_entity#" &
603 "exception_information#" &
604 "exception_message#" &
608 "import_largest_value#" &
616 "shift_right_arithmetic#" &
618 "unchecked_conversion#" &
619 "unchecked_deallocation#" &
633 "default_switches#" &
636 "executable_suffix#" &
639 "global_configuration_pragmas#" &
643 "implementation_exceptions#" &
644 "implementation_suffix#" &
647 "library_auto_init#" &
649 "library_interface#" &
653 "library_reference_symbol_file#" &
655 "library_symbol_file#" &
656 "library_symbol_policy#" &
659 "local_configuration_pragmas#" &
660 "locally_removed_files#" &
669 "source_list_file#" &
673 "specification_exceptions#" &
674 "specification_suffix#" &
679 ---------------------
680 -- Generated Names --
681 ---------------------
683 -- This section lists the various cases of generated names which are
684 -- built from existing names by adding unique leading and/or trailing
685 -- upper case letters. In some cases these names are built recursively,
686 -- in particular names built from types may be built from types which
687 -- themselves have generated names. In this list, xxx represents an
688 -- existing name to which identifying letters are prepended or appended,
689 -- and a trailing n represents a serial number in an external name that
690 -- has some semantic significance (e.g. the n'th index type of an array).
692 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
693 -- xxxB tag table for tagged type xxx (Exp_Ch3)
694 -- xxxB task body procedure for task xxx (Exp_Ch9)
695 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
696 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
697 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
698 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
699 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
700 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
701 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
702 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
703 -- xxxM master Id value for access type xxx (Exp_Ch3)
704 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
705 -- xxxP parameter record type for entry xxx (Exp_Ch9)
706 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
707 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
708 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
709 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
710 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
711 -- xxxV type for task value record for task xxx (Exp_Ch9)
712 -- xxxX entry index constant (Exp_Ch9)
713 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
714 -- xxxZ size variable for task xxx (Exp_Ch9)
718 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
719 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
720 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
721 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
722 -- xxxIP initialization procedure for type xxx (Exp_TSS)
723 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
724 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
725 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
726 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
727 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
728 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
729 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
730 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
732 -- Implicit type names
734 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
736 -- (Note: this list is not complete or accurate ???)
738 ----------------------
739 -- Get_Attribute_Id --
740 ----------------------
742 function Get_Attribute_Id
(N
: Name_Id
) return Attribute_Id
is
744 return Attribute_Id
'Val (N
- First_Attribute_Name
);
745 end Get_Attribute_Id
;
751 function Get_Check_Id
(N
: Name_Id
) return Check_Id
is
753 return Check_Id
'Val (N
- First_Check_Name
);
756 -----------------------
757 -- Get_Convention_Id --
758 -----------------------
760 function Get_Convention_Id
(N
: Name_Id
) return Convention_Id
is
763 when Name_Ada
=> return Convention_Ada
;
764 when Name_Assembler
=> return Convention_Assembler
;
765 when Name_C
=> return Convention_C
;
766 when Name_COBOL
=> return Convention_COBOL
;
767 when Name_CPP
=> return Convention_CPP
;
768 when Name_Fortran
=> return Convention_Fortran
;
769 when Name_Intrinsic
=> return Convention_Intrinsic
;
770 when Name_Java
=> return Convention_Java
;
771 when Name_Stdcall
=> return Convention_Stdcall
;
772 when Name_Stubbed
=> return Convention_Stubbed
;
774 -- If no direct match, then we must have a convention
775 -- identifier pragma that has specified this name.
778 for J
in 1 .. Convention_Identifiers
.Last
loop
779 if N
= Convention_Identifiers
.Table
(J
).Name
then
780 return Convention_Identifiers
.Table
(J
).Convention
;
786 end Get_Convention_Id
;
788 ---------------------------
789 -- Get_Locking_Policy_Id --
790 ---------------------------
792 function Get_Locking_Policy_Id
(N
: Name_Id
) return Locking_Policy_Id
is
794 return Locking_Policy_Id
'Val (N
- First_Locking_Policy_Name
);
795 end Get_Locking_Policy_Id
;
801 function Get_Pragma_Id
(N
: Name_Id
) return Pragma_Id
is
803 if N
= Name_AST_Entry
then
804 return Pragma_AST_Entry
;
805 elsif N
= Name_Storage_Size
then
806 return Pragma_Storage_Size
;
807 elsif N
= Name_Storage_Unit
then
808 return Pragma_Storage_Unit
;
809 elsif N
not in First_Pragma_Name
.. Last_Pragma_Name
then
810 return Unknown_Pragma
;
812 return Pragma_Id
'Val (N
- First_Pragma_Name
);
816 ---------------------------
817 -- Get_Queuing_Policy_Id --
818 ---------------------------
820 function Get_Queuing_Policy_Id
(N
: Name_Id
) return Queuing_Policy_Id
is
822 return Queuing_Policy_Id
'Val (N
- First_Queuing_Policy_Name
);
823 end Get_Queuing_Policy_Id
;
825 ------------------------------------
826 -- Get_Task_Dispatching_Policy_Id --
827 ------------------------------------
829 function Get_Task_Dispatching_Policy_Id
(N
: Name_Id
)
830 return Task_Dispatching_Policy_Id
is
832 return Task_Dispatching_Policy_Id
'Val
833 (N
- First_Task_Dispatching_Policy_Name
);
834 end Get_Task_Dispatching_Policy_Id
;
840 procedure Initialize
is
842 Discard_Name
: Name_Id
;
845 P_Index
:= Preset_Names
'First;
850 while Preset_Names
(P_Index
) /= '#' loop
851 Name_Len
:= Name_Len
+ 1;
852 Name_Buffer
(Name_Len
) := Preset_Names
(P_Index
);
853 P_Index
:= P_Index
+ 1;
856 -- We do the Name_Find call to enter the name into the table, but
857 -- we don't need to do anything with the result, since we already
858 -- initialized all the preset names to have the right value (we
859 -- are depending on the order of the names and Preset_Names).
861 Discard_Name
:= Name_Find
;
862 P_Index
:= P_Index
+ 1;
863 exit when Preset_Names
(P_Index
) = '#';
866 -- Make sure that number of names in standard table is correct. If
867 -- this check fails, run utility program XSNAMES to construct a new
868 -- properly matching version of the body.
870 pragma Assert
(Discard_Name
= Last_Predefined_Name
);
872 -- Initialize the convention identifiers table with the standard
873 -- set of synonyms that we recognize for conventions.
875 Convention_Identifiers
.Init
;
877 Convention_Identifiers
.Append
((Name_Asm
, Convention_Assembler
));
878 Convention_Identifiers
.Append
((Name_Assembly
, Convention_Assembler
));
880 Convention_Identifiers
.Append
((Name_Default
, Convention_C
));
881 Convention_Identifiers
.Append
((Name_External
, Convention_C
));
883 Convention_Identifiers
.Append
((Name_DLL
, Convention_Stdcall
));
884 Convention_Identifiers
.Append
((Name_Win32
, Convention_Stdcall
));
887 -----------------------
888 -- Is_Attribute_Name --
889 -----------------------
891 function Is_Attribute_Name
(N
: Name_Id
) return Boolean is
893 return N
in First_Attribute_Name
.. Last_Attribute_Name
;
894 end Is_Attribute_Name
;
900 function Is_Check_Name
(N
: Name_Id
) return Boolean is
902 return N
in First_Check_Name
.. Last_Check_Name
;
905 ------------------------
906 -- Is_Convention_Name --
907 ------------------------
909 function Is_Convention_Name
(N
: Name_Id
) return Boolean is
911 -- Check if this is one of the standard conventions
913 if N
in First_Convention_Name
.. Last_Convention_Name
918 -- Otherwise check if it is in convention identifier table
921 for J
in 1 .. Convention_Identifiers
.Last
loop
922 if N
= Convention_Identifiers
.Table
(J
).Name
then
929 end Is_Convention_Name
;
931 ------------------------------
932 -- Is_Entity_Attribute_Name --
933 ------------------------------
935 function Is_Entity_Attribute_Name
(N
: Name_Id
) return Boolean is
937 return N
in First_Entity_Attribute_Name
.. Last_Entity_Attribute_Name
;
938 end Is_Entity_Attribute_Name
;
940 --------------------------------
941 -- Is_Function_Attribute_Name --
942 --------------------------------
944 function Is_Function_Attribute_Name
(N
: Name_Id
) return Boolean is
947 First_Renamable_Function_Attribute
..
948 Last_Renamable_Function_Attribute
;
949 end Is_Function_Attribute_Name
;
951 ----------------------------
952 -- Is_Locking_Policy_Name --
953 ----------------------------
955 function Is_Locking_Policy_Name
(N
: Name_Id
) return Boolean is
957 return N
in First_Locking_Policy_Name
.. Last_Locking_Policy_Name
;
958 end Is_Locking_Policy_Name
;
960 -----------------------------
961 -- Is_Operator_Symbol_Name --
962 -----------------------------
964 function Is_Operator_Symbol_Name
(N
: Name_Id
) return Boolean is
966 return N
in First_Operator_Name
.. Last_Operator_Name
;
967 end Is_Operator_Symbol_Name
;
973 function Is_Pragma_Name
(N
: Name_Id
) return Boolean is
975 return N
in First_Pragma_Name
.. Last_Pragma_Name
976 or else N
= Name_AST_Entry
977 or else N
= Name_Storage_Size
978 or else N
= Name_Storage_Unit
;
981 ---------------------------------
982 -- Is_Procedure_Attribute_Name --
983 ---------------------------------
985 function Is_Procedure_Attribute_Name
(N
: Name_Id
) return Boolean is
987 return N
in First_Procedure_Attribute
.. Last_Procedure_Attribute
;
988 end Is_Procedure_Attribute_Name
;
990 ----------------------------
991 -- Is_Queuing_Policy_Name --
992 ----------------------------
994 function Is_Queuing_Policy_Name
(N
: Name_Id
) return Boolean is
996 return N
in First_Queuing_Policy_Name
.. Last_Queuing_Policy_Name
;
997 end Is_Queuing_Policy_Name
;
999 -------------------------------------
1000 -- Is_Task_Dispatching_Policy_Name --
1001 -------------------------------------
1003 function Is_Task_Dispatching_Policy_Name
(N
: Name_Id
) return Boolean is
1005 return N
in First_Task_Dispatching_Policy_Name
..
1006 Last_Task_Dispatching_Policy_Name
;
1007 end Is_Task_Dispatching_Policy_Name
;
1009 ----------------------------
1010 -- Is_Type_Attribute_Name --
1011 ----------------------------
1013 function Is_Type_Attribute_Name
(N
: Name_Id
) return Boolean is
1015 return N
in First_Type_Attribute_Name
.. Last_Type_Attribute_Name
;
1016 end Is_Type_Attribute_Name
;
1018 ----------------------------------
1019 -- Record_Convention_Identifier --
1020 ----------------------------------
1022 procedure Record_Convention_Identifier
1024 Convention
: Convention_Id
)
1027 Convention_Identifiers
.Append
((Id
, Convention
));
1028 end Record_Convention_Identifier
;