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