1 ------------------------------------------------------------------------------
\r
3 -- GNAT COMPILER COMPONENTS --
\r
9 -- Copyright (C) 1992-2003, Free Software Foundation, Inc. --
\r
11 -- GNAT is free software; you can redistribute it and/or modify it under --
\r
12 -- terms of the GNU General Public License as published by the Free Soft- --
\r
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
\r
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
\r
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
\r
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
\r
17 -- for more details. You should have received a copy of the GNU General --
\r
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
\r
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
\r
20 -- MA 02111-1307, USA. --
\r
22 -- As a special exception, if other files instantiate generics from this --
\r
23 -- unit, or you link this unit with other files to produce an executable, --
\r
24 -- this unit does not by itself cause the resulting executable to be --
\r
25 -- covered by the GNU General Public License. This exception does not --
\r
26 -- however invalidate any other reasons why the executable file might be --
\r
27 -- covered by the GNU Public License. --
\r
29 -- GNAT was originally developed by the GNAT team at New York University. --
\r
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
\r
32 ------------------------------------------------------------------------------
\r
34 with Namet; use Namet;
\r
37 package body Snames is
\r
39 -- Table used to record convention identifiers
\r
41 type Convention_Id_Entry is record
\r
43 Convention : Convention_Id;
\r
46 package Convention_Identifiers is new Table.Table (
\r
47 Table_Component_Type => Convention_Id_Entry,
\r
48 Table_Index_Type => Int,
\r
49 Table_Low_Bound => 1,
\r
50 Table_Initial => 50,
\r
51 Table_Increment => 200,
\r
52 Table_Name => "Name_Convention_Identifiers");
\r
54 -- Table of names to be set by Initialize. Each name is terminated by a
\r
55 -- single #, and the end of the list is marked by a null entry, i.e. by
\r
56 -- two # marks in succession. Note that the table does not include the
\r
57 -- entries for a-z, since these are initialized by Namet itself.
\r
59 Preset_Names : constant String :=
\r
76 "_local_final_list#" &
\r
81 "_secondary_stack#" &
\r
113 "finalization_root#" &
\r
121 "get_active_partition_id#" &
\r
122 "get_rci_package_receiver#" &
\r
126 "partition_interface#" &
\r
154 "c_pass_by_copy#" &
\r
155 "compile_time_warning#" &
\r
156 "component_alignment#" &
\r
157 "convention_identifier#" &
\r
159 "elaboration_checks#" &
\r
161 "explicit_overriding#" &
\r
163 "extensions_allowed#" &
\r
164 "external_name_casing#" &
\r
165 "float_representation#" &
\r
166 "initialize_scalars#" &
\r
167 "interrupt_state#" &
\r
169 "locking_policy#" &
\r
172 "normalize_scalars#" &
\r
174 "persistent_data#" &
\r
175 "persistent_object#" &
\r
176 "propagate_exceptions#" &
\r
177 "queuing_policy#" &
\r
179 "restricted_run_time#" &
\r
181 "restriction_warnings#" &
\r
183 "source_file_name#" &
\r
184 "source_file_name_project#" &
\r
187 "suppress_exception_locations#" &
\r
188 "task_dispatching_policy#" &
\r
189 "universal_data#" &
\r
192 "validity_checks#" &
\r
195 "all_calls_remote#" &
\r
200 "atomic_components#" &
\r
201 "attach_handler#" &
\r
204 "complex_representation#" &
\r
208 "cpp_constructor#" &
\r
214 "elaborate_body#" &
\r
216 "export_exception#" &
\r
217 "export_function#" &
\r
219 "export_procedure#" &
\r
221 "export_valued_procedure#" &
\r
223 "finalize_storage_only#" &
\r
226 "import_exception#" &
\r
227 "import_function#" &
\r
229 "import_procedure#" &
\r
230 "import_valued_procedure#" &
\r
233 "inline_generic#" &
\r
234 "inspection_point#" &
\r
236 "interface_name#" &
\r
237 "interrupt_handler#" &
\r
238 "interrupt_priority#" &
\r
239 "java_constructor#" &
\r
240 "java_interface#" &
\r
244 "linker_options#" &
\r
245 "linker_section#" &
\r
247 "machine_attribute#" &
\r
254 "optional_overriding#" &
\r
264 "remote_call_interface#" &
\r
268 "shared_passive#" &
\r
269 "source_reference#" &
\r
270 "stream_convert#" &
\r
273 "suppress_debug_info#" &
\r
274 "suppress_initialization#" &
\r
282 "unchecked_union#" &
\r
283 "unimplemented_unit#" &
\r
285 "unreserve_all_interrupts#" &
\r
287 "volatile_components#" &
\r
304 "body_file_name#" &
\r
308 "component_size_4#" &
\r
312 "dot_replacement#" &
\r
316 "first_optional_parameter#" &
\r
323 "homonym_number#" &
\r
335 "parameter_types#" &
\r
338 "result_mechanism#" &
\r
342 "secondary_stack_size#" &
\r
345 "spec_file_name#" &
\r
348 "subunit_file_name#" &
\r
349 "task_stack_size_default#" &
\r
351 "time_slicing_enabled#" &
\r
363 "working_storage#" &
\r
380 "component_size#" &
\r
384 "default_bit_order#" &
\r
399 "has_discriminants#" &
\r
410 "machine_mantissa#" &
\r
411 "machine_overflows#" &
\r
413 "machine_rounds#" &
\r
416 "max_size_in_storage_elements#" &
\r
417 "maximum_alignment#" &
\r
418 "mechanism_code#" &
\r
421 "model_mantissa#" &
\r
424 "null_parameter#" &
\r
427 "passed_by_reference#" &
\r
452 "unbiased_rounding#" &
\r
453 "unchecked_access#" &
\r
454 "unconstrained_array#" &
\r
455 "universal_literal_string#" &
\r
456 "unrestricted_access#" &
\r
493 "ceiling_locking#" &
\r
494 "inheritance_locking#" &
\r
496 "priority_queuing#" &
\r
497 "fifo_within_priorities#" &
\r
499 "accessibility_check#" &
\r
500 "discriminant_check#" &
\r
501 "division_check#" &
\r
502 "elaboration_check#" &
\r
505 "overflow_check#" &
\r
570 "enclosing_entity#" &
\r
571 "exception_information#" &
\r
572 "exception_message#" &
\r
573 "exception_name#" &
\r
575 "import_address#" &
\r
576 "import_largest_value#" &
\r
584 "shift_right_arithmetic#" &
\r
585 "source_location#" &
\r
586 "unchecked_conversion#" &
\r
587 "unchecked_deallocation#" &
\r
595 "raise_exception#" &
\r
600 "cross_reference#" &
\r
601 "default_switches#" &
\r
604 "executable_suffix#" &
\r
607 "global_configuration_pragmas#" &
\r
610 "implementation#" &
\r
611 "implementation_exceptions#" &
\r
612 "implementation_suffix#" &
\r
615 "library_auto_init#" &
\r
617 "library_interface#" &
\r
620 "library_options#" &
\r
621 "library_src_dir#" &
\r
622 "library_symbol_file#" &
\r
623 "library_version#" &
\r
625 "local_configuration_pragmas#" &
\r
626 "locally_removed_files#" &
\r
629 "pretty_printer#" &
\r
631 "separate_suffix#" &
\r
634 "source_list_file#" &
\r
638 "specification_exceptions#" &
\r
639 "specification_suffix#" &
\r
641 "unaligned_valid#" &
\r
644 ---------------------
\r
645 -- Generated Names --
\r
646 ---------------------
\r
648 -- This section lists the various cases of generated names which are
\r
649 -- built from existing names by adding unique leading and/or trailing
\r
650 -- upper case letters. In some cases these names are built recursively,
\r
651 -- in particular names built from types may be built from types which
\r
652 -- themselves have generated names. In this list, xxx represents an
\r
653 -- existing name to which identifying letters are prepended or appended,
\r
654 -- and a trailing n represents a serial number in an external name that
\r
655 -- has some semantic significance (e.g. the n'th index type of an array).
\r
657 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
\r
658 -- xxxB tag table for tagged type xxx (Exp_Ch3)
\r
659 -- xxxB task body procedure for task xxx (Exp_Ch9)
\r
660 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
\r
661 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
\r
662 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
\r
663 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
\r
664 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
\r
665 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
\r
666 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
\r
667 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
\r
668 -- xxxM master Id value for access type xxx (Exp_Ch3)
\r
669 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
\r
670 -- xxxP parameter record type for entry xxx (Exp_Ch9)
\r
671 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
\r
672 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
\r
673 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
\r
674 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
\r
675 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
\r
676 -- xxxV type for task value record for task xxx (Exp_Ch9)
\r
677 -- xxxX entry index constant (Exp_Ch9)
\r
678 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
\r
679 -- xxxZ size variable for task xxx (Exp_Ch9)
\r
683 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
\r
684 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
\r
685 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
\r
686 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
\r
687 -- xxxIP initialization procedure for type xxx (Exp_TSS)
\r
688 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
\r
689 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
\r
690 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
\r
691 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
\r
692 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
\r
693 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
\r
694 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
\r
696 -- Implicit type names
\r
698 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
\r
700 -- (Note: this list is not complete or accurate ???)
\r
702 ----------------------
\r
703 -- Get_Attribute_Id --
\r
704 ----------------------
\r
706 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
\r
708 return Attribute_Id'Val (N - First_Attribute_Name);
\r
709 end Get_Attribute_Id;
\r
715 function Get_Check_Id (N : Name_Id) return Check_Id is
\r
717 return Check_Id'Val (N - First_Check_Name);
\r
720 -----------------------
\r
721 -- Get_Convention_Id --
\r
722 -----------------------
\r
724 function Get_Convention_Id (N : Name_Id) return Convention_Id is
\r
727 when Name_Ada => return Convention_Ada;
\r
728 when Name_Assembler => return Convention_Assembler;
\r
729 when Name_C => return Convention_C;
\r
730 when Name_COBOL => return Convention_COBOL;
\r
731 when Name_CPP => return Convention_CPP;
\r
732 when Name_Fortran => return Convention_Fortran;
\r
733 when Name_Intrinsic => return Convention_Intrinsic;
\r
734 when Name_Java => return Convention_Java;
\r
735 when Name_Stdcall => return Convention_Stdcall;
\r
736 when Name_Stubbed => return Convention_Stubbed;
\r
738 -- If no direct match, then we must have a convention
\r
739 -- identifier pragma that has specified this name.
\r
742 for J in 1 .. Convention_Identifiers.Last loop
\r
743 if N = Convention_Identifiers.Table (J).Name then
\r
744 return Convention_Identifiers.Table (J).Convention;
\r
748 raise Program_Error;
\r
750 end Get_Convention_Id;
\r
752 ---------------------------
\r
753 -- Get_Locking_Policy_Id --
\r
754 ---------------------------
\r
756 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
\r
758 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
\r
759 end Get_Locking_Policy_Id;
\r
761 -------------------
\r
762 -- Get_Pragma_Id --
\r
763 -------------------
\r
765 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
\r
767 if N = Name_AST_Entry then
\r
768 return Pragma_AST_Entry;
\r
769 elsif N = Name_Storage_Size then
\r
770 return Pragma_Storage_Size;
\r
771 elsif N = Name_Storage_Unit then
\r
772 return Pragma_Storage_Unit;
\r
773 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
\r
774 return Unknown_Pragma;
\r
776 return Pragma_Id'Val (N - First_Pragma_Name);
\r
780 ---------------------------
\r
781 -- Get_Queuing_Policy_Id --
\r
782 ---------------------------
\r
784 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
\r
786 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
\r
787 end Get_Queuing_Policy_Id;
\r
789 ------------------------------------
\r
790 -- Get_Task_Dispatching_Policy_Id --
\r
791 ------------------------------------
\r
793 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
\r
794 return Task_Dispatching_Policy_Id is
\r
796 return Task_Dispatching_Policy_Id'Val
\r
797 (N - First_Task_Dispatching_Policy_Name);
\r
798 end Get_Task_Dispatching_Policy_Id;
\r
804 procedure Initialize is
\r
806 Discard_Name : Name_Id;
\r
809 P_Index := Preset_Names'First;
\r
814 while Preset_Names (P_Index) /= '#' loop
\r
815 Name_Len := Name_Len + 1;
\r
816 Name_Buffer (Name_Len) := Preset_Names (P_Index);
\r
817 P_Index := P_Index + 1;
\r
820 -- We do the Name_Find call to enter the name into the table, but
\r
821 -- we don't need to do anything with the result, since we already
\r
822 -- initialized all the preset names to have the right value (we
\r
823 -- are depending on the order of the names and Preset_Names).
\r
825 Discard_Name := Name_Find;
\r
826 P_Index := P_Index + 1;
\r
827 exit when Preset_Names (P_Index) = '#';
\r
830 -- Make sure that number of names in standard table is correct. If
\r
831 -- this check fails, run utility program XSNAMES to construct a new
\r
832 -- properly matching version of the body.
\r
834 pragma Assert (Discard_Name = Last_Predefined_Name);
\r
836 -- Initialize the convention identifiers table with the standard
\r
837 -- set of synonyms that we recognize for conventions.
\r
839 Convention_Identifiers.Init;
\r
841 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
\r
842 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
\r
844 Convention_Identifiers.Append ((Name_Default, Convention_C));
\r
845 Convention_Identifiers.Append ((Name_External, Convention_C));
\r
847 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
\r
848 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
\r
851 -----------------------
\r
852 -- Is_Attribute_Name --
\r
853 -----------------------
\r
855 function Is_Attribute_Name (N : Name_Id) return Boolean is
\r
857 return N in First_Attribute_Name .. Last_Attribute_Name;
\r
858 end Is_Attribute_Name;
\r
860 -------------------
\r
861 -- Is_Check_Name --
\r
862 -------------------
\r
864 function Is_Check_Name (N : Name_Id) return Boolean is
\r
866 return N in First_Check_Name .. Last_Check_Name;
\r
869 ------------------------
\r
870 -- Is_Convention_Name --
\r
871 ------------------------
\r
873 function Is_Convention_Name (N : Name_Id) return Boolean is
\r
875 -- Check if this is one of the standard conventions
\r
877 if N in First_Convention_Name .. Last_Convention_Name
\r
882 -- Otherwise check if it is in convention identifier table
\r
885 for J in 1 .. Convention_Identifiers.Last loop
\r
886 if N = Convention_Identifiers.Table (J).Name then
\r
893 end Is_Convention_Name;
\r
895 ------------------------------
\r
896 -- Is_Entity_Attribute_Name --
\r
897 ------------------------------
\r
899 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
\r
901 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
\r
902 end Is_Entity_Attribute_Name;
\r
904 --------------------------------
\r
905 -- Is_Function_Attribute_Name --
\r
906 --------------------------------
\r
908 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
\r
911 First_Renamable_Function_Attribute ..
\r
912 Last_Renamable_Function_Attribute;
\r
913 end Is_Function_Attribute_Name;
\r
915 ----------------------------
\r
916 -- Is_Locking_Policy_Name --
\r
917 ----------------------------
\r
919 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
\r
921 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
\r
922 end Is_Locking_Policy_Name;
\r
924 -----------------------------
\r
925 -- Is_Operator_Symbol_Name --
\r
926 -----------------------------
\r
928 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
\r
930 return N in First_Operator_Name .. Last_Operator_Name;
\r
931 end Is_Operator_Symbol_Name;
\r
933 --------------------
\r
934 -- Is_Pragma_Name --
\r
935 --------------------
\r
937 function Is_Pragma_Name (N : Name_Id) return Boolean is
\r
939 return N in First_Pragma_Name .. Last_Pragma_Name
\r
940 or else N = Name_AST_Entry
\r
941 or else N = Name_Storage_Size
\r
942 or else N = Name_Storage_Unit;
\r
943 end Is_Pragma_Name;
\r
945 ---------------------------------
\r
946 -- Is_Procedure_Attribute_Name --
\r
947 ---------------------------------
\r
949 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
\r
951 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
\r
952 end Is_Procedure_Attribute_Name;
\r
954 ----------------------------
\r
955 -- Is_Queuing_Policy_Name --
\r
956 ----------------------------
\r
958 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
\r
960 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
\r
961 end Is_Queuing_Policy_Name;
\r
963 -------------------------------------
\r
964 -- Is_Task_Dispatching_Policy_Name --
\r
965 -------------------------------------
\r
967 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
\r
969 return N in First_Task_Dispatching_Policy_Name ..
\r
970 Last_Task_Dispatching_Policy_Name;
\r
971 end Is_Task_Dispatching_Policy_Name;
\r
973 ----------------------------
\r
974 -- Is_Type_Attribute_Name --
\r
975 ----------------------------
\r
977 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
\r
979 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
\r
980 end Is_Type_Attribute_Name;
\r
982 ----------------------------------
\r
983 -- Record_Convention_Identifier --
\r
984 ----------------------------------
\r
986 procedure Record_Convention_Identifier
\r
988 Convention : Convention_Id)
\r
991 Convention_Identifiers.Append ((Id, Convention));
\r
992 end Record_Convention_Identifier;
\r