Fix memory barrier patterns for pre PA8800 processors
[official-gcc.git] / gcc / ada / output.ads
blobe5933c195d0832d386db722f786ca98b452d301e
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- O U T P U T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2023, 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 ------------------------------------------------------------------------------
26 -- This package contains low level output routines used by the compiler for
27 -- writing error messages and informational output. It is also used by the
28 -- debug source file output routines (see Sprint.Print_Debug_Line).
30 with Hostparm;
31 with Types; use Types;
33 pragma Warnings (Off);
34 -- This package is used also by gnatcoll
35 with System.OS_Lib; use System.OS_Lib;
36 pragma Warnings (On);
38 package Output is
39 pragma Elaborate_Body;
41 type Output_Proc is access procedure (S : String);
42 -- This type is used for the Set_Special_Output procedure. If Output_Proc
43 -- is called, then instead of lines being written to standard error or
44 -- standard output, a call is made to the given procedure for each line,
45 -- passing the line with an end of line character (which is a single
46 -- ASCII.LF character, even in systems which normally use CR/LF or some
47 -- other sequence for line end).
49 -----------------
50 -- Subprograms --
51 -----------------
53 procedure Set_Special_Output (P : Output_Proc);
54 -- Sets subsequent output to call procedure P. If P is null, then the call
55 -- cancels the effect of a previous call, reverting the output to standard
56 -- error or standard output depending on the mode at the time of previous
57 -- call. Any exception generated by calls to P is simply propagated to
58 -- the caller of the routine causing the write operation.
60 procedure Cancel_Special_Output;
61 -- Cancels the effect of a call to Set_Special_Output, if any. The output
62 -- is then directed to standard error or standard output depending on the
63 -- last call to Set_Standard_Error or Set_Standard_Output. It is never an
64 -- error to call Cancel_Special_Output. It has the same effect as calling
65 -- Set_Special_Output (null).
67 procedure Ignore_Output (S : String);
68 -- Does nothing. To disable output, pass Ignore_Output'Access to
69 -- Set_Special_Output.
71 procedure Set_Standard_Error;
72 -- Sets subsequent output to appear on the standard error file (whatever
73 -- that might mean for the host operating system, if anything) when
74 -- no special output is in effect. When a special output is in effect,
75 -- the output will appear on standard error only after special output
76 -- has been cancelled.
78 procedure Set_Standard_Output;
79 -- Sets subsequent output to appear on the standard output file (whatever
80 -- that might mean for the host operating system, if anything) when no
81 -- special output is in effect. When a special output is in effect, the
82 -- output will appear on standard output only after special output has been
83 -- cancelled. Output to standard output is the default mode before any call
84 -- to either of the Set procedures.
86 procedure Set_Output (FD : File_Descriptor);
87 -- Sets subsequent output to appear on the given file descriptor when no
88 -- special output is in effect. When a special output is in effect, the
89 -- output will appear on the given file descriptor only after special
90 -- output has been cancelled.
92 procedure Push_Output;
93 -- Saves the current output destination on a stack, but leaves it
94 -- unchanged. This subprogram only supports a small stack and is normally
95 -- used with a depth of one.
97 procedure Pop_Output;
98 -- Changes the current output destination to be the last output destination
99 -- popped using Push_Output.
101 procedure Indent;
102 -- Increases the current indentation level. Whenever a line is written
103 -- (triggered by Eol), an appropriate amount of whitespace is added to the
104 -- beginning of the line, wrapping around if it gets too long.
106 procedure Outdent;
107 -- Decreases the current indentation level
109 procedure Write_Char (C : Character);
110 -- Write one character to the standard output file. If the character is LF,
111 -- this is equivalent to Write_Eol.
113 procedure Write_Erase_Char (C : Character);
114 -- If last character in buffer matches C, erase it, otherwise no effect
116 procedure Write_Eol;
117 -- Write an end of line (whatever is required by the system in use, e.g.
118 -- CR/LF for DOS, or LF for Unix) to the standard output file. This routine
119 -- also empties the line buffer, actually writing it to the file. Note that
120 -- Write_Eol is the only routine that causes any actual output to be
121 -- written. Trailing spaces are removed.
123 procedure Write_Eol_Keep_Blanks;
124 -- Similar as Write_Eol, except that trailing spaces are not removed
126 procedure Write_Int (Val : Int);
127 procedure Write_Int_64 (Val : Int_64);
128 -- Write an integer value with no leading blanks or zeroes. Negative values
129 -- are preceded by a minus sign).
131 procedure Write_Spaces (N : Nat);
132 -- Write N spaces
134 procedure Write_Str (S : String);
135 -- Write a string of characters to the standard output file. Note that
136 -- end of line is normally handled separately using WRITE_EOL, but it is
137 -- allowable for the string to contain LF (but not CR) characters, which
138 -- are properly interpreted as end of line characters. The string may also
139 -- contain horizontal tab characters.
141 procedure Write_Line (S : String);
142 -- Equivalent to Write_Str (S) followed by Write_Eol;
144 function Last_Char return Character;
145 -- Returns last character written on the current line, or null if the
146 -- current line is (so far) empty.
148 procedure Delete_Last_Char;
149 -- Deletes last character written on the current line, no effect if the
150 -- current line is (so far) empty.
152 function Column return Pos;
153 pragma Inline (Column);
154 -- Returns the number of the column about to be written (e.g. a value of 1
155 -- means the current line is empty).
157 -------------------------
158 -- Buffer Save/Restore --
159 -------------------------
161 -- This facility allows the current line buffer to be saved and restored
163 type Saved_Output_Buffer is private;
164 -- Type used for Save/Restore_Buffer
166 Buffer_Max : constant := Hostparm.Max_Line_Length;
167 -- Maximal size of a buffered output line
169 function Save_Output_Buffer return Saved_Output_Buffer;
170 -- Save current line buffer and reset line buffer to empty
172 procedure Restore_Output_Buffer (S : Saved_Output_Buffer);
173 -- Restore previously saved output buffer. The value in S is not affected
174 -- so it is legitimate to restore a buffer more than once.
176 --------------------------
177 -- Debugging Procedures --
178 --------------------------
180 -- The following procedures are intended only for debugging purposes,
181 -- for temporary insertion into the text in environments where a debugger
182 -- is not available. They all have non-standard very short lower case
183 -- names, precisely to make sure that they are only used for debugging.
185 procedure w (C : Character);
186 -- Dump quote, character, quote, followed by line return
188 procedure w (S : String);
189 -- Dump string followed by line return
191 procedure w (V : Int);
192 -- Dump integer followed by line return
194 procedure w (B : Boolean);
195 -- Dump Boolean followed by line return
197 procedure w (L : String; C : Character);
198 -- Dump contents of string followed by blank, quote, character, quote
200 procedure w (L : String; S : String);
201 -- Dump two strings separated by blanks, followed by line return
203 procedure w (L : String; V : Int);
204 -- Dump contents of string followed by blank, integer, line return
206 procedure w (L : String; B : Boolean);
207 -- Dump contents of string followed by blank, Boolean, line return
209 private
211 type Saved_Output_Buffer is record
212 Buffer : String (1 .. Buffer_Max + 1);
213 Next_Col : Positive;
214 Cur_Indentation : Natural;
215 end record;
217 end Output;