OSDN Git Service

2006-02-13 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / snames.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               S N A M E S                                --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2006, Free Software Foundation, Inc.         --
10 --                                                                          --
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.                                              --
21 --                                                                          --
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.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 with Namet; use Namet;
35 with Opt;   use Opt;
36 with Table;
37
38 package body Snames is
39
40    --  Table used to record convention identifiers
41
42    type Convention_Id_Entry is record
43       Name       : Name_Id;
44       Convention : Convention_Id;
45    end record;
46
47    package Convention_Identifiers is new Table.Table (
48      Table_Component_Type => Convention_Id_Entry,
49      Table_Index_Type     => Int,
50      Table_Low_Bound      => 1,
51      Table_Initial        => 50,
52      Table_Increment      => 200,
53      Table_Name           => "Name_Convention_Identifiers");
54
55    --  Table of names to be set by Initialize. Each name is terminated by a
56    --  single #, and the end of the list is marked by a null entry, i.e. by
57    --  two # marks in succession. Note that the table does not include the
58    --  entries for a-z, since these are initialized by Namet itself.
59
60    Preset_Names : constant String :=
61      "_parent#" &
62      "_tag#" &
63      "off#" &
64      "space#" &
65      "time#" &
66      "_abort_signal#" &
67      "_alignment#" &
68      "_assign#" &
69      "_atcb#" &
70      "_chain#" &
71      "_clean#" &
72      "_controller#" &
73      "_entry_bodies#" &
74      "_expunge#" &
75      "_final_list#" &
76      "_idepth#" &
77      "_init#" &
78      "_local_final_list#" &
79      "_master#" &
80      "_object#" &
81      "_priority#" &
82      "_process_atsd#" &
83      "_secondary_stack#" &
84      "_service#" &
85      "_size#" &
86      "_stack#" &
87      "_tags#" &
88      "_task#" &
89      "_task_id#" &
90      "_task_info#" &
91      "_task_name#" &
92      "_trace_sp#" &
93      "_disp_asynchronous_select#" &
94      "_disp_conditional_select#" &
95      "_disp_get_prim_op_kind#" &
96      "_disp_timed_select#" &
97      "_disp_get_task_id#" &
98      "initialize#" &
99      "adjust#" &
100      "finalize#" &
101      "next#" &
102      "prev#" &
103      "_typecode#" &
104      "_from_any#" &
105      "_to_any#" &
106      "allocate#" &
107      "deallocate#" &
108      "dereference#" &
109      "decimal_io#" &
110      "enumeration_io#" &
111      "fixed_io#" &
112      "float_io#" &
113      "integer_io#" &
114      "modular_io#" &
115      "const#" &
116      "<error>#" &
117      "go#" &
118      "put#" &
119      "put_line#" &
120      "to#" &
121      "finalization#" &
122      "finalization_root#" &
123      "interfaces#" &
124      "standard#" &
125      "system#" &
126      "text_io#" &
127      "wide_text_io#" &
128      "wide_wide_text_io#" &
129      "no_dsa#" &
130      "garlic_dsa#" &
131      "polyorb_dsa#" &
132      "addr#" &
133      "async#" &
134      "get_active_partition_id#" &
135      "get_rci_package_receiver#" &
136      "get_rci_package_ref#" &
137      "origin#" &
138      "params#" &
139      "partition#" &
140      "partition_interface#" &
141      "ras#" &
142      "call#" &
143      "rci_name#" &
144      "receiver#" &
145      "result#" &
146      "rpc#" &
147      "subp_id#" &
148      "operation#" &
149      "argument#" &
150      "arg_modes#" &
151      "handler#" &
152      "target#" &
153      "req#" &
154      "obj_typecode#" &
155      "stub#" &
156      "Oabs#" &
157      "Oand#" &
158      "Omod#" &
159      "Onot#" &
160      "Oor#" &
161      "Orem#" &
162      "Oxor#" &
163      "Oeq#" &
164      "One#" &
165      "Olt#" &
166      "Ole#" &
167      "Ogt#" &
168      "Oge#" &
169      "Oadd#" &
170      "Osubtract#" &
171      "Oconcat#" &
172      "Omultiply#" &
173      "Odivide#" &
174      "Oexpon#" &
175      "ada_83#" &
176      "ada_95#" &
177      "ada_05#" &
178      "ada_2005#" &
179      "assertion_policy#" &
180      "c_pass_by_copy#" &
181      "compile_time_warning#" &
182      "component_alignment#" &
183      "convention_identifier#" &
184      "debug_policy#" &
185      "detect_blocking#" &
186      "discard_names#" &
187      "elaboration_checks#" &
188      "eliminate#" &
189      "explicit_overriding#" &
190      "extend_system#" &
191      "extensions_allowed#" &
192      "external_name_casing#" &
193      "float_representation#" &
194      "initialize_scalars#" &
195      "interrupt_state#" &
196      "license#" &
197      "locking_policy#" &
198      "long_float#" &
199      "no_run_time#" &
200      "no_strict_aliasing#" &
201      "normalize_scalars#" &
202      "polling#" &
203      "persistent_bss#" &
204      "profile#" &
205      "profile_warnings#" &
206      "propagate_exceptions#" &
207      "queuing_policy#" &
208      "ravenscar#" &
209      "restricted_run_time#" &
210      "restrictions#" &
211      "restriction_warnings#" &
212      "reviewable#" &
213      "source_file_name#" &
214      "source_file_name_project#" &
215      "style_checks#" &
216      "suppress#" &
217      "suppress_exception_locations#" &
218      "task_dispatching_policy#" &
219      "universal_data#" &
220      "unsuppress#" &
221      "use_vads_size#" &
222      "validity_checks#" &
223      "warnings#" &
224      "abort_defer#" &
225      "all_calls_remote#" &
226      "annotate#" &
227      "assert#" &
228      "asynchronous#" &
229      "atomic#" &
230      "atomic_components#" &
231      "attach_handler#" &
232      "comment#" &
233      "common_object#" &
234      "complete_representation#" &
235      "complex_representation#" &
236      "controlled#" &
237      "convention#" &
238      "cpp_class#" &
239      "cpp_constructor#" &
240      "cpp_virtual#" &
241      "cpp_vtable#" &
242      "debug#" &
243      "elaborate#" &
244      "elaborate_all#" &
245      "elaborate_body#" &
246      "export#" &
247      "export_exception#" &
248      "export_function#" &
249      "export_object#" &
250      "export_procedure#" &
251      "export_value#" &
252      "export_valued_procedure#" &
253      "external#" &
254      "finalize_storage_only#" &
255      "ident#" &
256      "import#" &
257      "import_exception#" &
258      "import_function#" &
259      "import_object#" &
260      "import_procedure#" &
261      "import_valued_procedure#" &
262      "inline#" &
263      "inline_always#" &
264      "inline_generic#" &
265      "inspection_point#" &
266      "interface_name#" &
267      "interrupt_handler#" &
268      "interrupt_priority#" &
269      "java_constructor#" &
270      "java_interface#" &
271      "keep_names#" &
272      "link_with#" &
273      "linker_alias#" &
274      "linker_constructor#" &
275      "linker_destructor#" &
276      "linker_options#" &
277      "linker_section#" &
278      "list#" &
279      "machine_attribute#" &
280      "main#" &
281      "main_storage#" &
282      "memory_size#" &
283      "no_return#" &
284      "obsolescent#" &
285      "optimize#" &
286      "optional_overriding#" &
287      "pack#" &
288      "page#" &
289      "passive#" &
290      "preelaborate#" &
291      "preelaborate_05#" &
292      "priority#" &
293      "psect_object#" &
294      "pure#" &
295      "pure_05#" &
296      "pure_function#" &
297      "remote_call_interface#" &
298      "remote_types#" &
299      "share_generic#" &
300      "shared#" &
301      "shared_passive#" &
302      "source_reference#" &
303      "stream_convert#" &
304      "subtitle#" &
305      "suppress_all#" &
306      "suppress_debug_info#" &
307      "suppress_initialization#" &
308      "system_name#" &
309      "task_info#" &
310      "task_name#" &
311      "task_storage#" &
312      "thread_body#" &
313      "time_slice#" &
314      "title#" &
315      "unchecked_union#" &
316      "unimplemented_unit#" &
317      "unreferenced#" &
318      "unreserve_all_interrupts#" &
319      "volatile#" &
320      "volatile_components#" &
321      "weak_external#" &
322      "ada#" &
323      "assembler#" &
324      "cobol#" &
325      "cpp#" &
326      "fortran#" &
327      "intrinsic#" &
328      "java#" &
329      "stdcall#" &
330      "stubbed#" &
331      "asm#" &
332      "assembly#" &
333      "default#" &
334      "dll#" &
335      "win32#" &
336      "as_is#" &
337      "attribute_name#" &
338      "body_file_name#" &
339      "boolean_entry_barriers#" &
340      "check#" &
341      "casing#" &
342      "code#" &
343      "component#" &
344      "component_size_4#" &
345      "copy#" &
346      "d_float#" &
347      "descriptor#" &
348      "dot_replacement#" &
349      "dynamic#" &
350      "entity#" &
351      "entry_count#" &
352      "external_name#" &
353      "first_optional_parameter#" &
354      "form#" &
355      "g_float#" &
356      "gcc#" &
357      "gnat#" &
358      "gpl#" &
359      "ieee_float#" &
360      "ignore#" &
361      "info#" &
362      "internal#" &
363      "link_name#" &
364      "lowercase#" &
365      "max_entry_queue_depth#" &
366      "max_entry_queue_length#" &
367      "max_size#" &
368      "mechanism#" &
369      "message#" &
370      "mixedcase#" &
371      "modified_gpl#" &
372      "name#" &
373      "nca#" &
374      "no#" &
375      "no_dependence#" &
376      "no_dynamic_attachment#" &
377      "no_dynamic_interrupts#" &
378      "no_requeue#" &
379      "no_requeue_statements#" &
380      "no_task_attributes#" &
381      "no_task_attributes_package#" &
382      "on#" &
383      "parameter_types#" &
384      "reference#" &
385      "restricted#" &
386      "result_mechanism#" &
387      "result_type#" &
388      "runtime#" &
389      "sb#" &
390      "secondary_stack_size#" &
391      "section#" &
392      "semaphore#" &
393      "simple_barriers#" &
394      "spec_file_name#" &
395      "state#" &
396      "static#" &
397      "stack_size#" &
398      "subunit_file_name#" &
399      "task_stack_size_default#" &
400      "task_type#" &
401      "time_slicing_enabled#" &
402      "top_guard#" &
403      "uba#" &
404      "ubs#" &
405      "ubsb#" &
406      "unit_name#" &
407      "unknown#" &
408      "unrestricted#" &
409      "uppercase#" &
410      "user#" &
411      "vax_float#" &
412      "vms#" &
413      "vtable_ptr#" &
414      "working_storage#" &
415      "abort_signal#" &
416      "access#" &
417      "address#" &
418      "address_size#" &
419      "aft#" &
420      "alignment#" &
421      "asm_input#" &
422      "asm_output#" &
423      "ast_entry#" &
424      "bit#" &
425      "bit_order#" &
426      "bit_position#" &
427      "body_version#" &
428      "callable#" &
429      "caller#" &
430      "code_address#" &
431      "component_size#" &
432      "compose#" &
433      "constrained#" &
434      "count#" &
435      "default_bit_order#" &
436      "definite#" &
437      "delta#" &
438      "denorm#" &
439      "digits#" &
440      "elaborated#" &
441      "emax#" &
442      "enum_rep#" &
443      "epsilon#" &
444      "exponent#" &
445      "external_tag#" &
446      "first#" &
447      "first_bit#" &
448      "fixed_value#" &
449      "fore#" &
450      "has_access_values#" &
451      "has_discriminants#" &
452      "identity#" &
453      "img#" &
454      "integer_value#" &
455      "large#" &
456      "last#" &
457      "last_bit#" &
458      "leading_part#" &
459      "length#" &
460      "machine_emax#" &
461      "machine_emin#" &
462      "machine_mantissa#" &
463      "machine_overflows#" &
464      "machine_radix#" &
465      "machine_rounding#" &
466      "machine_rounds#" &
467      "machine_size#" &
468      "mantissa#" &
469      "max_size_in_storage_elements#" &
470      "maximum_alignment#" &
471      "mechanism_code#" &
472      "mod#" &
473      "model_emin#" &
474      "model_epsilon#" &
475      "model_mantissa#" &
476      "model_small#" &
477      "modulus#" &
478      "null_parameter#" &
479      "object_size#" &
480      "partition_id#" &
481      "passed_by_reference#" &
482      "pool_address#" &
483      "pos#" &
484      "position#" &
485      "range#" &
486      "range_length#" &
487      "round#" &
488      "safe_emax#" &
489      "safe_first#" &
490      "safe_large#" &
491      "safe_last#" &
492      "safe_small#" &
493      "scale#" &
494      "scaling#" &
495      "signed_zeros#" &
496      "size#" &
497      "small#" &
498      "storage_size#" &
499      "storage_unit#" &
500      "stream_size#" &
501      "tag#" &
502      "target_name#" &
503      "terminated#" &
504      "to_address#" &
505      "type_class#" &
506      "uet_address#" &
507      "unbiased_rounding#" &
508      "unchecked_access#" &
509      "unconstrained_array#" &
510      "universal_literal_string#" &
511      "unrestricted_access#" &
512      "vads_size#" &
513      "val#" &
514      "valid#" &
515      "value_size#" &
516      "version#" &
517      "wchar_t_size#" &
518      "wide_wide_width#" &
519      "wide_width#" &
520      "width#" &
521      "word_size#" &
522      "adjacent#" &
523      "ceiling#" &
524      "copy_sign#" &
525      "floor#" &
526      "fraction#" &
527      "image#" &
528      "input#" &
529      "machine#" &
530      "max#" &
531      "min#" &
532      "model#" &
533      "pred#" &
534      "remainder#" &
535      "rounding#" &
536      "succ#" &
537      "truncation#" &
538      "value#" &
539      "wide_image#" &
540      "wide_wide_image#" &
541      "wide_value#" &
542      "wide_wide_value#" &
543      "output#" &
544      "read#" &
545      "write#" &
546      "elab_body#" &
547      "elab_spec#" &
548      "storage_pool#" &
549      "base#" &
550      "class#" &
551      "ceiling_locking#" &
552      "inheritance_locking#" &
553      "fifo_queuing#" &
554      "priority_queuing#" &
555      "fifo_within_priorities#" &
556      "access_check#" &
557      "accessibility_check#" &
558      "discriminant_check#" &
559      "division_check#" &
560      "elaboration_check#" &
561      "index_check#" &
562      "length_check#" &
563      "overflow_check#" &
564      "range_check#" &
565      "storage_check#" &
566      "tag_check#" &
567      "all_checks#" &
568      "abort#" &
569      "abs#" &
570      "accept#" &
571      "and#" &
572      "all#" &
573      "array#" &
574      "at#" &
575      "begin#" &
576      "body#" &
577      "case#" &
578      "constant#" &
579      "declare#" &
580      "delay#" &
581      "do#" &
582      "else#" &
583      "elsif#" &
584      "end#" &
585      "entry#" &
586      "exception#" &
587      "exit#" &
588      "for#" &
589      "function#" &
590      "generic#" &
591      "goto#" &
592      "if#" &
593      "in#" &
594      "is#" &
595      "limited#" &
596      "loop#" &
597      "new#" &
598      "not#" &
599      "null#" &
600      "of#" &
601      "or#" &
602      "others#" &
603      "out#" &
604      "package#" &
605      "pragma#" &
606      "private#" &
607      "procedure#" &
608      "raise#" &
609      "record#" &
610      "rem#" &
611      "renames#" &
612      "return#" &
613      "reverse#" &
614      "select#" &
615      "separate#" &
616      "subtype#" &
617      "task#" &
618      "terminate#" &
619      "then#" &
620      "type#" &
621      "use#" &
622      "when#" &
623      "while#" &
624      "with#" &
625      "xor#" &
626      "divide#" &
627      "enclosing_entity#" &
628      "exception_information#" &
629      "exception_message#" &
630      "exception_name#" &
631      "file#" &
632      "generic_dispatching_constructor#" &
633      "import_address#" &
634      "import_largest_value#" &
635      "import_value#" &
636      "is_negative#" &
637      "line#" &
638      "rotate_left#" &
639      "rotate_right#" &
640      "shift_left#" &
641      "shift_right#" &
642      "shift_right_arithmetic#" &
643      "source_location#" &
644      "unchecked_conversion#" &
645      "unchecked_deallocation#" &
646      "to_pointer#" &
647      "free#" &
648      "abstract#" &
649      "aliased#" &
650      "protected#" &
651      "until#" &
652      "requeue#" &
653      "tagged#" &
654      "raise_exception#" &
655      "ada_roots#" &
656      "binder#" &
657      "binder_driver#" &
658      "body_suffix#" &
659      "builder#" &
660      "compiler#" &
661      "compiler_driver#" &
662      "compiler_kind#" &
663      "compute_dependency#" &
664      "cross_reference#" &
665      "default_linker#" &
666      "default_switches#" &
667      "dependency_option#" &
668      "exec_dir#" &
669      "executable#" &
670      "executable_suffix#" &
671      "extends#" &
672      "externally_built#" &
673      "finder#" &
674      "global_configuration_pragmas#" &
675      "gnatls#" &
676      "gnatstub#" &
677      "implementation#" &
678      "implementation_exceptions#" &
679      "implementation_suffix#" &
680      "include_option#" &
681      "language_processing#" &
682      "languages#" &
683      "library_ali_dir#" &
684      "library_dir#" &
685      "library_auto_init#" &
686      "library_gcc#" &
687      "library_interface#" &
688      "library_kind#" &
689      "library_name#" &
690      "library_options#" &
691      "library_reference_symbol_file#" &
692      "library_src_dir#" &
693      "library_symbol_file#" &
694      "library_symbol_policy#" &
695      "library_version#" &
696      "linker#" &
697      "local_configuration_pragmas#" &
698      "locally_removed_files#" &
699      "metrics#" &
700      "naming#" &
701      "object_dir#" &
702      "pretty_printer#" &
703      "project#" &
704      "separate_suffix#" &
705      "source_dirs#" &
706      "source_files#" &
707      "source_list_file#" &
708      "spec#" &
709      "spec_suffix#" &
710      "specification#" &
711      "specification_exceptions#" &
712      "specification_suffix#" &
713      "switches#" &
714      "unaligned_valid#" &
715      "interface#" &
716      "overriding#" &
717      "synchronized#" &
718      "#";
719
720    ---------------------
721    -- Generated Names --
722    ---------------------
723
724    --  This section lists the various cases of generated names which are
725    --  built from existing names by adding unique leading and/or trailing
726    --  upper case letters. In some cases these names are built recursively,
727    --  in particular names built from types may be built from types which
728    --  themselves have generated names. In this list, xxx represents an
729    --  existing name to which identifying letters are prepended or appended,
730    --  and a trailing n represents a serial number in an external name that
731    --  has some semantic significance (e.g. the n'th index type of an array).
732
733    --    xxxA    access type for formal xxx in entry param record   (Exp_Ch9)
734    --    xxxB    tag table for tagged type xxx                      (Exp_Ch3)
735    --    xxxB    task body procedure for task xxx                   (Exp_Ch9)
736    --    xxxD    dispatch table for tagged type xxx                 (Exp_Ch3)
737    --    xxxD    discriminal for discriminant xxx                   (Sem_Ch3)
738    --    xxxDn   n'th discr check function for rec type xxx         (Exp_Ch3)
739    --    xxxE    elaboration boolean flag for task xxx              (Exp_Ch9)
740    --    xxxE    dispatch table pointer type for tagged type xxx    (Exp_Ch3)
741    --    xxxE    parameters for accept body for entry xxx           (Exp_Ch9)
742    --    xxxFn   n'th primitive of a tagged type (named xxx)        (Exp_Ch3)
743    --    xxxJ    tag table type index for tagged type xxx           (Exp_Ch3)
744    --    xxxM    master Id value for access type xxx                (Exp_Ch3)
745    --    xxxP    tag table pointer type for tagged type xxx         (Exp_Ch3)
746    --    xxxP    parameter record type for entry xxx                (Exp_Ch9)
747    --    xxxPA   access to parameter record type for entry xxx      (Exp_Ch9)
748    --    xxxPn   pointer type for n'th primitive of tagged type xxx (Exp_Ch3)
749    --    xxxR    dispatch table pointer for tagged type xxx         (Exp_Ch3)
750    --    xxxT    tag table type for tagged type xxx                 (Exp_Ch3)
751    --    xxxT    literal table for enumeration type xxx             (Sem_Ch3)
752    --    xxxV    type for task value record for task xxx            (Exp_Ch9)
753    --    xxxX    entry index constant                               (Exp_Ch9)
754    --    xxxY    dispatch table type for tagged type xxx            (Exp_Ch3)
755    --    xxxZ    size variable for task xxx                         (Exp_Ch9)
756
757    --  TSS names
758
759    --    xxxDA   deep adjust routine for type xxx                   (Exp_TSS)
760    --    xxxDF   deep finalize routine for type xxx                 (Exp_TSS)
761    --    xxxDI   deep initialize routine for type xxx               (Exp_TSS)
762    --    xxxEQ   composite equality routine for record type xxx     (Exp_TSS)
763    --    xxxFA   PolyORB/DSA From_Any converter for type xxx        (Exp_TSS)
764    --    xxxIP   initialization procedure for type xxx              (Exp_TSS)
765    --    xxxRA   RAS type access routine for type xxx               (Exp_TSS)
766    --    xxxRD   RAS type dereference routine for type xxx          (Exp_TSS)
767    --    xxxRP   Rep to Pos conversion for enumeration type xxx     (Exp_TSS)
768    --    xxxSA   array/slice assignment for controlled comp. arrays (Exp_TSS)
769    --    xxxSI   stream input attribute subprogram for type xxx     (Exp_TSS)
770    --    xxxSO   stream output attribute subprogram for type xxx    (Exp_TSS)
771    --    xxxSR   stream read attribute subprogram for type xxx      (Exp_TSS)
772    --    xxxSW   stream write attribute subprogram for type xxx     (Exp_TSS)
773    --    xxxTA   PolyORB/DSA To_Any converter for type xxx          (Exp_TSS)
774    --    xxxTC   PolyORB/DSA Typecode for type xxx                  (Exp_TSS)
775
776    --  Implicit type names
777
778    --    TxxxT   type of literal table for enumeration type xxx     (Sem_Ch3)
779
780    --  (Note: this list is not complete or accurate ???)
781
782    ----------------------
783    -- Get_Attribute_Id --
784    ----------------------
785
786    function Get_Attribute_Id (N : Name_Id) return Attribute_Id is
787    begin
788       return Attribute_Id'Val (N - First_Attribute_Name);
789    end Get_Attribute_Id;
790
791    ------------------
792    -- Get_Check_Id --
793    ------------------
794
795    function Get_Check_Id (N : Name_Id) return Check_Id is
796    begin
797       return Check_Id'Val (N - First_Check_Name);
798    end Get_Check_Id;
799
800    -----------------------
801    -- Get_Convention_Id --
802    -----------------------
803
804    function Get_Convention_Id (N : Name_Id) return Convention_Id is
805    begin
806       case N is
807          when Name_Ada        => return Convention_Ada;
808          when Name_Assembler  => return Convention_Assembler;
809          when Name_C          => return Convention_C;
810          when Name_COBOL      => return Convention_COBOL;
811          when Name_CPP        => return Convention_CPP;
812          when Name_Fortran    => return Convention_Fortran;
813          when Name_Intrinsic  => return Convention_Intrinsic;
814          when Name_Java       => return Convention_Java;
815          when Name_Stdcall    => return Convention_Stdcall;
816          when Name_Stubbed    => return Convention_Stubbed;
817
818          --  If no direct match, then we must have a convention
819          --  identifier pragma that has specified this name.
820
821          when others          =>
822             for J in 1 .. Convention_Identifiers.Last loop
823                if N = Convention_Identifiers.Table (J).Name then
824                   return Convention_Identifiers.Table (J).Convention;
825                end if;
826             end loop;
827
828             raise Program_Error;
829       end case;
830    end Get_Convention_Id;
831
832    ---------------------------
833    -- Get_Locking_Policy_Id --
834    ---------------------------
835
836    function Get_Locking_Policy_Id (N : Name_Id) return Locking_Policy_Id is
837    begin
838       return Locking_Policy_Id'Val (N - First_Locking_Policy_Name);
839    end Get_Locking_Policy_Id;
840
841    -------------------
842    -- Get_Pragma_Id --
843    -------------------
844
845    function Get_Pragma_Id (N : Name_Id) return Pragma_Id is
846    begin
847       if N = Name_AST_Entry then
848          return Pragma_AST_Entry;
849       elsif N = Name_Interface then
850          return Pragma_Interface;
851       elsif N = Name_Storage_Size then
852          return Pragma_Storage_Size;
853       elsif N = Name_Storage_Unit then
854          return Pragma_Storage_Unit;
855       elsif N not in First_Pragma_Name .. Last_Pragma_Name then
856          return Unknown_Pragma;
857       else
858          return Pragma_Id'Val (N - First_Pragma_Name);
859       end if;
860    end Get_Pragma_Id;
861
862    ---------------------------
863    -- Get_Queuing_Policy_Id --
864    ---------------------------
865
866    function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id is
867    begin
868       return Queuing_Policy_Id'Val (N - First_Queuing_Policy_Name);
869    end Get_Queuing_Policy_Id;
870
871    ------------------------------------
872    -- Get_Task_Dispatching_Policy_Id --
873    ------------------------------------
874
875    function Get_Task_Dispatching_Policy_Id (N : Name_Id)
876      return Task_Dispatching_Policy_Id is
877    begin
878       return Task_Dispatching_Policy_Id'Val
879         (N - First_Task_Dispatching_Policy_Name);
880    end Get_Task_Dispatching_Policy_Id;
881
882    ----------------
883    -- Initialize --
884    ----------------
885
886    procedure Initialize is
887       P_Index      : Natural;
888       Discard_Name : Name_Id;
889
890    begin
891       P_Index := Preset_Names'First;
892
893       loop
894          Name_Len := 0;
895
896          while Preset_Names (P_Index) /= '#' loop
897             Name_Len := Name_Len + 1;
898             Name_Buffer (Name_Len) := Preset_Names (P_Index);
899             P_Index := P_Index + 1;
900          end loop;
901
902          --  We do the Name_Find call to enter the name into the table, but
903          --  we don't need to do anything with the result, since we already
904          --  initialized all the preset names to have the right value (we
905          --  are depending on the order of the names and Preset_Names).
906
907          Discard_Name := Name_Find;
908          P_Index := P_Index + 1;
909          exit when Preset_Names (P_Index) = '#';
910       end loop;
911
912       --  Make sure that number of names in standard table is correct. If
913       --  this check fails, run utility program XSNAMES to construct a new
914       --  properly matching version of the body.
915
916       pragma Assert (Discard_Name = Last_Predefined_Name);
917
918       --  Initialize the convention identifiers table with the standard
919       --  set of synonyms that we recognize for conventions.
920
921       Convention_Identifiers.Init;
922
923       Convention_Identifiers.Append ((Name_Asm,      Convention_Assembler));
924       Convention_Identifiers.Append ((Name_Assembly, Convention_Assembler));
925
926       Convention_Identifiers.Append ((Name_Default,  Convention_C));
927       Convention_Identifiers.Append ((Name_External, Convention_C));
928
929       Convention_Identifiers.Append ((Name_DLL,      Convention_Stdcall));
930       Convention_Identifiers.Append ((Name_Win32,    Convention_Stdcall));
931    end Initialize;
932
933    -----------------------
934    -- Is_Attribute_Name --
935    -----------------------
936
937    function Is_Attribute_Name (N : Name_Id) return Boolean is
938    begin
939       return N in First_Attribute_Name .. Last_Attribute_Name;
940    end Is_Attribute_Name;
941
942    -------------------
943    -- Is_Check_Name --
944    -------------------
945
946    function Is_Check_Name (N : Name_Id) return Boolean is
947    begin
948       return N in First_Check_Name .. Last_Check_Name;
949    end Is_Check_Name;
950
951    ------------------------
952    -- Is_Convention_Name --
953    ------------------------
954
955    function Is_Convention_Name (N : Name_Id) return Boolean is
956    begin
957       --  Check if this is one of the standard conventions
958
959       if N in First_Convention_Name .. Last_Convention_Name
960         or else N = Name_C
961       then
962          return True;
963
964       --  Otherwise check if it is in convention identifier table
965
966       else
967          for J in 1 .. Convention_Identifiers.Last loop
968             if N = Convention_Identifiers.Table (J).Name then
969                return True;
970             end if;
971          end loop;
972
973          return False;
974       end if;
975    end Is_Convention_Name;
976
977    ------------------------------
978    -- Is_Entity_Attribute_Name --
979    ------------------------------
980
981    function Is_Entity_Attribute_Name (N : Name_Id) return Boolean is
982    begin
983       return N in First_Entity_Attribute_Name .. Last_Entity_Attribute_Name;
984    end Is_Entity_Attribute_Name;
985
986    --------------------------------
987    -- Is_Function_Attribute_Name --
988    --------------------------------
989
990    function Is_Function_Attribute_Name (N : Name_Id) return Boolean is
991    begin
992       return N in
993         First_Renamable_Function_Attribute ..
994           Last_Renamable_Function_Attribute;
995    end Is_Function_Attribute_Name;
996
997    ---------------------
998    -- Is_Keyword_Name --
999    ---------------------
1000
1001    function Is_Keyword_Name (N : Name_Id) return Boolean is
1002    begin
1003       return Get_Name_Table_Byte (N) /= 0
1004         and then (Ada_Version >= Ada_95
1005                   or else N not in Ada_95_Reserved_Words)
1006         and then (Ada_Version >= Ada_05
1007                   or else N not in Ada_2005_Reserved_Words);
1008    end Is_Keyword_Name;
1009
1010    ----------------------------
1011    -- Is_Locking_Policy_Name --
1012    ----------------------------
1013
1014    function Is_Locking_Policy_Name (N : Name_Id) return Boolean is
1015    begin
1016       return N in First_Locking_Policy_Name .. Last_Locking_Policy_Name;
1017    end Is_Locking_Policy_Name;
1018
1019    -----------------------------
1020    -- Is_Operator_Symbol_Name --
1021    -----------------------------
1022
1023    function Is_Operator_Symbol_Name (N : Name_Id) return Boolean is
1024    begin
1025       return N in First_Operator_Name .. Last_Operator_Name;
1026    end Is_Operator_Symbol_Name;
1027
1028    --------------------
1029    -- Is_Pragma_Name --
1030    --------------------
1031
1032    function Is_Pragma_Name (N : Name_Id) return Boolean is
1033    begin
1034       return N in First_Pragma_Name .. Last_Pragma_Name
1035         or else N = Name_AST_Entry
1036         or else N = Name_Interface
1037         or else N = Name_Storage_Size
1038         or else N = Name_Storage_Unit;
1039    end Is_Pragma_Name;
1040
1041    ---------------------------------
1042    -- Is_Procedure_Attribute_Name --
1043    ---------------------------------
1044
1045    function Is_Procedure_Attribute_Name (N : Name_Id) return Boolean is
1046    begin
1047       return N in First_Procedure_Attribute .. Last_Procedure_Attribute;
1048    end Is_Procedure_Attribute_Name;
1049
1050    ----------------------------
1051    -- Is_Queuing_Policy_Name --
1052    ----------------------------
1053
1054    function Is_Queuing_Policy_Name (N : Name_Id) return Boolean is
1055    begin
1056       return N in First_Queuing_Policy_Name .. Last_Queuing_Policy_Name;
1057    end Is_Queuing_Policy_Name;
1058
1059    -------------------------------------
1060    -- Is_Task_Dispatching_Policy_Name --
1061    -------------------------------------
1062
1063    function Is_Task_Dispatching_Policy_Name (N : Name_Id) return Boolean is
1064    begin
1065       return N in First_Task_Dispatching_Policy_Name ..
1066                   Last_Task_Dispatching_Policy_Name;
1067    end Is_Task_Dispatching_Policy_Name;
1068
1069    ----------------------------
1070    -- Is_Type_Attribute_Name --
1071    ----------------------------
1072
1073    function Is_Type_Attribute_Name (N : Name_Id) return Boolean is
1074    begin
1075       return N in First_Type_Attribute_Name .. Last_Type_Attribute_Name;
1076    end Is_Type_Attribute_Name;
1077
1078    ----------------------------------
1079    -- Record_Convention_Identifier --
1080    ----------------------------------
1081
1082    procedure Record_Convention_Identifier
1083      (Id         : Name_Id;
1084       Convention : Convention_Id)
1085    is
1086    begin
1087       Convention_Identifiers.Append ((Id, Convention));
1088    end Record_Convention_Identifier;
1089
1090 end Snames;