annotate gcc/ada/osint-c.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- O S I N T - C --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2001-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package contains the low level, operating system routines used only
kono
parents:
diff changeset
27 -- in the GNAT compiler for command line processing and file input output.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 package Osint.C is
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 procedure Set_Output_Object_File_Name (Name : String);
kono
parents:
diff changeset
32 -- Called by the subprogram processing the command line when an
kono
parents:
diff changeset
33 -- output object file name is found.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 function Get_Output_Object_File_Name return String;
kono
parents:
diff changeset
36 -- Returns the name of the output object file as saved by a call to
kono
parents:
diff changeset
37 -- Set_Output_Object_File_Name. Only valid to call if name has been set.
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 function More_Source_Files return Boolean;
kono
parents:
diff changeset
40 -- Indicates whether more source file remain to be processed. Returns
kono
parents:
diff changeset
41 -- False right away if no source files, or if all source files have
kono
parents:
diff changeset
42 -- been processed.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 function Next_Main_Source return File_Name_Type;
kono
parents:
diff changeset
45 -- This function returns the name of the next main source file specified
kono
parents:
diff changeset
46 -- on the command line. It is an error to call Next_Main_Source if no more
kono
parents:
diff changeset
47 -- source files exist (i.e. Next_Main_Source may be called only if a
kono
parents:
diff changeset
48 -- previous call to More_Source_Files returned True). This name is the
kono
parents:
diff changeset
49 -- simple file name (without any directory information).
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 ------------------------------
kono
parents:
diff changeset
52 -- Debug Source File Output --
kono
parents:
diff changeset
53 ------------------------------
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -- These routines are used by the compiler to generate the debug source
kono
parents:
diff changeset
56 -- file for the Debug_Generated_Code (-gnatD switch) option. Note that
kono
parents:
diff changeset
57 -- debug source file writing occurs at a completely different point in
kono
parents:
diff changeset
58 -- the processing from library information output, or representation
kono
parents:
diff changeset
59 -- output, so the code in the body can assume that no two of these
kono
parents:
diff changeset
60 -- functions are ever used at the same time.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 function Create_Debug_File (Src : File_Name_Type) return File_Name_Type;
kono
parents:
diff changeset
63 -- Given the simple name of a source file, this routine creates the
kono
parents:
diff changeset
64 -- corresponding debug file, and returns its full name.
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 procedure Write_Debug_Info (Info : String);
kono
parents:
diff changeset
67 -- Writes contents of given string as next line of the current debug
kono
parents:
diff changeset
68 -- source file created by the most recent call to Create_Debug_File.
kono
parents:
diff changeset
69 -- Info does not contain end of line or other formatting characters.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 procedure Close_Debug_File;
kono
parents:
diff changeset
72 -- Close current debug file created by the most recent call to
kono
parents:
diff changeset
73 -- Create_Debug_File.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 function Debug_File_Eol_Length return Nat;
kono
parents:
diff changeset
76 -- Returns the number of characters (1 for NL, 2 for CR/LF) written
kono
parents:
diff changeset
77 -- at the end of each line by Write_Debug_Info.
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 --------------------------------
kono
parents:
diff changeset
80 -- Representation File Output --
kono
parents:
diff changeset
81 --------------------------------
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 -- These routines are used by the compiler to generate the representation
kono
parents:
diff changeset
84 -- information to a file if this option is specified (-gnatR?s switch).
kono
parents:
diff changeset
85 -- Note that the writing of this file occurs at a completely different
kono
parents:
diff changeset
86 -- point in the processing from library information output, or from
kono
parents:
diff changeset
87 -- debug file output, so the code in the body can assume that no two
kono
parents:
diff changeset
88 -- of these functions are ever used at the same time.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 -- Note: these routines are called from Repinfo, but are not called
kono
parents:
diff changeset
91 -- directly, since we do not want Repinfo to depend on Osint. That
kono
parents:
diff changeset
92 -- would cause a lot of unwanted junk to be dragged into ASIS. So
kono
parents:
diff changeset
93 -- what we do is we have Initialize set the addresses of these three
kono
parents:
diff changeset
94 -- procedures in appropriate variables in Repinfo, so that they can
kono
parents:
diff changeset
95 -- be called indirectly without creating a dependence.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 procedure Create_Repinfo_File (Src : String);
kono
parents:
diff changeset
98 -- Given the simple name of a source file, this routine creates the
kono
parents:
diff changeset
99 -- corresponding file to hold representation information. Note that the
kono
parents:
diff changeset
100 -- call destroys the contents of Name_Buffer and Name_Len.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 procedure Write_Repinfo_Line (Info : String);
kono
parents:
diff changeset
103 -- Writes contents of given string as next line of the current debug
kono
parents:
diff changeset
104 -- source file created by the most recent call to Create_Repinfo_File.
kono
parents:
diff changeset
105 -- Info does not contain end of line or other formatting characters.
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Close_Repinfo_File;
kono
parents:
diff changeset
108 -- Close current debug file created by the most recent call to
kono
parents:
diff changeset
109 -- Create_Repinfo_File.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Set_File_Name (Ext : String);
kono
parents:
diff changeset
112 -- Sets a default file name from the main compiler source name. Ext is the
kono
parents:
diff changeset
113 -- extension, e.g. "ali" for a library information file. The name is in
kono
parents:
diff changeset
114 -- Name_Buffer (with length in Name_Len) on return, with
kono
parents:
diff changeset
115 -- Name_Buffer (Name_Len) always set to ASCII.NUL.
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 --------------------------------
kono
parents:
diff changeset
118 -- Library Information Output --
kono
parents:
diff changeset
119 --------------------------------
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 -- These routines are used by the compiler to generate the library
kono
parents:
diff changeset
122 -- information file for the main source file being compiled. See section
kono
parents:
diff changeset
123 -- above for a discussion of how library information files are stored.
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 procedure Create_Output_Library_Info;
kono
parents:
diff changeset
126 -- Creates the output library information file for the source file which
kono
parents:
diff changeset
127 -- is currently being compiled (i.e. the file which was most recently
kono
parents:
diff changeset
128 -- returned by Next_Main_Source).
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 procedure Open_Output_Library_Info;
kono
parents:
diff changeset
131 -- Opens the output library information file for the source file which
kono
parents:
diff changeset
132 -- is currently being compiled (i.e. the file which was most recently
kono
parents:
diff changeset
133 -- returned by Next_Main_Source) for appending. This is used to append
kono
parents:
diff changeset
134 -- the globals computed in flow analysis in gnatprove mode.
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 procedure Write_Library_Info (Info : String);
kono
parents:
diff changeset
137 -- Writes the contents of the referenced string to the library information
kono
parents:
diff changeset
138 -- file for the main source file currently being compiled (i.e. the file
kono
parents:
diff changeset
139 -- which was most recently opened with a call to Read_Next_File). Info
kono
parents:
diff changeset
140 -- represents a single line in the file, but does not contain any line
kono
parents:
diff changeset
141 -- termination characters. The implementation of Write_Library_Info is
kono
parents:
diff changeset
142 -- responsible for adding necessary end of line and end of file control
kono
parents:
diff changeset
143 -- characters to the generated file.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 procedure Close_Output_Library_Info;
kono
parents:
diff changeset
146 -- Closes the file created by Create_Output_Library_Info, flushing any
kono
parents:
diff changeset
147 -- buffers etc. from writes by Write_Library_Info.
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 procedure Read_Library_Info
kono
parents:
diff changeset
150 (Name : out File_Name_Type;
kono
parents:
diff changeset
151 Text : out Text_Buffer_Ptr);
kono
parents:
diff changeset
152 -- The procedure version of Read_Library_Info is used from the compiler
kono
parents:
diff changeset
153 -- to read an existing ali file associated with the main unit. If the
kono
parents:
diff changeset
154 -- ALI file exists, then its file name is returned in Name, and its
kono
parents:
diff changeset
155 -- text is returned in Text. If the file does not exist, then Text is
kono
parents:
diff changeset
156 -- set to null.
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 --------------------------
kono
parents:
diff changeset
159 -- C Translation Output --
kono
parents:
diff changeset
160 --------------------------
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 -- These routines are used by the compiler when the C translation option
kono
parents:
diff changeset
163 -- is activated to write *.c or *.h files to the current object directory.
kono
parents:
diff changeset
164 -- Each routine exists in a C and an H form for the two kinds of files.
kono
parents:
diff changeset
165 -- Only one of these files can be written at a time. Note that the files
kono
parents:
diff changeset
166 -- are written via the Output package routines, using Output_FD.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 procedure Create_C_File;
kono
parents:
diff changeset
169 procedure Create_H_File;
kono
parents:
diff changeset
170 -- Creates the *.c or *.h file for the source file which is currently
kono
parents:
diff changeset
171 -- being compiled (i.e. the file which was most recently returned by
kono
parents:
diff changeset
172 -- Next_Main_Source).
kono
parents:
diff changeset
173
kono
parents:
diff changeset
174 procedure Close_C_File;
kono
parents:
diff changeset
175 procedure Close_H_File;
kono
parents:
diff changeset
176 -- Closes the file created by Create_C_File or Create_H file, flushing any
kono
parents:
diff changeset
177 -- buffers etc. from writes by Write_C_File and Write_H_File;
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 procedure Delete_C_File;
kono
parents:
diff changeset
180 procedure Delete_H_File;
kono
parents:
diff changeset
181 -- Deletes the .c or .h file corresponding to the source file which is
kono
parents:
diff changeset
182 -- currently being compiled.
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 ----------------------
kono
parents:
diff changeset
185 -- List File Output --
kono
parents:
diff changeset
186 ----------------------
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 procedure Create_List_File (S : String);
kono
parents:
diff changeset
189 -- Creates the file whose name is given by S. If the name starts with a
kono
parents:
diff changeset
190 -- period, then the name is xxx & S, where xxx is the name of the main
kono
parents:
diff changeset
191 -- source file without the extension stripped. Information is written to
kono
parents:
diff changeset
192 -- this file using Write_List_File.
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 procedure Write_List_Info (S : String);
kono
parents:
diff changeset
195 -- Writes given string to the list file created by Create_List_File
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 procedure Close_List_File;
kono
parents:
diff changeset
198 -- Close file previously opened by Create_List_File
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 --------------------------------
kono
parents:
diff changeset
201 -- Semantic Tree Input-Output --
kono
parents:
diff changeset
202 --------------------------------
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 procedure Tree_Create;
kono
parents:
diff changeset
205 -- Creates the tree output file for the source file which is currently
kono
parents:
diff changeset
206 -- being compiled (i.e. the file which was most recently returned by
kono
parents:
diff changeset
207 -- Next_Main_Source), and initializes Tree_IO.Tree_Write for output.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 procedure Tree_Close;
kono
parents:
diff changeset
210 -- Closes the file previously opened by Tree_Create
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 end Osint.C;