OSDN Git Service

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