1 /****************************************************************************
2  *                                                                          *
3  *                         GNAT COMPILER COMPONENTS                         *
4  *                                                                          *
5  *                                N A M E T                                 *
6  *                                                                          *
7  *                              C Header File                               *
8  *                                                                          *
9  *            Copyright (C) 1992-2019, 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 3,  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 COPYING3.  If not, go to *
19  * http://www.gnu.org/licenses for a complete copy of the license.          *
20  *                                                                          *
21  * GNAT was originally developed  by the GNAT team at  New York University. *
22  * Extensive contributions were provided by Ada Core Technologies Inc.      *
23  *                                                                          *
24  ****************************************************************************/
25 
26 /* This is the C file that corresponds to the Ada package specification
27    Namet.  It was created manually from files namet.ads and namet.adb.
28    Subprograms from Exp_Dbug and Sinput are also made accessible here.  */
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Structure defining a names table entry.  */
35 
36 struct Name_Entry
37 {
38   Int Name_Chars_Index; /* Starting location of char in Name_Chars table. */
39   Short Name_Len;         /* Length of this name in characters. */
40   Byte Byte_Info;       /* Byte value associated with this name */
41   Byte Spare;           /* Unused */
42   Name_Id Hash_Link;    /* Link to next entry in names table for same hash
43                            code. Not accessed by C routines.  */
44   Int Int_Info;         /* Int value associated with this name */
45 };
46 
47 /* Pointer to names table vector. */
48 #define Names_Ptr namet__name_entries__table
49 extern struct Name_Entry *Names_Ptr;
50 
51 /* Pointer to name characters table. */
52 #define Name_Chars_Ptr namet__name_chars__table
53 extern char *Name_Chars_Ptr;
54 
55 /* This is Hostparm.Max_Line_Length.  */
56 #define Max_Line_Length (32767 - 1)
57 
58 /* The global name buffer.  */
59 struct Bounded_String
60 {
61   Nat Max_Length;
62   Nat Length;
63   char Chars[4 * Max_Line_Length]; /* Exact value for overflow detection.  */
64 };
65 
66 #define Global_Name_Buffer namet__global_name_buffer
67 extern struct Bounded_String Global_Name_Buffer;
68 
69 #define Name_Buffer Global_Name_Buffer.Chars
70 #define Name_Len Global_Name_Buffer.Length
71 
72 /* Get_Name_String returns a NUL terminated C string for the specified name.
73    We could use the official Ada routine for this purpose, but since the
74    strings we want are sitting in the name strings table in exactly the form
75    we need them (NUL terminated), we just point to the name directly. */
76 
77 static char *Get_Name_String (Name_Id);
78 
79 INLINE char *
Get_Name_String(Name_Id Id)80 Get_Name_String (Name_Id Id)
81 {
82   return Name_Chars_Ptr + Names_Ptr[Id - First_Name_Id].Name_Chars_Index + 1;
83 }
84 
85 #define Name_Equals namet__name_equals
86 extern Boolean Name_Equals (Name_Id, Name_Id);
87 
88 /* The following routines and variables are not part of Namet, but we
89    include the header here since it seems the best place for it.  */
90 
91 #define Get_Encoded_Type_Name exp_dbug__get_encoded_type_name
92 extern Boolean Get_Encoded_Type_Name (Entity_Id);
93 #define Get_Variant_Encoding exp_dbug__get_variant_encoding
94 extern void Get_Variant_Encoding (Entity_Id);
95 
96 #define Spec_Context_List exp_dbug__spec_context_list
97 #define Body_Context_List exp_dbug__body_context_list
98 extern char *Spec_Context_List, *Body_Context_List;
99 #define Spec_Filename exp_dbug__spec_filename
100 #define Body_Filename exp_dbug__body_filename
101 extern char *Spec_Filename, *Body_Filename;
102 
103 /* Here are some functions in sinput.adb we call from trans.c.  */
104 
105 typedef Nat Source_File_Index;
106 typedef Int Logical_Line_Number;
107 typedef Int Column_Number;
108 
109 #define Debug_Source_Name sinput__debug_source_name
110 #define Full_Debug_Name sinput__full_debug_name
111 #define Reference_Name sinput__reference_name
112 #define Get_Source_File_Index sinput__get_source_file_index
113 #define Get_Logical_Line_Number sinput__get_logical_line_number
114 #define Get_Column_Number sinput__get_column_number
115 #define Instantiation sinput__instantiation
116 
117 extern File_Name_Type Debug_Source_Name	(Source_File_Index);
118 extern File_Name_Type Full_Debug_Name	(Source_File_Index);
119 extern File_Name_Type Reference_Name	(Source_File_Index);
120 extern Source_File_Index Get_Source_File_Index (Source_Ptr);
121 extern Logical_Line_Number Get_Logical_Line_Number (Source_Ptr);
122 extern Column_Number Get_Column_Number (Source_Ptr);
123 extern Source_Ptr Instantiation (Source_File_Index);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128