1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2006, Free Software Foundation, Inc. --
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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- This package contains the low level, operating system routines used only
28 -- in the GNAT compiler for command line processing and file input output.
32 procedure Set_Output_Object_File_Name
(Name
: String);
33 -- Called by the subprogram processing the command line when an
34 -- output object file name is found.
36 function More_Source_Files
return Boolean;
37 -- Indicates whether more source file remain to be processed. Returns
38 -- False right away if no source files, or if all source files have
41 function Next_Main_Source
return File_Name_Type
;
42 -- This function returns the name of the next main source file specified
43 -- on the command line. It is an error to call Next_Main_Source if no more
44 -- source files exist (i.e. Next_Main_Source may be called only if a
45 -- previous call to More_Source_Files returned True). This name is the
46 -- simple file name (without any directory information).
48 ------------------------------
49 -- Debug Source File Output --
50 ------------------------------
52 -- These routines are used by the compiler to generate the debug source
53 -- file for the Debug_Generated_Code (-gnatD switch) option. Note that
54 -- debug source file writing occurs at a completely different point in
55 -- the processing from library information output, or representation
56 -- output, so the code in the body can assume that no two of these
57 -- functions are ever used at the same time.
59 function Create_Debug_File
(Src
: File_Name_Type
) return File_Name_Type
;
60 -- Given the simple name of a source file, this routine creates the
61 -- corresponding debug file, and returns its full name.
63 procedure Write_Debug_Info
(Info
: String);
64 -- Writes contents of given string as next line of the current debug
65 -- source file created by the most recent call to Create_Debug_File.
66 -- Info does not contain end of line or other formatting characters.
68 procedure Close_Debug_File
;
69 -- Close current debug file created by the most recent call to
72 function Debug_File_Eol_Length
return Nat
;
73 -- Returns the number of characters (1 for NL, 2 for CR/LF) written
74 -- at the end of each line by Write_Debug_Info.
76 --------------------------------
77 -- Representation File Output --
78 --------------------------------
80 -- These routines are used by the compiler to generate the representation
81 -- information to a file if this option is specified (-gnatR?s switch).
82 -- Note that the writing of this file occurs at a completely different
83 -- point in the processing from library information output, or from
84 -- debug file output, so the code in the body can assume that no two
85 -- of these functions are ever used at the same time.
87 -- Note: these routines are called from Repinfo, but are not called
88 -- directly, since we do not want Repinfo to depend on Osint. That
89 -- would cause a lot of unwanted junk to be dragged into ASIS. So
90 -- what we do is we have Initialize set the addresses of these three
91 -- procedures in appropriate variables in Repinfo, so that they can
92 -- be called indirectly without creating a dependence.
94 procedure Create_Repinfo_File
(Src
: File_Name_Type
);
95 -- Given the simple name of a source file, this routine creates the
96 -- corresponding file to hold representation information
98 procedure Write_Repinfo_Line
(Info
: String);
99 -- Writes contents of given string as next line of the current debug
100 -- source file created by the most recent call to Create_Repinfo_File.
101 -- Info does not contain end of line or other formatting characters.
103 procedure Close_Repinfo_File
;
104 -- Close current debug file created by the most recent call to
105 -- Create_Repinfo_File.
107 --------------------------------
108 -- Library Information Output --
109 --------------------------------
111 -- These routines are used by the compiler to generate the library
112 -- information file for the main source file being compiled. See section
113 -- above for a discussion of how library information files are stored.
115 procedure Create_Output_Library_Info
;
116 -- Creates the output library information file for the source file which
117 -- is currently being compiled (i.e. the file which was most recently
118 -- returned by Next_Main_Source).
120 procedure Write_Library_Info
(Info
: String);
121 -- Writes the contents of the referenced string to the library information
122 -- file for the main source file currently being compiled (i.e. the file
123 -- which was most recently opened with a call to Read_Next_File). Info
124 -- represents a single line in the file, but does not contain any line
125 -- termination characters. The implementation of Write_Library_Info is
126 -- responsible for adding necessary end of line and end of file control
127 -- characters to the generated file.
129 procedure Close_Output_Library_Info
;
130 -- Closes the file created by Create_Output_Library_Info, flushing any
131 -- buffers etc from writes by Write_Library_Info.
133 procedure Read_Library_Info
134 (Name
: out File_Name_Type
;
135 Text
: out Text_Buffer_Ptr
);
136 -- The procedure version of Read_Library_Info is used from the compiler
137 -- to read an existing ali file associated with the main unit. If the
138 -- ALI file exists, then its file name is returned in Name, and its
139 -- text is returned in Text. If the file does not exist, then Text is
142 ----------------------
143 -- List File Output --
144 ----------------------
146 procedure Create_List_File
(S
: String);
147 -- Creates the file whose name is given by S. If the name starts with a
148 -- period, then the name is xxx & S, where xxx is the name of the main
149 -- source file without the extension stripped. Information is written to
150 -- this file using Write_List_File.
152 procedure Write_List_Info
(S
: String);
153 -- Writes given string to the list file created by Create_List_File
155 procedure Close_List_File
;
156 -- Close file previously opened by Create_List_File
158 --------------------------------
159 -- Semantic Tree Input-Output --
160 --------------------------------
162 procedure Tree_Create
;
163 -- Creates the tree output file for the source file which is currently
164 -- being compiled (i.e. the file which was most recently returned by
165 -- Next_Main_Source), and initializes Tree_IO.Tree_Write for output.
167 procedure Tree_Close
;
168 -- Closes the file previously opened by Tree_Create