1 ------------------------------------------------------------------------------
\r
3 -- GNAT COMPILER COMPONENTS --
\r
9 -- Copyright (C) 1992-2005, 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
77 "_local_final_list#" &
\r
82 "_secondary_stack#" &
\r
104 "enumeration_io#" &
\r
116 "finalization_root#" &
\r
122 "wide_wide_text_io#" &
\r
128 "get_active_partition_id#" &
\r
129 "get_rci_package_receiver#" &
\r
130 "get_rci_package_ref#" &
\r
134 "partition_interface#" &
\r
172 "c_pass_by_copy#" &
\r
173 "compile_time_warning#" &
\r
174 "component_alignment#" &
\r
175 "convention_identifier#" &
\r
176 "detect_blocking#" &
\r
178 "elaboration_checks#" &
\r
180 "explicit_overriding#" &
\r
182 "extensions_allowed#" &
\r
183 "external_name_casing#" &
\r
184 "float_representation#" &
\r
185 "initialize_scalars#" &
\r
186 "interrupt_state#" &
\r
188 "locking_policy#" &
\r
191 "no_strict_aliasing#" &
\r
192 "normalize_scalars#" &
\r
194 "persistent_data#" &
\r
195 "persistent_object#" &
\r
197 "profile_warnings#" &
\r
198 "propagate_exceptions#" &
\r
199 "queuing_policy#" &
\r
201 "restricted_run_time#" &
\r
203 "restriction_warnings#" &
\r
205 "source_file_name#" &
\r
206 "source_file_name_project#" &
\r
209 "suppress_exception_locations#" &
\r
210 "task_dispatching_policy#" &
\r
211 "universal_data#" &
\r
214 "validity_checks#" &
\r
217 "all_calls_remote#" &
\r
222 "atomic_components#" &
\r
223 "attach_handler#" &
\r
226 "complex_representation#" &
\r
230 "cpp_constructor#" &
\r
236 "elaborate_body#" &
\r
238 "export_exception#" &
\r
239 "export_function#" &
\r
241 "export_procedure#" &
\r
243 "export_valued_procedure#" &
\r
245 "finalize_storage_only#" &
\r
248 "import_exception#" &
\r
249 "import_function#" &
\r
251 "import_procedure#" &
\r
252 "import_valued_procedure#" &
\r
255 "inline_generic#" &
\r
256 "inspection_point#" &
\r
257 "interface_name#" &
\r
258 "interrupt_handler#" &
\r
259 "interrupt_priority#" &
\r
260 "java_constructor#" &
\r
261 "java_interface#" &
\r
265 "linker_options#" &
\r
266 "linker_section#" &
\r
268 "machine_attribute#" &
\r
275 "optional_overriding#" &
\r
284 "remote_call_interface#" &
\r
288 "shared_passive#" &
\r
289 "source_reference#" &
\r
290 "stream_convert#" &
\r
293 "suppress_debug_info#" &
\r
294 "suppress_initialization#" &
\r
302 "unchecked_union#" &
\r
303 "unimplemented_unit#" &
\r
305 "unreserve_all_interrupts#" &
\r
307 "volatile_components#" &
\r
324 "body_file_name#" &
\r
325 "boolean_entry_barriers#" &
\r
329 "component_size_4#" &
\r
333 "dot_replacement#" &
\r
337 "first_optional_parameter#" &
\r
347 "max_entry_queue_depth#" &
\r
348 "max_entry_queue_length#" &
\r
357 "no_dynamic_attachment#" &
\r
358 "no_dynamic_interrupts#" &
\r
360 "no_requeue_statements#" &
\r
361 "no_task_attributes#" &
\r
362 "no_task_attributes_package#" &
\r
364 "parameter_types#" &
\r
367 "result_mechanism#" &
\r
371 "secondary_stack_size#" &
\r
374 "simple_barriers#" &
\r
375 "spec_file_name#" &
\r
378 "subunit_file_name#" &
\r
379 "task_stack_size_default#" &
\r
381 "time_slicing_enabled#" &
\r
393 "working_storage#" &
\r
410 "component_size#" &
\r
414 "default_bit_order#" &
\r
429 "has_access_values#" &
\r
430 "has_discriminants#" &
\r
441 "machine_mantissa#" &
\r
442 "machine_overflows#" &
\r
444 "machine_rounds#" &
\r
447 "max_size_in_storage_elements#" &
\r
448 "maximum_alignment#" &
\r
449 "mechanism_code#" &
\r
453 "model_mantissa#" &
\r
456 "null_parameter#" &
\r
459 "passed_by_reference#" &
\r
485 "unbiased_rounding#" &
\r
486 "unchecked_access#" &
\r
487 "unconstrained_array#" &
\r
488 "universal_literal_string#" &
\r
489 "unrestricted_access#" &
\r
496 "wide_wide_width#" &
\r
518 "wide_wide_image#" &
\r
520 "wide_wide_value#" &
\r
529 "ceiling_locking#" &
\r
530 "inheritance_locking#" &
\r
532 "priority_queuing#" &
\r
533 "fifo_within_priorities#" &
\r
535 "accessibility_check#" &
\r
536 "discriminant_check#" &
\r
537 "division_check#" &
\r
538 "elaboration_check#" &
\r
541 "overflow_check#" &
\r
605 "enclosing_entity#" &
\r
606 "exception_information#" &
\r
607 "exception_message#" &
\r
608 "exception_name#" &
\r
610 "import_address#" &
\r
611 "import_largest_value#" &
\r
619 "shift_right_arithmetic#" &
\r
620 "source_location#" &
\r
621 "unchecked_conversion#" &
\r
622 "unchecked_deallocation#" &
\r
630 "raise_exception#" &
\r
637 "compiler_driver#" &
\r
639 "compute_dependency#" &
\r
640 "cross_reference#" &
\r
641 "default_linker#" &
\r
642 "default_switches#" &
\r
643 "dependency_option#" &
\r
646 "executable_suffix#" &
\r
648 "externally_built#" &
\r
650 "global_configuration_pragmas#" &
\r
653 "implementation#" &
\r
654 "implementation_exceptions#" &
\r
655 "implementation_suffix#" &
\r
656 "include_option#" &
\r
657 "language_processing#" &
\r
660 "library_auto_init#" &
\r
662 "library_interface#" &
\r
665 "library_options#" &
\r
666 "library_reference_symbol_file#" &
\r
667 "library_src_dir#" &
\r
668 "library_symbol_file#" &
\r
669 "library_symbol_policy#" &
\r
670 "library_version#" &
\r
672 "local_configuration_pragmas#" &
\r
673 "locally_removed_files#" &
\r
677 "pretty_printer#" &
\r
679 "separate_suffix#" &
\r
682 "source_list_file#" &
\r
686 "specification_exceptions#" &
\r
687 "specification_suffix#" &
\r
689 "unaligned_valid#" &
\r
695 ---------------------
\r
696 -- Generated Names --
\r
697 ---------------------
\r
699 -- This section lists the various cases of generated names which are
\r
700 -- built from existing names by adding unique leading and/or trailing
\r
701 -- upper case letters. In some cases these names are built recursively,
\r
702 -- in particular names built from types may be built from types which
\r
703 -- themselves have generated names. In this list, xxx represents an
\r
704 -- existing name to which identifying letters are prepended or appended,
\r
705 -- and a trailing n represents a serial number in an external name that
\r
706 -- has some semantic significance (e.g. the n'th index type of an array).
\r
708 -- xxxA access type for formal xxx in entry param record (Exp_Ch9)
\r
709 -- xxxB tag table for tagged type xxx (Exp_Ch3)
\r
710 -- xxxB task body procedure for task xxx (Exp_Ch9)
\r
711 -- xxxD dispatch table for tagged type xxx (Exp_Ch3)
\r
712 -- xxxD discriminal for discriminant xxx (Sem_Ch3)
\r
713 -- xxxDn n'th discr check function for rec type xxx (Exp_Ch3)
\r
714 -- xxxE elaboration boolean flag for task xxx (Exp_Ch9)
\r
715 -- xxxE dispatch table pointer type for tagged type xxx (Exp_Ch3)
\r
716 -- xxxE parameters for accept body for entry xxx (Exp_Ch9)
\r
717 -- xxxFn n'th primitive of a tagged type (named xxx) (Exp_Ch3)
\r
718 -- xxxJ tag table type index for tagged type xxx (Exp_Ch3)
\r
719 -- xxxM master Id value for access type xxx (Exp_Ch3)
\r
720 -- xxxP tag table pointer type for tagged type xxx (Exp_Ch3)
\r
721 -- xxxP parameter record type for entry xxx (Exp_Ch9)
\r
722 -- xxxPA access to parameter record type for entry xxx (Exp_Ch9)
\r
723 -- xxxPn pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
\r
724 -- xxxR dispatch table pointer for tagged type xxx (Exp_Ch3)
\r
725 -- xxxT tag table type for tagged type xxx (Exp_Ch3)
\r
726 -- xxxT literal table for enumeration type xxx (Sem_Ch3)
\r
727 -- xxxV type for task value record for task xxx (Exp_Ch9)
\r
728 -- xxxX entry index constant (Exp_Ch9)
\r
729 -- xxxY dispatch table type for tagged type xxx (Exp_Ch3)
\r
730 -- xxxZ size variable for task xxx (Exp_Ch9)
\r
734 -- xxxDA deep adjust routine for type xxx (Exp_TSS)
\r
735 -- xxxDF deep finalize routine for type xxx (Exp_TSS)
\r
736 -- xxxDI deep initialize routine for type xxx (Exp_TSS)
\r
737 -- xxxEQ composite equality routine for record type xxx (Exp_TSS)
\r
738 -- xxxIP initialization procedure for type xxx (Exp_TSS)
\r
739 -- xxxRA RAs type access routine for type xxx (Exp_TSS)
\r
740 -- xxxRD RAs type dereference routine for type xxx (Exp_TSS)
\r
741 -- xxxRP Rep to Pos conversion for enumeration type xxx (Exp_TSS)
\r
742 -- xxxSA array/slice assignment for controlled comp. arrays (Exp_TSS)
\r
743 -- xxxSI stream input attribute subprogram for type xxx (Exp_TSS)
\r
744 -- xxxSO stream output attribute subprogram for type xxx (Exp_TSS)
\r
745 -- xxxSR stream read attribute subprogram for type xxx (Exp_TSS)
\r
746 -- xxxSW stream write attribute subprogram for type xxx (Exp_TSS)
\r
748 -- Implicit type names
\r
750 -- TxxxT type of literal table for enumeration type xxx (Sem_Ch3)
\r
752 -- (Note: this list is not complete or accurate ???)
\r
754 ----------------------
\r
755 -- Get_Attribute_Id --
\r
756 ----------------------
\r
758 function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
\r
760 return Attribute_Id'Val (N - First_Attribute_Name);
\r
761 end Get_Attribute_Id;
\r
767 function Get_Check_Id (N : Name_Id) return Check_Id is
\r
769 return Check_Id'Val (N - First_Check_Name);
\r
772 -----------------------
\r
773 -- Get_Convention_Id --
\r
774 -----------------------
\r
776 function Get_Convention_Id (N : Name_Id) return Convention_Id is
\r
779 when Name_Ada => return Convention_Ada;
\r
780 when Name_Assembler => return Convention_Assembler;
\r
781 when Name_C => return Convention_C;
\r
782 when Name_COBOL => return Convention_COBOL;
\r
783 when Name_CPP => return Convention_CPP;
\r
784 when Name_Fortran => return Convention_Fortran;
\r
785 when Name_Intrinsic => return Convention_Intrinsic;
\r
786 when Name_Java => return Convention_Java;
\r
787 when Name_Stdcall => return Convention_Stdcall;
\r
788 when Name_Stubbed => return Convention_Stubbed;
\r
790 -- If no direct match, then we must have a convention
\r
791 -- identifier pragma that has specified this name.
\r
794 for J in 1 .. Convention_Identifiers.Last loop
\r
795 if N = Convention_Identifiers.Table (J).Name then
\r
796 return Convention_Identifiers.Table (J).Convention;
\r
800 raise Program_Error;
\r
802 end Get_Convention_Id;
\r
804 ---------------------------
\r
805 -- Get_Locking_Policy_Id --
\r
806 ---------------------------
\r
808 function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
\r
810 return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
\r
811 end Get_Locking_Policy_Id;
\r
813 -------------------
\r
814 -- Get_Pragma_Id --
\r
815 -------------------
\r
817 function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
\r
819 if N = Name_AST_Entry then
\r
820 return Pragma_AST_Entry;
\r
821 elsif N = Name_Interface then
\r
822 return Pragma_Interface;
\r
823 elsif N = Name_Storage_Size then
\r
824 return Pragma_Storage_Size;
\r
825 elsif N = Name_Storage_Unit then
\r
826 return Pragma_Storage_Unit;
\r
827 elsif N not in First_Pragma_Name .. Last_Pragma_Name then
\r
828 return Unknown_Pragma;
\r
830 return Pragma_Id'Val (N - First_Pragma_Name);
\r
834 ---------------------------
\r
835 -- Get_Queuing_Policy_Id --
\r
836 ---------------------------
\r
838 function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
\r
840 return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
\r
841 end Get_Queuing_Policy_Id;
\r
843 ------------------------------------
\r
844 -- Get_Task_Dispatching_Policy_Id --
\r
845 ------------------------------------
\r
847 function Get_Task_Dispatching_Policy_Id (N : Name_Id)
\r
848 return Task_Dispatching_Policy_Id is
\r
850 return Task_Dispatching_Policy_Id'Val
\r
851 (N - First_Task_Dispatching_Policy_Name);
\r
852 end Get_Task_Dispatching_Policy_Id;
\r
858 procedure Initialize is
\r
860 Discard_Name : Name_Id;
\r
863 P_Index := Preset_Names'First;
\r
868 while Preset_Names (P_Index) /= '#' loop
\r
869 Name_Len := Name_Len + 1;
\r
870 Name_Buffer (Name_Len) := Preset_Names (P_Index);
\r
871 P_Index := P_Index + 1;
\r
874 -- We do the Name_Find call to enter the name into the table, but
\r
875 -- we don't need to do anything with the result, since we already
\r
876 -- initialized all the preset names to have the right value (we
\r
877 -- are depending on the order of the names and Preset_Names).
\r
879 Discard_Name := Name_Find;
\r
880 P_Index := P_Index + 1;
\r
881 exit when Preset_Names (P_Index) = '#';
\r
884 -- Make sure that number of names in standard table is correct. If
\r
885 -- this check fails, run utility program XSNAMES to construct a new
\r
886 -- properly matching version of the body.
\r
888 pragma Assert (Discard_Name = Last_Predefined_Name);
\r
890 -- Initialize the convention identifiers table with the standard
\r
891 -- set of synonyms that we recognize for conventions.
\r
893 Convention_Identifiers.Init;
\r
895 Convention_Identifiers.Append ((Name_Asm, Convention_Assembler));
\r
896 Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
\r
898 Convention_Identifiers.Append ((Name_Default, Convention_C));
\r
899 Convention_Identifiers.Append ((Name_External, Convention_C));
\r
901 Convention_Identifiers.Append ((Name_DLL, Convention_Stdcall));
\r
902 Convention_Identifiers.Append ((Name_Win32, Convention_Stdcall));
\r
905 -----------------------
\r
906 -- Is_Attribute_Name --
\r
907 -----------------------
\r
909 function Is_Attribute_Name (N : Name_Id) return Boolean is
\r
911 return N in First_Attribute_Name .. Last_Attribute_Name;
\r
912 end Is_Attribute_Name;
\r
914 -------------------
\r
915 -- Is_Check_Name --
\r
916 -------------------
\r
918 function Is_Check_Name (N : Name_Id) return Boolean is
\r
920 return N in First_Check_Name .. Last_Check_Name;
\r
923 ------------------------
\r
924 -- Is_Convention_Name --
\r
925 ------------------------
\r
927 function Is_Convention_Name (N : Name_Id) return Boolean is
\r
929 -- Check if this is one of the standard conventions
\r
931 if N in First_Convention_Name .. Last_Convention_Name
\r
936 -- Otherwise check if it is in convention identifier table
\r
939 for J in 1 .. Convention_Identifiers.Last loop
\r
940 if N = Convention_Identifiers.Table (J).Name then
\r
947 end Is_Convention_Name;
\r
949 ------------------------------
\r
950 -- Is_Entity_Attribute_Name --
\r
951 ------------------------------
\r
953 function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
\r
955 return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
\r
956 end Is_Entity_Attribute_Name;
\r
958 --------------------------------
\r
959 -- Is_Function_Attribute_Name --
\r
960 --------------------------------
\r
962 function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
\r
965 First_Renamable_Function_Attribute ..
\r
966 Last_Renamable_Function_Attribute;
\r
967 end Is_Function_Attribute_Name;
\r
969 ----------------------------
\r
970 -- Is_Locking_Policy_Name --
\r
971 ----------------------------
\r
973 function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
\r
975 return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
\r
976 end Is_Locking_Policy_Name;
\r
978 -----------------------------
\r
979 -- Is_Operator_Symbol_Name --
\r
980 -----------------------------
\r
982 function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
\r
984 return N in First_Operator_Name .. Last_Operator_Name;
\r
985 end Is_Operator_Symbol_Name;
\r
987 --------------------
\r
988 -- Is_Pragma_Name --
\r
989 --------------------
\r
991 function Is_Pragma_Name (N : Name_Id) return Boolean is
\r
993 return N in First_Pragma_Name .. Last_Pragma_Name
\r
994 or else N = Name_AST_Entry
\r
995 or else N = Name_Interface
\r
996 or else N = Name_Storage_Size
\r
997 or else N = Name_Storage_Unit;
\r
998 end Is_Pragma_Name;
\r
1000 ---------------------------------
\r
1001 -- Is_Procedure_Attribute_Name --
\r
1002 ---------------------------------
\r
1004 function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
\r
1006 return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
\r
1007 end Is_Procedure_Attribute_Name;
\r
1009 ----------------------------
\r
1010 -- Is_Queuing_Policy_Name --
\r
1011 ----------------------------
\r
1013 function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
\r
1015 return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
\r
1016 end Is_Queuing_Policy_Name;
\r
1018 -------------------------------------
\r
1019 -- Is_Task_Dispatching_Policy_Name --
\r
1020 -------------------------------------
\r
1022 function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
\r
1024 return N in First_Task_Dispatching_Policy_Name ..
\r
1025 Last_Task_Dispatching_Policy_Name;
\r
1026 end Is_Task_Dispatching_Policy_Name;
\r
1028 ----------------------------
\r
1029 -- Is_Type_Attribute_Name --
\r
1030 ----------------------------
\r
1032 function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
\r
1034 return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
\r
1035 end Is_Type_Attribute_Name;
\r
1037 ----------------------------------
\r
1038 -- Record_Convention_Identifier --
\r
1039 ----------------------------------
\r
1041 procedure Record_Convention_Identifier
\r
1043 Convention : Convention_Id)
\r
1046 Convention_Identifiers.Append ((Id, Convention));
\r
1047 end Record_Convention_Identifier;
\r